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>
96 static struct cmdline *testpmd_cl;
98 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
100 /* *** Help command with introduction. *** */
101 struct cmd_help_brief_result {
102 cmdline_fixed_string_t help;
105 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
107 __attribute__((unused)) void *data)
112 "Help is available for the following sections:\n\n"
113 " help control : Start and stop forwarding.\n"
114 " help display : Displaying port, stats and config "
116 " help config : Configuration information.\n"
117 " help ports : Configuring ports.\n"
118 " help registers : Reading and setting port registers.\n"
119 " help filters : Filters configuration help.\n"
120 " help all : All of the above sections.\n\n"
125 cmdline_parse_token_string_t cmd_help_brief_help =
126 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
128 cmdline_parse_inst_t cmd_help_brief = {
129 .f = cmd_help_brief_parsed,
131 .help_str = "help: Show help",
133 (void *)&cmd_help_brief_help,
138 /* *** Help command with help sections. *** */
139 struct cmd_help_long_result {
140 cmdline_fixed_string_t help;
141 cmdline_fixed_string_t section;
144 static void cmd_help_long_parsed(void *parsed_result,
146 __attribute__((unused)) void *data)
149 struct cmd_help_long_result *res = parsed_result;
151 if (!strcmp(res->section, "all"))
154 if (show_all || !strcmp(res->section, "control")) {
159 "Control forwarding:\n"
160 "-------------------\n\n"
163 " Start packet forwarding with current configuration.\n\n"
166 " Start packet forwarding with current config"
167 " after sending one burst of packets.\n\n"
170 " Stop packet forwarding, and display accumulated"
174 " Quit to prompt.\n\n"
178 if (show_all || !strcmp(res->section, "display")) {
186 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
187 " Display information for port_id, or all.\n\n"
189 "show port X rss reta (size) (mask0,mask1,...)\n"
190 " Display the rss redirection table entry indicated"
191 " by masks on port X. size is used to indicate the"
192 " hardware supported reta size\n\n"
194 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
195 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
196 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
197 " Display the RSS hash functions and RSS hash key"
200 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
201 " Clear information for port_id, or all.\n\n"
203 "show (rxq|txq) info (port_id) (queue_id)\n"
204 " Display information for configured RX/TX queue.\n\n"
206 "show config (rxtx|cores|fwd|txpkts)\n"
207 " Display the given configuration.\n\n"
209 "read rxd (port_id) (queue_id) (rxd_id)\n"
210 " Display an RX descriptor of a port RX queue.\n\n"
212 "read txd (port_id) (queue_id) (txd_id)\n"
213 " Display a TX descriptor of a port TX queue.\n\n"
217 if (show_all || !strcmp(res->section, "config")) {
223 "Configuration changes only become active when"
224 " forwarding is started/restarted.\n\n"
227 " Reset forwarding to the default configuration.\n\n"
229 "set verbose (level)\n"
230 " Set the debug verbosity level X.\n\n"
233 " Set number of ports.\n\n"
236 " Set number of cores.\n\n"
238 "set coremask (mask)\n"
239 " Set the forwarding cores hexadecimal mask.\n\n"
241 "set portmask (mask)\n"
242 " Set the forwarding ports hexadecimal mask.\n\n"
245 " Set number of packets per burst.\n\n"
247 "set burst tx delay (microseconds) retry (num)\n"
248 " Set the transmit delay time and number of retries,"
249 " effective when retry is enabled.\n\n"
251 "set txpkts (x[,y]*)\n"
252 " Set the length of each segment of TXONLY"
253 " and optionally CSUM packets.\n\n"
255 "set txsplit (off|on|rand)\n"
256 " Set the split policy for the TX packets."
257 " Right now only applicable for CSUM and TXONLY"
260 "set corelist (x[,y]*)\n"
261 " Set the list of forwarding cores.\n\n"
263 "set portlist (x[,y]*)\n"
264 " Set the list of forwarding ports.\n\n"
266 #ifdef RTE_LIBRTE_IXGBE_PMD
267 "set tx loopback (port_id) (on|off)\n"
268 " Enable or disable tx loopback.\n\n"
270 "set all queues drop (port_id) (on|off)\n"
271 " Set drop enable bit for all queues.\n\n"
273 "set vf split drop (port_id) (vf_id) (on|off)\n"
274 " Set split drop enable bit for a VF from the PF.\n\n"
276 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
277 " Set MAC antispoof for a VF from the PF.\n\n"
280 "vlan set strip (on|off) (port_id)\n"
281 " Set the VLAN strip on a port.\n\n"
283 "vlan set stripq (on|off) (port_id,queue_id)\n"
284 " Set the VLAN strip for a queue on a port.\n\n"
286 #ifdef RTE_LIBRTE_IXGBE_PMD
287 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
288 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
290 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
291 " Set VLAN insert for a VF from the PF.\n\n"
293 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
294 " Set VLAN antispoof for a VF from the PF.\n\n"
297 "vlan set filter (on|off) (port_id)\n"
298 " Set the VLAN filter on a port.\n\n"
300 "vlan set qinq (on|off) (port_id)\n"
301 " Set the VLAN QinQ (extended queue in queue)"
304 "vlan set (inner|outer) tpid (value) (port_id)\n"
305 " Set the VLAN TPID for Packet Filtering on"
308 "rx_vlan add (vlan_id|all) (port_id)\n"
309 " Add a vlan_id, or all identifiers, to the set"
310 " of VLAN identifiers filtered by port_id.\n\n"
312 "rx_vlan rm (vlan_id|all) (port_id)\n"
313 " Remove a vlan_id, or all identifiers, from the set"
314 " of VLAN identifiers filtered by port_id.\n\n"
316 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
317 " Add a vlan_id, to the set of VLAN identifiers"
318 "filtered for VF(s) from port_id.\n\n"
320 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
321 " Remove a vlan_id, to the set of VLAN identifiers"
322 "filtered for VF(s) from port_id.\n\n"
324 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
325 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
326 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
327 " add a tunnel filter of a port.\n\n"
329 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
330 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
331 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
332 " remove a tunnel filter of a port.\n\n"
334 "rx_vxlan_port add (udp_port) (port_id)\n"
335 " Add an UDP port for VXLAN packet filter on a port\n\n"
337 "rx_vxlan_port rm (udp_port) (port_id)\n"
338 " Remove an UDP port for VXLAN packet filter on a port\n\n"
340 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
341 " Set hardware insertion of VLAN IDs (single or double VLAN "
342 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
344 "tx_vlan set pvid port_id vlan_id (on|off)\n"
345 " Set port based TX VLAN insertion.\n\n"
347 "tx_vlan reset (port_id)\n"
348 " Disable hardware insertion of a VLAN header in"
349 " packets sent on a port.\n\n"
351 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
352 " Select hardware or software calculation of the"
353 " checksum when transmitting a packet using the"
354 " csum forward engine.\n"
355 " ip|udp|tcp|sctp always concern the inner layer.\n"
356 " outer-ip concerns the outer IP layer in"
357 " case the packet is recognized as a tunnel packet by"
358 " the forward engine (vxlan, gre and ipip are supported)\n"
359 " Please check the NIC datasheet for HW limits.\n\n"
361 "csum parse-tunnel (on|off) (tx_port_id)\n"
362 " If disabled, treat tunnel packets as non-tunneled"
363 " packets (treat inner headers as payload). The port\n"
364 " argument is the port used for TX in csum forward"
367 "csum show (port_id)\n"
368 " Display tx checksum offload configuration\n\n"
370 "tso set (segsize) (portid)\n"
371 " Enable TCP Segmentation Offload in csum forward"
373 " Please check the NIC datasheet for HW limits.\n\n"
376 " Display the status of TCP Segmentation Offload.\n\n"
379 " Set packet forwarding mode.\n\n"
381 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
382 " Add a MAC address on port_id.\n\n"
384 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
385 " Remove a MAC address from port_id.\n\n"
387 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
388 " Add a MAC address for a VF on the port.\n\n"
390 #ifdef RTE_LIBRTE_IXGBE_PMD
391 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
392 " Set the MAC address for a VF from the PF.\n\n"
395 "set port (port_id) uta (mac_address|all) (on|off)\n"
396 " Add/Remove a or all unicast hash filter(s)"
399 "set promisc (port_id|all) (on|off)\n"
400 " Set the promiscuous mode on port_id, or all.\n\n"
402 "set allmulti (port_id|all) (on|off)\n"
403 " Set the allmulti mode on port_id, or all.\n\n"
405 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
406 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
407 " (on|off) autoneg (on|off) (port_id)\n"
408 "set flow_ctrl rx (on|off) (portid)\n"
409 "set flow_ctrl tx (on|off) (portid)\n"
410 "set flow_ctrl high_water (high_water) (portid)\n"
411 "set flow_ctrl low_water (low_water) (portid)\n"
412 "set flow_ctrl pause_time (pause_time) (portid)\n"
413 "set flow_ctrl send_xon (send_xon) (portid)\n"
414 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
415 "set flow_ctrl autoneg (on|off) (port_id)\n"
416 " Set the link flow control parameter on a port.\n\n"
418 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
419 " (low_water) (pause_time) (priority) (port_id)\n"
420 " Set the priority flow control parameter on a"
423 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
424 " Set statistics mapping (qmapping 0..15) for RX/TX"
426 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
427 " on port 0 to mapping 5.\n\n"
429 "set port (port_id) vf (vf_id) rx|tx on|off\n"
430 " Enable/Disable a VF receive/tranmit from a port\n\n"
432 "set port (port_id) vf (vf_id) (mac_addr)"
433 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
434 " Add/Remove unicast or multicast MAC addr filter"
437 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
439 " AUPE:accepts untagged VLAN;"
440 "ROPE:accept unicast hash\n\n"
441 " BAM:accepts broadcast packets;"
442 "MPE:accepts all multicast packets\n\n"
443 " Enable/Disable a VF receive mode of a port\n\n"
445 "set port (port_id) queue (queue_id) rate (rate_num)\n"
446 " Set rate limit for a queue of a port\n\n"
448 "set port (port_id) vf (vf_id) rate (rate_num) "
449 "queue_mask (queue_mask_value)\n"
450 " Set rate limit for queues in VF of a port\n\n"
452 "set port (port_id) mirror-rule (rule_id)"
453 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
454 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
455 " Set pool or vlan type mirror rule on a port.\n"
456 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
457 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
460 "set port (port_id) mirror-rule (rule_id)"
461 " (uplink-mirror|downlink-mirror) dst-pool"
462 " (pool_id) (on|off)\n"
463 " Set uplink or downlink type mirror rule on a port.\n"
464 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
465 " 0 on' enable mirror income traffic to pool 0.\n\n"
467 "reset port (port_id) mirror-rule (rule_id)\n"
468 " Reset a mirror rule.\n\n"
470 "set flush_rx (on|off)\n"
471 " Flush (default) or don't flush RX streams before"
472 " forwarding. Mainly used with PCAP drivers.\n\n"
474 #ifdef RTE_NIC_BYPASS
475 "set bypass mode (normal|bypass|isolate) (port_id)\n"
476 " Set the bypass mode for the lowest port on bypass enabled"
479 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
480 "mode (normal|bypass|isolate) (port_id)\n"
481 " Set the event required to initiate specified bypass mode for"
482 " the lowest port on a bypass enabled NIC where:\n"
483 " timeout = enable bypass after watchdog timeout.\n"
484 " os_on = enable bypass when OS/board is powered on.\n"
485 " os_off = enable bypass when OS/board is powered off.\n"
486 " power_on = enable bypass when power supply is turned on.\n"
487 " power_off = enable bypass when power supply is turned off."
490 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
491 " Set the bypass watchdog timeout to 'n' seconds"
492 " where 0 = instant.\n\n"
494 "show bypass config (port_id)\n"
495 " Show the bypass configuration for a bypass enabled NIC"
496 " using the lowest port on the NIC.\n\n"
498 #ifdef RTE_LIBRTE_PMD_BOND
499 "create bonded device (mode) (socket)\n"
500 " Create a new bonded device with specific bonding mode and socket.\n\n"
502 "add bonding slave (slave_id) (port_id)\n"
503 " Add a slave device to a bonded device.\n\n"
505 "remove bonding slave (slave_id) (port_id)\n"
506 " Remove a slave device from a bonded device.\n\n"
508 "set bonding mode (value) (port_id)\n"
509 " Set the bonding mode on a bonded device.\n\n"
511 "set bonding primary (slave_id) (port_id)\n"
512 " Set the primary slave for a bonded device.\n\n"
514 "show bonding config (port_id)\n"
515 " Show the bonding config for port_id.\n\n"
517 "set bonding mac_addr (port_id) (address)\n"
518 " Set the MAC address of a bonded device.\n\n"
520 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
521 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
523 "set bonding mon_period (port_id) (value)\n"
524 " Set the bonding link status monitoring polling period in ms.\n\n"
526 "set link-up port (port_id)\n"
527 " Set link up for a port.\n\n"
529 "set link-down port (port_id)\n"
530 " Set link down for a port.\n\n"
532 "E-tag set insertion on port-tag-id (value)"
533 " port (port_id) vf (vf_id)\n"
534 " Enable E-tag insertion for a VF on a port\n\n"
536 "E-tag set insertion off port (port_id) vf (vf_id)\n"
537 " Disable E-tag insertion for a VF on a port\n\n"
539 "E-tag set stripping (on|off) port (port_id)\n"
540 " Enable/disable E-tag stripping on a port\n\n"
542 "E-tag set forwarding (on|off) port (port_id)\n"
543 " Enable/disable E-tag based forwarding"
546 "E-tag set filter add e-tag-id (value) dst-pool"
547 " (pool_id) port (port_id)\n"
548 " Add an E-tag forwarding filter on a port\n\n"
550 "E-tag set filter del e-tag-id (value) port (port_id)\n"
551 " Delete an E-tag forwarding filter on a port\n\n"
553 , list_pkt_forwarding_modes()
557 if (show_all || !strcmp(res->section, "ports")) {
563 "----------------\n\n"
565 "port start (port_id|all)\n"
566 " Start all ports or port_id.\n\n"
568 "port stop (port_id|all)\n"
569 " Stop all ports or port_id.\n\n"
571 "port close (port_id|all)\n"
572 " Close all ports or port_id.\n\n"
574 "port attach (ident)\n"
575 " Attach physical or virtual dev by pci address or virtual device name\n\n"
577 "port detach (port_id)\n"
578 " Detach physical or virtual dev by port_id\n\n"
580 "port config (port_id|all)"
581 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
582 " duplex (half|full|auto)\n"
583 " Set speed and duplex for all ports or port_id\n\n"
585 "port config all (rxq|txq|rxd|txd) (value)\n"
586 " Set number for rxq/txq/rxd/txd.\n\n"
588 "port config all max-pkt-len (value)\n"
589 " Set the max packet length.\n\n"
591 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
592 "hw-vlan-strip|hw-vlan-extend|drop-en)"
594 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
597 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
598 " Set the RSS mode.\n\n"
600 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
601 " Set the RSS redirection table.\n\n"
603 "port config (port_id) dcb vt (on|off) (traffic_class)"
605 " Set the DCB mode.\n\n"
607 "port config all burst (value)\n"
608 " Set the number of packets per burst.\n\n"
610 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
612 " Set the ring prefetch/host/writeback threshold"
613 " for tx/rx queue.\n\n"
615 "port config all (txfreet|txrst|rxfreet) (value)\n"
616 " Set free threshold for rx/tx, or set"
617 " tx rs bit threshold.\n\n"
618 "port config mtu X value\n"
619 " Set the MTU of port X to a given value\n\n"
621 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
622 " Start/stop a rx/tx queue of port X. Only take effect"
623 " when port X is started\n\n"
625 "port config (port_id|all) l2-tunnel E-tag ether-type"
627 " Set the value of E-tag ether-type.\n\n"
629 "port config (port_id|all) l2-tunnel E-tag"
630 " (enable|disable)\n"
631 " Enable/disable the E-tag support.\n\n"
635 if (show_all || !strcmp(res->section, "registers")) {
643 "read reg (port_id) (address)\n"
644 " Display value of a port register.\n\n"
646 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
647 " Display a port register bit field.\n\n"
649 "read regbit (port_id) (address) (bit_x)\n"
650 " Display a single port register bit.\n\n"
652 "write reg (port_id) (address) (value)\n"
653 " Set value of a port register.\n\n"
655 "write regfield (port_id) (address) (bit_x) (bit_y)"
657 " Set bit field of a port register.\n\n"
659 "write regbit (port_id) (address) (bit_x) (value)\n"
660 " Set single bit value of a port register.\n\n"
663 if (show_all || !strcmp(res->section, "filters")) {
671 "ethertype_filter (port_id) (add|del)"
672 " (mac_addr|mac_ignr) (mac_address) ethertype"
673 " (ether_type) (drop|fwd) queue (queue_id)\n"
674 " Add/Del an ethertype filter.\n\n"
676 "2tuple_filter (port_id) (add|del)"
677 " dst_port (dst_port_value) protocol (protocol_value)"
678 " mask (mask_value) tcp_flags (tcp_flags_value)"
679 " priority (prio_value) queue (queue_id)\n"
680 " Add/Del a 2tuple filter.\n\n"
682 "5tuple_filter (port_id) (add|del)"
683 " dst_ip (dst_address) src_ip (src_address)"
684 " dst_port (dst_port_value) src_port (src_port_value)"
685 " protocol (protocol_value)"
686 " mask (mask_value) tcp_flags (tcp_flags_value)"
687 " priority (prio_value) queue (queue_id)\n"
688 " Add/Del a 5tuple filter.\n\n"
690 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
691 " Add/Del syn filter.\n\n"
693 "flex_filter (port_id) (add|del) len (len_value)"
694 " bytes (bytes_value) mask (mask_value)"
695 " priority (prio_value) queue (queue_id)\n"
696 " Add/Del a flex filter.\n\n"
698 "flow_director_filter (port_id) mode IP (add|del|update)"
699 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
700 " src (src_ip_address) dst (dst_ip_address)"
701 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
702 " vlan (vlan_value) flexbytes (flexbytes_value)"
703 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
704 " fd_id (fd_id_value)\n"
705 " Add/Del an IP type flow director filter.\n\n"
707 "flow_director_filter (port_id) mode IP (add|del|update)"
708 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
709 " src (src_ip_address) (src_port)"
710 " dst (dst_ip_address) (dst_port)"
711 " tos (tos_value) ttl (ttl_value)"
712 " vlan (vlan_value) flexbytes (flexbytes_value)"
713 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
714 " fd_id (fd_id_value)\n"
715 " Add/Del an UDP/TCP type flow director filter.\n\n"
717 "flow_director_filter (port_id) mode IP (add|del|update)"
718 " flow (ipv4-sctp|ipv6-sctp)"
719 " src (src_ip_address) (src_port)"
720 " dst (dst_ip_address) (dst_port)"
721 " tag (verification_tag) "
722 " tos (tos_value) ttl (ttl_value)"
724 " flexbytes (flexbytes_value) (drop|fwd)"
725 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
726 " Add/Del a SCTP type flow director filter.\n\n"
728 "flow_director_filter (port_id) mode IP (add|del|update)"
729 " flow l2_payload ether (ethertype)"
730 " flexbytes (flexbytes_value) (drop|fwd)"
731 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
732 " Add/Del a l2 payload type flow director filter.\n\n"
734 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
735 " mac (mac_address) vlan (vlan_value)"
736 " flexbytes (flexbytes_value) (drop|fwd)"
737 " queue (queue_id) fd_id (fd_id_value)\n"
738 " Add/Del a MAC-VLAN flow director filter.\n\n"
740 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
741 " mac (mac_address) vlan (vlan_value)"
742 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
743 " flexbytes (flexbytes_value) (drop|fwd)"
744 " queue (queue_id) fd_id (fd_id_value)\n"
745 " Add/Del a Tunnel flow director filter.\n\n"
747 "flush_flow_director (port_id)\n"
748 " Flush all flow director entries of a device.\n\n"
750 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
751 " src_mask (ipv4_src) (ipv6_src) (src_port)"
752 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
753 " Set flow director IP mask.\n\n"
755 "flow_director_mask (port_id) mode MAC-VLAN"
756 " vlan (vlan_value)\n"
757 " Set flow director MAC-VLAN mask.\n\n"
759 "flow_director_mask (port_id) mode Tunnel"
760 " vlan (vlan_value) mac (mac_value)"
761 " tunnel-type (tunnel_type_value)"
762 " tunnel-id (tunnel_id_value)\n"
763 " Set flow director Tunnel mask.\n\n"
765 "flow_director_flex_mask (port_id)"
766 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
767 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
769 " Configure mask of flex payload.\n\n"
771 "flow_director_flex_payload (port_id)"
772 " (raw|l2|l3|l4) (config)\n"
773 " Configure flex payload selection.\n\n"
775 "get_sym_hash_ena_per_port (port_id)\n"
776 " get symmetric hash enable configuration per port.\n\n"
778 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
779 " set symmetric hash enable configuration per port"
780 " to enable or disable.\n\n"
782 "get_hash_global_config (port_id)\n"
783 " Get the global configurations of hash filters.\n\n"
785 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
786 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
787 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
788 " (enable|disable)\n"
789 " Set the global configurations of hash filters.\n\n"
791 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
792 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
793 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
794 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
795 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
796 "ipv6-next-header|udp-src-port|udp-dst-port|"
797 "tcp-src-port|tcp-dst-port|sctp-src-port|"
798 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
799 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
800 "fld-8th|none) (select|add)\n"
801 " Set the input set for hash.\n\n"
803 "set_fdir_input_set (port_id) "
804 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
805 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
806 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
807 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
808 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
809 "udp-dst-port|tcp-src-port|tcp-dst-port|"
810 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
812 " Set the input set for FDir.\n\n"
814 "flow flush {port_id}\n"
815 " Destroy all flow rules.\n\n"
817 "flow list {port_id} [group {group_id}] [...]\n"
818 " List existing flow rules sorted by priority,"
819 " filtered by group identifiers.\n\n"
824 cmdline_parse_token_string_t cmd_help_long_help =
825 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
827 cmdline_parse_token_string_t cmd_help_long_section =
828 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
829 "all#control#display#config#"
830 "ports#registers#filters");
832 cmdline_parse_inst_t cmd_help_long = {
833 .f = cmd_help_long_parsed,
835 .help_str = "help all|control|display|config|ports|register|filters: "
838 (void *)&cmd_help_long_help,
839 (void *)&cmd_help_long_section,
845 /* *** start/stop/close all ports *** */
846 struct cmd_operate_port_result {
847 cmdline_fixed_string_t keyword;
848 cmdline_fixed_string_t name;
849 cmdline_fixed_string_t value;
852 static void cmd_operate_port_parsed(void *parsed_result,
853 __attribute__((unused)) struct cmdline *cl,
854 __attribute__((unused)) void *data)
856 struct cmd_operate_port_result *res = parsed_result;
858 if (!strcmp(res->name, "start"))
859 start_port(RTE_PORT_ALL);
860 else if (!strcmp(res->name, "stop"))
861 stop_port(RTE_PORT_ALL);
862 else if (!strcmp(res->name, "close"))
863 close_port(RTE_PORT_ALL);
865 printf("Unknown parameter\n");
868 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
869 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
871 cmdline_parse_token_string_t cmd_operate_port_all_port =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
874 cmdline_parse_token_string_t cmd_operate_port_all_all =
875 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
877 cmdline_parse_inst_t cmd_operate_port = {
878 .f = cmd_operate_port_parsed,
880 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
882 (void *)&cmd_operate_port_all_cmd,
883 (void *)&cmd_operate_port_all_port,
884 (void *)&cmd_operate_port_all_all,
889 /* *** start/stop/close specific port *** */
890 struct cmd_operate_specific_port_result {
891 cmdline_fixed_string_t keyword;
892 cmdline_fixed_string_t name;
896 static void cmd_operate_specific_port_parsed(void *parsed_result,
897 __attribute__((unused)) struct cmdline *cl,
898 __attribute__((unused)) void *data)
900 struct cmd_operate_specific_port_result *res = parsed_result;
902 if (!strcmp(res->name, "start"))
903 start_port(res->value);
904 else if (!strcmp(res->name, "stop"))
905 stop_port(res->value);
906 else if (!strcmp(res->name, "close"))
907 close_port(res->value);
909 printf("Unknown parameter\n");
912 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
913 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
915 cmdline_parse_token_string_t cmd_operate_specific_port_port =
916 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
917 name, "start#stop#close");
918 cmdline_parse_token_num_t cmd_operate_specific_port_id =
919 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
922 cmdline_parse_inst_t cmd_operate_specific_port = {
923 .f = cmd_operate_specific_port_parsed,
925 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
927 (void *)&cmd_operate_specific_port_cmd,
928 (void *)&cmd_operate_specific_port_port,
929 (void *)&cmd_operate_specific_port_id,
934 /* *** attach a specified port *** */
935 struct cmd_operate_attach_port_result {
936 cmdline_fixed_string_t port;
937 cmdline_fixed_string_t keyword;
938 cmdline_fixed_string_t identifier;
941 static void cmd_operate_attach_port_parsed(void *parsed_result,
942 __attribute__((unused)) struct cmdline *cl,
943 __attribute__((unused)) void *data)
945 struct cmd_operate_attach_port_result *res = parsed_result;
947 if (!strcmp(res->keyword, "attach"))
948 attach_port(res->identifier);
950 printf("Unknown parameter\n");
953 cmdline_parse_token_string_t cmd_operate_attach_port_port =
954 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
956 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
957 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
959 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
960 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
963 cmdline_parse_inst_t cmd_operate_attach_port = {
964 .f = cmd_operate_attach_port_parsed,
966 .help_str = "port attach <identifier>: "
967 "(identifier: pci address or virtual dev name)",
969 (void *)&cmd_operate_attach_port_port,
970 (void *)&cmd_operate_attach_port_keyword,
971 (void *)&cmd_operate_attach_port_identifier,
976 /* *** detach a specified port *** */
977 struct cmd_operate_detach_port_result {
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t keyword;
983 static void cmd_operate_detach_port_parsed(void *parsed_result,
984 __attribute__((unused)) struct cmdline *cl,
985 __attribute__((unused)) void *data)
987 struct cmd_operate_detach_port_result *res = parsed_result;
989 if (!strcmp(res->keyword, "detach"))
990 detach_port(res->port_id);
992 printf("Unknown parameter\n");
995 cmdline_parse_token_string_t cmd_operate_detach_port_port =
996 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
998 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
999 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1001 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1002 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1005 cmdline_parse_inst_t cmd_operate_detach_port = {
1006 .f = cmd_operate_detach_port_parsed,
1008 .help_str = "port detach <port_id>",
1010 (void *)&cmd_operate_detach_port_port,
1011 (void *)&cmd_operate_detach_port_keyword,
1012 (void *)&cmd_operate_detach_port_port_id,
1017 /* *** configure speed for all ports *** */
1018 struct cmd_config_speed_all {
1019 cmdline_fixed_string_t port;
1020 cmdline_fixed_string_t keyword;
1021 cmdline_fixed_string_t all;
1022 cmdline_fixed_string_t item1;
1023 cmdline_fixed_string_t item2;
1024 cmdline_fixed_string_t value1;
1025 cmdline_fixed_string_t value2;
1029 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1034 if (!strcmp(duplexstr, "half")) {
1035 duplex = ETH_LINK_HALF_DUPLEX;
1036 } else if (!strcmp(duplexstr, "full")) {
1037 duplex = ETH_LINK_FULL_DUPLEX;
1038 } else if (!strcmp(duplexstr, "auto")) {
1039 duplex = ETH_LINK_FULL_DUPLEX;
1041 printf("Unknown duplex parameter\n");
1045 if (!strcmp(speedstr, "10")) {
1046 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1047 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1048 } else if (!strcmp(speedstr, "100")) {
1049 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1050 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1052 if (duplex != ETH_LINK_FULL_DUPLEX) {
1053 printf("Invalid speed/duplex parameters\n");
1056 if (!strcmp(speedstr, "1000")) {
1057 *speed = ETH_LINK_SPEED_1G;
1058 } else if (!strcmp(speedstr, "10000")) {
1059 *speed = ETH_LINK_SPEED_10G;
1060 } else if (!strcmp(speedstr, "25000")) {
1061 *speed = ETH_LINK_SPEED_25G;
1062 } else if (!strcmp(speedstr, "40000")) {
1063 *speed = ETH_LINK_SPEED_40G;
1064 } else if (!strcmp(speedstr, "50000")) {
1065 *speed = ETH_LINK_SPEED_50G;
1066 } else if (!strcmp(speedstr, "100000")) {
1067 *speed = ETH_LINK_SPEED_100G;
1068 } else if (!strcmp(speedstr, "auto")) {
1069 *speed = ETH_LINK_SPEED_AUTONEG;
1071 printf("Unknown speed parameter\n");
1080 cmd_config_speed_all_parsed(void *parsed_result,
1081 __attribute__((unused)) struct cmdline *cl,
1082 __attribute__((unused)) void *data)
1084 struct cmd_config_speed_all *res = parsed_result;
1085 uint32_t link_speed;
1088 if (!all_ports_stopped()) {
1089 printf("Please stop all ports first\n");
1093 if (parse_and_check_speed_duplex(res->value1, res->value2,
1097 FOREACH_PORT(pid, ports) {
1098 ports[pid].dev_conf.link_speeds = link_speed;
1101 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1104 cmdline_parse_token_string_t cmd_config_speed_all_port =
1105 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1106 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1109 cmdline_parse_token_string_t cmd_config_speed_all_all =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1111 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1113 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1114 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1115 "10#100#1000#10000#25000#40000#50000#100000#auto");
1116 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1117 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1118 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1119 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1122 cmdline_parse_inst_t cmd_config_speed_all = {
1123 .f = cmd_config_speed_all_parsed,
1125 .help_str = "port config all speed "
1126 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1129 (void *)&cmd_config_speed_all_port,
1130 (void *)&cmd_config_speed_all_keyword,
1131 (void *)&cmd_config_speed_all_all,
1132 (void *)&cmd_config_speed_all_item1,
1133 (void *)&cmd_config_speed_all_value1,
1134 (void *)&cmd_config_speed_all_item2,
1135 (void *)&cmd_config_speed_all_value2,
1140 /* *** configure speed for specific port *** */
1141 struct cmd_config_speed_specific {
1142 cmdline_fixed_string_t port;
1143 cmdline_fixed_string_t keyword;
1145 cmdline_fixed_string_t item1;
1146 cmdline_fixed_string_t item2;
1147 cmdline_fixed_string_t value1;
1148 cmdline_fixed_string_t value2;
1152 cmd_config_speed_specific_parsed(void *parsed_result,
1153 __attribute__((unused)) struct cmdline *cl,
1154 __attribute__((unused)) void *data)
1156 struct cmd_config_speed_specific *res = parsed_result;
1157 uint32_t link_speed;
1159 if (!all_ports_stopped()) {
1160 printf("Please stop all ports first\n");
1164 if (port_id_is_invalid(res->id, ENABLED_WARN))
1167 if (parse_and_check_speed_duplex(res->value1, res->value2,
1171 ports[res->id].dev_conf.link_speeds = link_speed;
1173 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1177 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1180 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1183 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1184 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1185 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1188 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1190 "10#100#1000#10000#25000#40000#50000#100000#auto");
1191 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1194 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1195 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1198 cmdline_parse_inst_t cmd_config_speed_specific = {
1199 .f = cmd_config_speed_specific_parsed,
1201 .help_str = "port config <port_id> speed "
1202 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1205 (void *)&cmd_config_speed_specific_port,
1206 (void *)&cmd_config_speed_specific_keyword,
1207 (void *)&cmd_config_speed_specific_id,
1208 (void *)&cmd_config_speed_specific_item1,
1209 (void *)&cmd_config_speed_specific_value1,
1210 (void *)&cmd_config_speed_specific_item2,
1211 (void *)&cmd_config_speed_specific_value2,
1216 /* *** configure txq/rxq, txd/rxd *** */
1217 struct cmd_config_rx_tx {
1218 cmdline_fixed_string_t port;
1219 cmdline_fixed_string_t keyword;
1220 cmdline_fixed_string_t all;
1221 cmdline_fixed_string_t name;
1226 cmd_config_rx_tx_parsed(void *parsed_result,
1227 __attribute__((unused)) struct cmdline *cl,
1228 __attribute__((unused)) void *data)
1230 struct cmd_config_rx_tx *res = parsed_result;
1232 if (!all_ports_stopped()) {
1233 printf("Please stop all ports first\n");
1236 if (!strcmp(res->name, "rxq")) {
1237 if (!res->value && !nb_txq) {
1238 printf("Warning: Either rx or tx queues should be non zero\n");
1241 nb_rxq = res->value;
1243 else if (!strcmp(res->name, "txq")) {
1244 if (!res->value && !nb_rxq) {
1245 printf("Warning: Either rx or tx queues should be non zero\n");
1248 nb_txq = res->value;
1250 else if (!strcmp(res->name, "rxd")) {
1251 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1252 printf("rxd %d invalid - must be > 0 && <= %d\n",
1253 res->value, RTE_TEST_RX_DESC_MAX);
1256 nb_rxd = res->value;
1257 } else if (!strcmp(res->name, "txd")) {
1258 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1259 printf("txd %d invalid - must be > 0 && <= %d\n",
1260 res->value, RTE_TEST_TX_DESC_MAX);
1263 nb_txd = res->value;
1265 printf("Unknown parameter\n");
1273 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1276 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1278 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1280 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1282 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1285 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1286 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1288 cmdline_parse_inst_t cmd_config_rx_tx = {
1289 .f = cmd_config_rx_tx_parsed,
1291 .help_str = "port config all rxq|txq|rxd|txd <value>",
1293 (void *)&cmd_config_rx_tx_port,
1294 (void *)&cmd_config_rx_tx_keyword,
1295 (void *)&cmd_config_rx_tx_all,
1296 (void *)&cmd_config_rx_tx_name,
1297 (void *)&cmd_config_rx_tx_value,
1302 /* *** config max packet length *** */
1303 struct cmd_config_max_pkt_len_result {
1304 cmdline_fixed_string_t port;
1305 cmdline_fixed_string_t keyword;
1306 cmdline_fixed_string_t all;
1307 cmdline_fixed_string_t name;
1312 cmd_config_max_pkt_len_parsed(void *parsed_result,
1313 __attribute__((unused)) struct cmdline *cl,
1314 __attribute__((unused)) void *data)
1316 struct cmd_config_max_pkt_len_result *res = parsed_result;
1318 if (!all_ports_stopped()) {
1319 printf("Please stop all ports first\n");
1323 if (!strcmp(res->name, "max-pkt-len")) {
1324 if (res->value < ETHER_MIN_LEN) {
1325 printf("max-pkt-len can not be less than %d\n",
1329 if (res->value == rx_mode.max_rx_pkt_len)
1332 rx_mode.max_rx_pkt_len = res->value;
1333 if (res->value > ETHER_MAX_LEN)
1334 rx_mode.jumbo_frame = 1;
1336 rx_mode.jumbo_frame = 0;
1338 printf("Unknown parameter\n");
1344 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1347 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1350 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1353 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1356 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1359 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1360 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1363 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1364 .f = cmd_config_max_pkt_len_parsed,
1366 .help_str = "port config all max-pkt-len <value>",
1368 (void *)&cmd_config_max_pkt_len_port,
1369 (void *)&cmd_config_max_pkt_len_keyword,
1370 (void *)&cmd_config_max_pkt_len_all,
1371 (void *)&cmd_config_max_pkt_len_name,
1372 (void *)&cmd_config_max_pkt_len_value,
1377 /* *** configure port MTU *** */
1378 struct cmd_config_mtu_result {
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t keyword;
1381 cmdline_fixed_string_t mtu;
1387 cmd_config_mtu_parsed(void *parsed_result,
1388 __attribute__((unused)) struct cmdline *cl,
1389 __attribute__((unused)) void *data)
1391 struct cmd_config_mtu_result *res = parsed_result;
1393 if (res->value < ETHER_MIN_LEN) {
1394 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1397 port_mtu_set(res->port_id, res->value);
1400 cmdline_parse_token_string_t cmd_config_mtu_port =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1403 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1406 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1409 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1410 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1411 cmdline_parse_token_num_t cmd_config_mtu_value =
1412 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1414 cmdline_parse_inst_t cmd_config_mtu = {
1415 .f = cmd_config_mtu_parsed,
1417 .help_str = "port config mtu <port_id> <value>",
1419 (void *)&cmd_config_mtu_port,
1420 (void *)&cmd_config_mtu_keyword,
1421 (void *)&cmd_config_mtu_mtu,
1422 (void *)&cmd_config_mtu_port_id,
1423 (void *)&cmd_config_mtu_value,
1428 /* *** configure rx mode *** */
1429 struct cmd_config_rx_mode_flag {
1430 cmdline_fixed_string_t port;
1431 cmdline_fixed_string_t keyword;
1432 cmdline_fixed_string_t all;
1433 cmdline_fixed_string_t name;
1434 cmdline_fixed_string_t value;
1438 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1439 __attribute__((unused)) struct cmdline *cl,
1440 __attribute__((unused)) void *data)
1442 struct cmd_config_rx_mode_flag *res = parsed_result;
1444 if (!all_ports_stopped()) {
1445 printf("Please stop all ports first\n");
1449 if (!strcmp(res->name, "crc-strip")) {
1450 if (!strcmp(res->value, "on"))
1451 rx_mode.hw_strip_crc = 1;
1452 else if (!strcmp(res->value, "off"))
1453 rx_mode.hw_strip_crc = 0;
1455 printf("Unknown parameter\n");
1458 } else if (!strcmp(res->name, "scatter")) {
1459 if (!strcmp(res->value, "on"))
1460 rx_mode.enable_scatter = 1;
1461 else if (!strcmp(res->value, "off"))
1462 rx_mode.enable_scatter = 0;
1464 printf("Unknown parameter\n");
1467 } else if (!strcmp(res->name, "rx-cksum")) {
1468 if (!strcmp(res->value, "on"))
1469 rx_mode.hw_ip_checksum = 1;
1470 else if (!strcmp(res->value, "off"))
1471 rx_mode.hw_ip_checksum = 0;
1473 printf("Unknown parameter\n");
1476 } else if (!strcmp(res->name, "hw-vlan")) {
1477 if (!strcmp(res->value, "on")) {
1478 rx_mode.hw_vlan_filter = 1;
1479 rx_mode.hw_vlan_strip = 1;
1481 else if (!strcmp(res->value, "off")) {
1482 rx_mode.hw_vlan_filter = 0;
1483 rx_mode.hw_vlan_strip = 0;
1486 printf("Unknown parameter\n");
1489 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1490 if (!strcmp(res->value, "on"))
1491 rx_mode.hw_vlan_filter = 1;
1492 else if (!strcmp(res->value, "off"))
1493 rx_mode.hw_vlan_filter = 0;
1495 printf("Unknown parameter\n");
1498 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1499 if (!strcmp(res->value, "on"))
1500 rx_mode.hw_vlan_strip = 1;
1501 else if (!strcmp(res->value, "off"))
1502 rx_mode.hw_vlan_strip = 0;
1504 printf("Unknown parameter\n");
1507 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1508 if (!strcmp(res->value, "on"))
1509 rx_mode.hw_vlan_extend = 1;
1510 else if (!strcmp(res->value, "off"))
1511 rx_mode.hw_vlan_extend = 0;
1513 printf("Unknown parameter\n");
1516 } else if (!strcmp(res->name, "drop-en")) {
1517 if (!strcmp(res->value, "on"))
1519 else if (!strcmp(res->value, "off"))
1522 printf("Unknown parameter\n");
1526 printf("Unknown parameter\n");
1532 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1535 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1536 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1537 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1540 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1542 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1543 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1544 "crc-strip#scatter#rx-cksum#hw-vlan#"
1545 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1546 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1550 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1551 .f = cmd_config_rx_mode_flag_parsed,
1553 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1554 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1556 (void *)&cmd_config_rx_mode_flag_port,
1557 (void *)&cmd_config_rx_mode_flag_keyword,
1558 (void *)&cmd_config_rx_mode_flag_all,
1559 (void *)&cmd_config_rx_mode_flag_name,
1560 (void *)&cmd_config_rx_mode_flag_value,
1565 /* *** configure rss *** */
1566 struct cmd_config_rss {
1567 cmdline_fixed_string_t port;
1568 cmdline_fixed_string_t keyword;
1569 cmdline_fixed_string_t all;
1570 cmdline_fixed_string_t name;
1571 cmdline_fixed_string_t value;
1575 cmd_config_rss_parsed(void *parsed_result,
1576 __attribute__((unused)) struct cmdline *cl,
1577 __attribute__((unused)) void *data)
1579 struct cmd_config_rss *res = parsed_result;
1580 struct rte_eth_rss_conf rss_conf;
1584 if (!strcmp(res->value, "all"))
1585 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1586 ETH_RSS_UDP | ETH_RSS_SCTP |
1588 else if (!strcmp(res->value, "ip"))
1589 rss_conf.rss_hf = ETH_RSS_IP;
1590 else if (!strcmp(res->value, "udp"))
1591 rss_conf.rss_hf = ETH_RSS_UDP;
1592 else if (!strcmp(res->value, "tcp"))
1593 rss_conf.rss_hf = ETH_RSS_TCP;
1594 else if (!strcmp(res->value, "sctp"))
1595 rss_conf.rss_hf = ETH_RSS_SCTP;
1596 else if (!strcmp(res->value, "ether"))
1597 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1598 else if (!strcmp(res->value, "port"))
1599 rss_conf.rss_hf = ETH_RSS_PORT;
1600 else if (!strcmp(res->value, "vxlan"))
1601 rss_conf.rss_hf = ETH_RSS_VXLAN;
1602 else if (!strcmp(res->value, "geneve"))
1603 rss_conf.rss_hf = ETH_RSS_GENEVE;
1604 else if (!strcmp(res->value, "nvgre"))
1605 rss_conf.rss_hf = ETH_RSS_NVGRE;
1606 else if (!strcmp(res->value, "none"))
1607 rss_conf.rss_hf = 0;
1609 printf("Unknown parameter\n");
1612 rss_conf.rss_key = NULL;
1613 for (i = 0; i < rte_eth_dev_count(); i++) {
1614 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1616 printf("Configuration of RSS hash at ethernet port %d "
1617 "failed with error (%d): %s.\n",
1618 i, -diag, strerror(-diag));
1622 cmdline_parse_token_string_t cmd_config_rss_port =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1624 cmdline_parse_token_string_t cmd_config_rss_keyword =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1626 cmdline_parse_token_string_t cmd_config_rss_all =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1628 cmdline_parse_token_string_t cmd_config_rss_name =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1630 cmdline_parse_token_string_t cmd_config_rss_value =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1632 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1634 cmdline_parse_inst_t cmd_config_rss = {
1635 .f = cmd_config_rss_parsed,
1637 .help_str = "port config all rss "
1638 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1640 (void *)&cmd_config_rss_port,
1641 (void *)&cmd_config_rss_keyword,
1642 (void *)&cmd_config_rss_all,
1643 (void *)&cmd_config_rss_name,
1644 (void *)&cmd_config_rss_value,
1649 /* *** configure rss hash key *** */
1650 struct cmd_config_rss_hash_key {
1651 cmdline_fixed_string_t port;
1652 cmdline_fixed_string_t config;
1654 cmdline_fixed_string_t rss_hash_key;
1655 cmdline_fixed_string_t rss_type;
1656 cmdline_fixed_string_t key;
1660 hexa_digit_to_value(char hexa_digit)
1662 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1663 return (uint8_t) (hexa_digit - '0');
1664 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1665 return (uint8_t) ((hexa_digit - 'a') + 10);
1666 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1667 return (uint8_t) ((hexa_digit - 'A') + 10);
1668 /* Invalid hexa digit */
1673 parse_and_check_key_hexa_digit(char *key, int idx)
1677 hexa_v = hexa_digit_to_value(key[idx]);
1679 printf("invalid key: character %c at position %d is not a "
1680 "valid hexa digit\n", key[idx], idx);
1685 cmd_config_rss_hash_key_parsed(void *parsed_result,
1686 __attribute__((unused)) struct cmdline *cl,
1687 __attribute__((unused)) void *data)
1689 struct cmd_config_rss_hash_key *res = parsed_result;
1690 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1694 struct rte_eth_dev_info dev_info;
1695 uint8_t hash_key_size;
1698 memset(&dev_info, 0, sizeof(dev_info));
1699 rte_eth_dev_info_get(res->port_id, &dev_info);
1700 if (dev_info.hash_key_size > 0 &&
1701 dev_info.hash_key_size <= sizeof(hash_key))
1702 hash_key_size = dev_info.hash_key_size;
1704 printf("dev_info did not provide a valid hash key size\n");
1707 /* Check the length of the RSS hash key */
1708 key_len = strlen(res->key);
1709 if (key_len != (hash_key_size * 2)) {
1710 printf("key length: %d invalid - key must be a string of %d"
1711 " hexa-decimal numbers\n",
1712 (int) key_len, hash_key_size * 2);
1715 /* Translate RSS hash key into binary representation */
1716 for (i = 0; i < hash_key_size; i++) {
1717 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1720 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1723 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1725 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1729 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1731 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1734 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1735 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1736 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1738 rss_hash_key, "rss-hash-key");
1739 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1741 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1742 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1743 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1744 "ipv6-tcp-ex#ipv6-udp-ex");
1745 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1748 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1749 .f = cmd_config_rss_hash_key_parsed,
1751 .help_str = "port config <port_id> rss-hash-key "
1752 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1753 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1754 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1755 "<string of hex digits (variable length, NIC dependent)>",
1757 (void *)&cmd_config_rss_hash_key_port,
1758 (void *)&cmd_config_rss_hash_key_config,
1759 (void *)&cmd_config_rss_hash_key_port_id,
1760 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1761 (void *)&cmd_config_rss_hash_key_rss_type,
1762 (void *)&cmd_config_rss_hash_key_value,
1767 /* *** configure port rxq/txq start/stop *** */
1768 struct cmd_config_rxtx_queue {
1769 cmdline_fixed_string_t port;
1771 cmdline_fixed_string_t rxtxq;
1773 cmdline_fixed_string_t opname;
1777 cmd_config_rxtx_queue_parsed(void *parsed_result,
1778 __attribute__((unused)) struct cmdline *cl,
1779 __attribute__((unused)) void *data)
1781 struct cmd_config_rxtx_queue *res = parsed_result;
1786 if (test_done == 0) {
1787 printf("Please stop forwarding first\n");
1791 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1794 if (port_is_started(res->portid) != 1) {
1795 printf("Please start port %u first\n", res->portid);
1799 if (!strcmp(res->rxtxq, "rxq"))
1801 else if (!strcmp(res->rxtxq, "txq"))
1804 printf("Unknown parameter\n");
1808 if (isrx && rx_queue_id_is_invalid(res->qid))
1810 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1813 if (!strcmp(res->opname, "start"))
1815 else if (!strcmp(res->opname, "stop"))
1818 printf("Unknown parameter\n");
1822 if (isstart && isrx)
1823 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1824 else if (!isstart && isrx)
1825 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1826 else if (isstart && !isrx)
1827 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1829 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1831 if (ret == -ENOTSUP)
1832 printf("Function not supported in PMD driver\n");
1835 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1837 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1838 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1839 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1841 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1842 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1843 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1847 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1848 .f = cmd_config_rxtx_queue_parsed,
1850 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1852 (void *)&cmd_config_speed_all_port,
1853 (void *)&cmd_config_rxtx_queue_portid,
1854 (void *)&cmd_config_rxtx_queue_rxtxq,
1855 (void *)&cmd_config_rxtx_queue_qid,
1856 (void *)&cmd_config_rxtx_queue_opname,
1861 /* *** Configure RSS RETA *** */
1862 struct cmd_config_rss_reta {
1863 cmdline_fixed_string_t port;
1864 cmdline_fixed_string_t keyword;
1866 cmdline_fixed_string_t name;
1867 cmdline_fixed_string_t list_name;
1868 cmdline_fixed_string_t list_of_items;
1872 parse_reta_config(const char *str,
1873 struct rte_eth_rss_reta_entry64 *reta_conf,
1874 uint16_t nb_entries)
1878 uint16_t hash_index, idx, shift;
1881 const char *p, *p0 = str;
1888 unsigned long int_fld[_NUM_FLD];
1889 char *str_fld[_NUM_FLD];
1891 while ((p = strchr(p0,'(')) != NULL) {
1893 if((p0 = strchr(p,')')) == NULL)
1897 if(size >= sizeof(s))
1900 snprintf(s, sizeof(s), "%.*s", size, p);
1901 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1903 for (i = 0; i < _NUM_FLD; i++) {
1905 int_fld[i] = strtoul(str_fld[i], &end, 0);
1906 if (errno != 0 || end == str_fld[i] ||
1911 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1912 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1914 if (hash_index >= nb_entries) {
1915 printf("Invalid RETA hash index=%d\n", hash_index);
1919 idx = hash_index / RTE_RETA_GROUP_SIZE;
1920 shift = hash_index % RTE_RETA_GROUP_SIZE;
1921 reta_conf[idx].mask |= (1ULL << shift);
1922 reta_conf[idx].reta[shift] = nb_queue;
1929 cmd_set_rss_reta_parsed(void *parsed_result,
1930 __attribute__((unused)) struct cmdline *cl,
1931 __attribute__((unused)) void *data)
1934 struct rte_eth_dev_info dev_info;
1935 struct rte_eth_rss_reta_entry64 reta_conf[8];
1936 struct cmd_config_rss_reta *res = parsed_result;
1938 memset(&dev_info, 0, sizeof(dev_info));
1939 rte_eth_dev_info_get(res->port_id, &dev_info);
1940 if (dev_info.reta_size == 0) {
1941 printf("Redirection table size is 0 which is "
1942 "invalid for RSS\n");
1945 printf("The reta size of port %d is %u\n",
1946 res->port_id, dev_info.reta_size);
1947 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1948 printf("Currently do not support more than %u entries of "
1949 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1953 memset(reta_conf, 0, sizeof(reta_conf));
1954 if (!strcmp(res->list_name, "reta")) {
1955 if (parse_reta_config(res->list_of_items, reta_conf,
1956 dev_info.reta_size)) {
1957 printf("Invalid RSS Redirection Table "
1958 "config entered\n");
1961 ret = rte_eth_dev_rss_reta_update(res->port_id,
1962 reta_conf, dev_info.reta_size);
1964 printf("Bad redirection table parameter, "
1965 "return code = %d \n", ret);
1969 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1971 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1972 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1973 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1974 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1975 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1976 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1977 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1978 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1979 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1982 cmdline_parse_inst_t cmd_config_rss_reta = {
1983 .f = cmd_set_rss_reta_parsed,
1985 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
1987 (void *)&cmd_config_rss_reta_port,
1988 (void *)&cmd_config_rss_reta_keyword,
1989 (void *)&cmd_config_rss_reta_port_id,
1990 (void *)&cmd_config_rss_reta_name,
1991 (void *)&cmd_config_rss_reta_list_name,
1992 (void *)&cmd_config_rss_reta_list_of_items,
1997 /* *** SHOW PORT RETA INFO *** */
1998 struct cmd_showport_reta {
1999 cmdline_fixed_string_t show;
2000 cmdline_fixed_string_t port;
2002 cmdline_fixed_string_t rss;
2003 cmdline_fixed_string_t reta;
2005 cmdline_fixed_string_t list_of_items;
2009 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2010 uint16_t nb_entries,
2014 const char *p, *p0 = str;
2018 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2021 p = strchr(p0, '(');
2025 p0 = strchr(p, ')');
2029 if (size >= sizeof(s)) {
2030 printf("The string size exceeds the internal buffer size\n");
2033 snprintf(s, sizeof(s), "%.*s", size, p);
2034 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2035 if (ret <= 0 || ret != num) {
2036 printf("The bits of masks do not match the number of "
2037 "reta entries: %u\n", num);
2040 for (i = 0; i < ret; i++)
2041 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2047 cmd_showport_reta_parsed(void *parsed_result,
2048 __attribute__((unused)) struct cmdline *cl,
2049 __attribute__((unused)) void *data)
2051 struct cmd_showport_reta *res = parsed_result;
2052 struct rte_eth_rss_reta_entry64 reta_conf[8];
2053 struct rte_eth_dev_info dev_info;
2055 memset(&dev_info, 0, sizeof(dev_info));
2056 rte_eth_dev_info_get(res->port_id, &dev_info);
2057 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2058 res->size > ETH_RSS_RETA_SIZE_512) {
2059 printf("Invalid redirection table size: %u\n", res->size);
2063 memset(reta_conf, 0, sizeof(reta_conf));
2064 if (showport_parse_reta_config(reta_conf, res->size,
2065 res->list_of_items) < 0) {
2066 printf("Invalid string: %s for reta masks\n",
2067 res->list_of_items);
2070 port_rss_reta_info(res->port_id, reta_conf, res->size);
2073 cmdline_parse_token_string_t cmd_showport_reta_show =
2074 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2075 cmdline_parse_token_string_t cmd_showport_reta_port =
2076 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2077 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2078 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2079 cmdline_parse_token_string_t cmd_showport_reta_rss =
2080 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2081 cmdline_parse_token_string_t cmd_showport_reta_reta =
2082 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2083 cmdline_parse_token_num_t cmd_showport_reta_size =
2084 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2085 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2086 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2087 list_of_items, NULL);
2089 cmdline_parse_inst_t cmd_showport_reta = {
2090 .f = cmd_showport_reta_parsed,
2092 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2094 (void *)&cmd_showport_reta_show,
2095 (void *)&cmd_showport_reta_port,
2096 (void *)&cmd_showport_reta_port_id,
2097 (void *)&cmd_showport_reta_rss,
2098 (void *)&cmd_showport_reta_reta,
2099 (void *)&cmd_showport_reta_size,
2100 (void *)&cmd_showport_reta_list_of_items,
2105 /* *** Show RSS hash configuration *** */
2106 struct cmd_showport_rss_hash {
2107 cmdline_fixed_string_t show;
2108 cmdline_fixed_string_t port;
2110 cmdline_fixed_string_t rss_hash;
2111 cmdline_fixed_string_t rss_type;
2112 cmdline_fixed_string_t key; /* optional argument */
2115 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2116 __attribute__((unused)) struct cmdline *cl,
2119 struct cmd_showport_rss_hash *res = parsed_result;
2121 port_rss_hash_conf_show(res->port_id, res->rss_type,
2122 show_rss_key != NULL);
2125 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2126 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2127 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2128 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2129 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2130 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2131 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2132 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2134 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2135 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2136 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2137 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2138 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2139 "ipv6-tcp-ex#ipv6-udp-ex");
2140 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2141 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2143 cmdline_parse_inst_t cmd_showport_rss_hash = {
2144 .f = cmd_showport_rss_hash_parsed,
2146 .help_str = "show port <port_id> rss-hash "
2147 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2148 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2149 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2151 (void *)&cmd_showport_rss_hash_show,
2152 (void *)&cmd_showport_rss_hash_port,
2153 (void *)&cmd_showport_rss_hash_port_id,
2154 (void *)&cmd_showport_rss_hash_rss_hash,
2155 (void *)&cmd_showport_rss_hash_rss_hash_info,
2160 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2161 .f = cmd_showport_rss_hash_parsed,
2163 .help_str = "show port <port_id> rss-hash "
2164 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2165 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2166 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2168 (void *)&cmd_showport_rss_hash_show,
2169 (void *)&cmd_showport_rss_hash_port,
2170 (void *)&cmd_showport_rss_hash_port_id,
2171 (void *)&cmd_showport_rss_hash_rss_hash,
2172 (void *)&cmd_showport_rss_hash_rss_hash_info,
2173 (void *)&cmd_showport_rss_hash_rss_key,
2178 /* *** Configure DCB *** */
2179 struct cmd_config_dcb {
2180 cmdline_fixed_string_t port;
2181 cmdline_fixed_string_t config;
2183 cmdline_fixed_string_t dcb;
2184 cmdline_fixed_string_t vt;
2185 cmdline_fixed_string_t vt_en;
2187 cmdline_fixed_string_t pfc;
2188 cmdline_fixed_string_t pfc_en;
2192 cmd_config_dcb_parsed(void *parsed_result,
2193 __attribute__((unused)) struct cmdline *cl,
2194 __attribute__((unused)) void *data)
2196 struct cmd_config_dcb *res = parsed_result;
2197 portid_t port_id = res->port_id;
2198 struct rte_port *port;
2202 port = &ports[port_id];
2203 /** Check if the port is not started **/
2204 if (port->port_status != RTE_PORT_STOPPED) {
2205 printf("Please stop port %d first\n", port_id);
2209 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2210 printf("The invalid number of traffic class,"
2211 " only 4 or 8 allowed.\n");
2215 if (nb_fwd_lcores < res->num_tcs) {
2216 printf("nb_cores shouldn't be less than number of TCs.\n");
2219 if (!strncmp(res->pfc_en, "on", 2))
2224 /* DCB in VT mode */
2225 if (!strncmp(res->vt_en, "on", 2))
2226 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2227 (enum rte_eth_nb_tcs)res->num_tcs,
2230 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2231 (enum rte_eth_nb_tcs)res->num_tcs,
2236 printf("Cannot initialize network ports.\n");
2240 cmd_reconfig_device_queue(port_id, 1, 1);
2243 cmdline_parse_token_string_t cmd_config_dcb_port =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2245 cmdline_parse_token_string_t cmd_config_dcb_config =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2247 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2248 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2249 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2251 cmdline_parse_token_string_t cmd_config_dcb_vt =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2253 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2255 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2256 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2257 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2258 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2259 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2260 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2262 cmdline_parse_inst_t cmd_config_dcb = {
2263 .f = cmd_config_dcb_parsed,
2265 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2267 (void *)&cmd_config_dcb_port,
2268 (void *)&cmd_config_dcb_config,
2269 (void *)&cmd_config_dcb_port_id,
2270 (void *)&cmd_config_dcb_dcb,
2271 (void *)&cmd_config_dcb_vt,
2272 (void *)&cmd_config_dcb_vt_en,
2273 (void *)&cmd_config_dcb_num_tcs,
2274 (void *)&cmd_config_dcb_pfc,
2275 (void *)&cmd_config_dcb_pfc_en,
2280 /* *** configure number of packets per burst *** */
2281 struct cmd_config_burst {
2282 cmdline_fixed_string_t port;
2283 cmdline_fixed_string_t keyword;
2284 cmdline_fixed_string_t all;
2285 cmdline_fixed_string_t name;
2290 cmd_config_burst_parsed(void *parsed_result,
2291 __attribute__((unused)) struct cmdline *cl,
2292 __attribute__((unused)) void *data)
2294 struct cmd_config_burst *res = parsed_result;
2296 if (!all_ports_stopped()) {
2297 printf("Please stop all ports first\n");
2301 if (!strcmp(res->name, "burst")) {
2302 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2303 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2306 nb_pkt_per_burst = res->value;
2308 printf("Unknown parameter\n");
2314 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2317 cmdline_parse_token_string_t cmd_config_burst_port =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2319 cmdline_parse_token_string_t cmd_config_burst_keyword =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2321 cmdline_parse_token_string_t cmd_config_burst_all =
2322 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2323 cmdline_parse_token_string_t cmd_config_burst_name =
2324 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2325 cmdline_parse_token_num_t cmd_config_burst_value =
2326 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2328 cmdline_parse_inst_t cmd_config_burst = {
2329 .f = cmd_config_burst_parsed,
2331 .help_str = "port config all burst <value>",
2333 (void *)&cmd_config_burst_port,
2334 (void *)&cmd_config_burst_keyword,
2335 (void *)&cmd_config_burst_all,
2336 (void *)&cmd_config_burst_name,
2337 (void *)&cmd_config_burst_value,
2342 /* *** configure rx/tx queues *** */
2343 struct cmd_config_thresh {
2344 cmdline_fixed_string_t port;
2345 cmdline_fixed_string_t keyword;
2346 cmdline_fixed_string_t all;
2347 cmdline_fixed_string_t name;
2352 cmd_config_thresh_parsed(void *parsed_result,
2353 __attribute__((unused)) struct cmdline *cl,
2354 __attribute__((unused)) void *data)
2356 struct cmd_config_thresh *res = parsed_result;
2358 if (!all_ports_stopped()) {
2359 printf("Please stop all ports first\n");
2363 if (!strcmp(res->name, "txpt"))
2364 tx_pthresh = res->value;
2365 else if(!strcmp(res->name, "txht"))
2366 tx_hthresh = res->value;
2367 else if(!strcmp(res->name, "txwt"))
2368 tx_wthresh = res->value;
2369 else if(!strcmp(res->name, "rxpt"))
2370 rx_pthresh = res->value;
2371 else if(!strcmp(res->name, "rxht"))
2372 rx_hthresh = res->value;
2373 else if(!strcmp(res->name, "rxwt"))
2374 rx_wthresh = res->value;
2376 printf("Unknown parameter\n");
2382 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2385 cmdline_parse_token_string_t cmd_config_thresh_port =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2387 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2389 cmdline_parse_token_string_t cmd_config_thresh_all =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2391 cmdline_parse_token_string_t cmd_config_thresh_name =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2393 "txpt#txht#txwt#rxpt#rxht#rxwt");
2394 cmdline_parse_token_num_t cmd_config_thresh_value =
2395 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2397 cmdline_parse_inst_t cmd_config_thresh = {
2398 .f = cmd_config_thresh_parsed,
2400 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2402 (void *)&cmd_config_thresh_port,
2403 (void *)&cmd_config_thresh_keyword,
2404 (void *)&cmd_config_thresh_all,
2405 (void *)&cmd_config_thresh_name,
2406 (void *)&cmd_config_thresh_value,
2411 /* *** configure free/rs threshold *** */
2412 struct cmd_config_threshold {
2413 cmdline_fixed_string_t port;
2414 cmdline_fixed_string_t keyword;
2415 cmdline_fixed_string_t all;
2416 cmdline_fixed_string_t name;
2421 cmd_config_threshold_parsed(void *parsed_result,
2422 __attribute__((unused)) struct cmdline *cl,
2423 __attribute__((unused)) void *data)
2425 struct cmd_config_threshold *res = parsed_result;
2427 if (!all_ports_stopped()) {
2428 printf("Please stop all ports first\n");
2432 if (!strcmp(res->name, "txfreet"))
2433 tx_free_thresh = res->value;
2434 else if (!strcmp(res->name, "txrst"))
2435 tx_rs_thresh = res->value;
2436 else if (!strcmp(res->name, "rxfreet"))
2437 rx_free_thresh = res->value;
2439 printf("Unknown parameter\n");
2445 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2448 cmdline_parse_token_string_t cmd_config_threshold_port =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2450 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2451 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2453 cmdline_parse_token_string_t cmd_config_threshold_all =
2454 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2455 cmdline_parse_token_string_t cmd_config_threshold_name =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2457 "txfreet#txrst#rxfreet");
2458 cmdline_parse_token_num_t cmd_config_threshold_value =
2459 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2461 cmdline_parse_inst_t cmd_config_threshold = {
2462 .f = cmd_config_threshold_parsed,
2464 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2466 (void *)&cmd_config_threshold_port,
2467 (void *)&cmd_config_threshold_keyword,
2468 (void *)&cmd_config_threshold_all,
2469 (void *)&cmd_config_threshold_name,
2470 (void *)&cmd_config_threshold_value,
2476 struct cmd_stop_result {
2477 cmdline_fixed_string_t stop;
2480 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2481 __attribute__((unused)) struct cmdline *cl,
2482 __attribute__((unused)) void *data)
2484 stop_packet_forwarding();
2487 cmdline_parse_token_string_t cmd_stop_stop =
2488 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2490 cmdline_parse_inst_t cmd_stop = {
2491 .f = cmd_stop_parsed,
2493 .help_str = "stop: Stop packet forwarding",
2495 (void *)&cmd_stop_stop,
2500 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2503 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2504 unsigned int *parsed_items, int check_unique_values)
2506 unsigned int nb_item;
2514 * First parse all items in the list and store their value.
2519 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2521 if ((c >= '0') && (c <= '9')) {
2522 value = (unsigned int) (value * 10 + (c - '0'));
2527 printf("character %c is not a decimal digit\n", c);
2531 printf("No valid value before comma\n");
2534 if (nb_item < max_items) {
2535 parsed_items[nb_item] = value;
2541 if (nb_item >= max_items) {
2542 printf("Number of %s = %u > %u (maximum items)\n",
2543 item_name, nb_item + 1, max_items);
2546 parsed_items[nb_item++] = value;
2547 if (! check_unique_values)
2551 * Then, check that all values in the list are differents.
2552 * No optimization here...
2554 for (i = 0; i < nb_item; i++) {
2555 for (j = i + 1; j < nb_item; j++) {
2556 if (parsed_items[j] == parsed_items[i]) {
2557 printf("duplicated %s %u at index %u and %u\n",
2558 item_name, parsed_items[i], i, j);
2566 struct cmd_set_list_result {
2567 cmdline_fixed_string_t cmd_keyword;
2568 cmdline_fixed_string_t list_name;
2569 cmdline_fixed_string_t list_of_items;
2572 static void cmd_set_list_parsed(void *parsed_result,
2573 __attribute__((unused)) struct cmdline *cl,
2574 __attribute__((unused)) void *data)
2576 struct cmd_set_list_result *res;
2578 unsigned int lcorelist[RTE_MAX_LCORE];
2579 unsigned int portlist[RTE_MAX_ETHPORTS];
2581 unsigned int nb_item;
2583 if (test_done == 0) {
2584 printf("Please stop forwarding first\n");
2588 res = parsed_result;
2589 if (!strcmp(res->list_name, "corelist")) {
2590 nb_item = parse_item_list(res->list_of_items, "core",
2592 parsed_items.lcorelist, 1);
2594 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2599 if (!strcmp(res->list_name, "portlist")) {
2600 nb_item = parse_item_list(res->list_of_items, "port",
2602 parsed_items.portlist, 1);
2604 set_fwd_ports_list(parsed_items.portlist, nb_item);
2610 cmdline_parse_token_string_t cmd_set_list_keyword =
2611 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2613 cmdline_parse_token_string_t cmd_set_list_name =
2614 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2615 "corelist#portlist");
2616 cmdline_parse_token_string_t cmd_set_list_of_items =
2617 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2620 cmdline_parse_inst_t cmd_set_fwd_list = {
2621 .f = cmd_set_list_parsed,
2623 .help_str = "set corelist|portlist <list0[,list1]*>",
2625 (void *)&cmd_set_list_keyword,
2626 (void *)&cmd_set_list_name,
2627 (void *)&cmd_set_list_of_items,
2632 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2634 struct cmd_setmask_result {
2635 cmdline_fixed_string_t set;
2636 cmdline_fixed_string_t mask;
2640 static void cmd_set_mask_parsed(void *parsed_result,
2641 __attribute__((unused)) struct cmdline *cl,
2642 __attribute__((unused)) void *data)
2644 struct cmd_setmask_result *res = parsed_result;
2646 if (test_done == 0) {
2647 printf("Please stop forwarding first\n");
2650 if (!strcmp(res->mask, "coremask")) {
2651 set_fwd_lcores_mask(res->hexavalue);
2653 } else if (!strcmp(res->mask, "portmask")) {
2654 set_fwd_ports_mask(res->hexavalue);
2659 cmdline_parse_token_string_t cmd_setmask_set =
2660 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2661 cmdline_parse_token_string_t cmd_setmask_mask =
2662 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2663 "coremask#portmask");
2664 cmdline_parse_token_num_t cmd_setmask_value =
2665 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2667 cmdline_parse_inst_t cmd_set_fwd_mask = {
2668 .f = cmd_set_mask_parsed,
2670 .help_str = "set coremask|portmask <hexadecimal value>",
2672 (void *)&cmd_setmask_set,
2673 (void *)&cmd_setmask_mask,
2674 (void *)&cmd_setmask_value,
2680 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2682 struct cmd_set_result {
2683 cmdline_fixed_string_t set;
2684 cmdline_fixed_string_t what;
2688 static void cmd_set_parsed(void *parsed_result,
2689 __attribute__((unused)) struct cmdline *cl,
2690 __attribute__((unused)) void *data)
2692 struct cmd_set_result *res = parsed_result;
2693 if (!strcmp(res->what, "nbport")) {
2694 set_fwd_ports_number(res->value);
2696 } else if (!strcmp(res->what, "nbcore")) {
2697 set_fwd_lcores_number(res->value);
2699 } else if (!strcmp(res->what, "burst"))
2700 set_nb_pkt_per_burst(res->value);
2701 else if (!strcmp(res->what, "verbose"))
2702 set_verbose_level(res->value);
2705 cmdline_parse_token_string_t cmd_set_set =
2706 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2707 cmdline_parse_token_string_t cmd_set_what =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2709 "nbport#nbcore#burst#verbose");
2710 cmdline_parse_token_num_t cmd_set_value =
2711 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2713 cmdline_parse_inst_t cmd_set_numbers = {
2714 .f = cmd_set_parsed,
2716 .help_str = "set nbport|nbcore|burst|verbose <value>",
2718 (void *)&cmd_set_set,
2719 (void *)&cmd_set_what,
2720 (void *)&cmd_set_value,
2725 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2727 struct cmd_set_txpkts_result {
2728 cmdline_fixed_string_t cmd_keyword;
2729 cmdline_fixed_string_t txpkts;
2730 cmdline_fixed_string_t seg_lengths;
2734 cmd_set_txpkts_parsed(void *parsed_result,
2735 __attribute__((unused)) struct cmdline *cl,
2736 __attribute__((unused)) void *data)
2738 struct cmd_set_txpkts_result *res;
2739 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2740 unsigned int nb_segs;
2742 res = parsed_result;
2743 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2744 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2746 set_tx_pkt_segments(seg_lengths, nb_segs);
2749 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2751 cmd_keyword, "set");
2752 cmdline_parse_token_string_t cmd_set_txpkts_name =
2753 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2755 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2756 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2759 cmdline_parse_inst_t cmd_set_txpkts = {
2760 .f = cmd_set_txpkts_parsed,
2762 .help_str = "set txpkts <len0[,len1]*>",
2764 (void *)&cmd_set_txpkts_keyword,
2765 (void *)&cmd_set_txpkts_name,
2766 (void *)&cmd_set_txpkts_lengths,
2771 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2773 struct cmd_set_txsplit_result {
2774 cmdline_fixed_string_t cmd_keyword;
2775 cmdline_fixed_string_t txsplit;
2776 cmdline_fixed_string_t mode;
2780 cmd_set_txsplit_parsed(void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2782 __attribute__((unused)) void *data)
2784 struct cmd_set_txsplit_result *res;
2786 res = parsed_result;
2787 set_tx_pkt_split(res->mode);
2790 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2791 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2792 cmd_keyword, "set");
2793 cmdline_parse_token_string_t cmd_set_txsplit_name =
2794 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2795 txsplit, "txsplit");
2796 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2797 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2800 cmdline_parse_inst_t cmd_set_txsplit = {
2801 .f = cmd_set_txsplit_parsed,
2803 .help_str = "set txsplit on|off|rand",
2805 (void *)&cmd_set_txsplit_keyword,
2806 (void *)&cmd_set_txsplit_name,
2807 (void *)&cmd_set_txsplit_mode,
2812 /* *** CONFIG TX QUEUE FLAGS *** */
2814 struct cmd_config_txqflags_result {
2815 cmdline_fixed_string_t port;
2816 cmdline_fixed_string_t config;
2817 cmdline_fixed_string_t all;
2818 cmdline_fixed_string_t what;
2822 static void cmd_config_txqflags_parsed(void *parsed_result,
2823 __attribute__((unused)) struct cmdline *cl,
2824 __attribute__((unused)) void *data)
2826 struct cmd_config_txqflags_result *res = parsed_result;
2828 if (!all_ports_stopped()) {
2829 printf("Please stop all ports first\n");
2833 if (strcmp(res->what, "txqflags")) {
2834 printf("Unknown parameter\n");
2838 if (res->hexvalue >= 0) {
2839 txq_flags = res->hexvalue;
2841 printf("txqflags must be >= 0\n");
2847 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2850 cmdline_parse_token_string_t cmd_config_txqflags_port =
2851 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2853 cmdline_parse_token_string_t cmd_config_txqflags_config =
2854 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2856 cmdline_parse_token_string_t cmd_config_txqflags_all =
2857 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2859 cmdline_parse_token_string_t cmd_config_txqflags_what =
2860 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2862 cmdline_parse_token_num_t cmd_config_txqflags_value =
2863 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2866 cmdline_parse_inst_t cmd_config_txqflags = {
2867 .f = cmd_config_txqflags_parsed,
2869 .help_str = "port config all txqflags <value>",
2871 (void *)&cmd_config_txqflags_port,
2872 (void *)&cmd_config_txqflags_config,
2873 (void *)&cmd_config_txqflags_all,
2874 (void *)&cmd_config_txqflags_what,
2875 (void *)&cmd_config_txqflags_value,
2880 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2881 struct cmd_rx_vlan_filter_all_result {
2882 cmdline_fixed_string_t rx_vlan;
2883 cmdline_fixed_string_t what;
2884 cmdline_fixed_string_t all;
2889 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2890 __attribute__((unused)) struct cmdline *cl,
2891 __attribute__((unused)) void *data)
2893 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2895 if (!strcmp(res->what, "add"))
2896 rx_vlan_all_filter_set(res->port_id, 1);
2898 rx_vlan_all_filter_set(res->port_id, 0);
2901 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2902 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2903 rx_vlan, "rx_vlan");
2904 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2905 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2907 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2908 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2910 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2911 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2914 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2915 .f = cmd_rx_vlan_filter_all_parsed,
2917 .help_str = "rx_vlan add|rm all <port_id>: "
2918 "Add/Remove all identifiers to/from the set of VLAN "
2919 "identifiers filtered by a port",
2921 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2922 (void *)&cmd_rx_vlan_filter_all_what,
2923 (void *)&cmd_rx_vlan_filter_all_all,
2924 (void *)&cmd_rx_vlan_filter_all_portid,
2929 /* *** VLAN OFFLOAD SET ON A PORT *** */
2930 struct cmd_vlan_offload_result {
2931 cmdline_fixed_string_t vlan;
2932 cmdline_fixed_string_t set;
2933 cmdline_fixed_string_t vlan_type;
2934 cmdline_fixed_string_t what;
2935 cmdline_fixed_string_t on;
2936 cmdline_fixed_string_t port_id;
2940 cmd_vlan_offload_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2945 struct cmd_vlan_offload_result *res = parsed_result;
2948 portid_t port_id = 0;
2952 len = strnlen(str, STR_TOKEN_SIZE);
2954 /* Get port_id first */
2962 tmp = strtoul(str, NULL, 0);
2963 /* If port_id greater that what portid_t can represent, return */
2964 if(tmp >= RTE_MAX_ETHPORTS)
2966 port_id = (portid_t)tmp;
2968 if (!strcmp(res->on, "on"))
2973 if (!strcmp(res->what, "strip"))
2974 rx_vlan_strip_set(port_id, on);
2975 else if(!strcmp(res->what, "stripq")){
2976 uint16_t queue_id = 0;
2978 /* No queue_id, return */
2980 printf("must specify (port,queue_id)\n");
2983 tmp = strtoul(str + i + 1, NULL, 0);
2984 /* If queue_id greater that what 16-bits can represent, return */
2988 queue_id = (uint16_t)tmp;
2989 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2991 else if (!strcmp(res->what, "filter"))
2992 rx_vlan_filter_set(port_id, on);
2994 vlan_extend_set(port_id, on);
2999 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3000 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3002 cmdline_parse_token_string_t cmd_vlan_offload_set =
3003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3005 cmdline_parse_token_string_t cmd_vlan_offload_what =
3006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3007 what, "strip#filter#qinq#stripq");
3008 cmdline_parse_token_string_t cmd_vlan_offload_on =
3009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3011 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3012 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3015 cmdline_parse_inst_t cmd_vlan_offload = {
3016 .f = cmd_vlan_offload_parsed,
3018 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3019 "<port_id[,queue_id]>: "
3020 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3022 (void *)&cmd_vlan_offload_vlan,
3023 (void *)&cmd_vlan_offload_set,
3024 (void *)&cmd_vlan_offload_what,
3025 (void *)&cmd_vlan_offload_on,
3026 (void *)&cmd_vlan_offload_portid,
3031 /* *** VLAN TPID SET ON A PORT *** */
3032 struct cmd_vlan_tpid_result {
3033 cmdline_fixed_string_t vlan;
3034 cmdline_fixed_string_t set;
3035 cmdline_fixed_string_t vlan_type;
3036 cmdline_fixed_string_t what;
3042 cmd_vlan_tpid_parsed(void *parsed_result,
3043 __attribute__((unused)) struct cmdline *cl,
3044 __attribute__((unused)) void *data)
3046 struct cmd_vlan_tpid_result *res = parsed_result;
3047 enum rte_vlan_type vlan_type;
3049 if (!strcmp(res->vlan_type, "inner"))
3050 vlan_type = ETH_VLAN_TYPE_INNER;
3051 else if (!strcmp(res->vlan_type, "outer"))
3052 vlan_type = ETH_VLAN_TYPE_OUTER;
3054 printf("Unknown vlan type\n");
3057 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3060 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3061 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3063 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3064 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3066 cmdline_parse_token_string_t cmd_vlan_type =
3067 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3068 vlan_type, "inner#outer");
3069 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3070 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3072 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3073 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3075 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3076 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3079 cmdline_parse_inst_t cmd_vlan_tpid = {
3080 .f = cmd_vlan_tpid_parsed,
3082 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3083 "Set the VLAN Ether type",
3085 (void *)&cmd_vlan_tpid_vlan,
3086 (void *)&cmd_vlan_tpid_set,
3087 (void *)&cmd_vlan_type,
3088 (void *)&cmd_vlan_tpid_what,
3089 (void *)&cmd_vlan_tpid_tpid,
3090 (void *)&cmd_vlan_tpid_portid,
3095 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3096 struct cmd_rx_vlan_filter_result {
3097 cmdline_fixed_string_t rx_vlan;
3098 cmdline_fixed_string_t what;
3104 cmd_rx_vlan_filter_parsed(void *parsed_result,
3105 __attribute__((unused)) struct cmdline *cl,
3106 __attribute__((unused)) void *data)
3108 struct cmd_rx_vlan_filter_result *res = parsed_result;
3110 if (!strcmp(res->what, "add"))
3111 rx_vft_set(res->port_id, res->vlan_id, 1);
3113 rx_vft_set(res->port_id, res->vlan_id, 0);
3116 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3117 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3118 rx_vlan, "rx_vlan");
3119 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3120 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3122 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3123 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3125 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3126 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3129 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3130 .f = cmd_rx_vlan_filter_parsed,
3132 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3133 "Add/Remove a VLAN identifier to/from the set of VLAN "
3134 "identifiers filtered by a port",
3136 (void *)&cmd_rx_vlan_filter_rx_vlan,
3137 (void *)&cmd_rx_vlan_filter_what,
3138 (void *)&cmd_rx_vlan_filter_vlanid,
3139 (void *)&cmd_rx_vlan_filter_portid,
3144 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3145 struct cmd_tx_vlan_set_result {
3146 cmdline_fixed_string_t tx_vlan;
3147 cmdline_fixed_string_t set;
3153 cmd_tx_vlan_set_parsed(void *parsed_result,
3154 __attribute__((unused)) struct cmdline *cl,
3155 __attribute__((unused)) void *data)
3157 struct cmd_tx_vlan_set_result *res = parsed_result;
3159 tx_vlan_set(res->port_id, res->vlan_id);
3162 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3163 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3164 tx_vlan, "tx_vlan");
3165 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3166 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3168 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3169 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3171 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3175 cmdline_parse_inst_t cmd_tx_vlan_set = {
3176 .f = cmd_tx_vlan_set_parsed,
3178 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3179 "Enable hardware insertion of a single VLAN header "
3180 "with a given TAG Identifier in packets sent on a port",
3182 (void *)&cmd_tx_vlan_set_tx_vlan,
3183 (void *)&cmd_tx_vlan_set_set,
3184 (void *)&cmd_tx_vlan_set_portid,
3185 (void *)&cmd_tx_vlan_set_vlanid,
3190 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3191 struct cmd_tx_vlan_set_qinq_result {
3192 cmdline_fixed_string_t tx_vlan;
3193 cmdline_fixed_string_t set;
3196 uint16_t vlan_id_outer;
3200 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3201 __attribute__((unused)) struct cmdline *cl,
3202 __attribute__((unused)) void *data)
3204 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3206 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3209 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3210 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3211 tx_vlan, "tx_vlan");
3212 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3213 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3215 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3216 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3218 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3219 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3221 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3222 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3223 vlan_id_outer, UINT16);
3225 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3226 .f = cmd_tx_vlan_set_qinq_parsed,
3228 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3229 "Enable hardware insertion of double VLAN header "
3230 "with given TAG Identifiers in packets sent on a port",
3232 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3233 (void *)&cmd_tx_vlan_set_qinq_set,
3234 (void *)&cmd_tx_vlan_set_qinq_portid,
3235 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3236 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3241 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3242 struct cmd_tx_vlan_set_pvid_result {
3243 cmdline_fixed_string_t tx_vlan;
3244 cmdline_fixed_string_t set;
3245 cmdline_fixed_string_t pvid;
3248 cmdline_fixed_string_t mode;
3252 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3253 __attribute__((unused)) struct cmdline *cl,
3254 __attribute__((unused)) void *data)
3256 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3258 if (strcmp(res->mode, "on") == 0)
3259 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3261 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3264 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3265 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3266 tx_vlan, "tx_vlan");
3267 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3270 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3271 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3273 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3274 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3276 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3277 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3279 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3283 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3284 .f = cmd_tx_vlan_set_pvid_parsed,
3286 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3288 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3289 (void *)&cmd_tx_vlan_set_pvid_set,
3290 (void *)&cmd_tx_vlan_set_pvid_pvid,
3291 (void *)&cmd_tx_vlan_set_pvid_port_id,
3292 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3293 (void *)&cmd_tx_vlan_set_pvid_mode,
3298 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3299 struct cmd_tx_vlan_reset_result {
3300 cmdline_fixed_string_t tx_vlan;
3301 cmdline_fixed_string_t reset;
3306 cmd_tx_vlan_reset_parsed(void *parsed_result,
3307 __attribute__((unused)) struct cmdline *cl,
3308 __attribute__((unused)) void *data)
3310 struct cmd_tx_vlan_reset_result *res = parsed_result;
3312 tx_vlan_reset(res->port_id);
3315 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3316 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3317 tx_vlan, "tx_vlan");
3318 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3319 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3321 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3322 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3325 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3326 .f = cmd_tx_vlan_reset_parsed,
3328 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3329 "VLAN header in packets sent on a port",
3331 (void *)&cmd_tx_vlan_reset_tx_vlan,
3332 (void *)&cmd_tx_vlan_reset_reset,
3333 (void *)&cmd_tx_vlan_reset_portid,
3339 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3340 struct cmd_csum_result {
3341 cmdline_fixed_string_t csum;
3342 cmdline_fixed_string_t mode;
3343 cmdline_fixed_string_t proto;
3344 cmdline_fixed_string_t hwsw;
3349 csum_show(int port_id)
3351 struct rte_eth_dev_info dev_info;
3354 ol_flags = ports[port_id].tx_ol_flags;
3355 printf("Parse tunnel is %s\n",
3356 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3357 printf("IP checksum offload is %s\n",
3358 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3359 printf("UDP checksum offload is %s\n",
3360 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3361 printf("TCP checksum offload is %s\n",
3362 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3363 printf("SCTP checksum offload is %s\n",
3364 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3365 printf("Outer-Ip checksum offload is %s\n",
3366 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3368 /* display warnings if configuration is not supported by the NIC */
3369 rte_eth_dev_info_get(port_id, &dev_info);
3370 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3371 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3372 printf("Warning: hardware IP checksum enabled but not "
3373 "supported by port %d\n", port_id);
3375 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3376 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3377 printf("Warning: hardware UDP checksum enabled but not "
3378 "supported by port %d\n", port_id);
3380 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3381 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3382 printf("Warning: hardware TCP checksum enabled but not "
3383 "supported by port %d\n", port_id);
3385 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3386 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3387 printf("Warning: hardware SCTP checksum enabled but not "
3388 "supported by port %d\n", port_id);
3390 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3391 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3392 printf("Warning: hardware outer IP checksum enabled but not "
3393 "supported by port %d\n", port_id);
3398 cmd_csum_parsed(void *parsed_result,
3399 __attribute__((unused)) struct cmdline *cl,
3400 __attribute__((unused)) void *data)
3402 struct cmd_csum_result *res = parsed_result;
3406 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3407 printf("invalid port %d\n", res->port_id);
3411 if (!strcmp(res->mode, "set")) {
3413 if (!strcmp(res->hwsw, "hw"))
3416 if (!strcmp(res->proto, "ip")) {
3417 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3418 } else if (!strcmp(res->proto, "udp")) {
3419 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3420 } else if (!strcmp(res->proto, "tcp")) {
3421 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3422 } else if (!strcmp(res->proto, "sctp")) {
3423 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3424 } else if (!strcmp(res->proto, "outer-ip")) {
3425 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3429 ports[res->port_id].tx_ol_flags |= mask;
3431 ports[res->port_id].tx_ol_flags &= (~mask);
3433 csum_show(res->port_id);
3436 cmdline_parse_token_string_t cmd_csum_csum =
3437 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3439 cmdline_parse_token_string_t cmd_csum_mode =
3440 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3442 cmdline_parse_token_string_t cmd_csum_proto =
3443 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3444 proto, "ip#tcp#udp#sctp#outer-ip");
3445 cmdline_parse_token_string_t cmd_csum_hwsw =
3446 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3448 cmdline_parse_token_num_t cmd_csum_portid =
3449 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3452 cmdline_parse_inst_t cmd_csum_set = {
3453 .f = cmd_csum_parsed,
3455 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3456 "Enable/Disable hardware calculation of L3/L4 checksum when "
3457 "using csum forward engine",
3459 (void *)&cmd_csum_csum,
3460 (void *)&cmd_csum_mode,
3461 (void *)&cmd_csum_proto,
3462 (void *)&cmd_csum_hwsw,
3463 (void *)&cmd_csum_portid,
3468 cmdline_parse_token_string_t cmd_csum_mode_show =
3469 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3472 cmdline_parse_inst_t cmd_csum_show = {
3473 .f = cmd_csum_parsed,
3475 .help_str = "csum show <port_id>: Show checksum offload configuration",
3477 (void *)&cmd_csum_csum,
3478 (void *)&cmd_csum_mode_show,
3479 (void *)&cmd_csum_portid,
3484 /* Enable/disable tunnel parsing */
3485 struct cmd_csum_tunnel_result {
3486 cmdline_fixed_string_t csum;
3487 cmdline_fixed_string_t parse;
3488 cmdline_fixed_string_t onoff;
3493 cmd_csum_tunnel_parsed(void *parsed_result,
3494 __attribute__((unused)) struct cmdline *cl,
3495 __attribute__((unused)) void *data)
3497 struct cmd_csum_tunnel_result *res = parsed_result;
3499 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3502 if (!strcmp(res->onoff, "on"))
3503 ports[res->port_id].tx_ol_flags |=
3504 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3506 ports[res->port_id].tx_ol_flags &=
3507 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3509 csum_show(res->port_id);
3512 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3513 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3515 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3516 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3517 parse, "parse_tunnel");
3518 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3519 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3521 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3522 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3525 cmdline_parse_inst_t cmd_csum_tunnel = {
3526 .f = cmd_csum_tunnel_parsed,
3528 .help_str = "csum parse_tunnel on|off <port_id>: "
3529 "Enable/Disable parsing of tunnels for csum engine",
3531 (void *)&cmd_csum_tunnel_csum,
3532 (void *)&cmd_csum_tunnel_parse,
3533 (void *)&cmd_csum_tunnel_onoff,
3534 (void *)&cmd_csum_tunnel_portid,
3539 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3540 struct cmd_tso_set_result {
3541 cmdline_fixed_string_t tso;
3542 cmdline_fixed_string_t mode;
3548 cmd_tso_set_parsed(void *parsed_result,
3549 __attribute__((unused)) struct cmdline *cl,
3550 __attribute__((unused)) void *data)
3552 struct cmd_tso_set_result *res = parsed_result;
3553 struct rte_eth_dev_info dev_info;
3555 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3558 if (!strcmp(res->mode, "set"))
3559 ports[res->port_id].tso_segsz = res->tso_segsz;
3561 if (ports[res->port_id].tso_segsz == 0)
3562 printf("TSO for non-tunneled packets is disabled\n");
3564 printf("TSO segment size for non-tunneled packets is %d\n",
3565 ports[res->port_id].tso_segsz);
3567 /* display warnings if configuration is not supported by the NIC */
3568 rte_eth_dev_info_get(res->port_id, &dev_info);
3569 if ((ports[res->port_id].tso_segsz != 0) &&
3570 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3571 printf("Warning: TSO enabled but not "
3572 "supported by port %d\n", res->port_id);
3576 cmdline_parse_token_string_t cmd_tso_set_tso =
3577 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3579 cmdline_parse_token_string_t cmd_tso_set_mode =
3580 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3582 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3583 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3585 cmdline_parse_token_num_t cmd_tso_set_portid =
3586 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3589 cmdline_parse_inst_t cmd_tso_set = {
3590 .f = cmd_tso_set_parsed,
3592 .help_str = "tso set <tso_segsz> <port_id>: "
3593 "Set TSO segment size of non-tunneled packets for csum engine "
3596 (void *)&cmd_tso_set_tso,
3597 (void *)&cmd_tso_set_mode,
3598 (void *)&cmd_tso_set_tso_segsz,
3599 (void *)&cmd_tso_set_portid,
3604 cmdline_parse_token_string_t cmd_tso_show_mode =
3605 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3609 cmdline_parse_inst_t cmd_tso_show = {
3610 .f = cmd_tso_set_parsed,
3612 .help_str = "tso show <port_id>: "
3613 "Show TSO segment size of non-tunneled packets for csum engine",
3615 (void *)&cmd_tso_set_tso,
3616 (void *)&cmd_tso_show_mode,
3617 (void *)&cmd_tso_set_portid,
3622 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3623 struct cmd_tunnel_tso_set_result {
3624 cmdline_fixed_string_t tso;
3625 cmdline_fixed_string_t mode;
3631 check_tunnel_tso_nic_support(uint8_t port_id)
3633 struct rte_eth_dev_info dev_info;
3635 rte_eth_dev_info_get(port_id, &dev_info);
3636 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3637 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3638 "supported by port %d\n", port_id);
3639 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3640 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3641 "supported by port %d\n", port_id);
3642 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3643 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3644 "supported by port %d\n", port_id);
3645 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3646 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3647 "supported by port %d\n", port_id);
3651 cmd_tunnel_tso_set_parsed(void *parsed_result,
3652 __attribute__((unused)) struct cmdline *cl,
3653 __attribute__((unused)) void *data)
3655 struct cmd_tunnel_tso_set_result *res = parsed_result;
3657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3660 if (!strcmp(res->mode, "set"))
3661 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3663 if (ports[res->port_id].tunnel_tso_segsz == 0)
3664 printf("TSO for tunneled packets is disabled\n");
3666 printf("TSO segment size for tunneled packets is %d\n",
3667 ports[res->port_id].tunnel_tso_segsz);
3669 /* Below conditions are needed to make it work:
3670 * (1) tunnel TSO is supported by the NIC;
3671 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3673 * (3) for tunneled pkts with outer L3 of IPv4,
3674 * "csum set outer-ip" must be set to hw, because after tso,
3675 * total_len of outer IP header is changed, and the checksum
3676 * of outer IP header calculated by sw should be wrong; that
3677 * is not necessary for IPv6 tunneled pkts because there's no
3678 * checksum in IP header anymore.
3680 check_tunnel_tso_nic_support(res->port_id);
3682 if (!(ports[res->port_id].tx_ol_flags &
3683 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3684 printf("Warning: csum parse_tunnel must be set "
3685 "so that tunneled packets are recognized\n");
3686 if (!(ports[res->port_id].tx_ol_flags &
3687 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3688 printf("Warning: csum set outer-ip must be set to hw "
3689 "if outer L3 is IPv4; not necessary for IPv6\n");
3693 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3694 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3696 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3697 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3699 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3700 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3702 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3703 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3706 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3707 .f = cmd_tunnel_tso_set_parsed,
3709 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3710 "Set TSO segment size of tunneled packets for csum engine "
3713 (void *)&cmd_tunnel_tso_set_tso,
3714 (void *)&cmd_tunnel_tso_set_mode,
3715 (void *)&cmd_tunnel_tso_set_tso_segsz,
3716 (void *)&cmd_tunnel_tso_set_portid,
3721 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3722 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3726 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3727 .f = cmd_tunnel_tso_set_parsed,
3729 .help_str = "tunnel_tso show <port_id> "
3730 "Show TSO segment size of tunneled packets for csum engine",
3732 (void *)&cmd_tunnel_tso_set_tso,
3733 (void *)&cmd_tunnel_tso_show_mode,
3734 (void *)&cmd_tunnel_tso_set_portid,
3739 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3740 struct cmd_set_flush_rx {
3741 cmdline_fixed_string_t set;
3742 cmdline_fixed_string_t flush_rx;
3743 cmdline_fixed_string_t mode;
3747 cmd_set_flush_rx_parsed(void *parsed_result,
3748 __attribute__((unused)) struct cmdline *cl,
3749 __attribute__((unused)) void *data)
3751 struct cmd_set_flush_rx *res = parsed_result;
3752 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3755 cmdline_parse_token_string_t cmd_setflushrx_set =
3756 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3758 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3760 flush_rx, "flush_rx");
3761 cmdline_parse_token_string_t cmd_setflushrx_mode =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3766 cmdline_parse_inst_t cmd_set_flush_rx = {
3767 .f = cmd_set_flush_rx_parsed,
3768 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3771 (void *)&cmd_setflushrx_set,
3772 (void *)&cmd_setflushrx_flush_rx,
3773 (void *)&cmd_setflushrx_mode,
3778 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3779 struct cmd_set_link_check {
3780 cmdline_fixed_string_t set;
3781 cmdline_fixed_string_t link_check;
3782 cmdline_fixed_string_t mode;
3786 cmd_set_link_check_parsed(void *parsed_result,
3787 __attribute__((unused)) struct cmdline *cl,
3788 __attribute__((unused)) void *data)
3790 struct cmd_set_link_check *res = parsed_result;
3791 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3794 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3795 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3797 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3799 link_check, "link_check");
3800 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3805 cmdline_parse_inst_t cmd_set_link_check = {
3806 .f = cmd_set_link_check_parsed,
3807 .help_str = "set link_check on|off: Enable/Disable link status check "
3808 "when starting/stopping a port",
3811 (void *)&cmd_setlinkcheck_set,
3812 (void *)&cmd_setlinkcheck_link_check,
3813 (void *)&cmd_setlinkcheck_mode,
3818 #ifdef RTE_NIC_BYPASS
3819 /* *** SET NIC BYPASS MODE *** */
3820 struct cmd_set_bypass_mode_result {
3821 cmdline_fixed_string_t set;
3822 cmdline_fixed_string_t bypass;
3823 cmdline_fixed_string_t mode;
3824 cmdline_fixed_string_t value;
3829 cmd_set_bypass_mode_parsed(void *parsed_result,
3830 __attribute__((unused)) struct cmdline *cl,
3831 __attribute__((unused)) void *data)
3833 struct cmd_set_bypass_mode_result *res = parsed_result;
3834 portid_t port_id = res->port_id;
3835 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3837 if (!strcmp(res->value, "bypass"))
3838 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3839 else if (!strcmp(res->value, "isolate"))
3840 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3842 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3844 /* Set the bypass mode for the relevant port. */
3845 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3846 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3850 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3853 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3856 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3859 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3860 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3861 value, "normal#bypass#isolate");
3862 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3863 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3866 cmdline_parse_inst_t cmd_set_bypass_mode = {
3867 .f = cmd_set_bypass_mode_parsed,
3868 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3869 "Set the NIC bypass mode for port_id",
3872 (void *)&cmd_setbypass_mode_set,
3873 (void *)&cmd_setbypass_mode_bypass,
3874 (void *)&cmd_setbypass_mode_mode,
3875 (void *)&cmd_setbypass_mode_value,
3876 (void *)&cmd_setbypass_mode_port,
3881 /* *** SET NIC BYPASS EVENT *** */
3882 struct cmd_set_bypass_event_result {
3883 cmdline_fixed_string_t set;
3884 cmdline_fixed_string_t bypass;
3885 cmdline_fixed_string_t event;
3886 cmdline_fixed_string_t event_value;
3887 cmdline_fixed_string_t mode;
3888 cmdline_fixed_string_t mode_value;
3893 cmd_set_bypass_event_parsed(void *parsed_result,
3894 __attribute__((unused)) struct cmdline *cl,
3895 __attribute__((unused)) void *data)
3898 struct cmd_set_bypass_event_result *res = parsed_result;
3899 portid_t port_id = res->port_id;
3900 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3901 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3903 if (!strcmp(res->event_value, "timeout"))
3904 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3905 else if (!strcmp(res->event_value, "os_on"))
3906 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3907 else if (!strcmp(res->event_value, "os_off"))
3908 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3909 else if (!strcmp(res->event_value, "power_on"))
3910 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3911 else if (!strcmp(res->event_value, "power_off"))
3912 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3914 bypass_event = RTE_BYPASS_EVENT_NONE;
3916 if (!strcmp(res->mode_value, "bypass"))
3917 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3918 else if (!strcmp(res->mode_value, "isolate"))
3919 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3921 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3923 /* Set the watchdog timeout. */
3924 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3927 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3928 (rc = rte_eth_dev_wd_timeout_store(port_id,
3929 bypass_timeout)) != 0) {
3930 printf("Failed to set timeout value %u "
3931 "for port %d, errto code: %d.\n",
3932 bypass_timeout, port_id, rc);
3936 /* Set the bypass event to transition to bypass mode. */
3937 if (0 != rte_eth_dev_bypass_event_store(port_id,
3938 bypass_event, bypass_mode)) {
3939 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3944 cmdline_parse_token_string_t cmd_setbypass_event_set =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3947 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3950 cmdline_parse_token_string_t cmd_setbypass_event_event =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3953 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3955 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3956 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3959 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3961 mode_value, "normal#bypass#isolate");
3962 cmdline_parse_token_num_t cmd_setbypass_event_port =
3963 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3966 cmdline_parse_inst_t cmd_set_bypass_event = {
3967 .f = cmd_set_bypass_event_parsed,
3968 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
3969 "power_off mode normal|bypass|isolate <port_id>: "
3970 "Set the NIC bypass event mode for port_id",
3973 (void *)&cmd_setbypass_event_set,
3974 (void *)&cmd_setbypass_event_bypass,
3975 (void *)&cmd_setbypass_event_event,
3976 (void *)&cmd_setbypass_event_event_value,
3977 (void *)&cmd_setbypass_event_mode,
3978 (void *)&cmd_setbypass_event_mode_value,
3979 (void *)&cmd_setbypass_event_port,
3985 /* *** SET NIC BYPASS TIMEOUT *** */
3986 struct cmd_set_bypass_timeout_result {
3987 cmdline_fixed_string_t set;
3988 cmdline_fixed_string_t bypass;
3989 cmdline_fixed_string_t timeout;
3990 cmdline_fixed_string_t value;
3994 cmd_set_bypass_timeout_parsed(void *parsed_result,
3995 __attribute__((unused)) struct cmdline *cl,
3996 __attribute__((unused)) void *data)
3998 struct cmd_set_bypass_timeout_result *res = parsed_result;
4000 if (!strcmp(res->value, "1.5"))
4001 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4002 else if (!strcmp(res->value, "2"))
4003 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4004 else if (!strcmp(res->value, "3"))
4005 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4006 else if (!strcmp(res->value, "4"))
4007 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4008 else if (!strcmp(res->value, "8"))
4009 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4010 else if (!strcmp(res->value, "16"))
4011 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4012 else if (!strcmp(res->value, "32"))
4013 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4015 bypass_timeout = RTE_BYPASS_TMT_OFF;
4018 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4021 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4024 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4026 timeout, "timeout");
4027 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4029 value, "0#1.5#2#3#4#8#16#32");
4031 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4032 .f = cmd_set_bypass_timeout_parsed,
4033 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4034 "Set the NIC bypass watchdog timeout in seconds",
4037 (void *)&cmd_setbypass_timeout_set,
4038 (void *)&cmd_setbypass_timeout_bypass,
4039 (void *)&cmd_setbypass_timeout_timeout,
4040 (void *)&cmd_setbypass_timeout_value,
4045 /* *** SHOW NIC BYPASS MODE *** */
4046 struct cmd_show_bypass_config_result {
4047 cmdline_fixed_string_t show;
4048 cmdline_fixed_string_t bypass;
4049 cmdline_fixed_string_t config;
4054 cmd_show_bypass_config_parsed(void *parsed_result,
4055 __attribute__((unused)) struct cmdline *cl,
4056 __attribute__((unused)) void *data)
4058 struct cmd_show_bypass_config_result *res = parsed_result;
4059 uint32_t event_mode;
4060 uint32_t bypass_mode;
4061 portid_t port_id = res->port_id;
4062 uint32_t timeout = bypass_timeout;
4065 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4066 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4067 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4068 {"UNKNOWN", "normal", "bypass", "isolate"};
4069 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4076 int num_events = (sizeof events) / (sizeof events[0]);
4078 /* Display the bypass mode.*/
4079 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4080 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4084 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4085 bypass_mode = RTE_BYPASS_MODE_NONE;
4087 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4090 /* Display the bypass timeout.*/
4091 if (!RTE_BYPASS_TMT_VALID(timeout))
4092 timeout = RTE_BYPASS_TMT_OFF;
4094 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4096 /* Display the bypass events and associated modes. */
4097 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4099 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4100 printf("\tFailed to get bypass mode for event = %s\n",
4103 if (!RTE_BYPASS_MODE_VALID(event_mode))
4104 event_mode = RTE_BYPASS_MODE_NONE;
4106 printf("\tbypass event: %-16s = %s\n", events[i],
4112 cmdline_parse_token_string_t cmd_showbypass_config_show =
4113 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4115 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4116 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4118 cmdline_parse_token_string_t cmd_showbypass_config_config =
4119 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4121 cmdline_parse_token_num_t cmd_showbypass_config_port =
4122 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4125 cmdline_parse_inst_t cmd_show_bypass_config = {
4126 .f = cmd_show_bypass_config_parsed,
4127 .help_str = "show bypass config <port_id>: "
4128 "Show the NIC bypass config for port_id",
4131 (void *)&cmd_showbypass_config_show,
4132 (void *)&cmd_showbypass_config_bypass,
4133 (void *)&cmd_showbypass_config_config,
4134 (void *)&cmd_showbypass_config_port,
4140 #ifdef RTE_LIBRTE_PMD_BOND
4141 /* *** SET BONDING MODE *** */
4142 struct cmd_set_bonding_mode_result {
4143 cmdline_fixed_string_t set;
4144 cmdline_fixed_string_t bonding;
4145 cmdline_fixed_string_t mode;
4150 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4151 __attribute__((unused)) struct cmdline *cl,
4152 __attribute__((unused)) void *data)
4154 struct cmd_set_bonding_mode_result *res = parsed_result;
4155 portid_t port_id = res->port_id;
4157 /* Set the bonding mode for the relevant port. */
4158 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4159 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4162 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4163 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4165 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4167 bonding, "bonding");
4168 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4171 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4172 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4174 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4175 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4178 cmdline_parse_inst_t cmd_set_bonding_mode = {
4179 .f = cmd_set_bonding_mode_parsed,
4180 .help_str = "set bonding mode <mode_value> <port_id>: "
4181 "Set the bonding mode for port_id",
4184 (void *) &cmd_setbonding_mode_set,
4185 (void *) &cmd_setbonding_mode_bonding,
4186 (void *) &cmd_setbonding_mode_mode,
4187 (void *) &cmd_setbonding_mode_value,
4188 (void *) &cmd_setbonding_mode_port,
4193 /* *** SET BALANCE XMIT POLICY *** */
4194 struct cmd_set_bonding_balance_xmit_policy_result {
4195 cmdline_fixed_string_t set;
4196 cmdline_fixed_string_t bonding;
4197 cmdline_fixed_string_t balance_xmit_policy;
4199 cmdline_fixed_string_t policy;
4202 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4203 __attribute__((unused)) struct cmdline *cl,
4204 __attribute__((unused)) void *data)
4206 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4207 portid_t port_id = res->port_id;
4210 if (!strcmp(res->policy, "l2")) {
4211 policy = BALANCE_XMIT_POLICY_LAYER2;
4212 } else if (!strcmp(res->policy, "l23")) {
4213 policy = BALANCE_XMIT_POLICY_LAYER23;
4214 } else if (!strcmp(res->policy, "l34")) {
4215 policy = BALANCE_XMIT_POLICY_LAYER34;
4217 printf("\t Invalid xmit policy selection");
4221 /* Set the bonding mode for the relevant port. */
4222 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4223 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4228 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4231 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4233 bonding, "bonding");
4234 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4235 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4236 balance_xmit_policy, "balance_xmit_policy");
4237 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4238 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4240 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4241 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4242 policy, "l2#l23#l34");
4244 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4245 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4246 .help_str = "set bonding balance_xmit_policy <port_id> "
4248 "Set the bonding balance_xmit_policy for port_id",
4251 (void *)&cmd_setbonding_balance_xmit_policy_set,
4252 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4253 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4254 (void *)&cmd_setbonding_balance_xmit_policy_port,
4255 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4260 /* *** SHOW NIC BONDING CONFIGURATION *** */
4261 struct cmd_show_bonding_config_result {
4262 cmdline_fixed_string_t show;
4263 cmdline_fixed_string_t bonding;
4264 cmdline_fixed_string_t config;
4268 static void cmd_show_bonding_config_parsed(void *parsed_result,
4269 __attribute__((unused)) struct cmdline *cl,
4270 __attribute__((unused)) void *data)
4272 struct cmd_show_bonding_config_result *res = parsed_result;
4274 uint8_t slaves[RTE_MAX_ETHPORTS];
4275 int num_slaves, num_active_slaves;
4278 portid_t port_id = res->port_id;
4280 /* Display the bonding mode.*/
4281 bonding_mode = rte_eth_bond_mode_get(port_id);
4282 if (bonding_mode < 0) {
4283 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4286 printf("\tBonding mode: %d\n", bonding_mode);
4288 if (bonding_mode == BONDING_MODE_BALANCE) {
4289 int balance_xmit_policy;
4291 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4292 if (balance_xmit_policy < 0) {
4293 printf("\tFailed to get balance xmit policy for port = %d\n",
4297 printf("\tBalance Xmit Policy: ");
4299 switch (balance_xmit_policy) {
4300 case BALANCE_XMIT_POLICY_LAYER2:
4301 printf("BALANCE_XMIT_POLICY_LAYER2");
4303 case BALANCE_XMIT_POLICY_LAYER23:
4304 printf("BALANCE_XMIT_POLICY_LAYER23");
4306 case BALANCE_XMIT_POLICY_LAYER34:
4307 printf("BALANCE_XMIT_POLICY_LAYER34");
4314 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4316 if (num_slaves < 0) {
4317 printf("\tFailed to get slave list for port = %d\n", port_id);
4320 if (num_slaves > 0) {
4321 printf("\tSlaves (%d): [", num_slaves);
4322 for (i = 0; i < num_slaves - 1; i++)
4323 printf("%d ", slaves[i]);
4325 printf("%d]\n", slaves[num_slaves - 1]);
4327 printf("\tSlaves: []\n");
4331 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4334 if (num_active_slaves < 0) {
4335 printf("\tFailed to get active slave list for port = %d\n", port_id);
4338 if (num_active_slaves > 0) {
4339 printf("\tActive Slaves (%d): [", num_active_slaves);
4340 for (i = 0; i < num_active_slaves - 1; i++)
4341 printf("%d ", slaves[i]);
4343 printf("%d]\n", slaves[num_active_slaves - 1]);
4346 printf("\tActive Slaves: []\n");
4350 primary_id = rte_eth_bond_primary_get(port_id);
4351 if (primary_id < 0) {
4352 printf("\tFailed to get primary slave for port = %d\n", port_id);
4355 printf("\tPrimary: [%d]\n", primary_id);
4359 cmdline_parse_token_string_t cmd_showbonding_config_show =
4360 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4362 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4363 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4364 bonding, "bonding");
4365 cmdline_parse_token_string_t cmd_showbonding_config_config =
4366 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4368 cmdline_parse_token_num_t cmd_showbonding_config_port =
4369 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4372 cmdline_parse_inst_t cmd_show_bonding_config = {
4373 .f = cmd_show_bonding_config_parsed,
4374 .help_str = "show bonding config <port_id>: "
4375 "Show the bonding config for port_id",
4378 (void *)&cmd_showbonding_config_show,
4379 (void *)&cmd_showbonding_config_bonding,
4380 (void *)&cmd_showbonding_config_config,
4381 (void *)&cmd_showbonding_config_port,
4386 /* *** SET BONDING PRIMARY *** */
4387 struct cmd_set_bonding_primary_result {
4388 cmdline_fixed_string_t set;
4389 cmdline_fixed_string_t bonding;
4390 cmdline_fixed_string_t primary;
4395 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4396 __attribute__((unused)) struct cmdline *cl,
4397 __attribute__((unused)) void *data)
4399 struct cmd_set_bonding_primary_result *res = parsed_result;
4400 portid_t master_port_id = res->port_id;
4401 portid_t slave_port_id = res->slave_id;
4403 /* Set the primary slave for a bonded device. */
4404 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4405 printf("\t Failed to set primary slave for port = %d.\n",
4412 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4415 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4417 bonding, "bonding");
4418 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4420 primary, "primary");
4421 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4422 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4424 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4425 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4428 cmdline_parse_inst_t cmd_set_bonding_primary = {
4429 .f = cmd_set_bonding_primary_parsed,
4430 .help_str = "set bonding primary <slave_id> <port_id>: "
4431 "Set the primary slave for port_id",
4434 (void *)&cmd_setbonding_primary_set,
4435 (void *)&cmd_setbonding_primary_bonding,
4436 (void *)&cmd_setbonding_primary_primary,
4437 (void *)&cmd_setbonding_primary_slave,
4438 (void *)&cmd_setbonding_primary_port,
4443 /* *** ADD SLAVE *** */
4444 struct cmd_add_bonding_slave_result {
4445 cmdline_fixed_string_t add;
4446 cmdline_fixed_string_t bonding;
4447 cmdline_fixed_string_t slave;
4452 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4453 __attribute__((unused)) struct cmdline *cl,
4454 __attribute__((unused)) void *data)
4456 struct cmd_add_bonding_slave_result *res = parsed_result;
4457 portid_t master_port_id = res->port_id;
4458 portid_t slave_port_id = res->slave_id;
4460 /* Set the primary slave for a bonded device. */
4461 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4462 printf("\t Failed to add slave %d to master port = %d.\n",
4463 slave_port_id, master_port_id);
4467 set_port_slave_flag(slave_port_id);
4470 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4471 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4473 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4474 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4475 bonding, "bonding");
4476 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4477 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4479 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4480 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4482 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4483 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4486 cmdline_parse_inst_t cmd_add_bonding_slave = {
4487 .f = cmd_add_bonding_slave_parsed,
4488 .help_str = "add bonding slave <slave_id> <port_id>: "
4489 "Add a slave device to a bonded device",
4492 (void *)&cmd_addbonding_slave_add,
4493 (void *)&cmd_addbonding_slave_bonding,
4494 (void *)&cmd_addbonding_slave_slave,
4495 (void *)&cmd_addbonding_slave_slaveid,
4496 (void *)&cmd_addbonding_slave_port,
4501 /* *** REMOVE SLAVE *** */
4502 struct cmd_remove_bonding_slave_result {
4503 cmdline_fixed_string_t remove;
4504 cmdline_fixed_string_t bonding;
4505 cmdline_fixed_string_t slave;
4510 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4511 __attribute__((unused)) struct cmdline *cl,
4512 __attribute__((unused)) void *data)
4514 struct cmd_remove_bonding_slave_result *res = parsed_result;
4515 portid_t master_port_id = res->port_id;
4516 portid_t slave_port_id = res->slave_id;
4518 /* Set the primary slave for a bonded device. */
4519 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4520 printf("\t Failed to remove slave %d from master port = %d.\n",
4521 slave_port_id, master_port_id);
4525 clear_port_slave_flag(slave_port_id);
4528 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4529 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4531 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4532 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4533 bonding, "bonding");
4534 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4535 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4537 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4538 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4540 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4541 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4544 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4545 .f = cmd_remove_bonding_slave_parsed,
4546 .help_str = "remove bonding slave <slave_id> <port_id>: "
4547 "Remove a slave device from a bonded device",
4550 (void *)&cmd_removebonding_slave_remove,
4551 (void *)&cmd_removebonding_slave_bonding,
4552 (void *)&cmd_removebonding_slave_slave,
4553 (void *)&cmd_removebonding_slave_slaveid,
4554 (void *)&cmd_removebonding_slave_port,
4559 /* *** CREATE BONDED DEVICE *** */
4560 struct cmd_create_bonded_device_result {
4561 cmdline_fixed_string_t create;
4562 cmdline_fixed_string_t bonded;
4563 cmdline_fixed_string_t device;
4568 static int bond_dev_num = 0;
4570 static void cmd_create_bonded_device_parsed(void *parsed_result,
4571 __attribute__((unused)) struct cmdline *cl,
4572 __attribute__((unused)) void *data)
4574 struct cmd_create_bonded_device_result *res = parsed_result;
4575 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4578 if (test_done == 0) {
4579 printf("Please stop forwarding first\n");
4583 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4586 /* Create a new bonded device. */
4587 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4589 printf("\t Failed to create bonded device.\n");
4592 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4595 /* Update number of ports */
4596 nb_ports = rte_eth_dev_count();
4597 reconfig(port_id, res->socket);
4598 rte_eth_promiscuous_enable(port_id);
4599 ports[port_id].enabled = 1;
4604 cmdline_parse_token_string_t cmd_createbonded_device_create =
4605 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4607 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4608 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4610 cmdline_parse_token_string_t cmd_createbonded_device_device =
4611 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4613 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4614 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4616 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4617 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4620 cmdline_parse_inst_t cmd_create_bonded_device = {
4621 .f = cmd_create_bonded_device_parsed,
4622 .help_str = "create bonded device <mode> <socket>: "
4623 "Create a new bonded device with specific bonding mode and socket",
4626 (void *)&cmd_createbonded_device_create,
4627 (void *)&cmd_createbonded_device_bonded,
4628 (void *)&cmd_createbonded_device_device,
4629 (void *)&cmd_createbonded_device_mode,
4630 (void *)&cmd_createbonded_device_socket,
4635 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4636 struct cmd_set_bond_mac_addr_result {
4637 cmdline_fixed_string_t set;
4638 cmdline_fixed_string_t bonding;
4639 cmdline_fixed_string_t mac_addr;
4641 struct ether_addr address;
4644 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4645 __attribute__((unused)) struct cmdline *cl,
4646 __attribute__((unused)) void *data)
4648 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4651 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4654 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4656 /* check the return value and print it if is < 0 */
4658 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4661 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4662 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4663 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4664 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4666 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4667 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4669 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4670 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4671 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4672 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4674 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4675 .f = cmd_set_bond_mac_addr_parsed,
4677 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4679 (void *)&cmd_set_bond_mac_addr_set,
4680 (void *)&cmd_set_bond_mac_addr_bonding,
4681 (void *)&cmd_set_bond_mac_addr_mac,
4682 (void *)&cmd_set_bond_mac_addr_portnum,
4683 (void *)&cmd_set_bond_mac_addr_addr,
4689 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4690 struct cmd_set_bond_mon_period_result {
4691 cmdline_fixed_string_t set;
4692 cmdline_fixed_string_t bonding;
4693 cmdline_fixed_string_t mon_period;
4698 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4699 __attribute__((unused)) struct cmdline *cl,
4700 __attribute__((unused)) void *data)
4702 struct cmd_set_bond_mon_period_result *res = parsed_result;
4705 if (res->port_num >= nb_ports) {
4706 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4710 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4712 /* check the return value and print it if is < 0 */
4714 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4717 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4720 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4722 bonding, "bonding");
4723 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4725 mon_period, "mon_period");
4726 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4727 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4729 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4730 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4733 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4734 .f = cmd_set_bond_mon_period_parsed,
4736 .help_str = "set bonding mon_period <port_id> <period_ms>",
4738 (void *)&cmd_set_bond_mon_period_set,
4739 (void *)&cmd_set_bond_mon_period_bonding,
4740 (void *)&cmd_set_bond_mon_period_mon_period,
4741 (void *)&cmd_set_bond_mon_period_portnum,
4742 (void *)&cmd_set_bond_mon_period_period_ms,
4747 #endif /* RTE_LIBRTE_PMD_BOND */
4749 /* *** SET FORWARDING MODE *** */
4750 struct cmd_set_fwd_mode_result {
4751 cmdline_fixed_string_t set;
4752 cmdline_fixed_string_t fwd;
4753 cmdline_fixed_string_t mode;
4756 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4757 __attribute__((unused)) struct cmdline *cl,
4758 __attribute__((unused)) void *data)
4760 struct cmd_set_fwd_mode_result *res = parsed_result;
4763 set_pkt_forwarding_mode(res->mode);
4766 cmdline_parse_token_string_t cmd_setfwd_set =
4767 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4768 cmdline_parse_token_string_t cmd_setfwd_fwd =
4769 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4770 cmdline_parse_token_string_t cmd_setfwd_mode =
4771 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4772 "" /* defined at init */);
4774 cmdline_parse_inst_t cmd_set_fwd_mode = {
4775 .f = cmd_set_fwd_mode_parsed,
4777 .help_str = NULL, /* defined at init */
4779 (void *)&cmd_setfwd_set,
4780 (void *)&cmd_setfwd_fwd,
4781 (void *)&cmd_setfwd_mode,
4786 static void cmd_set_fwd_mode_init(void)
4789 static char token[128];
4790 static char help[256];
4791 cmdline_parse_token_string_t *token_struct;
4793 modes = list_pkt_forwarding_modes();
4794 snprintf(help, sizeof(help), "set fwd %s: "
4795 "Set packet forwarding mode", modes);
4796 cmd_set_fwd_mode.help_str = help;
4798 /* string token separator is # */
4799 for (c = token; *modes != '\0'; modes++)
4804 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4805 token_struct->string_data.str = token;
4808 /* *** SET RETRY FORWARDING MODE *** */
4809 struct cmd_set_fwd_retry_mode_result {
4810 cmdline_fixed_string_t set;
4811 cmdline_fixed_string_t fwd;
4812 cmdline_fixed_string_t mode;
4813 cmdline_fixed_string_t retry;
4816 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4817 __attribute__((unused)) struct cmdline *cl,
4818 __attribute__((unused)) void *data)
4820 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4823 set_pkt_forwarding_mode(res->mode);
4826 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4829 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4832 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4833 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4835 "" /* defined at init */);
4836 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4837 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4840 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4841 .f = cmd_set_fwd_retry_mode_parsed,
4843 .help_str = NULL, /* defined at init */
4845 (void *)&cmd_setfwd_retry_set,
4846 (void *)&cmd_setfwd_retry_fwd,
4847 (void *)&cmd_setfwd_retry_mode,
4848 (void *)&cmd_setfwd_retry_retry,
4853 static void cmd_set_fwd_retry_mode_init(void)
4856 static char token[128];
4857 static char help[256];
4858 cmdline_parse_token_string_t *token_struct;
4860 modes = list_pkt_forwarding_retry_modes();
4861 snprintf(help, sizeof(help), "set fwd %s retry: "
4862 "Set packet forwarding mode with retry", modes);
4863 cmd_set_fwd_retry_mode.help_str = help;
4865 /* string token separator is # */
4866 for (c = token; *modes != '\0'; modes++)
4871 token_struct = (cmdline_parse_token_string_t *)
4872 cmd_set_fwd_retry_mode.tokens[2];
4873 token_struct->string_data.str = token;
4876 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4877 struct cmd_set_burst_tx_retry_result {
4878 cmdline_fixed_string_t set;
4879 cmdline_fixed_string_t burst;
4880 cmdline_fixed_string_t tx;
4881 cmdline_fixed_string_t delay;
4883 cmdline_fixed_string_t retry;
4887 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4888 __attribute__((unused)) struct cmdline *cl,
4889 __attribute__((unused)) void *data)
4891 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4893 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4894 && !strcmp(res->tx, "tx")) {
4895 if (!strcmp(res->delay, "delay"))
4896 burst_tx_delay_time = res->time;
4897 if (!strcmp(res->retry, "retry"))
4898 burst_tx_retry_num = res->retry_num;
4903 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4904 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4905 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4906 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4908 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4909 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4910 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4911 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4912 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4913 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4914 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4915 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4916 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4917 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4919 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4920 .f = cmd_set_burst_tx_retry_parsed,
4921 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4923 (void *)&cmd_set_burst_tx_retry_set,
4924 (void *)&cmd_set_burst_tx_retry_burst,
4925 (void *)&cmd_set_burst_tx_retry_tx,
4926 (void *)&cmd_set_burst_tx_retry_delay,
4927 (void *)&cmd_set_burst_tx_retry_time,
4928 (void *)&cmd_set_burst_tx_retry_retry,
4929 (void *)&cmd_set_burst_tx_retry_retry_num,
4934 /* *** SET PROMISC MODE *** */
4935 struct cmd_set_promisc_mode_result {
4936 cmdline_fixed_string_t set;
4937 cmdline_fixed_string_t promisc;
4938 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4939 uint8_t port_num; /* valid if "allports" argument == 0 */
4940 cmdline_fixed_string_t mode;
4943 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4944 __attribute__((unused)) struct cmdline *cl,
4947 struct cmd_set_promisc_mode_result *res = parsed_result;
4951 if (!strcmp(res->mode, "on"))
4958 FOREACH_PORT(i, ports) {
4960 rte_eth_promiscuous_enable(i);
4962 rte_eth_promiscuous_disable(i);
4967 rte_eth_promiscuous_enable(res->port_num);
4969 rte_eth_promiscuous_disable(res->port_num);
4973 cmdline_parse_token_string_t cmd_setpromisc_set =
4974 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4975 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4976 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4978 cmdline_parse_token_string_t cmd_setpromisc_portall =
4979 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4981 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4982 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4984 cmdline_parse_token_string_t cmd_setpromisc_mode =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4988 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4989 .f = cmd_set_promisc_mode_parsed,
4991 .help_str = "set promisc all on|off: Set promisc mode for all ports",
4993 (void *)&cmd_setpromisc_set,
4994 (void *)&cmd_setpromisc_promisc,
4995 (void *)&cmd_setpromisc_portall,
4996 (void *)&cmd_setpromisc_mode,
5001 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5002 .f = cmd_set_promisc_mode_parsed,
5004 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5006 (void *)&cmd_setpromisc_set,
5007 (void *)&cmd_setpromisc_promisc,
5008 (void *)&cmd_setpromisc_portnum,
5009 (void *)&cmd_setpromisc_mode,
5014 /* *** SET ALLMULTI MODE *** */
5015 struct cmd_set_allmulti_mode_result {
5016 cmdline_fixed_string_t set;
5017 cmdline_fixed_string_t allmulti;
5018 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5019 uint8_t port_num; /* valid if "allports" argument == 0 */
5020 cmdline_fixed_string_t mode;
5023 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5024 __attribute__((unused)) struct cmdline *cl,
5027 struct cmd_set_allmulti_mode_result *res = parsed_result;
5031 if (!strcmp(res->mode, "on"))
5038 FOREACH_PORT(i, ports) {
5040 rte_eth_allmulticast_enable(i);
5042 rte_eth_allmulticast_disable(i);
5047 rte_eth_allmulticast_enable(res->port_num);
5049 rte_eth_allmulticast_disable(res->port_num);
5053 cmdline_parse_token_string_t cmd_setallmulti_set =
5054 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5055 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5058 cmdline_parse_token_string_t cmd_setallmulti_portall =
5059 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5061 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5062 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5064 cmdline_parse_token_string_t cmd_setallmulti_mode =
5065 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5068 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5069 .f = cmd_set_allmulti_mode_parsed,
5071 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5073 (void *)&cmd_setallmulti_set,
5074 (void *)&cmd_setallmulti_allmulti,
5075 (void *)&cmd_setallmulti_portall,
5076 (void *)&cmd_setallmulti_mode,
5081 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5082 .f = cmd_set_allmulti_mode_parsed,
5084 .help_str = "set allmulti <port_id> on|off: "
5085 "Set allmulti mode on port_id",
5087 (void *)&cmd_setallmulti_set,
5088 (void *)&cmd_setallmulti_allmulti,
5089 (void *)&cmd_setallmulti_portnum,
5090 (void *)&cmd_setallmulti_mode,
5095 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5096 struct cmd_link_flow_ctrl_set_result {
5097 cmdline_fixed_string_t set;
5098 cmdline_fixed_string_t flow_ctrl;
5099 cmdline_fixed_string_t rx;
5100 cmdline_fixed_string_t rx_lfc_mode;
5101 cmdline_fixed_string_t tx;
5102 cmdline_fixed_string_t tx_lfc_mode;
5103 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5104 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5105 cmdline_fixed_string_t autoneg_str;
5106 cmdline_fixed_string_t autoneg;
5107 cmdline_fixed_string_t hw_str;
5108 uint32_t high_water;
5109 cmdline_fixed_string_t lw_str;
5111 cmdline_fixed_string_t pt_str;
5112 uint16_t pause_time;
5113 cmdline_fixed_string_t xon_str;
5118 cmdline_parse_token_string_t cmd_lfc_set_set =
5119 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5121 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5122 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5123 flow_ctrl, "flow_ctrl");
5124 cmdline_parse_token_string_t cmd_lfc_set_rx =
5125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5127 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5128 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5129 rx_lfc_mode, "on#off");
5130 cmdline_parse_token_string_t cmd_lfc_set_tx =
5131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5133 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5135 tx_lfc_mode, "on#off");
5136 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5138 hw_str, "high_water");
5139 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5140 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5141 high_water, UINT32);
5142 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5143 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5144 lw_str, "low_water");
5145 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5146 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5148 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5149 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5150 pt_str, "pause_time");
5151 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5152 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5153 pause_time, UINT16);
5154 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5155 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5156 xon_str, "send_xon");
5157 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5158 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5160 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5162 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5163 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 mac_ctrl_frame_fwd_mode, "on#off");
5166 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 autoneg_str, "autoneg");
5169 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5172 cmdline_parse_token_num_t cmd_lfc_set_portid =
5173 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5176 /* forward declaration */
5178 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5181 cmdline_parse_inst_t cmd_link_flow_control_set = {
5182 .f = cmd_link_flow_ctrl_set_parsed,
5184 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5185 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5186 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5188 (void *)&cmd_lfc_set_set,
5189 (void *)&cmd_lfc_set_flow_ctrl,
5190 (void *)&cmd_lfc_set_rx,
5191 (void *)&cmd_lfc_set_rx_mode,
5192 (void *)&cmd_lfc_set_tx,
5193 (void *)&cmd_lfc_set_tx_mode,
5194 (void *)&cmd_lfc_set_high_water,
5195 (void *)&cmd_lfc_set_low_water,
5196 (void *)&cmd_lfc_set_pause_time,
5197 (void *)&cmd_lfc_set_send_xon,
5198 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5199 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5200 (void *)&cmd_lfc_set_autoneg_str,
5201 (void *)&cmd_lfc_set_autoneg,
5202 (void *)&cmd_lfc_set_portid,
5207 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5208 .f = cmd_link_flow_ctrl_set_parsed,
5209 .data = (void *)&cmd_link_flow_control_set_rx,
5210 .help_str = "set flow_ctrl rx on|off <port_id>: "
5211 "Change rx flow control parameter",
5213 (void *)&cmd_lfc_set_set,
5214 (void *)&cmd_lfc_set_flow_ctrl,
5215 (void *)&cmd_lfc_set_rx,
5216 (void *)&cmd_lfc_set_rx_mode,
5217 (void *)&cmd_lfc_set_portid,
5222 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5223 .f = cmd_link_flow_ctrl_set_parsed,
5224 .data = (void *)&cmd_link_flow_control_set_tx,
5225 .help_str = "set flow_ctrl tx on|off <port_id>: "
5226 "Change tx flow control parameter",
5228 (void *)&cmd_lfc_set_set,
5229 (void *)&cmd_lfc_set_flow_ctrl,
5230 (void *)&cmd_lfc_set_tx,
5231 (void *)&cmd_lfc_set_tx_mode,
5232 (void *)&cmd_lfc_set_portid,
5237 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5238 .f = cmd_link_flow_ctrl_set_parsed,
5239 .data = (void *)&cmd_link_flow_control_set_hw,
5240 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5241 "Change high water flow control parameter",
5243 (void *)&cmd_lfc_set_set,
5244 (void *)&cmd_lfc_set_flow_ctrl,
5245 (void *)&cmd_lfc_set_high_water_str,
5246 (void *)&cmd_lfc_set_high_water,
5247 (void *)&cmd_lfc_set_portid,
5252 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5253 .f = cmd_link_flow_ctrl_set_parsed,
5254 .data = (void *)&cmd_link_flow_control_set_lw,
5255 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5256 "Change low water flow control parameter",
5258 (void *)&cmd_lfc_set_set,
5259 (void *)&cmd_lfc_set_flow_ctrl,
5260 (void *)&cmd_lfc_set_low_water_str,
5261 (void *)&cmd_lfc_set_low_water,
5262 (void *)&cmd_lfc_set_portid,
5267 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5268 .f = cmd_link_flow_ctrl_set_parsed,
5269 .data = (void *)&cmd_link_flow_control_set_pt,
5270 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5271 "Change pause time flow control parameter",
5273 (void *)&cmd_lfc_set_set,
5274 (void *)&cmd_lfc_set_flow_ctrl,
5275 (void *)&cmd_lfc_set_pause_time_str,
5276 (void *)&cmd_lfc_set_pause_time,
5277 (void *)&cmd_lfc_set_portid,
5282 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5283 .f = cmd_link_flow_ctrl_set_parsed,
5284 .data = (void *)&cmd_link_flow_control_set_xon,
5285 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5286 "Change send_xon flow control parameter",
5288 (void *)&cmd_lfc_set_set,
5289 (void *)&cmd_lfc_set_flow_ctrl,
5290 (void *)&cmd_lfc_set_send_xon_str,
5291 (void *)&cmd_lfc_set_send_xon,
5292 (void *)&cmd_lfc_set_portid,
5297 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5298 .f = cmd_link_flow_ctrl_set_parsed,
5299 .data = (void *)&cmd_link_flow_control_set_macfwd,
5300 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5301 "Change mac ctrl fwd flow control parameter",
5303 (void *)&cmd_lfc_set_set,
5304 (void *)&cmd_lfc_set_flow_ctrl,
5305 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5306 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5307 (void *)&cmd_lfc_set_portid,
5312 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5313 .f = cmd_link_flow_ctrl_set_parsed,
5314 .data = (void *)&cmd_link_flow_control_set_autoneg,
5315 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5316 "Change autoneg flow control parameter",
5318 (void *)&cmd_lfc_set_set,
5319 (void *)&cmd_lfc_set_flow_ctrl,
5320 (void *)&cmd_lfc_set_autoneg_str,
5321 (void *)&cmd_lfc_set_autoneg,
5322 (void *)&cmd_lfc_set_portid,
5328 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5329 __attribute__((unused)) struct cmdline *cl,
5332 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5333 cmdline_parse_inst_t *cmd = data;
5334 struct rte_eth_fc_conf fc_conf;
5340 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5341 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5342 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5343 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5345 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5346 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5349 /* Partial command line, retrieve current configuration */
5351 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5353 printf("cannot get current flow ctrl parameters, return"
5354 "code = %d\n", ret);
5358 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5359 (fc_conf.mode == RTE_FC_FULL))
5361 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5362 (fc_conf.mode == RTE_FC_FULL))
5366 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5367 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5369 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5370 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5372 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5374 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5375 fc_conf.high_water = res->high_water;
5377 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5378 fc_conf.low_water = res->low_water;
5380 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5381 fc_conf.pause_time = res->pause_time;
5383 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5384 fc_conf.send_xon = res->send_xon;
5386 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5387 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5388 fc_conf.mac_ctrl_frame_fwd = 1;
5390 fc_conf.mac_ctrl_frame_fwd = 0;
5393 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5394 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5396 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5398 printf("bad flow contrl parameter, return code = %d \n", ret);
5401 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5402 struct cmd_priority_flow_ctrl_set_result {
5403 cmdline_fixed_string_t set;
5404 cmdline_fixed_string_t pfc_ctrl;
5405 cmdline_fixed_string_t rx;
5406 cmdline_fixed_string_t rx_pfc_mode;
5407 cmdline_fixed_string_t tx;
5408 cmdline_fixed_string_t tx_pfc_mode;
5409 uint32_t high_water;
5411 uint16_t pause_time;
5417 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5418 __attribute__((unused)) struct cmdline *cl,
5419 __attribute__((unused)) void *data)
5421 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5422 struct rte_eth_pfc_conf pfc_conf;
5423 int rx_fc_enable, tx_fc_enable;
5427 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5428 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5429 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5430 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5432 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5433 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5436 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5437 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5438 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5439 pfc_conf.fc.high_water = res->high_water;
5440 pfc_conf.fc.low_water = res->low_water;
5441 pfc_conf.fc.pause_time = res->pause_time;
5442 pfc_conf.priority = res->priority;
5444 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5446 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5449 cmdline_parse_token_string_t cmd_pfc_set_set =
5450 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5452 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5453 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5454 pfc_ctrl, "pfc_ctrl");
5455 cmdline_parse_token_string_t cmd_pfc_set_rx =
5456 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5458 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5459 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5460 rx_pfc_mode, "on#off");
5461 cmdline_parse_token_string_t cmd_pfc_set_tx =
5462 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5464 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5465 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5466 tx_pfc_mode, "on#off");
5467 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5468 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5469 high_water, UINT32);
5470 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5471 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5473 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5474 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5475 pause_time, UINT16);
5476 cmdline_parse_token_num_t cmd_pfc_set_priority =
5477 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5479 cmdline_parse_token_num_t cmd_pfc_set_portid =
5480 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5483 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5484 .f = cmd_priority_flow_ctrl_set_parsed,
5486 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5487 "<pause_time> <priority> <port_id>: "
5488 "Configure the Ethernet priority flow control",
5490 (void *)&cmd_pfc_set_set,
5491 (void *)&cmd_pfc_set_flow_ctrl,
5492 (void *)&cmd_pfc_set_rx,
5493 (void *)&cmd_pfc_set_rx_mode,
5494 (void *)&cmd_pfc_set_tx,
5495 (void *)&cmd_pfc_set_tx_mode,
5496 (void *)&cmd_pfc_set_high_water,
5497 (void *)&cmd_pfc_set_low_water,
5498 (void *)&cmd_pfc_set_pause_time,
5499 (void *)&cmd_pfc_set_priority,
5500 (void *)&cmd_pfc_set_portid,
5505 /* *** RESET CONFIGURATION *** */
5506 struct cmd_reset_result {
5507 cmdline_fixed_string_t reset;
5508 cmdline_fixed_string_t def;
5511 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5513 __attribute__((unused)) void *data)
5515 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5516 set_def_fwd_config();
5519 cmdline_parse_token_string_t cmd_reset_set =
5520 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5521 cmdline_parse_token_string_t cmd_reset_def =
5522 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5525 cmdline_parse_inst_t cmd_reset = {
5526 .f = cmd_reset_parsed,
5528 .help_str = "set default: Reset default forwarding configuration",
5530 (void *)&cmd_reset_set,
5531 (void *)&cmd_reset_def,
5536 /* *** START FORWARDING *** */
5537 struct cmd_start_result {
5538 cmdline_fixed_string_t start;
5541 cmdline_parse_token_string_t cmd_start_start =
5542 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5544 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5545 __attribute__((unused)) struct cmdline *cl,
5546 __attribute__((unused)) void *data)
5548 start_packet_forwarding(0);
5551 cmdline_parse_inst_t cmd_start = {
5552 .f = cmd_start_parsed,
5554 .help_str = "start: Start packet forwarding",
5556 (void *)&cmd_start_start,
5561 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5562 struct cmd_start_tx_first_result {
5563 cmdline_fixed_string_t start;
5564 cmdline_fixed_string_t tx_first;
5568 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5569 __attribute__((unused)) struct cmdline *cl,
5570 __attribute__((unused)) void *data)
5572 start_packet_forwarding(1);
5575 cmdline_parse_token_string_t cmd_start_tx_first_start =
5576 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5578 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5579 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5580 tx_first, "tx_first");
5582 cmdline_parse_inst_t cmd_start_tx_first = {
5583 .f = cmd_start_tx_first_parsed,
5585 .help_str = "start tx_first: Start packet forwarding, "
5586 "after sending 1 burst of packets",
5588 (void *)&cmd_start_tx_first_start,
5589 (void *)&cmd_start_tx_first_tx_first,
5594 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5595 struct cmd_start_tx_first_n_result {
5596 cmdline_fixed_string_t start;
5597 cmdline_fixed_string_t tx_first;
5602 cmd_start_tx_first_n_parsed(void *parsed_result,
5603 __attribute__((unused)) struct cmdline *cl,
5604 __attribute__((unused)) void *data)
5606 struct cmd_start_tx_first_n_result *res = parsed_result;
5608 start_packet_forwarding(res->tx_num);
5611 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5612 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5614 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5615 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5616 tx_first, "tx_first");
5617 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5618 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5621 cmdline_parse_inst_t cmd_start_tx_first_n = {
5622 .f = cmd_start_tx_first_n_parsed,
5624 .help_str = "start tx_first <num>: "
5625 "packet forwarding, after sending <num> bursts of packets",
5627 (void *)&cmd_start_tx_first_n_start,
5628 (void *)&cmd_start_tx_first_n_tx_first,
5629 (void *)&cmd_start_tx_first_n_tx_num,
5634 /* *** SET LINK UP *** */
5635 struct cmd_set_link_up_result {
5636 cmdline_fixed_string_t set;
5637 cmdline_fixed_string_t link_up;
5638 cmdline_fixed_string_t port;
5642 cmdline_parse_token_string_t cmd_set_link_up_set =
5643 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5644 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5645 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5647 cmdline_parse_token_string_t cmd_set_link_up_port =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5649 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5650 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5652 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5653 __attribute__((unused)) struct cmdline *cl,
5654 __attribute__((unused)) void *data)
5656 struct cmd_set_link_up_result *res = parsed_result;
5657 dev_set_link_up(res->port_id);
5660 cmdline_parse_inst_t cmd_set_link_up = {
5661 .f = cmd_set_link_up_parsed,
5663 .help_str = "set link-up port <port id>",
5665 (void *)&cmd_set_link_up_set,
5666 (void *)&cmd_set_link_up_link_up,
5667 (void *)&cmd_set_link_up_port,
5668 (void *)&cmd_set_link_up_port_id,
5673 /* *** SET LINK DOWN *** */
5674 struct cmd_set_link_down_result {
5675 cmdline_fixed_string_t set;
5676 cmdline_fixed_string_t link_down;
5677 cmdline_fixed_string_t port;
5681 cmdline_parse_token_string_t cmd_set_link_down_set =
5682 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5683 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5686 cmdline_parse_token_string_t cmd_set_link_down_port =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5688 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5689 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5691 static void cmd_set_link_down_parsed(
5692 __attribute__((unused)) void *parsed_result,
5693 __attribute__((unused)) struct cmdline *cl,
5694 __attribute__((unused)) void *data)
5696 struct cmd_set_link_down_result *res = parsed_result;
5697 dev_set_link_down(res->port_id);
5700 cmdline_parse_inst_t cmd_set_link_down = {
5701 .f = cmd_set_link_down_parsed,
5703 .help_str = "set link-down port <port id>",
5705 (void *)&cmd_set_link_down_set,
5706 (void *)&cmd_set_link_down_link_down,
5707 (void *)&cmd_set_link_down_port,
5708 (void *)&cmd_set_link_down_port_id,
5713 /* *** SHOW CFG *** */
5714 struct cmd_showcfg_result {
5715 cmdline_fixed_string_t show;
5716 cmdline_fixed_string_t cfg;
5717 cmdline_fixed_string_t what;
5720 static void cmd_showcfg_parsed(void *parsed_result,
5721 __attribute__((unused)) struct cmdline *cl,
5722 __attribute__((unused)) void *data)
5724 struct cmd_showcfg_result *res = parsed_result;
5725 if (!strcmp(res->what, "rxtx"))
5726 rxtx_config_display();
5727 else if (!strcmp(res->what, "cores"))
5728 fwd_lcores_config_display();
5729 else if (!strcmp(res->what, "fwd"))
5730 pkt_fwd_config_display(&cur_fwd_config);
5731 else if (!strcmp(res->what, "txpkts"))
5732 show_tx_pkt_segments();
5735 cmdline_parse_token_string_t cmd_showcfg_show =
5736 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5737 cmdline_parse_token_string_t cmd_showcfg_port =
5738 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5739 cmdline_parse_token_string_t cmd_showcfg_what =
5740 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5741 "rxtx#cores#fwd#txpkts");
5743 cmdline_parse_inst_t cmd_showcfg = {
5744 .f = cmd_showcfg_parsed,
5746 .help_str = "show config rxtx|cores|fwd|txpkts",
5748 (void *)&cmd_showcfg_show,
5749 (void *)&cmd_showcfg_port,
5750 (void *)&cmd_showcfg_what,
5755 /* *** SHOW ALL PORT INFO *** */
5756 struct cmd_showportall_result {
5757 cmdline_fixed_string_t show;
5758 cmdline_fixed_string_t port;
5759 cmdline_fixed_string_t what;
5760 cmdline_fixed_string_t all;
5763 static void cmd_showportall_parsed(void *parsed_result,
5764 __attribute__((unused)) struct cmdline *cl,
5765 __attribute__((unused)) void *data)
5769 struct cmd_showportall_result *res = parsed_result;
5770 if (!strcmp(res->show, "clear")) {
5771 if (!strcmp(res->what, "stats"))
5772 FOREACH_PORT(i, ports)
5774 else if (!strcmp(res->what, "xstats"))
5775 FOREACH_PORT(i, ports)
5776 nic_xstats_clear(i);
5777 } else if (!strcmp(res->what, "info"))
5778 FOREACH_PORT(i, ports)
5779 port_infos_display(i);
5780 else if (!strcmp(res->what, "stats"))
5781 FOREACH_PORT(i, ports)
5782 nic_stats_display(i);
5783 else if (!strcmp(res->what, "xstats"))
5784 FOREACH_PORT(i, ports)
5785 nic_xstats_display(i);
5786 else if (!strcmp(res->what, "fdir"))
5787 FOREACH_PORT(i, ports)
5789 else if (!strcmp(res->what, "stat_qmap"))
5790 FOREACH_PORT(i, ports)
5791 nic_stats_mapping_display(i);
5792 else if (!strcmp(res->what, "dcb_tc"))
5793 FOREACH_PORT(i, ports)
5794 port_dcb_info_display(i);
5797 cmdline_parse_token_string_t cmd_showportall_show =
5798 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5800 cmdline_parse_token_string_t cmd_showportall_port =
5801 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5802 cmdline_parse_token_string_t cmd_showportall_what =
5803 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5804 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5805 cmdline_parse_token_string_t cmd_showportall_all =
5806 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5807 cmdline_parse_inst_t cmd_showportall = {
5808 .f = cmd_showportall_parsed,
5810 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5812 (void *)&cmd_showportall_show,
5813 (void *)&cmd_showportall_port,
5814 (void *)&cmd_showportall_what,
5815 (void *)&cmd_showportall_all,
5820 /* *** SHOW PORT INFO *** */
5821 struct cmd_showport_result {
5822 cmdline_fixed_string_t show;
5823 cmdline_fixed_string_t port;
5824 cmdline_fixed_string_t what;
5828 static void cmd_showport_parsed(void *parsed_result,
5829 __attribute__((unused)) struct cmdline *cl,
5830 __attribute__((unused)) void *data)
5832 struct cmd_showport_result *res = parsed_result;
5833 if (!strcmp(res->show, "clear")) {
5834 if (!strcmp(res->what, "stats"))
5835 nic_stats_clear(res->portnum);
5836 else if (!strcmp(res->what, "xstats"))
5837 nic_xstats_clear(res->portnum);
5838 } else if (!strcmp(res->what, "info"))
5839 port_infos_display(res->portnum);
5840 else if (!strcmp(res->what, "stats"))
5841 nic_stats_display(res->portnum);
5842 else if (!strcmp(res->what, "xstats"))
5843 nic_xstats_display(res->portnum);
5844 else if (!strcmp(res->what, "fdir"))
5845 fdir_get_infos(res->portnum);
5846 else if (!strcmp(res->what, "stat_qmap"))
5847 nic_stats_mapping_display(res->portnum);
5848 else if (!strcmp(res->what, "dcb_tc"))
5849 port_dcb_info_display(res->portnum);
5852 cmdline_parse_token_string_t cmd_showport_show =
5853 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5855 cmdline_parse_token_string_t cmd_showport_port =
5856 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5857 cmdline_parse_token_string_t cmd_showport_what =
5858 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5859 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5860 cmdline_parse_token_num_t cmd_showport_portnum =
5861 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5863 cmdline_parse_inst_t cmd_showport = {
5864 .f = cmd_showport_parsed,
5866 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5869 (void *)&cmd_showport_show,
5870 (void *)&cmd_showport_port,
5871 (void *)&cmd_showport_what,
5872 (void *)&cmd_showport_portnum,
5877 /* *** SHOW QUEUE INFO *** */
5878 struct cmd_showqueue_result {
5879 cmdline_fixed_string_t show;
5880 cmdline_fixed_string_t type;
5881 cmdline_fixed_string_t what;
5887 cmd_showqueue_parsed(void *parsed_result,
5888 __attribute__((unused)) struct cmdline *cl,
5889 __attribute__((unused)) void *data)
5891 struct cmd_showqueue_result *res = parsed_result;
5893 if (!strcmp(res->type, "rxq"))
5894 rx_queue_infos_display(res->portnum, res->queuenum);
5895 else if (!strcmp(res->type, "txq"))
5896 tx_queue_infos_display(res->portnum, res->queuenum);
5899 cmdline_parse_token_string_t cmd_showqueue_show =
5900 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5901 cmdline_parse_token_string_t cmd_showqueue_type =
5902 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5903 cmdline_parse_token_string_t cmd_showqueue_what =
5904 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5905 cmdline_parse_token_num_t cmd_showqueue_portnum =
5906 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5907 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5908 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5910 cmdline_parse_inst_t cmd_showqueue = {
5911 .f = cmd_showqueue_parsed,
5913 .help_str = "show rxq|txq info <port_id> <queue_id>",
5915 (void *)&cmd_showqueue_show,
5916 (void *)&cmd_showqueue_type,
5917 (void *)&cmd_showqueue_what,
5918 (void *)&cmd_showqueue_portnum,
5919 (void *)&cmd_showqueue_queuenum,
5924 /* *** READ PORT REGISTER *** */
5925 struct cmd_read_reg_result {
5926 cmdline_fixed_string_t read;
5927 cmdline_fixed_string_t reg;
5933 cmd_read_reg_parsed(void *parsed_result,
5934 __attribute__((unused)) struct cmdline *cl,
5935 __attribute__((unused)) void *data)
5937 struct cmd_read_reg_result *res = parsed_result;
5938 port_reg_display(res->port_id, res->reg_off);
5941 cmdline_parse_token_string_t cmd_read_reg_read =
5942 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5943 cmdline_parse_token_string_t cmd_read_reg_reg =
5944 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5945 cmdline_parse_token_num_t cmd_read_reg_port_id =
5946 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5947 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5948 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5950 cmdline_parse_inst_t cmd_read_reg = {
5951 .f = cmd_read_reg_parsed,
5953 .help_str = "read reg <port_id> <reg_off>",
5955 (void *)&cmd_read_reg_read,
5956 (void *)&cmd_read_reg_reg,
5957 (void *)&cmd_read_reg_port_id,
5958 (void *)&cmd_read_reg_reg_off,
5963 /* *** READ PORT REGISTER BIT FIELD *** */
5964 struct cmd_read_reg_bit_field_result {
5965 cmdline_fixed_string_t read;
5966 cmdline_fixed_string_t regfield;
5974 cmd_read_reg_bit_field_parsed(void *parsed_result,
5975 __attribute__((unused)) struct cmdline *cl,
5976 __attribute__((unused)) void *data)
5978 struct cmd_read_reg_bit_field_result *res = parsed_result;
5979 port_reg_bit_field_display(res->port_id, res->reg_off,
5980 res->bit1_pos, res->bit2_pos);
5983 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5984 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5986 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5987 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5988 regfield, "regfield");
5989 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5990 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5992 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5993 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5995 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5996 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5998 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5999 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6002 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6003 .f = cmd_read_reg_bit_field_parsed,
6005 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6006 "Read register bit field between bit_x and bit_y included",
6008 (void *)&cmd_read_reg_bit_field_read,
6009 (void *)&cmd_read_reg_bit_field_regfield,
6010 (void *)&cmd_read_reg_bit_field_port_id,
6011 (void *)&cmd_read_reg_bit_field_reg_off,
6012 (void *)&cmd_read_reg_bit_field_bit1_pos,
6013 (void *)&cmd_read_reg_bit_field_bit2_pos,
6018 /* *** READ PORT REGISTER BIT *** */
6019 struct cmd_read_reg_bit_result {
6020 cmdline_fixed_string_t read;
6021 cmdline_fixed_string_t regbit;
6028 cmd_read_reg_bit_parsed(void *parsed_result,
6029 __attribute__((unused)) struct cmdline *cl,
6030 __attribute__((unused)) void *data)
6032 struct cmd_read_reg_bit_result *res = parsed_result;
6033 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6036 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6037 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6038 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6039 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6041 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6042 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6043 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6044 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6045 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6046 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6048 cmdline_parse_inst_t cmd_read_reg_bit = {
6049 .f = cmd_read_reg_bit_parsed,
6051 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6053 (void *)&cmd_read_reg_bit_read,
6054 (void *)&cmd_read_reg_bit_regbit,
6055 (void *)&cmd_read_reg_bit_port_id,
6056 (void *)&cmd_read_reg_bit_reg_off,
6057 (void *)&cmd_read_reg_bit_bit_pos,
6062 /* *** WRITE PORT REGISTER *** */
6063 struct cmd_write_reg_result {
6064 cmdline_fixed_string_t write;
6065 cmdline_fixed_string_t reg;
6072 cmd_write_reg_parsed(void *parsed_result,
6073 __attribute__((unused)) struct cmdline *cl,
6074 __attribute__((unused)) void *data)
6076 struct cmd_write_reg_result *res = parsed_result;
6077 port_reg_set(res->port_id, res->reg_off, res->value);
6080 cmdline_parse_token_string_t cmd_write_reg_write =
6081 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6082 cmdline_parse_token_string_t cmd_write_reg_reg =
6083 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6084 cmdline_parse_token_num_t cmd_write_reg_port_id =
6085 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6086 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6087 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6088 cmdline_parse_token_num_t cmd_write_reg_value =
6089 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6091 cmdline_parse_inst_t cmd_write_reg = {
6092 .f = cmd_write_reg_parsed,
6094 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6096 (void *)&cmd_write_reg_write,
6097 (void *)&cmd_write_reg_reg,
6098 (void *)&cmd_write_reg_port_id,
6099 (void *)&cmd_write_reg_reg_off,
6100 (void *)&cmd_write_reg_value,
6105 /* *** WRITE PORT REGISTER BIT FIELD *** */
6106 struct cmd_write_reg_bit_field_result {
6107 cmdline_fixed_string_t write;
6108 cmdline_fixed_string_t regfield;
6117 cmd_write_reg_bit_field_parsed(void *parsed_result,
6118 __attribute__((unused)) struct cmdline *cl,
6119 __attribute__((unused)) void *data)
6121 struct cmd_write_reg_bit_field_result *res = parsed_result;
6122 port_reg_bit_field_set(res->port_id, res->reg_off,
6123 res->bit1_pos, res->bit2_pos, res->value);
6126 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6127 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6129 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6130 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6131 regfield, "regfield");
6132 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6133 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6135 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6138 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6139 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6141 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6142 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6144 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6145 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6148 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6149 .f = cmd_write_reg_bit_field_parsed,
6151 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6153 "Set register bit field between bit_x and bit_y included",
6155 (void *)&cmd_write_reg_bit_field_write,
6156 (void *)&cmd_write_reg_bit_field_regfield,
6157 (void *)&cmd_write_reg_bit_field_port_id,
6158 (void *)&cmd_write_reg_bit_field_reg_off,
6159 (void *)&cmd_write_reg_bit_field_bit1_pos,
6160 (void *)&cmd_write_reg_bit_field_bit2_pos,
6161 (void *)&cmd_write_reg_bit_field_value,
6166 /* *** WRITE PORT REGISTER BIT *** */
6167 struct cmd_write_reg_bit_result {
6168 cmdline_fixed_string_t write;
6169 cmdline_fixed_string_t regbit;
6177 cmd_write_reg_bit_parsed(void *parsed_result,
6178 __attribute__((unused)) struct cmdline *cl,
6179 __attribute__((unused)) void *data)
6181 struct cmd_write_reg_bit_result *res = parsed_result;
6182 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6185 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6186 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6188 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6189 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6191 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6192 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6193 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6195 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6196 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6197 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6200 cmdline_parse_inst_t cmd_write_reg_bit = {
6201 .f = cmd_write_reg_bit_parsed,
6203 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6206 (void *)&cmd_write_reg_bit_write,
6207 (void *)&cmd_write_reg_bit_regbit,
6208 (void *)&cmd_write_reg_bit_port_id,
6209 (void *)&cmd_write_reg_bit_reg_off,
6210 (void *)&cmd_write_reg_bit_bit_pos,
6211 (void *)&cmd_write_reg_bit_value,
6216 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6217 struct cmd_read_rxd_txd_result {
6218 cmdline_fixed_string_t read;
6219 cmdline_fixed_string_t rxd_txd;
6226 cmd_read_rxd_txd_parsed(void *parsed_result,
6227 __attribute__((unused)) struct cmdline *cl,
6228 __attribute__((unused)) void *data)
6230 struct cmd_read_rxd_txd_result *res = parsed_result;
6232 if (!strcmp(res->rxd_txd, "rxd"))
6233 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6234 else if (!strcmp(res->rxd_txd, "txd"))
6235 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6238 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6239 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6240 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6241 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6243 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6244 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6245 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6246 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6247 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6248 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6250 cmdline_parse_inst_t cmd_read_rxd_txd = {
6251 .f = cmd_read_rxd_txd_parsed,
6253 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6255 (void *)&cmd_read_rxd_txd_read,
6256 (void *)&cmd_read_rxd_txd_rxd_txd,
6257 (void *)&cmd_read_rxd_txd_port_id,
6258 (void *)&cmd_read_rxd_txd_queue_id,
6259 (void *)&cmd_read_rxd_txd_desc_id,
6265 struct cmd_quit_result {
6266 cmdline_fixed_string_t quit;
6269 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6271 __attribute__((unused)) void *data)
6277 cmdline_parse_token_string_t cmd_quit_quit =
6278 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6280 cmdline_parse_inst_t cmd_quit = {
6281 .f = cmd_quit_parsed,
6283 .help_str = "quit: Exit application",
6285 (void *)&cmd_quit_quit,
6290 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6291 struct cmd_mac_addr_result {
6292 cmdline_fixed_string_t mac_addr_cmd;
6293 cmdline_fixed_string_t what;
6295 struct ether_addr address;
6298 static void cmd_mac_addr_parsed(void *parsed_result,
6299 __attribute__((unused)) struct cmdline *cl,
6300 __attribute__((unused)) void *data)
6302 struct cmd_mac_addr_result *res = parsed_result;
6305 if (strcmp(res->what, "add") == 0)
6306 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6308 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6310 /* check the return value and print it if is < 0 */
6312 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6316 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6317 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6319 cmdline_parse_token_string_t cmd_mac_addr_what =
6320 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6322 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6323 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6324 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6327 cmdline_parse_inst_t cmd_mac_addr = {
6328 .f = cmd_mac_addr_parsed,
6330 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6331 "Add/Remove MAC address on port_id",
6333 (void *)&cmd_mac_addr_cmd,
6334 (void *)&cmd_mac_addr_what,
6335 (void *)&cmd_mac_addr_portnum,
6336 (void *)&cmd_mac_addr_addr,
6342 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6343 struct cmd_set_qmap_result {
6344 cmdline_fixed_string_t set;
6345 cmdline_fixed_string_t qmap;
6346 cmdline_fixed_string_t what;
6353 cmd_set_qmap_parsed(void *parsed_result,
6354 __attribute__((unused)) struct cmdline *cl,
6355 __attribute__((unused)) void *data)
6357 struct cmd_set_qmap_result *res = parsed_result;
6358 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6360 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6363 cmdline_parse_token_string_t cmd_setqmap_set =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6366 cmdline_parse_token_string_t cmd_setqmap_qmap =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6369 cmdline_parse_token_string_t cmd_setqmap_what =
6370 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6372 cmdline_parse_token_num_t cmd_setqmap_portid =
6373 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6375 cmdline_parse_token_num_t cmd_setqmap_queueid =
6376 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6378 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6379 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6382 cmdline_parse_inst_t cmd_set_qmap = {
6383 .f = cmd_set_qmap_parsed,
6385 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6386 "Set statistics mapping value on tx|rx queue_id of port_id",
6388 (void *)&cmd_setqmap_set,
6389 (void *)&cmd_setqmap_qmap,
6390 (void *)&cmd_setqmap_what,
6391 (void *)&cmd_setqmap_portid,
6392 (void *)&cmd_setqmap_queueid,
6393 (void *)&cmd_setqmap_mapvalue,
6398 /* *** CONFIGURE UNICAST HASH TABLE *** */
6399 struct cmd_set_uc_hash_table {
6400 cmdline_fixed_string_t set;
6401 cmdline_fixed_string_t port;
6403 cmdline_fixed_string_t what;
6404 struct ether_addr address;
6405 cmdline_fixed_string_t mode;
6409 cmd_set_uc_hash_parsed(void *parsed_result,
6410 __attribute__((unused)) struct cmdline *cl,
6411 __attribute__((unused)) void *data)
6414 struct cmd_set_uc_hash_table *res = parsed_result;
6416 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6418 if (strcmp(res->what, "uta") == 0)
6419 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6420 &res->address,(uint8_t)is_on);
6422 printf("bad unicast hash table parameter, return code = %d \n", ret);
6426 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6429 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6430 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6432 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6433 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6435 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6438 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6439 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6441 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6442 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6445 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6446 .f = cmd_set_uc_hash_parsed,
6448 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6450 (void *)&cmd_set_uc_hash_set,
6451 (void *)&cmd_set_uc_hash_port,
6452 (void *)&cmd_set_uc_hash_portid,
6453 (void *)&cmd_set_uc_hash_what,
6454 (void *)&cmd_set_uc_hash_mac,
6455 (void *)&cmd_set_uc_hash_mode,
6460 struct cmd_set_uc_all_hash_table {
6461 cmdline_fixed_string_t set;
6462 cmdline_fixed_string_t port;
6464 cmdline_fixed_string_t what;
6465 cmdline_fixed_string_t value;
6466 cmdline_fixed_string_t mode;
6470 cmd_set_uc_all_hash_parsed(void *parsed_result,
6471 __attribute__((unused)) struct cmdline *cl,
6472 __attribute__((unused)) void *data)
6475 struct cmd_set_uc_all_hash_table *res = parsed_result;
6477 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6479 if ((strcmp(res->what, "uta") == 0) &&
6480 (strcmp(res->value, "all") == 0))
6481 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6483 printf("bad unicast hash table parameter,"
6484 "return code = %d \n", ret);
6487 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6490 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6493 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6494 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6496 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6499 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6502 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6506 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6507 .f = cmd_set_uc_all_hash_parsed,
6509 .help_str = "set port <port_id> uta all on|off",
6511 (void *)&cmd_set_uc_all_hash_set,
6512 (void *)&cmd_set_uc_all_hash_port,
6513 (void *)&cmd_set_uc_all_hash_portid,
6514 (void *)&cmd_set_uc_all_hash_what,
6515 (void *)&cmd_set_uc_all_hash_value,
6516 (void *)&cmd_set_uc_all_hash_mode,
6521 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6522 struct cmd_set_vf_macvlan_filter {
6523 cmdline_fixed_string_t set;
6524 cmdline_fixed_string_t port;
6526 cmdline_fixed_string_t vf;
6528 struct ether_addr address;
6529 cmdline_fixed_string_t filter_type;
6530 cmdline_fixed_string_t mode;
6534 cmd_set_vf_macvlan_parsed(void *parsed_result,
6535 __attribute__((unused)) struct cmdline *cl,
6536 __attribute__((unused)) void *data)
6539 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6540 struct rte_eth_mac_filter filter;
6542 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6544 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6546 /* set VF MAC filter */
6550 filter.dst_id = res->vf_id;
6552 if (!strcmp(res->filter_type, "exact-mac"))
6553 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6554 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6555 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6556 else if (!strcmp(res->filter_type, "hashmac"))
6557 filter.filter_type = RTE_MAC_HASH_MATCH;
6558 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6559 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6561 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6564 ret = rte_eth_dev_filter_ctrl(res->port_id,
6565 RTE_ETH_FILTER_MACVLAN,
6569 ret = rte_eth_dev_filter_ctrl(res->port_id,
6570 RTE_ETH_FILTER_MACVLAN,
6571 RTE_ETH_FILTER_DELETE,
6575 printf("bad set MAC hash parameter, return code = %d\n", ret);
6579 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6582 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6585 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6586 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6588 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6591 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6592 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6594 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6595 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6597 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6599 filter_type, "exact-mac#exact-mac-vlan"
6600 "#hashmac#hashmac-vlan");
6601 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6605 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6606 .f = cmd_set_vf_macvlan_parsed,
6608 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6609 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6610 "Exact match rule: exact match of MAC or MAC and VLAN; "
6611 "hash match rule: hash match of MAC and exact match of VLAN",
6613 (void *)&cmd_set_vf_macvlan_set,
6614 (void *)&cmd_set_vf_macvlan_port,
6615 (void *)&cmd_set_vf_macvlan_portid,
6616 (void *)&cmd_set_vf_macvlan_vf,
6617 (void *)&cmd_set_vf_macvlan_vf_id,
6618 (void *)&cmd_set_vf_macvlan_mac,
6619 (void *)&cmd_set_vf_macvlan_filter_type,
6620 (void *)&cmd_set_vf_macvlan_mode,
6625 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6626 struct cmd_set_vf_traffic {
6627 cmdline_fixed_string_t set;
6628 cmdline_fixed_string_t port;
6630 cmdline_fixed_string_t vf;
6632 cmdline_fixed_string_t what;
6633 cmdline_fixed_string_t mode;
6637 cmd_set_vf_traffic_parsed(void *parsed_result,
6638 __attribute__((unused)) struct cmdline *cl,
6639 __attribute__((unused)) void *data)
6641 struct cmd_set_vf_traffic *res = parsed_result;
6642 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6643 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6645 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6648 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6651 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6652 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6654 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6655 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6657 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6658 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6660 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6661 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6663 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6666 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6670 cmdline_parse_inst_t cmd_set_vf_traffic = {
6671 .f = cmd_set_vf_traffic_parsed,
6673 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6675 (void *)&cmd_setvf_traffic_set,
6676 (void *)&cmd_setvf_traffic_port,
6677 (void *)&cmd_setvf_traffic_portid,
6678 (void *)&cmd_setvf_traffic_vf,
6679 (void *)&cmd_setvf_traffic_vfid,
6680 (void *)&cmd_setvf_traffic_what,
6681 (void *)&cmd_setvf_traffic_mode,
6686 /* *** CONFIGURE VF RECEIVE MODE *** */
6687 struct cmd_set_vf_rxmode {
6688 cmdline_fixed_string_t set;
6689 cmdline_fixed_string_t port;
6691 cmdline_fixed_string_t vf;
6693 cmdline_fixed_string_t what;
6694 cmdline_fixed_string_t mode;
6695 cmdline_fixed_string_t on;
6699 cmd_set_vf_rxmode_parsed(void *parsed_result,
6700 __attribute__((unused)) struct cmdline *cl,
6701 __attribute__((unused)) void *data)
6704 uint16_t rx_mode = 0;
6705 struct cmd_set_vf_rxmode *res = parsed_result;
6707 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6708 if (!strcmp(res->what,"rxmode")) {
6709 if (!strcmp(res->mode, "AUPE"))
6710 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6711 else if (!strcmp(res->mode, "ROPE"))
6712 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6713 else if (!strcmp(res->mode, "BAM"))
6714 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6715 else if (!strncmp(res->mode, "MPE",3))
6716 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6719 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6721 printf("bad VF receive mode parameter, return code = %d \n",
6725 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6728 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6731 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6732 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6734 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6737 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6738 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6740 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6743 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6745 mode, "AUPE#ROPE#BAM#MPE");
6746 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6750 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6751 .f = cmd_set_vf_rxmode_parsed,
6753 .help_str = "set port <port_id> vf <vf_id> rxmode "
6754 "AUPE|ROPE|BAM|MPE on|off",
6756 (void *)&cmd_set_vf_rxmode_set,
6757 (void *)&cmd_set_vf_rxmode_port,
6758 (void *)&cmd_set_vf_rxmode_portid,
6759 (void *)&cmd_set_vf_rxmode_vf,
6760 (void *)&cmd_set_vf_rxmode_vfid,
6761 (void *)&cmd_set_vf_rxmode_what,
6762 (void *)&cmd_set_vf_rxmode_mode,
6763 (void *)&cmd_set_vf_rxmode_on,
6768 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6769 struct cmd_vf_mac_addr_result {
6770 cmdline_fixed_string_t mac_addr_cmd;
6771 cmdline_fixed_string_t what;
6772 cmdline_fixed_string_t port;
6774 cmdline_fixed_string_t vf;
6776 struct ether_addr address;
6779 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6780 __attribute__((unused)) struct cmdline *cl,
6781 __attribute__((unused)) void *data)
6783 struct cmd_vf_mac_addr_result *res = parsed_result;
6786 if (strcmp(res->what, "add") == 0)
6787 ret = rte_eth_dev_mac_addr_add(res->port_num,
6788 &res->address, res->vf_num);
6790 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6794 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6795 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6796 mac_addr_cmd,"mac_addr");
6797 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6798 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6800 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6801 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6803 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6804 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6806 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6807 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6809 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6810 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6812 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6813 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6816 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6817 .f = cmd_vf_mac_addr_parsed,
6819 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6820 "Add MAC address filtering for a VF on port_id",
6822 (void *)&cmd_vf_mac_addr_cmd,
6823 (void *)&cmd_vf_mac_addr_what,
6824 (void *)&cmd_vf_mac_addr_port,
6825 (void *)&cmd_vf_mac_addr_portnum,
6826 (void *)&cmd_vf_mac_addr_vf,
6827 (void *)&cmd_vf_mac_addr_vfnum,
6828 (void *)&cmd_vf_mac_addr_addr,
6833 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6834 struct cmd_vf_rx_vlan_filter {
6835 cmdline_fixed_string_t rx_vlan;
6836 cmdline_fixed_string_t what;
6838 cmdline_fixed_string_t port;
6840 cmdline_fixed_string_t vf;
6845 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6846 __attribute__((unused)) struct cmdline *cl,
6847 __attribute__((unused)) void *data)
6849 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6851 if (!strcmp(res->what, "add"))
6852 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6854 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6857 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6858 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6859 rx_vlan, "rx_vlan");
6860 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6861 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6863 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6864 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6866 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6867 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6869 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6870 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6872 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6873 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6875 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6876 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6879 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6880 .f = cmd_vf_rx_vlan_filter_parsed,
6882 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6883 "(vf_mask = hexadecimal VF mask)",
6885 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6886 (void *)&cmd_vf_rx_vlan_filter_what,
6887 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6888 (void *)&cmd_vf_rx_vlan_filter_port,
6889 (void *)&cmd_vf_rx_vlan_filter_portid,
6890 (void *)&cmd_vf_rx_vlan_filter_vf,
6891 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6896 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6897 struct cmd_queue_rate_limit_result {
6898 cmdline_fixed_string_t set;
6899 cmdline_fixed_string_t port;
6901 cmdline_fixed_string_t queue;
6903 cmdline_fixed_string_t rate;
6907 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6911 struct cmd_queue_rate_limit_result *res = parsed_result;
6914 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6915 && (strcmp(res->queue, "queue") == 0)
6916 && (strcmp(res->rate, "rate") == 0))
6917 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6920 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6924 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6925 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6927 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6928 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6930 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6931 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6933 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6934 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6936 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6937 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6939 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6940 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6942 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6943 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6946 cmdline_parse_inst_t cmd_queue_rate_limit = {
6947 .f = cmd_queue_rate_limit_parsed,
6949 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6950 "Set rate limit for a queue on port_id",
6952 (void *)&cmd_queue_rate_limit_set,
6953 (void *)&cmd_queue_rate_limit_port,
6954 (void *)&cmd_queue_rate_limit_portnum,
6955 (void *)&cmd_queue_rate_limit_queue,
6956 (void *)&cmd_queue_rate_limit_queuenum,
6957 (void *)&cmd_queue_rate_limit_rate,
6958 (void *)&cmd_queue_rate_limit_ratenum,
6963 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6964 struct cmd_vf_rate_limit_result {
6965 cmdline_fixed_string_t set;
6966 cmdline_fixed_string_t port;
6968 cmdline_fixed_string_t vf;
6970 cmdline_fixed_string_t rate;
6972 cmdline_fixed_string_t q_msk;
6976 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6977 __attribute__((unused)) struct cmdline *cl,
6978 __attribute__((unused)) void *data)
6980 struct cmd_vf_rate_limit_result *res = parsed_result;
6983 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6984 && (strcmp(res->vf, "vf") == 0)
6985 && (strcmp(res->rate, "rate") == 0)
6986 && (strcmp(res->q_msk, "queue_mask") == 0))
6987 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6988 res->rate_num, res->q_msk_val);
6990 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6994 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6995 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6997 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6998 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7000 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7001 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7003 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7004 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7006 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7007 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7009 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7010 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7012 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7013 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7015 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7016 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7017 q_msk, "queue_mask");
7018 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7019 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7022 cmdline_parse_inst_t cmd_vf_rate_limit = {
7023 .f = cmd_vf_rate_limit_parsed,
7025 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7026 "queue_mask <queue_mask_value>: "
7027 "Set rate limit for queues of VF on port_id",
7029 (void *)&cmd_vf_rate_limit_set,
7030 (void *)&cmd_vf_rate_limit_port,
7031 (void *)&cmd_vf_rate_limit_portnum,
7032 (void *)&cmd_vf_rate_limit_vf,
7033 (void *)&cmd_vf_rate_limit_vfnum,
7034 (void *)&cmd_vf_rate_limit_rate,
7035 (void *)&cmd_vf_rate_limit_ratenum,
7036 (void *)&cmd_vf_rate_limit_q_msk,
7037 (void *)&cmd_vf_rate_limit_q_msk_val,
7042 /* *** ADD TUNNEL FILTER OF A PORT *** */
7043 struct cmd_tunnel_filter_result {
7044 cmdline_fixed_string_t cmd;
7045 cmdline_fixed_string_t what;
7047 struct ether_addr outer_mac;
7048 struct ether_addr inner_mac;
7049 cmdline_ipaddr_t ip_value;
7050 uint16_t inner_vlan;
7051 cmdline_fixed_string_t tunnel_type;
7052 cmdline_fixed_string_t filter_type;
7058 cmd_tunnel_filter_parsed(void *parsed_result,
7059 __attribute__((unused)) struct cmdline *cl,
7060 __attribute__((unused)) void *data)
7062 struct cmd_tunnel_filter_result *res = parsed_result;
7063 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7066 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7068 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7069 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7070 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7072 if (res->ip_value.family == AF_INET) {
7073 tunnel_filter_conf.ip_addr.ipv4_addr =
7074 res->ip_value.addr.ipv4.s_addr;
7075 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7077 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7078 &(res->ip_value.addr.ipv6),
7079 sizeof(struct in6_addr));
7080 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7083 if (!strcmp(res->filter_type, "imac-ivlan"))
7084 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7085 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7086 tunnel_filter_conf.filter_type =
7087 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7088 else if (!strcmp(res->filter_type, "imac-tenid"))
7089 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7090 else if (!strcmp(res->filter_type, "imac"))
7091 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7092 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7093 tunnel_filter_conf.filter_type =
7094 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7095 else if (!strcmp(res->filter_type, "oip"))
7096 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7097 else if (!strcmp(res->filter_type, "iip"))
7098 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7100 printf("The filter type is not supported");
7104 if (!strcmp(res->tunnel_type, "vxlan"))
7105 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7106 else if (!strcmp(res->tunnel_type, "nvgre"))
7107 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7108 else if (!strcmp(res->tunnel_type, "ipingre"))
7109 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7111 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7115 tunnel_filter_conf.tenant_id = res->tenant_id;
7116 tunnel_filter_conf.queue_id = res->queue_num;
7117 if (!strcmp(res->what, "add"))
7118 ret = rte_eth_dev_filter_ctrl(res->port_id,
7119 RTE_ETH_FILTER_TUNNEL,
7121 &tunnel_filter_conf);
7123 ret = rte_eth_dev_filter_ctrl(res->port_id,
7124 RTE_ETH_FILTER_TUNNEL,
7125 RTE_ETH_FILTER_DELETE,
7126 &tunnel_filter_conf);
7128 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7132 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7133 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7134 cmd, "tunnel_filter");
7135 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7136 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7138 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7139 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7141 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7142 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7144 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7145 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7147 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7148 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7149 inner_vlan, UINT16);
7150 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7151 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7153 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7154 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7155 tunnel_type, "vxlan#nvgre#ipingre");
7157 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7158 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7159 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7160 "imac#omac-imac-tenid");
7161 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7162 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7164 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7165 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7168 cmdline_parse_inst_t cmd_tunnel_filter = {
7169 .f = cmd_tunnel_filter_parsed,
7171 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7172 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7173 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7174 "<queue_id>: Add/Rm tunnel filter of a port",
7176 (void *)&cmd_tunnel_filter_cmd,
7177 (void *)&cmd_tunnel_filter_what,
7178 (void *)&cmd_tunnel_filter_port_id,
7179 (void *)&cmd_tunnel_filter_outer_mac,
7180 (void *)&cmd_tunnel_filter_inner_mac,
7181 (void *)&cmd_tunnel_filter_ip_value,
7182 (void *)&cmd_tunnel_filter_innner_vlan,
7183 (void *)&cmd_tunnel_filter_tunnel_type,
7184 (void *)&cmd_tunnel_filter_filter_type,
7185 (void *)&cmd_tunnel_filter_tenant_id,
7186 (void *)&cmd_tunnel_filter_queue_num,
7191 /* *** CONFIGURE TUNNEL UDP PORT *** */
7192 struct cmd_tunnel_udp_config {
7193 cmdline_fixed_string_t cmd;
7194 cmdline_fixed_string_t what;
7200 cmd_tunnel_udp_config_parsed(void *parsed_result,
7201 __attribute__((unused)) struct cmdline *cl,
7202 __attribute__((unused)) void *data)
7204 struct cmd_tunnel_udp_config *res = parsed_result;
7205 struct rte_eth_udp_tunnel tunnel_udp;
7208 tunnel_udp.udp_port = res->udp_port;
7210 if (!strcmp(res->cmd, "rx_vxlan_port"))
7211 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7213 if (!strcmp(res->what, "add"))
7214 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7217 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7221 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7224 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7226 cmd, "rx_vxlan_port");
7227 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7230 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7233 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7234 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7237 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7238 .f = cmd_tunnel_udp_config_parsed,
7240 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7241 "Add/Remove a tunneling UDP port filter",
7243 (void *)&cmd_tunnel_udp_config_cmd,
7244 (void *)&cmd_tunnel_udp_config_what,
7245 (void *)&cmd_tunnel_udp_config_udp_port,
7246 (void *)&cmd_tunnel_udp_config_port_id,
7251 /* *** GLOBAL CONFIG *** */
7252 struct cmd_global_config_result {
7253 cmdline_fixed_string_t cmd;
7255 cmdline_fixed_string_t cfg_type;
7260 cmd_global_config_parsed(void *parsed_result,
7261 __attribute__((unused)) struct cmdline *cl,
7262 __attribute__((unused)) void *data)
7264 struct cmd_global_config_result *res = parsed_result;
7265 struct rte_eth_global_cfg conf;
7268 memset(&conf, 0, sizeof(conf));
7269 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7270 conf.cfg.gre_key_len = res->len;
7271 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7272 RTE_ETH_FILTER_SET, &conf);
7274 printf("Global config error\n");
7277 cmdline_parse_token_string_t cmd_global_config_cmd =
7278 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7280 cmdline_parse_token_num_t cmd_global_config_port_id =
7281 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7282 cmdline_parse_token_string_t cmd_global_config_type =
7283 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7284 cfg_type, "gre-key-len");
7285 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7286 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7289 cmdline_parse_inst_t cmd_global_config = {
7290 .f = cmd_global_config_parsed,
7291 .data = (void *)NULL,
7292 .help_str = "global_config <port_id> gre-key-len <key_len>",
7294 (void *)&cmd_global_config_cmd,
7295 (void *)&cmd_global_config_port_id,
7296 (void *)&cmd_global_config_type,
7297 (void *)&cmd_global_config_gre_key_len,
7302 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7303 struct cmd_set_mirror_mask_result {
7304 cmdline_fixed_string_t set;
7305 cmdline_fixed_string_t port;
7307 cmdline_fixed_string_t mirror;
7309 cmdline_fixed_string_t what;
7310 cmdline_fixed_string_t value;
7311 cmdline_fixed_string_t dstpool;
7313 cmdline_fixed_string_t on;
7316 cmdline_parse_token_string_t cmd_mirror_mask_set =
7317 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7319 cmdline_parse_token_string_t cmd_mirror_mask_port =
7320 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7322 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7323 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7325 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7327 mirror, "mirror-rule");
7328 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7329 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7331 cmdline_parse_token_string_t cmd_mirror_mask_what =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7333 what, "pool-mirror-up#pool-mirror-down"
7335 cmdline_parse_token_string_t cmd_mirror_mask_value =
7336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7338 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7339 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7340 dstpool, "dst-pool");
7341 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7342 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7344 cmdline_parse_token_string_t cmd_mirror_mask_on =
7345 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7349 cmd_set_mirror_mask_parsed(void *parsed_result,
7350 __attribute__((unused)) struct cmdline *cl,
7351 __attribute__((unused)) void *data)
7354 struct cmd_set_mirror_mask_result *res = parsed_result;
7355 struct rte_eth_mirror_conf mr_conf;
7357 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7359 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7361 mr_conf.dst_pool = res->dstpool_id;
7363 if (!strcmp(res->what, "pool-mirror-up")) {
7364 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7365 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7366 } else if (!strcmp(res->what, "pool-mirror-down")) {
7367 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7368 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7369 } else if (!strcmp(res->what, "vlan-mirror")) {
7370 mr_conf.rule_type = ETH_MIRROR_VLAN;
7371 nb_item = parse_item_list(res->value, "vlan",
7372 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7376 for (i = 0; i < nb_item; i++) {
7377 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7378 printf("Invalid vlan_id: must be < 4096\n");
7382 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7383 mr_conf.vlan.vlan_mask |= 1ULL << i;
7387 if (!strcmp(res->on, "on"))
7388 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7391 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7394 printf("mirror rule add error: (%s)\n", strerror(-ret));
7397 cmdline_parse_inst_t cmd_set_mirror_mask = {
7398 .f = cmd_set_mirror_mask_parsed,
7400 .help_str = "set port <port_id> mirror-rule <rule_id> "
7401 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7402 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7404 (void *)&cmd_mirror_mask_set,
7405 (void *)&cmd_mirror_mask_port,
7406 (void *)&cmd_mirror_mask_portid,
7407 (void *)&cmd_mirror_mask_mirror,
7408 (void *)&cmd_mirror_mask_ruleid,
7409 (void *)&cmd_mirror_mask_what,
7410 (void *)&cmd_mirror_mask_value,
7411 (void *)&cmd_mirror_mask_dstpool,
7412 (void *)&cmd_mirror_mask_poolid,
7413 (void *)&cmd_mirror_mask_on,
7418 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7419 struct cmd_set_mirror_link_result {
7420 cmdline_fixed_string_t set;
7421 cmdline_fixed_string_t port;
7423 cmdline_fixed_string_t mirror;
7425 cmdline_fixed_string_t what;
7426 cmdline_fixed_string_t dstpool;
7428 cmdline_fixed_string_t on;
7431 cmdline_parse_token_string_t cmd_mirror_link_set =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7434 cmdline_parse_token_string_t cmd_mirror_link_port =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7437 cmdline_parse_token_num_t cmd_mirror_link_portid =
7438 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7440 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7442 mirror, "mirror-rule");
7443 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7444 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7446 cmdline_parse_token_string_t cmd_mirror_link_what =
7447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7448 what, "uplink-mirror#downlink-mirror");
7449 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7450 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7451 dstpool, "dst-pool");
7452 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7453 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7455 cmdline_parse_token_string_t cmd_mirror_link_on =
7456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7460 cmd_set_mirror_link_parsed(void *parsed_result,
7461 __attribute__((unused)) struct cmdline *cl,
7462 __attribute__((unused)) void *data)
7465 struct cmd_set_mirror_link_result *res = parsed_result;
7466 struct rte_eth_mirror_conf mr_conf;
7468 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7469 if (!strcmp(res->what, "uplink-mirror"))
7470 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7472 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7474 mr_conf.dst_pool = res->dstpool_id;
7476 if (!strcmp(res->on, "on"))
7477 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7480 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7483 /* check the return value and print it if is < 0 */
7485 printf("mirror rule add error: (%s)\n", strerror(-ret));
7489 cmdline_parse_inst_t cmd_set_mirror_link = {
7490 .f = cmd_set_mirror_link_parsed,
7492 .help_str = "set port <port_id> mirror-rule <rule_id> "
7493 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7495 (void *)&cmd_mirror_link_set,
7496 (void *)&cmd_mirror_link_port,
7497 (void *)&cmd_mirror_link_portid,
7498 (void *)&cmd_mirror_link_mirror,
7499 (void *)&cmd_mirror_link_ruleid,
7500 (void *)&cmd_mirror_link_what,
7501 (void *)&cmd_mirror_link_dstpool,
7502 (void *)&cmd_mirror_link_poolid,
7503 (void *)&cmd_mirror_link_on,
7508 /* *** RESET VM MIRROR RULE *** */
7509 struct cmd_rm_mirror_rule_result {
7510 cmdline_fixed_string_t reset;
7511 cmdline_fixed_string_t port;
7513 cmdline_fixed_string_t mirror;
7517 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7518 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7520 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7521 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7523 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7524 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7526 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7527 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7528 mirror, "mirror-rule");
7529 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7530 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7534 cmd_reset_mirror_rule_parsed(void *parsed_result,
7535 __attribute__((unused)) struct cmdline *cl,
7536 __attribute__((unused)) void *data)
7539 struct cmd_set_mirror_link_result *res = parsed_result;
7541 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7543 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7546 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7547 .f = cmd_reset_mirror_rule_parsed,
7549 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7551 (void *)&cmd_rm_mirror_rule_reset,
7552 (void *)&cmd_rm_mirror_rule_port,
7553 (void *)&cmd_rm_mirror_rule_portid,
7554 (void *)&cmd_rm_mirror_rule_mirror,
7555 (void *)&cmd_rm_mirror_rule_ruleid,
7560 /* ******************************************************************************** */
7562 struct cmd_dump_result {
7563 cmdline_fixed_string_t dump;
7567 dump_struct_sizes(void)
7569 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7570 DUMP_SIZE(struct rte_mbuf);
7571 DUMP_SIZE(struct rte_mempool);
7572 DUMP_SIZE(struct rte_ring);
7576 static void cmd_dump_parsed(void *parsed_result,
7577 __attribute__((unused)) struct cmdline *cl,
7578 __attribute__((unused)) void *data)
7580 struct cmd_dump_result *res = parsed_result;
7582 if (!strcmp(res->dump, "dump_physmem"))
7583 rte_dump_physmem_layout(stdout);
7584 else if (!strcmp(res->dump, "dump_memzone"))
7585 rte_memzone_dump(stdout);
7586 else if (!strcmp(res->dump, "dump_struct_sizes"))
7587 dump_struct_sizes();
7588 else if (!strcmp(res->dump, "dump_ring"))
7589 rte_ring_list_dump(stdout);
7590 else if (!strcmp(res->dump, "dump_mempool"))
7591 rte_mempool_list_dump(stdout);
7592 else if (!strcmp(res->dump, "dump_devargs"))
7593 rte_eal_devargs_dump(stdout);
7596 cmdline_parse_token_string_t cmd_dump_dump =
7597 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7600 "dump_struct_sizes#"
7605 cmdline_parse_inst_t cmd_dump = {
7606 .f = cmd_dump_parsed, /* function to call */
7607 .data = NULL, /* 2nd arg of func */
7608 .help_str = "Dump status",
7609 .tokens = { /* token list, NULL terminated */
7610 (void *)&cmd_dump_dump,
7615 /* ******************************************************************************** */
7617 struct cmd_dump_one_result {
7618 cmdline_fixed_string_t dump;
7619 cmdline_fixed_string_t name;
7622 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7623 __attribute__((unused)) void *data)
7625 struct cmd_dump_one_result *res = parsed_result;
7627 if (!strcmp(res->dump, "dump_ring")) {
7629 r = rte_ring_lookup(res->name);
7631 cmdline_printf(cl, "Cannot find ring\n");
7634 rte_ring_dump(stdout, r);
7635 } else if (!strcmp(res->dump, "dump_mempool")) {
7636 struct rte_mempool *mp;
7637 mp = rte_mempool_lookup(res->name);
7639 cmdline_printf(cl, "Cannot find mempool\n");
7642 rte_mempool_dump(stdout, mp);
7646 cmdline_parse_token_string_t cmd_dump_one_dump =
7647 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7648 "dump_ring#dump_mempool");
7650 cmdline_parse_token_string_t cmd_dump_one_name =
7651 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7653 cmdline_parse_inst_t cmd_dump_one = {
7654 .f = cmd_dump_one_parsed, /* function to call */
7655 .data = NULL, /* 2nd arg of func */
7656 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7657 .tokens = { /* token list, NULL terminated */
7658 (void *)&cmd_dump_one_dump,
7659 (void *)&cmd_dump_one_name,
7664 /* *** Add/Del syn filter *** */
7665 struct cmd_syn_filter_result {
7666 cmdline_fixed_string_t filter;
7668 cmdline_fixed_string_t ops;
7669 cmdline_fixed_string_t priority;
7670 cmdline_fixed_string_t high;
7671 cmdline_fixed_string_t queue;
7676 cmd_syn_filter_parsed(void *parsed_result,
7677 __attribute__((unused)) struct cmdline *cl,
7678 __attribute__((unused)) void *data)
7680 struct cmd_syn_filter_result *res = parsed_result;
7681 struct rte_eth_syn_filter syn_filter;
7684 ret = rte_eth_dev_filter_supported(res->port_id,
7685 RTE_ETH_FILTER_SYN);
7687 printf("syn filter is not supported on port %u.\n",
7692 memset(&syn_filter, 0, sizeof(syn_filter));
7694 if (!strcmp(res->ops, "add")) {
7695 if (!strcmp(res->high, "high"))
7696 syn_filter.hig_pri = 1;
7698 syn_filter.hig_pri = 0;
7700 syn_filter.queue = res->queue_id;
7701 ret = rte_eth_dev_filter_ctrl(res->port_id,
7706 ret = rte_eth_dev_filter_ctrl(res->port_id,
7708 RTE_ETH_FILTER_DELETE,
7712 printf("syn filter programming error: (%s)\n",
7716 cmdline_parse_token_string_t cmd_syn_filter_filter =
7717 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7718 filter, "syn_filter");
7719 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7720 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7722 cmdline_parse_token_string_t cmd_syn_filter_ops =
7723 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7725 cmdline_parse_token_string_t cmd_syn_filter_priority =
7726 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7727 priority, "priority");
7728 cmdline_parse_token_string_t cmd_syn_filter_high =
7729 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7731 cmdline_parse_token_string_t cmd_syn_filter_queue =
7732 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7734 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7735 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7738 cmdline_parse_inst_t cmd_syn_filter = {
7739 .f = cmd_syn_filter_parsed,
7741 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7742 "<queue_id>: Add/Delete syn filter",
7744 (void *)&cmd_syn_filter_filter,
7745 (void *)&cmd_syn_filter_port_id,
7746 (void *)&cmd_syn_filter_ops,
7747 (void *)&cmd_syn_filter_priority,
7748 (void *)&cmd_syn_filter_high,
7749 (void *)&cmd_syn_filter_queue,
7750 (void *)&cmd_syn_filter_queue_id,
7755 /* *** ADD/REMOVE A 2tuple FILTER *** */
7756 struct cmd_2tuple_filter_result {
7757 cmdline_fixed_string_t filter;
7759 cmdline_fixed_string_t ops;
7760 cmdline_fixed_string_t dst_port;
7761 uint16_t dst_port_value;
7762 cmdline_fixed_string_t protocol;
7763 uint8_t protocol_value;
7764 cmdline_fixed_string_t mask;
7766 cmdline_fixed_string_t tcp_flags;
7767 uint8_t tcp_flags_value;
7768 cmdline_fixed_string_t priority;
7769 uint8_t priority_value;
7770 cmdline_fixed_string_t queue;
7775 cmd_2tuple_filter_parsed(void *parsed_result,
7776 __attribute__((unused)) struct cmdline *cl,
7777 __attribute__((unused)) void *data)
7779 struct rte_eth_ntuple_filter filter;
7780 struct cmd_2tuple_filter_result *res = parsed_result;
7783 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7785 printf("ntuple filter is not supported on port %u.\n",
7790 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7792 filter.flags = RTE_2TUPLE_FLAGS;
7793 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7794 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7795 filter.proto = res->protocol_value;
7796 filter.priority = res->priority_value;
7797 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7798 printf("nonzero tcp_flags is only meaningful"
7799 " when protocol is TCP.\n");
7802 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7803 printf("invalid TCP flags.\n");
7807 if (res->tcp_flags_value != 0) {
7808 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7809 filter.tcp_flags = res->tcp_flags_value;
7812 /* need convert to big endian. */
7813 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7814 filter.queue = res->queue_id;
7816 if (!strcmp(res->ops, "add"))
7817 ret = rte_eth_dev_filter_ctrl(res->port_id,
7818 RTE_ETH_FILTER_NTUPLE,
7822 ret = rte_eth_dev_filter_ctrl(res->port_id,
7823 RTE_ETH_FILTER_NTUPLE,
7824 RTE_ETH_FILTER_DELETE,
7827 printf("2tuple filter programming error: (%s)\n",
7832 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7833 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7834 filter, "2tuple_filter");
7835 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7836 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7838 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7839 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7841 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7842 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7843 dst_port, "dst_port");
7844 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7845 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7846 dst_port_value, UINT16);
7847 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7848 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7849 protocol, "protocol");
7850 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7851 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7852 protocol_value, UINT8);
7853 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7854 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7856 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7857 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7859 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7860 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7861 tcp_flags, "tcp_flags");
7862 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7863 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7864 tcp_flags_value, UINT8);
7865 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7866 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7867 priority, "priority");
7868 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7869 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7870 priority_value, UINT8);
7871 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7872 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7874 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7875 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7878 cmdline_parse_inst_t cmd_2tuple_filter = {
7879 .f = cmd_2tuple_filter_parsed,
7881 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7882 "<value> mask <value> tcp_flags <value> priority <value> queue "
7883 "<queue_id>: Add a 2tuple filter",
7885 (void *)&cmd_2tuple_filter_filter,
7886 (void *)&cmd_2tuple_filter_port_id,
7887 (void *)&cmd_2tuple_filter_ops,
7888 (void *)&cmd_2tuple_filter_dst_port,
7889 (void *)&cmd_2tuple_filter_dst_port_value,
7890 (void *)&cmd_2tuple_filter_protocol,
7891 (void *)&cmd_2tuple_filter_protocol_value,
7892 (void *)&cmd_2tuple_filter_mask,
7893 (void *)&cmd_2tuple_filter_mask_value,
7894 (void *)&cmd_2tuple_filter_tcp_flags,
7895 (void *)&cmd_2tuple_filter_tcp_flags_value,
7896 (void *)&cmd_2tuple_filter_priority,
7897 (void *)&cmd_2tuple_filter_priority_value,
7898 (void *)&cmd_2tuple_filter_queue,
7899 (void *)&cmd_2tuple_filter_queue_id,
7904 /* *** ADD/REMOVE A 5tuple FILTER *** */
7905 struct cmd_5tuple_filter_result {
7906 cmdline_fixed_string_t filter;
7908 cmdline_fixed_string_t ops;
7909 cmdline_fixed_string_t dst_ip;
7910 cmdline_ipaddr_t dst_ip_value;
7911 cmdline_fixed_string_t src_ip;
7912 cmdline_ipaddr_t src_ip_value;
7913 cmdline_fixed_string_t dst_port;
7914 uint16_t dst_port_value;
7915 cmdline_fixed_string_t src_port;
7916 uint16_t src_port_value;
7917 cmdline_fixed_string_t protocol;
7918 uint8_t protocol_value;
7919 cmdline_fixed_string_t mask;
7921 cmdline_fixed_string_t tcp_flags;
7922 uint8_t tcp_flags_value;
7923 cmdline_fixed_string_t priority;
7924 uint8_t priority_value;
7925 cmdline_fixed_string_t queue;
7930 cmd_5tuple_filter_parsed(void *parsed_result,
7931 __attribute__((unused)) struct cmdline *cl,
7932 __attribute__((unused)) void *data)
7934 struct rte_eth_ntuple_filter filter;
7935 struct cmd_5tuple_filter_result *res = parsed_result;
7938 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7940 printf("ntuple filter is not supported on port %u.\n",
7945 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7947 filter.flags = RTE_5TUPLE_FLAGS;
7948 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7949 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7950 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7951 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7952 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7953 filter.proto = res->protocol_value;
7954 filter.priority = res->priority_value;
7955 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7956 printf("nonzero tcp_flags is only meaningful"
7957 " when protocol is TCP.\n");
7960 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7961 printf("invalid TCP flags.\n");
7965 if (res->tcp_flags_value != 0) {
7966 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7967 filter.tcp_flags = res->tcp_flags_value;
7970 if (res->dst_ip_value.family == AF_INET)
7971 /* no need to convert, already big endian. */
7972 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7974 if (filter.dst_ip_mask == 0) {
7975 printf("can not support ipv6 involved compare.\n");
7981 if (res->src_ip_value.family == AF_INET)
7982 /* no need to convert, already big endian. */
7983 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7985 if (filter.src_ip_mask == 0) {
7986 printf("can not support ipv6 involved compare.\n");
7991 /* need convert to big endian. */
7992 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7993 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7994 filter.queue = res->queue_id;
7996 if (!strcmp(res->ops, "add"))
7997 ret = rte_eth_dev_filter_ctrl(res->port_id,
7998 RTE_ETH_FILTER_NTUPLE,
8002 ret = rte_eth_dev_filter_ctrl(res->port_id,
8003 RTE_ETH_FILTER_NTUPLE,
8004 RTE_ETH_FILTER_DELETE,
8007 printf("5tuple filter programming error: (%s)\n",
8011 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8012 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8013 filter, "5tuple_filter");
8014 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8015 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8017 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8018 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8020 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8021 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8023 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8024 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8026 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8027 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8029 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8030 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8032 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8033 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8034 dst_port, "dst_port");
8035 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8036 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8037 dst_port_value, UINT16);
8038 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8039 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8040 src_port, "src_port");
8041 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8042 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8043 src_port_value, UINT16);
8044 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8045 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8046 protocol, "protocol");
8047 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8048 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8049 protocol_value, UINT8);
8050 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8051 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8053 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8054 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8056 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8057 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8058 tcp_flags, "tcp_flags");
8059 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8060 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8061 tcp_flags_value, UINT8);
8062 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8063 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8064 priority, "priority");
8065 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8066 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8067 priority_value, UINT8);
8068 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8069 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8071 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8072 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8075 cmdline_parse_inst_t cmd_5tuple_filter = {
8076 .f = cmd_5tuple_filter_parsed,
8078 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8079 "src_ip <value> dst_port <value> src_port <value> "
8080 "protocol <value> mask <value> tcp_flags <value> "
8081 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8083 (void *)&cmd_5tuple_filter_filter,
8084 (void *)&cmd_5tuple_filter_port_id,
8085 (void *)&cmd_5tuple_filter_ops,
8086 (void *)&cmd_5tuple_filter_dst_ip,
8087 (void *)&cmd_5tuple_filter_dst_ip_value,
8088 (void *)&cmd_5tuple_filter_src_ip,
8089 (void *)&cmd_5tuple_filter_src_ip_value,
8090 (void *)&cmd_5tuple_filter_dst_port,
8091 (void *)&cmd_5tuple_filter_dst_port_value,
8092 (void *)&cmd_5tuple_filter_src_port,
8093 (void *)&cmd_5tuple_filter_src_port_value,
8094 (void *)&cmd_5tuple_filter_protocol,
8095 (void *)&cmd_5tuple_filter_protocol_value,
8096 (void *)&cmd_5tuple_filter_mask,
8097 (void *)&cmd_5tuple_filter_mask_value,
8098 (void *)&cmd_5tuple_filter_tcp_flags,
8099 (void *)&cmd_5tuple_filter_tcp_flags_value,
8100 (void *)&cmd_5tuple_filter_priority,
8101 (void *)&cmd_5tuple_filter_priority_value,
8102 (void *)&cmd_5tuple_filter_queue,
8103 (void *)&cmd_5tuple_filter_queue_id,
8108 /* *** ADD/REMOVE A flex FILTER *** */
8109 struct cmd_flex_filter_result {
8110 cmdline_fixed_string_t filter;
8111 cmdline_fixed_string_t ops;
8113 cmdline_fixed_string_t len;
8115 cmdline_fixed_string_t bytes;
8116 cmdline_fixed_string_t bytes_value;
8117 cmdline_fixed_string_t mask;
8118 cmdline_fixed_string_t mask_value;
8119 cmdline_fixed_string_t priority;
8120 uint8_t priority_value;
8121 cmdline_fixed_string_t queue;
8125 static int xdigit2val(unsigned char c)
8130 else if (isupper(c))
8138 cmd_flex_filter_parsed(void *parsed_result,
8139 __attribute__((unused)) struct cmdline *cl,
8140 __attribute__((unused)) void *data)
8143 struct rte_eth_flex_filter filter;
8144 struct cmd_flex_filter_result *res = parsed_result;
8145 char *bytes_ptr, *mask_ptr;
8146 uint16_t len, i, j = 0;
8151 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8152 printf("the len exceed the max length 128\n");
8155 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8156 filter.len = res->len_value;
8157 filter.priority = res->priority_value;
8158 filter.queue = res->queue_id;
8159 bytes_ptr = res->bytes_value;
8160 mask_ptr = res->mask_value;
8162 /* translate bytes string to array. */
8163 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8164 (bytes_ptr[1] == 'X')))
8166 len = strnlen(bytes_ptr, res->len_value * 2);
8167 if (len == 0 || (len % 8 != 0)) {
8168 printf("please check len and bytes input\n");
8171 for (i = 0; i < len; i++) {
8173 if (isxdigit(c) == 0) {
8174 /* invalid characters. */
8175 printf("invalid input\n");
8178 val = xdigit2val(c);
8181 filter.bytes[j] = byte;
8182 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8189 /* translate mask string to uint8_t array. */
8190 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8191 (mask_ptr[1] == 'X')))
8193 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8195 printf("invalid input\n");
8200 for (i = 0; i < len; i++) {
8202 if (isxdigit(c) == 0) {
8203 /* invalid characters. */
8204 printf("invalid input\n");
8207 val = xdigit2val(c);
8210 filter.mask[j] = byte;
8211 printf("mask[%d]:%02x ", j, filter.mask[j]);
8219 if (!strcmp(res->ops, "add"))
8220 ret = rte_eth_dev_filter_ctrl(res->port_id,
8221 RTE_ETH_FILTER_FLEXIBLE,
8225 ret = rte_eth_dev_filter_ctrl(res->port_id,
8226 RTE_ETH_FILTER_FLEXIBLE,
8227 RTE_ETH_FILTER_DELETE,
8231 printf("flex filter setting error: (%s)\n", strerror(-ret));
8234 cmdline_parse_token_string_t cmd_flex_filter_filter =
8235 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8236 filter, "flex_filter");
8237 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8238 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8240 cmdline_parse_token_string_t cmd_flex_filter_ops =
8241 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8243 cmdline_parse_token_string_t cmd_flex_filter_len =
8244 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8246 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8247 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8249 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8250 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8252 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8253 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8255 cmdline_parse_token_string_t cmd_flex_filter_mask =
8256 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8258 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8259 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8261 cmdline_parse_token_string_t cmd_flex_filter_priority =
8262 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8263 priority, "priority");
8264 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8265 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8266 priority_value, UINT8);
8267 cmdline_parse_token_string_t cmd_flex_filter_queue =
8268 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8270 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8271 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8273 cmdline_parse_inst_t cmd_flex_filter = {
8274 .f = cmd_flex_filter_parsed,
8276 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8277 "<value> mask <value> priority <value> queue <queue_id>: "
8278 "Add/Del a flex filter",
8280 (void *)&cmd_flex_filter_filter,
8281 (void *)&cmd_flex_filter_port_id,
8282 (void *)&cmd_flex_filter_ops,
8283 (void *)&cmd_flex_filter_len,
8284 (void *)&cmd_flex_filter_len_value,
8285 (void *)&cmd_flex_filter_bytes,
8286 (void *)&cmd_flex_filter_bytes_value,
8287 (void *)&cmd_flex_filter_mask,
8288 (void *)&cmd_flex_filter_mask_value,
8289 (void *)&cmd_flex_filter_priority,
8290 (void *)&cmd_flex_filter_priority_value,
8291 (void *)&cmd_flex_filter_queue,
8292 (void *)&cmd_flex_filter_queue_id,
8297 /* *** Filters Control *** */
8299 /* *** deal with ethertype filter *** */
8300 struct cmd_ethertype_filter_result {
8301 cmdline_fixed_string_t filter;
8303 cmdline_fixed_string_t ops;
8304 cmdline_fixed_string_t mac;
8305 struct ether_addr mac_addr;
8306 cmdline_fixed_string_t ethertype;
8307 uint16_t ethertype_value;
8308 cmdline_fixed_string_t drop;
8309 cmdline_fixed_string_t queue;
8313 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8314 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8315 filter, "ethertype_filter");
8316 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8317 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8319 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8320 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8322 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8323 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8324 mac, "mac_addr#mac_ignr");
8325 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8326 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8328 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8329 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8330 ethertype, "ethertype");
8331 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8332 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8333 ethertype_value, UINT16);
8334 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8335 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8337 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8338 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8340 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8341 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8345 cmd_ethertype_filter_parsed(void *parsed_result,
8346 __attribute__((unused)) struct cmdline *cl,
8347 __attribute__((unused)) void *data)
8349 struct cmd_ethertype_filter_result *res = parsed_result;
8350 struct rte_eth_ethertype_filter filter;
8353 ret = rte_eth_dev_filter_supported(res->port_id,
8354 RTE_ETH_FILTER_ETHERTYPE);
8356 printf("ethertype filter is not supported on port %u.\n",
8361 memset(&filter, 0, sizeof(filter));
8362 if (!strcmp(res->mac, "mac_addr")) {
8363 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8364 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8365 sizeof(struct ether_addr));
8367 if (!strcmp(res->drop, "drop"))
8368 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8369 filter.ether_type = res->ethertype_value;
8370 filter.queue = res->queue_id;
8372 if (!strcmp(res->ops, "add"))
8373 ret = rte_eth_dev_filter_ctrl(res->port_id,
8374 RTE_ETH_FILTER_ETHERTYPE,
8378 ret = rte_eth_dev_filter_ctrl(res->port_id,
8379 RTE_ETH_FILTER_ETHERTYPE,
8380 RTE_ETH_FILTER_DELETE,
8383 printf("ethertype filter programming error: (%s)\n",
8387 cmdline_parse_inst_t cmd_ethertype_filter = {
8388 .f = cmd_ethertype_filter_parsed,
8390 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8391 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8392 "Add or delete an ethertype filter entry",
8394 (void *)&cmd_ethertype_filter_filter,
8395 (void *)&cmd_ethertype_filter_port_id,
8396 (void *)&cmd_ethertype_filter_ops,
8397 (void *)&cmd_ethertype_filter_mac,
8398 (void *)&cmd_ethertype_filter_mac_addr,
8399 (void *)&cmd_ethertype_filter_ethertype,
8400 (void *)&cmd_ethertype_filter_ethertype_value,
8401 (void *)&cmd_ethertype_filter_drop,
8402 (void *)&cmd_ethertype_filter_queue,
8403 (void *)&cmd_ethertype_filter_queue_id,
8408 /* *** deal with flow director filter *** */
8409 struct cmd_flow_director_result {
8410 cmdline_fixed_string_t flow_director_filter;
8412 cmdline_fixed_string_t mode;
8413 cmdline_fixed_string_t mode_value;
8414 cmdline_fixed_string_t ops;
8415 cmdline_fixed_string_t flow;
8416 cmdline_fixed_string_t flow_type;
8417 cmdline_fixed_string_t ether;
8418 uint16_t ether_type;
8419 cmdline_fixed_string_t src;
8420 cmdline_ipaddr_t ip_src;
8422 cmdline_fixed_string_t dst;
8423 cmdline_ipaddr_t ip_dst;
8425 cmdline_fixed_string_t verify_tag;
8426 uint32_t verify_tag_value;
8427 cmdline_ipaddr_t tos;
8429 cmdline_ipaddr_t proto;
8430 uint8_t proto_value;
8431 cmdline_ipaddr_t ttl;
8433 cmdline_fixed_string_t vlan;
8434 uint16_t vlan_value;
8435 cmdline_fixed_string_t flexbytes;
8436 cmdline_fixed_string_t flexbytes_value;
8437 cmdline_fixed_string_t pf_vf;
8438 cmdline_fixed_string_t drop;
8439 cmdline_fixed_string_t queue;
8441 cmdline_fixed_string_t fd_id;
8442 uint32_t fd_id_value;
8443 cmdline_fixed_string_t mac;
8444 struct ether_addr mac_addr;
8445 cmdline_fixed_string_t tunnel;
8446 cmdline_fixed_string_t tunnel_type;
8447 cmdline_fixed_string_t tunnel_id;
8448 uint32_t tunnel_id_value;
8452 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8455 const char *p, *p0 = q_arg;
8457 unsigned long int_fld;
8458 char *str_fld[max_num];
8463 p = strchr(p0, '(');
8467 p0 = strchr(p, ')');
8472 if (size >= sizeof(s))
8475 snprintf(s, sizeof(s), "%.*s", size, p);
8476 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8477 if (ret < 0 || ret > max_num)
8479 for (i = 0; i < ret; i++) {
8481 int_fld = strtoul(str_fld[i], &end, 0);
8482 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8484 flexbytes[i] = (uint8_t)int_fld;
8490 str2flowtype(char *string)
8493 static const struct {
8496 } flowtype_str[] = {
8497 {"raw", RTE_ETH_FLOW_RAW},
8498 {"ipv4", RTE_ETH_FLOW_IPV4},
8499 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8500 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8501 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8502 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8503 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8504 {"ipv6", RTE_ETH_FLOW_IPV6},
8505 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8506 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8507 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8508 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8509 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8510 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8513 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8514 if (!strcmp(flowtype_str[i].str, string))
8515 return flowtype_str[i].type;
8517 return RTE_ETH_FLOW_UNKNOWN;
8520 static enum rte_eth_fdir_tunnel_type
8521 str2fdir_tunneltype(char *string)
8525 static const struct {
8527 enum rte_eth_fdir_tunnel_type type;
8528 } tunneltype_str[] = {
8529 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8530 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8533 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8534 if (!strcmp(tunneltype_str[i].str, string))
8535 return tunneltype_str[i].type;
8537 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8540 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8542 if ((ip_addr).family == AF_INET) \
8543 (ip) = (ip_addr).addr.ipv4.s_addr; \
8545 printf("invalid parameter.\n"); \
8550 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8552 if ((ip_addr).family == AF_INET6) \
8553 (void)rte_memcpy(&(ip), \
8554 &((ip_addr).addr.ipv6), \
8555 sizeof(struct in6_addr)); \
8557 printf("invalid parameter.\n"); \
8563 cmd_flow_director_filter_parsed(void *parsed_result,
8564 __attribute__((unused)) struct cmdline *cl,
8565 __attribute__((unused)) void *data)
8567 struct cmd_flow_director_result *res = parsed_result;
8568 struct rte_eth_fdir_filter entry;
8569 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8571 unsigned long vf_id;
8574 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8576 printf("flow director is not supported on port %u.\n",
8580 memset(flexbytes, 0, sizeof(flexbytes));
8581 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8583 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8584 if (strcmp(res->mode_value, "MAC-VLAN")) {
8585 printf("Please set mode to MAC-VLAN.\n");
8588 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8589 if (strcmp(res->mode_value, "Tunnel")) {
8590 printf("Please set mode to Tunnel.\n");
8594 if (strcmp(res->mode_value, "IP")) {
8595 printf("Please set mode to IP.\n");
8598 entry.input.flow_type = str2flowtype(res->flow_type);
8601 ret = parse_flexbytes(res->flexbytes_value,
8603 RTE_ETH_FDIR_MAX_FLEXLEN);
8605 printf("error: Cannot parse flexbytes input.\n");
8609 switch (entry.input.flow_type) {
8610 case RTE_ETH_FLOW_FRAG_IPV4:
8611 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8612 entry.input.flow.ip4_flow.proto = res->proto_value;
8613 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8614 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8615 IPV4_ADDR_TO_UINT(res->ip_dst,
8616 entry.input.flow.ip4_flow.dst_ip);
8617 IPV4_ADDR_TO_UINT(res->ip_src,
8618 entry.input.flow.ip4_flow.src_ip);
8619 entry.input.flow.ip4_flow.tos = res->tos_value;
8620 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8621 /* need convert to big endian. */
8622 entry.input.flow.udp4_flow.dst_port =
8623 rte_cpu_to_be_16(res->port_dst);
8624 entry.input.flow.udp4_flow.src_port =
8625 rte_cpu_to_be_16(res->port_src);
8627 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8628 IPV4_ADDR_TO_UINT(res->ip_dst,
8629 entry.input.flow.sctp4_flow.ip.dst_ip);
8630 IPV4_ADDR_TO_UINT(res->ip_src,
8631 entry.input.flow.sctp4_flow.ip.src_ip);
8632 entry.input.flow.ip4_flow.tos = res->tos_value;
8633 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8634 /* need convert to big endian. */
8635 entry.input.flow.sctp4_flow.dst_port =
8636 rte_cpu_to_be_16(res->port_dst);
8637 entry.input.flow.sctp4_flow.src_port =
8638 rte_cpu_to_be_16(res->port_src);
8639 entry.input.flow.sctp4_flow.verify_tag =
8640 rte_cpu_to_be_32(res->verify_tag_value);
8642 case RTE_ETH_FLOW_FRAG_IPV6:
8643 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8644 entry.input.flow.ipv6_flow.proto = res->proto_value;
8645 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8646 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8647 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8648 entry.input.flow.ipv6_flow.dst_ip);
8649 IPV6_ADDR_TO_ARRAY(res->ip_src,
8650 entry.input.flow.ipv6_flow.src_ip);
8651 entry.input.flow.ipv6_flow.tc = res->tos_value;
8652 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8653 /* need convert to big endian. */
8654 entry.input.flow.udp6_flow.dst_port =
8655 rte_cpu_to_be_16(res->port_dst);
8656 entry.input.flow.udp6_flow.src_port =
8657 rte_cpu_to_be_16(res->port_src);
8659 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8660 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8661 entry.input.flow.sctp6_flow.ip.dst_ip);
8662 IPV6_ADDR_TO_ARRAY(res->ip_src,
8663 entry.input.flow.sctp6_flow.ip.src_ip);
8664 entry.input.flow.ipv6_flow.tc = res->tos_value;
8665 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8666 /* need convert to big endian. */
8667 entry.input.flow.sctp6_flow.dst_port =
8668 rte_cpu_to_be_16(res->port_dst);
8669 entry.input.flow.sctp6_flow.src_port =
8670 rte_cpu_to_be_16(res->port_src);
8671 entry.input.flow.sctp6_flow.verify_tag =
8672 rte_cpu_to_be_32(res->verify_tag_value);
8674 case RTE_ETH_FLOW_L2_PAYLOAD:
8675 entry.input.flow.l2_flow.ether_type =
8676 rte_cpu_to_be_16(res->ether_type);
8682 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8683 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8685 sizeof(struct ether_addr));
8687 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8688 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8690 sizeof(struct ether_addr));
8691 entry.input.flow.tunnel_flow.tunnel_type =
8692 str2fdir_tunneltype(res->tunnel_type);
8693 entry.input.flow.tunnel_flow.tunnel_id =
8694 rte_cpu_to_be_32(res->tunnel_id_value);
8697 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8699 RTE_ETH_FDIR_MAX_FLEXLEN);
8701 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8703 entry.action.flex_off = 0; /*use 0 by default */
8704 if (!strcmp(res->drop, "drop"))
8705 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8707 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8709 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8710 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8711 if (!strcmp(res->pf_vf, "pf"))
8712 entry.input.flow_ext.is_vf = 0;
8713 else if (!strncmp(res->pf_vf, "vf", 2)) {
8714 struct rte_eth_dev_info dev_info;
8716 memset(&dev_info, 0, sizeof(dev_info));
8717 rte_eth_dev_info_get(res->port_id, &dev_info);
8719 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8720 if (errno != 0 || *end != '\0' ||
8721 vf_id >= dev_info.max_vfs) {
8722 printf("invalid parameter %s.\n", res->pf_vf);
8725 entry.input.flow_ext.is_vf = 1;
8726 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8728 printf("invalid parameter %s.\n", res->pf_vf);
8733 /* set to report FD ID by default */
8734 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8735 entry.action.rx_queue = res->queue_id;
8736 entry.soft_id = res->fd_id_value;
8737 if (!strcmp(res->ops, "add"))
8738 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8739 RTE_ETH_FILTER_ADD, &entry);
8740 else if (!strcmp(res->ops, "del"))
8741 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8742 RTE_ETH_FILTER_DELETE, &entry);
8744 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8745 RTE_ETH_FILTER_UPDATE, &entry);
8747 printf("flow director programming error: (%s)\n",
8751 cmdline_parse_token_string_t cmd_flow_director_filter =
8752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8753 flow_director_filter, "flow_director_filter");
8754 cmdline_parse_token_num_t cmd_flow_director_port_id =
8755 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8757 cmdline_parse_token_string_t cmd_flow_director_ops =
8758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8759 ops, "add#del#update");
8760 cmdline_parse_token_string_t cmd_flow_director_flow =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8763 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8765 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8766 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8767 cmdline_parse_token_string_t cmd_flow_director_ether =
8768 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8770 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8771 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8772 ether_type, UINT16);
8773 cmdline_parse_token_string_t cmd_flow_director_src =
8774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8776 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8777 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8779 cmdline_parse_token_num_t cmd_flow_director_port_src =
8780 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8782 cmdline_parse_token_string_t cmd_flow_director_dst =
8783 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8785 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8786 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8788 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8789 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8791 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8793 verify_tag, "verify_tag");
8794 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8795 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8796 verify_tag_value, UINT32);
8797 cmdline_parse_token_string_t cmd_flow_director_tos =
8798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8800 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8801 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8803 cmdline_parse_token_string_t cmd_flow_director_proto =
8804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8806 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8808 proto_value, UINT8);
8809 cmdline_parse_token_string_t cmd_flow_director_ttl =
8810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8812 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8815 cmdline_parse_token_string_t cmd_flow_director_vlan =
8816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8818 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8820 vlan_value, UINT16);
8821 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8823 flexbytes, "flexbytes");
8824 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8826 flexbytes_value, NULL);
8827 cmdline_parse_token_string_t cmd_flow_director_drop =
8828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_string_t cmd_flow_director_queue =
8834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8836 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8842 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8844 fd_id_value, UINT32);
8846 cmdline_parse_token_string_t cmd_flow_director_mode =
8847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8849 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8852 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8854 mode_value, "MAC-VLAN");
8855 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8857 mode_value, "Tunnel");
8858 cmdline_parse_token_string_t cmd_flow_director_mac =
8859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8861 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8862 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8864 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8867 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 tunnel_type, "NVGRE#VxLAN");
8870 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8872 tunnel_id, "tunnel-id");
8873 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8874 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8875 tunnel_id_value, UINT32);
8877 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8878 .f = cmd_flow_director_filter_parsed,
8880 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8881 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8882 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8883 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8884 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8885 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8886 "fd_id <fd_id_value>: "
8887 "Add or delete an ip flow director entry on NIC",
8889 (void *)&cmd_flow_director_filter,
8890 (void *)&cmd_flow_director_port_id,
8891 (void *)&cmd_flow_director_mode,
8892 (void *)&cmd_flow_director_mode_ip,
8893 (void *)&cmd_flow_director_ops,
8894 (void *)&cmd_flow_director_flow,
8895 (void *)&cmd_flow_director_flow_type,
8896 (void *)&cmd_flow_director_src,
8897 (void *)&cmd_flow_director_ip_src,
8898 (void *)&cmd_flow_director_dst,
8899 (void *)&cmd_flow_director_ip_dst,
8900 (void *)&cmd_flow_director_tos,
8901 (void *)&cmd_flow_director_tos_value,
8902 (void *)&cmd_flow_director_proto,
8903 (void *)&cmd_flow_director_proto_value,
8904 (void *)&cmd_flow_director_ttl,
8905 (void *)&cmd_flow_director_ttl_value,
8906 (void *)&cmd_flow_director_vlan,
8907 (void *)&cmd_flow_director_vlan_value,
8908 (void *)&cmd_flow_director_flexbytes,
8909 (void *)&cmd_flow_director_flexbytes_value,
8910 (void *)&cmd_flow_director_drop,
8911 (void *)&cmd_flow_director_pf_vf,
8912 (void *)&cmd_flow_director_queue,
8913 (void *)&cmd_flow_director_queue_id,
8914 (void *)&cmd_flow_director_fd_id,
8915 (void *)&cmd_flow_director_fd_id_value,
8920 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8921 .f = cmd_flow_director_filter_parsed,
8923 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8924 "director entry on NIC",
8926 (void *)&cmd_flow_director_filter,
8927 (void *)&cmd_flow_director_port_id,
8928 (void *)&cmd_flow_director_mode,
8929 (void *)&cmd_flow_director_mode_ip,
8930 (void *)&cmd_flow_director_ops,
8931 (void *)&cmd_flow_director_flow,
8932 (void *)&cmd_flow_director_flow_type,
8933 (void *)&cmd_flow_director_src,
8934 (void *)&cmd_flow_director_ip_src,
8935 (void *)&cmd_flow_director_port_src,
8936 (void *)&cmd_flow_director_dst,
8937 (void *)&cmd_flow_director_ip_dst,
8938 (void *)&cmd_flow_director_port_dst,
8939 (void *)&cmd_flow_director_tos,
8940 (void *)&cmd_flow_director_tos_value,
8941 (void *)&cmd_flow_director_ttl,
8942 (void *)&cmd_flow_director_ttl_value,
8943 (void *)&cmd_flow_director_vlan,
8944 (void *)&cmd_flow_director_vlan_value,
8945 (void *)&cmd_flow_director_flexbytes,
8946 (void *)&cmd_flow_director_flexbytes_value,
8947 (void *)&cmd_flow_director_drop,
8948 (void *)&cmd_flow_director_pf_vf,
8949 (void *)&cmd_flow_director_queue,
8950 (void *)&cmd_flow_director_queue_id,
8951 (void *)&cmd_flow_director_fd_id,
8952 (void *)&cmd_flow_director_fd_id_value,
8957 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8958 .f = cmd_flow_director_filter_parsed,
8960 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
8961 "director entry on NIC",
8963 (void *)&cmd_flow_director_filter,
8964 (void *)&cmd_flow_director_port_id,
8965 (void *)&cmd_flow_director_mode,
8966 (void *)&cmd_flow_director_mode_ip,
8967 (void *)&cmd_flow_director_ops,
8968 (void *)&cmd_flow_director_flow,
8969 (void *)&cmd_flow_director_flow_type,
8970 (void *)&cmd_flow_director_src,
8971 (void *)&cmd_flow_director_ip_src,
8972 (void *)&cmd_flow_director_port_dst,
8973 (void *)&cmd_flow_director_dst,
8974 (void *)&cmd_flow_director_ip_dst,
8975 (void *)&cmd_flow_director_port_dst,
8976 (void *)&cmd_flow_director_verify_tag,
8977 (void *)&cmd_flow_director_verify_tag_value,
8978 (void *)&cmd_flow_director_tos,
8979 (void *)&cmd_flow_director_tos_value,
8980 (void *)&cmd_flow_director_ttl,
8981 (void *)&cmd_flow_director_ttl_value,
8982 (void *)&cmd_flow_director_vlan,
8983 (void *)&cmd_flow_director_vlan_value,
8984 (void *)&cmd_flow_director_flexbytes,
8985 (void *)&cmd_flow_director_flexbytes_value,
8986 (void *)&cmd_flow_director_drop,
8987 (void *)&cmd_flow_director_pf_vf,
8988 (void *)&cmd_flow_director_queue,
8989 (void *)&cmd_flow_director_queue_id,
8990 (void *)&cmd_flow_director_fd_id,
8991 (void *)&cmd_flow_director_fd_id_value,
8996 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8997 .f = cmd_flow_director_filter_parsed,
8999 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9000 "director entry on NIC",
9002 (void *)&cmd_flow_director_filter,
9003 (void *)&cmd_flow_director_port_id,
9004 (void *)&cmd_flow_director_mode,
9005 (void *)&cmd_flow_director_mode_ip,
9006 (void *)&cmd_flow_director_ops,
9007 (void *)&cmd_flow_director_flow,
9008 (void *)&cmd_flow_director_flow_type,
9009 (void *)&cmd_flow_director_ether,
9010 (void *)&cmd_flow_director_ether_type,
9011 (void *)&cmd_flow_director_flexbytes,
9012 (void *)&cmd_flow_director_flexbytes_value,
9013 (void *)&cmd_flow_director_drop,
9014 (void *)&cmd_flow_director_pf_vf,
9015 (void *)&cmd_flow_director_queue,
9016 (void *)&cmd_flow_director_queue_id,
9017 (void *)&cmd_flow_director_fd_id,
9018 (void *)&cmd_flow_director_fd_id_value,
9023 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9024 .f = cmd_flow_director_filter_parsed,
9026 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9027 "director entry on NIC",
9029 (void *)&cmd_flow_director_filter,
9030 (void *)&cmd_flow_director_port_id,
9031 (void *)&cmd_flow_director_mode,
9032 (void *)&cmd_flow_director_mode_mac_vlan,
9033 (void *)&cmd_flow_director_ops,
9034 (void *)&cmd_flow_director_mac,
9035 (void *)&cmd_flow_director_mac_addr,
9036 (void *)&cmd_flow_director_vlan,
9037 (void *)&cmd_flow_director_vlan_value,
9038 (void *)&cmd_flow_director_flexbytes,
9039 (void *)&cmd_flow_director_flexbytes_value,
9040 (void *)&cmd_flow_director_drop,
9041 (void *)&cmd_flow_director_queue,
9042 (void *)&cmd_flow_director_queue_id,
9043 (void *)&cmd_flow_director_fd_id,
9044 (void *)&cmd_flow_director_fd_id_value,
9049 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9050 .f = cmd_flow_director_filter_parsed,
9052 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9053 "director entry on NIC",
9055 (void *)&cmd_flow_director_filter,
9056 (void *)&cmd_flow_director_port_id,
9057 (void *)&cmd_flow_director_mode,
9058 (void *)&cmd_flow_director_mode_tunnel,
9059 (void *)&cmd_flow_director_ops,
9060 (void *)&cmd_flow_director_mac,
9061 (void *)&cmd_flow_director_mac_addr,
9062 (void *)&cmd_flow_director_vlan,
9063 (void *)&cmd_flow_director_vlan_value,
9064 (void *)&cmd_flow_director_tunnel,
9065 (void *)&cmd_flow_director_tunnel_type,
9066 (void *)&cmd_flow_director_tunnel_id,
9067 (void *)&cmd_flow_director_tunnel_id_value,
9068 (void *)&cmd_flow_director_flexbytes,
9069 (void *)&cmd_flow_director_flexbytes_value,
9070 (void *)&cmd_flow_director_drop,
9071 (void *)&cmd_flow_director_queue,
9072 (void *)&cmd_flow_director_queue_id,
9073 (void *)&cmd_flow_director_fd_id,
9074 (void *)&cmd_flow_director_fd_id_value,
9079 struct cmd_flush_flow_director_result {
9080 cmdline_fixed_string_t flush_flow_director;
9084 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9085 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9086 flush_flow_director, "flush_flow_director");
9087 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9088 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9092 cmd_flush_flow_director_parsed(void *parsed_result,
9093 __attribute__((unused)) struct cmdline *cl,
9094 __attribute__((unused)) void *data)
9096 struct cmd_flow_director_result *res = parsed_result;
9099 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9101 printf("flow director is not supported on port %u.\n",
9106 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9107 RTE_ETH_FILTER_FLUSH, NULL);
9109 printf("flow director table flushing error: (%s)\n",
9113 cmdline_parse_inst_t cmd_flush_flow_director = {
9114 .f = cmd_flush_flow_director_parsed,
9116 .help_str = "flush_flow_director <port_id>: "
9117 "Flush all flow director entries of a device on NIC",
9119 (void *)&cmd_flush_flow_director_flush,
9120 (void *)&cmd_flush_flow_director_port_id,
9125 /* *** deal with flow director mask *** */
9126 struct cmd_flow_director_mask_result {
9127 cmdline_fixed_string_t flow_director_mask;
9129 cmdline_fixed_string_t mode;
9130 cmdline_fixed_string_t mode_value;
9131 cmdline_fixed_string_t vlan;
9133 cmdline_fixed_string_t src_mask;
9134 cmdline_ipaddr_t ipv4_src;
9135 cmdline_ipaddr_t ipv6_src;
9137 cmdline_fixed_string_t dst_mask;
9138 cmdline_ipaddr_t ipv4_dst;
9139 cmdline_ipaddr_t ipv6_dst;
9141 cmdline_fixed_string_t mac;
9142 uint8_t mac_addr_byte_mask;
9143 cmdline_fixed_string_t tunnel_id;
9144 uint32_t tunnel_id_mask;
9145 cmdline_fixed_string_t tunnel_type;
9146 uint8_t tunnel_type_mask;
9150 cmd_flow_director_mask_parsed(void *parsed_result,
9151 __attribute__((unused)) struct cmdline *cl,
9152 __attribute__((unused)) void *data)
9154 struct cmd_flow_director_mask_result *res = parsed_result;
9155 struct rte_eth_fdir_masks *mask;
9156 struct rte_port *port;
9158 if (res->port_id > nb_ports) {
9159 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9163 port = &ports[res->port_id];
9164 /** Check if the port is not started **/
9165 if (port->port_status != RTE_PORT_STOPPED) {
9166 printf("Please stop port %d first\n", res->port_id);
9170 mask = &port->dev_conf.fdir_conf.mask;
9172 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9173 if (strcmp(res->mode_value, "MAC-VLAN")) {
9174 printf("Please set mode to MAC-VLAN.\n");
9178 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9179 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9180 if (strcmp(res->mode_value, "Tunnel")) {
9181 printf("Please set mode to Tunnel.\n");
9185 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9186 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9187 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9188 mask->tunnel_type_mask = res->tunnel_type_mask;
9190 if (strcmp(res->mode_value, "IP")) {
9191 printf("Please set mode to IP.\n");
9195 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9196 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9197 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9198 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9199 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9200 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9201 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9204 cmd_reconfig_device_queue(res->port_id, 1, 1);
9207 cmdline_parse_token_string_t cmd_flow_director_mask =
9208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9209 flow_director_mask, "flow_director_mask");
9210 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9211 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9213 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9216 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9217 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9219 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9221 src_mask, "src_mask");
9222 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9223 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9225 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9226 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9228 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9229 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9231 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9233 dst_mask, "dst_mask");
9234 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9235 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9237 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9238 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9240 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9241 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9244 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9247 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9250 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9252 mode_value, "MAC-VLAN");
9253 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9255 mode_value, "Tunnel");
9256 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9259 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9260 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9261 mac_addr_byte_mask, UINT8);
9262 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9264 tunnel_type, "tunnel-type");
9265 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9266 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9267 tunnel_type_mask, UINT8);
9268 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9270 tunnel_id, "tunnel-id");
9271 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9272 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9273 tunnel_id_mask, UINT32);
9275 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9276 .f = cmd_flow_director_mask_parsed,
9278 .help_str = "flow_director_mask ... : "
9279 "Set IP mode flow director's mask on NIC",
9281 (void *)&cmd_flow_director_mask,
9282 (void *)&cmd_flow_director_mask_port_id,
9283 (void *)&cmd_flow_director_mask_mode,
9284 (void *)&cmd_flow_director_mask_mode_ip,
9285 (void *)&cmd_flow_director_mask_vlan,
9286 (void *)&cmd_flow_director_mask_vlan_value,
9287 (void *)&cmd_flow_director_mask_src,
9288 (void *)&cmd_flow_director_mask_ipv4_src,
9289 (void *)&cmd_flow_director_mask_ipv6_src,
9290 (void *)&cmd_flow_director_mask_port_src,
9291 (void *)&cmd_flow_director_mask_dst,
9292 (void *)&cmd_flow_director_mask_ipv4_dst,
9293 (void *)&cmd_flow_director_mask_ipv6_dst,
9294 (void *)&cmd_flow_director_mask_port_dst,
9299 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9300 .f = cmd_flow_director_mask_parsed,
9302 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9303 "flow director's mask on NIC",
9305 (void *)&cmd_flow_director_mask,
9306 (void *)&cmd_flow_director_mask_port_id,
9307 (void *)&cmd_flow_director_mask_mode,
9308 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9309 (void *)&cmd_flow_director_mask_vlan,
9310 (void *)&cmd_flow_director_mask_vlan_value,
9315 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9316 .f = cmd_flow_director_mask_parsed,
9318 .help_str = "flow_director_mask ... : Set tunnel mode "
9319 "flow director's mask on NIC",
9321 (void *)&cmd_flow_director_mask,
9322 (void *)&cmd_flow_director_mask_port_id,
9323 (void *)&cmd_flow_director_mask_mode,
9324 (void *)&cmd_flow_director_mask_mode_tunnel,
9325 (void *)&cmd_flow_director_mask_vlan,
9326 (void *)&cmd_flow_director_mask_vlan_value,
9327 (void *)&cmd_flow_director_mask_mac,
9328 (void *)&cmd_flow_director_mask_mac_value,
9329 (void *)&cmd_flow_director_mask_tunnel_type,
9330 (void *)&cmd_flow_director_mask_tunnel_type_value,
9331 (void *)&cmd_flow_director_mask_tunnel_id,
9332 (void *)&cmd_flow_director_mask_tunnel_id_value,
9337 /* *** deal with flow director mask on flexible payload *** */
9338 struct cmd_flow_director_flex_mask_result {
9339 cmdline_fixed_string_t flow_director_flexmask;
9341 cmdline_fixed_string_t flow;
9342 cmdline_fixed_string_t flow_type;
9343 cmdline_fixed_string_t mask;
9347 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9348 __attribute__((unused)) struct cmdline *cl,
9349 __attribute__((unused)) void *data)
9351 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9352 struct rte_eth_fdir_info fdir_info;
9353 struct rte_eth_fdir_flex_mask flex_mask;
9354 struct rte_port *port;
9355 uint32_t flow_type_mask;
9359 if (res->port_id > nb_ports) {
9360 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9364 port = &ports[res->port_id];
9365 /** Check if the port is not started **/
9366 if (port->port_status != RTE_PORT_STOPPED) {
9367 printf("Please stop port %d first\n", res->port_id);
9371 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9372 ret = parse_flexbytes(res->mask,
9374 RTE_ETH_FDIR_MAX_FLEXLEN);
9376 printf("error: Cannot parse mask input.\n");
9380 memset(&fdir_info, 0, sizeof(fdir_info));
9381 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9382 RTE_ETH_FILTER_INFO, &fdir_info);
9384 printf("Cannot get FDir filter info\n");
9388 if (!strcmp(res->flow_type, "none")) {
9389 /* means don't specify the flow type */
9390 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9391 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9392 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9393 0, sizeof(struct rte_eth_fdir_flex_mask));
9394 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9395 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9397 sizeof(struct rte_eth_fdir_flex_mask));
9398 cmd_reconfig_device_queue(res->port_id, 1, 1);
9401 flow_type_mask = fdir_info.flow_types_mask[0];
9402 if (!strcmp(res->flow_type, "all")) {
9403 if (!flow_type_mask) {
9404 printf("No flow type supported\n");
9407 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9408 if (flow_type_mask & (1 << i)) {
9409 flex_mask.flow_type = i;
9410 fdir_set_flex_mask(res->port_id, &flex_mask);
9413 cmd_reconfig_device_queue(res->port_id, 1, 1);
9416 flex_mask.flow_type = str2flowtype(res->flow_type);
9417 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9418 printf("Flow type %s not supported on port %d\n",
9419 res->flow_type, res->port_id);
9422 fdir_set_flex_mask(res->port_id, &flex_mask);
9423 cmd_reconfig_device_queue(res->port_id, 1, 1);
9426 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9428 flow_director_flexmask,
9429 "flow_director_flex_mask");
9430 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9431 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9433 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9436 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9438 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9439 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9440 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9441 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9444 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9445 .f = cmd_flow_director_flex_mask_parsed,
9447 .help_str = "flow_director_flex_mask ... : "
9448 "Set flow director's flex mask on NIC",
9450 (void *)&cmd_flow_director_flexmask,
9451 (void *)&cmd_flow_director_flexmask_port_id,
9452 (void *)&cmd_flow_director_flexmask_flow,
9453 (void *)&cmd_flow_director_flexmask_flow_type,
9454 (void *)&cmd_flow_director_flexmask_mask,
9459 /* *** deal with flow director flexible payload configuration *** */
9460 struct cmd_flow_director_flexpayload_result {
9461 cmdline_fixed_string_t flow_director_flexpayload;
9463 cmdline_fixed_string_t payload_layer;
9464 cmdline_fixed_string_t payload_cfg;
9468 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9471 const char *p, *p0 = q_arg;
9473 unsigned long int_fld;
9474 char *str_fld[max_num];
9479 p = strchr(p0, '(');
9483 p0 = strchr(p, ')');
9488 if (size >= sizeof(s))
9491 snprintf(s, sizeof(s), "%.*s", size, p);
9492 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9493 if (ret < 0 || ret > max_num)
9495 for (i = 0; i < ret; i++) {
9497 int_fld = strtoul(str_fld[i], &end, 0);
9498 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9500 offsets[i] = (uint16_t)int_fld;
9506 cmd_flow_director_flxpld_parsed(void *parsed_result,
9507 __attribute__((unused)) struct cmdline *cl,
9508 __attribute__((unused)) void *data)
9510 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9511 struct rte_eth_flex_payload_cfg flex_cfg;
9512 struct rte_port *port;
9515 if (res->port_id > nb_ports) {
9516 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9520 port = &ports[res->port_id];
9521 /** Check if the port is not started **/
9522 if (port->port_status != RTE_PORT_STOPPED) {
9523 printf("Please stop port %d first\n", res->port_id);
9527 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9529 if (!strcmp(res->payload_layer, "raw"))
9530 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9531 else if (!strcmp(res->payload_layer, "l2"))
9532 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9533 else if (!strcmp(res->payload_layer, "l3"))
9534 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9535 else if (!strcmp(res->payload_layer, "l4"))
9536 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9538 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9539 RTE_ETH_FDIR_MAX_FLEXLEN);
9541 printf("error: Cannot parse flex payload input.\n");
9545 fdir_set_flex_payload(res->port_id, &flex_cfg);
9546 cmd_reconfig_device_queue(res->port_id, 1, 1);
9549 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9551 flow_director_flexpayload,
9552 "flow_director_flex_payload");
9553 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9554 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9556 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9558 payload_layer, "raw#l2#l3#l4");
9559 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9563 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9564 .f = cmd_flow_director_flxpld_parsed,
9566 .help_str = "flow_director_flexpayload ... : "
9567 "Set flow director's flex payload on NIC",
9569 (void *)&cmd_flow_director_flexpayload,
9570 (void *)&cmd_flow_director_flexpayload_port_id,
9571 (void *)&cmd_flow_director_flexpayload_payload_layer,
9572 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9577 /* Generic flow interface command. */
9578 extern cmdline_parse_inst_t cmd_flow;
9580 /* *** Classification Filters Control *** */
9581 /* *** Get symmetric hash enable per port *** */
9582 struct cmd_get_sym_hash_ena_per_port_result {
9583 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9588 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9589 __rte_unused struct cmdline *cl,
9590 __rte_unused void *data)
9592 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9593 struct rte_eth_hash_filter_info info;
9596 if (rte_eth_dev_filter_supported(res->port_id,
9597 RTE_ETH_FILTER_HASH) < 0) {
9598 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9603 memset(&info, 0, sizeof(info));
9604 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9605 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9606 RTE_ETH_FILTER_GET, &info);
9609 printf("Cannot get symmetric hash enable per port "
9610 "on port %u\n", res->port_id);
9614 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9615 "enabled" : "disabled", res->port_id);
9618 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9619 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9620 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9621 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9622 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9625 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9626 .f = cmd_get_sym_hash_per_port_parsed,
9628 .help_str = "get_sym_hash_ena_per_port <port_id>",
9630 (void *)&cmd_get_sym_hash_ena_per_port_all,
9631 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9636 /* *** Set symmetric hash enable per port *** */
9637 struct cmd_set_sym_hash_ena_per_port_result {
9638 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9639 cmdline_fixed_string_t enable;
9644 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9645 __rte_unused struct cmdline *cl,
9646 __rte_unused void *data)
9648 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9649 struct rte_eth_hash_filter_info info;
9652 if (rte_eth_dev_filter_supported(res->port_id,
9653 RTE_ETH_FILTER_HASH) < 0) {
9654 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9659 memset(&info, 0, sizeof(info));
9660 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9661 if (!strcmp(res->enable, "enable"))
9662 info.info.enable = 1;
9663 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9664 RTE_ETH_FILTER_SET, &info);
9666 printf("Cannot set symmetric hash enable per port on "
9667 "port %u\n", res->port_id);
9670 printf("Symmetric hash has been set to %s on port %u\n",
9671 res->enable, res->port_id);
9674 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9675 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9676 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9677 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9678 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9680 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9681 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9682 enable, "enable#disable");
9684 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9685 .f = cmd_set_sym_hash_per_port_parsed,
9687 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9689 (void *)&cmd_set_sym_hash_ena_per_port_all,
9690 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9691 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9696 /* Get global config of hash function */
9697 struct cmd_get_hash_global_config_result {
9698 cmdline_fixed_string_t get_hash_global_config;
9703 flowtype_to_str(uint16_t ftype)
9710 {"ipv4", RTE_ETH_FLOW_IPV4},
9711 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9712 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9713 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9714 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9715 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9716 {"ipv6", RTE_ETH_FLOW_IPV6},
9717 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9718 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9719 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9720 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9721 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9722 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9723 {"port", RTE_ETH_FLOW_PORT},
9724 {"vxlan", RTE_ETH_FLOW_VXLAN},
9725 {"geneve", RTE_ETH_FLOW_GENEVE},
9726 {"nvgre", RTE_ETH_FLOW_NVGRE},
9729 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9730 if (ftype_table[i].ftype == ftype)
9731 return ftype_table[i].str;
9738 cmd_get_hash_global_config_parsed(void *parsed_result,
9739 __rte_unused struct cmdline *cl,
9740 __rte_unused void *data)
9742 struct cmd_get_hash_global_config_result *res = parsed_result;
9743 struct rte_eth_hash_filter_info info;
9744 uint32_t idx, offset;
9749 if (rte_eth_dev_filter_supported(res->port_id,
9750 RTE_ETH_FILTER_HASH) < 0) {
9751 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9756 memset(&info, 0, sizeof(info));
9757 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9758 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9759 RTE_ETH_FILTER_GET, &info);
9761 printf("Cannot get hash global configurations by port %d\n",
9766 switch (info.info.global_conf.hash_func) {
9767 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9768 printf("Hash function is Toeplitz\n");
9770 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9771 printf("Hash function is Simple XOR\n");
9774 printf("Unknown hash function\n");
9778 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9779 idx = i / UINT32_BIT;
9780 offset = i % UINT32_BIT;
9781 if (!(info.info.global_conf.valid_bit_mask[idx] &
9784 str = flowtype_to_str(i);
9787 printf("Symmetric hash is %s globally for flow type %s "
9789 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9790 (1UL << offset)) ? "enabled" : "disabled"), str,
9795 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9796 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9797 get_hash_global_config, "get_hash_global_config");
9798 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9799 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9802 cmdline_parse_inst_t cmd_get_hash_global_config = {
9803 .f = cmd_get_hash_global_config_parsed,
9805 .help_str = "get_hash_global_config <port_id>",
9807 (void *)&cmd_get_hash_global_config_all,
9808 (void *)&cmd_get_hash_global_config_port_id,
9813 /* Set global config of hash function */
9814 struct cmd_set_hash_global_config_result {
9815 cmdline_fixed_string_t set_hash_global_config;
9817 cmdline_fixed_string_t hash_func;
9818 cmdline_fixed_string_t flow_type;
9819 cmdline_fixed_string_t enable;
9823 cmd_set_hash_global_config_parsed(void *parsed_result,
9824 __rte_unused struct cmdline *cl,
9825 __rte_unused void *data)
9827 struct cmd_set_hash_global_config_result *res = parsed_result;
9828 struct rte_eth_hash_filter_info info;
9829 uint32_t ftype, idx, offset;
9832 if (rte_eth_dev_filter_supported(res->port_id,
9833 RTE_ETH_FILTER_HASH) < 0) {
9834 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9838 memset(&info, 0, sizeof(info));
9839 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9840 if (!strcmp(res->hash_func, "toeplitz"))
9841 info.info.global_conf.hash_func =
9842 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9843 else if (!strcmp(res->hash_func, "simple_xor"))
9844 info.info.global_conf.hash_func =
9845 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9846 else if (!strcmp(res->hash_func, "default"))
9847 info.info.global_conf.hash_func =
9848 RTE_ETH_HASH_FUNCTION_DEFAULT;
9850 ftype = str2flowtype(res->flow_type);
9851 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9852 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9853 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9854 if (!strcmp(res->enable, "enable"))
9855 info.info.global_conf.sym_hash_enable_mask[idx] |=
9857 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9858 RTE_ETH_FILTER_SET, &info);
9860 printf("Cannot set global hash configurations by port %d\n",
9863 printf("Global hash configurations have been set "
9864 "succcessfully by port %d\n", res->port_id);
9867 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9868 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9869 set_hash_global_config, "set_hash_global_config");
9870 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9871 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9873 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9874 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9875 hash_func, "toeplitz#simple_xor#default");
9876 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9877 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9879 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9880 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9881 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9882 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9883 enable, "enable#disable");
9885 cmdline_parse_inst_t cmd_set_hash_global_config = {
9886 .f = cmd_set_hash_global_config_parsed,
9888 .help_str = "set_hash_global_config <port_id> "
9889 "toeplitz|simple_xor|default "
9890 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9891 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9892 "l2_payload enable|disable",
9894 (void *)&cmd_set_hash_global_config_all,
9895 (void *)&cmd_set_hash_global_config_port_id,
9896 (void *)&cmd_set_hash_global_config_hash_func,
9897 (void *)&cmd_set_hash_global_config_flow_type,
9898 (void *)&cmd_set_hash_global_config_enable,
9903 /* Set hash input set */
9904 struct cmd_set_hash_input_set_result {
9905 cmdline_fixed_string_t set_hash_input_set;
9907 cmdline_fixed_string_t flow_type;
9908 cmdline_fixed_string_t inset_field;
9909 cmdline_fixed_string_t select;
9912 static enum rte_eth_input_set_field
9913 str2inset(char *string)
9917 static const struct {
9919 enum rte_eth_input_set_field inset;
9921 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9922 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9923 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9924 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9925 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9926 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9927 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9928 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9929 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9930 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9931 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9932 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9933 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9934 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9935 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9936 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9937 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9938 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9939 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9940 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9941 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9942 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9943 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9944 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9945 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9946 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9947 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9948 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9949 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9950 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9951 {"none", RTE_ETH_INPUT_SET_NONE},
9954 for (i = 0; i < RTE_DIM(inset_table); i++) {
9955 if (!strcmp(string, inset_table[i].str))
9956 return inset_table[i].inset;
9959 return RTE_ETH_INPUT_SET_UNKNOWN;
9963 cmd_set_hash_input_set_parsed(void *parsed_result,
9964 __rte_unused struct cmdline *cl,
9965 __rte_unused void *data)
9967 struct cmd_set_hash_input_set_result *res = parsed_result;
9968 struct rte_eth_hash_filter_info info;
9970 memset(&info, 0, sizeof(info));
9971 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9972 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9973 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9974 info.info.input_set_conf.inset_size = 1;
9975 if (!strcmp(res->select, "select"))
9976 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9977 else if (!strcmp(res->select, "add"))
9978 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9979 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9980 RTE_ETH_FILTER_SET, &info);
9983 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9984 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9985 set_hash_input_set, "set_hash_input_set");
9986 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9987 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9989 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9990 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9992 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9993 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9994 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9995 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9997 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9998 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9999 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10000 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10001 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10003 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10004 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10005 select, "select#add");
10007 cmdline_parse_inst_t cmd_set_hash_input_set = {
10008 .f = cmd_set_hash_input_set_parsed,
10010 .help_str = "set_hash_input_set <port_id> "
10011 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10012 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10013 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10014 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10015 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10016 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10017 "fld-7th|fld-8th|none select|add",
10019 (void *)&cmd_set_hash_input_set_cmd,
10020 (void *)&cmd_set_hash_input_set_port_id,
10021 (void *)&cmd_set_hash_input_set_flow_type,
10022 (void *)&cmd_set_hash_input_set_field,
10023 (void *)&cmd_set_hash_input_set_select,
10028 /* Set flow director input set */
10029 struct cmd_set_fdir_input_set_result {
10030 cmdline_fixed_string_t set_fdir_input_set;
10032 cmdline_fixed_string_t flow_type;
10033 cmdline_fixed_string_t inset_field;
10034 cmdline_fixed_string_t select;
10038 cmd_set_fdir_input_set_parsed(void *parsed_result,
10039 __rte_unused struct cmdline *cl,
10040 __rte_unused void *data)
10042 struct cmd_set_fdir_input_set_result *res = parsed_result;
10043 struct rte_eth_fdir_filter_info info;
10045 memset(&info, 0, sizeof(info));
10046 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10047 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10048 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10049 info.info.input_set_conf.inset_size = 1;
10050 if (!strcmp(res->select, "select"))
10051 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10052 else if (!strcmp(res->select, "add"))
10053 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10054 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10055 RTE_ETH_FILTER_SET, &info);
10058 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10059 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10060 set_fdir_input_set, "set_fdir_input_set");
10061 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10062 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10064 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10065 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10067 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10068 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10069 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10070 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10072 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10073 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10074 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10075 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10076 "sctp-veri-tag#none");
10077 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10078 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10079 select, "select#add");
10081 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10082 .f = cmd_set_fdir_input_set_parsed,
10084 .help_str = "set_fdir_input_set <port_id> "
10085 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10086 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10087 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10088 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10089 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10090 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10091 "sctp-veri-tag|none select|add",
10093 (void *)&cmd_set_fdir_input_set_cmd,
10094 (void *)&cmd_set_fdir_input_set_port_id,
10095 (void *)&cmd_set_fdir_input_set_flow_type,
10096 (void *)&cmd_set_fdir_input_set_field,
10097 (void *)&cmd_set_fdir_input_set_select,
10102 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10103 struct cmd_mcast_addr_result {
10104 cmdline_fixed_string_t mcast_addr_cmd;
10105 cmdline_fixed_string_t what;
10107 struct ether_addr mc_addr;
10110 static void cmd_mcast_addr_parsed(void *parsed_result,
10111 __attribute__((unused)) struct cmdline *cl,
10112 __attribute__((unused)) void *data)
10114 struct cmd_mcast_addr_result *res = parsed_result;
10116 if (!is_multicast_ether_addr(&res->mc_addr)) {
10117 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10118 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10119 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10120 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10123 if (strcmp(res->what, "add") == 0)
10124 mcast_addr_add(res->port_num, &res->mc_addr);
10126 mcast_addr_remove(res->port_num, &res->mc_addr);
10129 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10130 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10131 mcast_addr_cmd, "mcast_addr");
10132 cmdline_parse_token_string_t cmd_mcast_addr_what =
10133 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10135 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10136 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10137 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10138 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10140 cmdline_parse_inst_t cmd_mcast_addr = {
10141 .f = cmd_mcast_addr_parsed,
10143 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10144 "Add/Remove multicast MAC address on port_id",
10146 (void *)&cmd_mcast_addr_cmd,
10147 (void *)&cmd_mcast_addr_what,
10148 (void *)&cmd_mcast_addr_portnum,
10149 (void *)&cmd_mcast_addr_addr,
10154 /* l2 tunnel config
10155 * only support E-tag now.
10158 /* Ether type config */
10159 struct cmd_config_l2_tunnel_eth_type_result {
10160 cmdline_fixed_string_t port;
10161 cmdline_fixed_string_t config;
10162 cmdline_fixed_string_t all;
10164 cmdline_fixed_string_t l2_tunnel;
10165 cmdline_fixed_string_t l2_tunnel_type;
10166 cmdline_fixed_string_t eth_type;
10167 uint16_t eth_type_val;
10170 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10171 TOKEN_STRING_INITIALIZER
10172 (struct cmd_config_l2_tunnel_eth_type_result,
10174 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10175 TOKEN_STRING_INITIALIZER
10176 (struct cmd_config_l2_tunnel_eth_type_result,
10178 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10179 TOKEN_STRING_INITIALIZER
10180 (struct cmd_config_l2_tunnel_eth_type_result,
10182 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10183 TOKEN_NUM_INITIALIZER
10184 (struct cmd_config_l2_tunnel_eth_type_result,
10186 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10187 TOKEN_STRING_INITIALIZER
10188 (struct cmd_config_l2_tunnel_eth_type_result,
10189 l2_tunnel, "l2-tunnel");
10190 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10191 TOKEN_STRING_INITIALIZER
10192 (struct cmd_config_l2_tunnel_eth_type_result,
10193 l2_tunnel_type, "E-tag");
10194 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10195 TOKEN_STRING_INITIALIZER
10196 (struct cmd_config_l2_tunnel_eth_type_result,
10197 eth_type, "ether-type");
10198 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10199 TOKEN_NUM_INITIALIZER
10200 (struct cmd_config_l2_tunnel_eth_type_result,
10201 eth_type_val, UINT16);
10203 static enum rte_eth_tunnel_type
10204 str2fdir_l2_tunnel_type(char *string)
10208 static const struct {
10210 enum rte_eth_tunnel_type type;
10211 } l2_tunnel_type_str[] = {
10212 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10215 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10216 if (!strcmp(l2_tunnel_type_str[i].str, string))
10217 return l2_tunnel_type_str[i].type;
10219 return RTE_TUNNEL_TYPE_NONE;
10222 /* ether type config for all ports */
10224 cmd_config_l2_tunnel_eth_type_all_parsed
10225 (void *parsed_result,
10226 __attribute__((unused)) struct cmdline *cl,
10227 __attribute__((unused)) void *data)
10229 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10230 struct rte_eth_l2_tunnel_conf entry;
10233 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10234 entry.ether_type = res->eth_type_val;
10236 FOREACH_PORT(pid, ports) {
10237 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10241 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10242 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10244 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10246 (void *)&cmd_config_l2_tunnel_eth_type_port,
10247 (void *)&cmd_config_l2_tunnel_eth_type_config,
10248 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10249 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10250 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10251 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10252 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10257 /* ether type config for a specific port */
10259 cmd_config_l2_tunnel_eth_type_specific_parsed(
10260 void *parsed_result,
10261 __attribute__((unused)) struct cmdline *cl,
10262 __attribute__((unused)) void *data)
10264 struct cmd_config_l2_tunnel_eth_type_result *res =
10266 struct rte_eth_l2_tunnel_conf entry;
10268 if (port_id_is_invalid(res->id, ENABLED_WARN))
10271 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10272 entry.ether_type = res->eth_type_val;
10274 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10277 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10278 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10280 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10282 (void *)&cmd_config_l2_tunnel_eth_type_port,
10283 (void *)&cmd_config_l2_tunnel_eth_type_config,
10284 (void *)&cmd_config_l2_tunnel_eth_type_id,
10285 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10286 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10287 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10288 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10293 /* Enable/disable l2 tunnel */
10294 struct cmd_config_l2_tunnel_en_dis_result {
10295 cmdline_fixed_string_t port;
10296 cmdline_fixed_string_t config;
10297 cmdline_fixed_string_t all;
10299 cmdline_fixed_string_t l2_tunnel;
10300 cmdline_fixed_string_t l2_tunnel_type;
10301 cmdline_fixed_string_t en_dis;
10304 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10305 TOKEN_STRING_INITIALIZER
10306 (struct cmd_config_l2_tunnel_en_dis_result,
10308 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10309 TOKEN_STRING_INITIALIZER
10310 (struct cmd_config_l2_tunnel_en_dis_result,
10312 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10313 TOKEN_STRING_INITIALIZER
10314 (struct cmd_config_l2_tunnel_en_dis_result,
10316 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10317 TOKEN_NUM_INITIALIZER
10318 (struct cmd_config_l2_tunnel_en_dis_result,
10320 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10321 TOKEN_STRING_INITIALIZER
10322 (struct cmd_config_l2_tunnel_en_dis_result,
10323 l2_tunnel, "l2-tunnel");
10324 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10325 TOKEN_STRING_INITIALIZER
10326 (struct cmd_config_l2_tunnel_en_dis_result,
10327 l2_tunnel_type, "E-tag");
10328 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10329 TOKEN_STRING_INITIALIZER
10330 (struct cmd_config_l2_tunnel_en_dis_result,
10331 en_dis, "enable#disable");
10333 /* enable/disable l2 tunnel for all ports */
10335 cmd_config_l2_tunnel_en_dis_all_parsed(
10336 void *parsed_result,
10337 __attribute__((unused)) struct cmdline *cl,
10338 __attribute__((unused)) void *data)
10340 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10341 struct rte_eth_l2_tunnel_conf entry;
10345 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10347 if (!strcmp("enable", res->en_dis))
10352 FOREACH_PORT(pid, ports) {
10353 rte_eth_dev_l2_tunnel_offload_set(pid,
10355 ETH_L2_TUNNEL_ENABLE_MASK,
10360 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10361 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10363 .help_str = "port config all l2-tunnel E-tag enable|disable",
10365 (void *)&cmd_config_l2_tunnel_en_dis_port,
10366 (void *)&cmd_config_l2_tunnel_en_dis_config,
10367 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10368 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10369 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10370 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10375 /* enable/disable l2 tunnel for a port */
10377 cmd_config_l2_tunnel_en_dis_specific_parsed(
10378 void *parsed_result,
10379 __attribute__((unused)) struct cmdline *cl,
10380 __attribute__((unused)) void *data)
10382 struct cmd_config_l2_tunnel_en_dis_result *res =
10384 struct rte_eth_l2_tunnel_conf entry;
10386 if (port_id_is_invalid(res->id, ENABLED_WARN))
10389 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10391 if (!strcmp("enable", res->en_dis))
10392 rte_eth_dev_l2_tunnel_offload_set(res->id,
10394 ETH_L2_TUNNEL_ENABLE_MASK,
10397 rte_eth_dev_l2_tunnel_offload_set(res->id,
10399 ETH_L2_TUNNEL_ENABLE_MASK,
10403 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10404 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10406 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10408 (void *)&cmd_config_l2_tunnel_en_dis_port,
10409 (void *)&cmd_config_l2_tunnel_en_dis_config,
10410 (void *)&cmd_config_l2_tunnel_en_dis_id,
10411 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10412 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10413 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10418 /* E-tag configuration */
10420 /* Common result structure for all E-tag configuration */
10421 struct cmd_config_e_tag_result {
10422 cmdline_fixed_string_t e_tag;
10423 cmdline_fixed_string_t set;
10424 cmdline_fixed_string_t insertion;
10425 cmdline_fixed_string_t stripping;
10426 cmdline_fixed_string_t forwarding;
10427 cmdline_fixed_string_t filter;
10428 cmdline_fixed_string_t add;
10429 cmdline_fixed_string_t del;
10430 cmdline_fixed_string_t on;
10431 cmdline_fixed_string_t off;
10432 cmdline_fixed_string_t on_off;
10433 cmdline_fixed_string_t port_tag_id;
10434 uint32_t port_tag_id_val;
10435 cmdline_fixed_string_t e_tag_id;
10436 uint16_t e_tag_id_val;
10437 cmdline_fixed_string_t dst_pool;
10438 uint8_t dst_pool_val;
10439 cmdline_fixed_string_t port;
10441 cmdline_fixed_string_t vf;
10445 /* Common CLI fields for all E-tag configuration */
10446 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10447 TOKEN_STRING_INITIALIZER
10448 (struct cmd_config_e_tag_result,
10450 cmdline_parse_token_string_t cmd_config_e_tag_set =
10451 TOKEN_STRING_INITIALIZER
10452 (struct cmd_config_e_tag_result,
10454 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10455 TOKEN_STRING_INITIALIZER
10456 (struct cmd_config_e_tag_result,
10457 insertion, "insertion");
10458 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10459 TOKEN_STRING_INITIALIZER
10460 (struct cmd_config_e_tag_result,
10461 stripping, "stripping");
10462 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10463 TOKEN_STRING_INITIALIZER
10464 (struct cmd_config_e_tag_result,
10465 forwarding, "forwarding");
10466 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10467 TOKEN_STRING_INITIALIZER
10468 (struct cmd_config_e_tag_result,
10470 cmdline_parse_token_string_t cmd_config_e_tag_add =
10471 TOKEN_STRING_INITIALIZER
10472 (struct cmd_config_e_tag_result,
10474 cmdline_parse_token_string_t cmd_config_e_tag_del =
10475 TOKEN_STRING_INITIALIZER
10476 (struct cmd_config_e_tag_result,
10478 cmdline_parse_token_string_t cmd_config_e_tag_on =
10479 TOKEN_STRING_INITIALIZER
10480 (struct cmd_config_e_tag_result,
10482 cmdline_parse_token_string_t cmd_config_e_tag_off =
10483 TOKEN_STRING_INITIALIZER
10484 (struct cmd_config_e_tag_result,
10486 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10487 TOKEN_STRING_INITIALIZER
10488 (struct cmd_config_e_tag_result,
10490 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10491 TOKEN_STRING_INITIALIZER
10492 (struct cmd_config_e_tag_result,
10493 port_tag_id, "port-tag-id");
10494 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10495 TOKEN_NUM_INITIALIZER
10496 (struct cmd_config_e_tag_result,
10497 port_tag_id_val, UINT32);
10498 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10499 TOKEN_STRING_INITIALIZER
10500 (struct cmd_config_e_tag_result,
10501 e_tag_id, "e-tag-id");
10502 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10503 TOKEN_NUM_INITIALIZER
10504 (struct cmd_config_e_tag_result,
10505 e_tag_id_val, UINT16);
10506 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10507 TOKEN_STRING_INITIALIZER
10508 (struct cmd_config_e_tag_result,
10509 dst_pool, "dst-pool");
10510 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10511 TOKEN_NUM_INITIALIZER
10512 (struct cmd_config_e_tag_result,
10513 dst_pool_val, UINT8);
10514 cmdline_parse_token_string_t cmd_config_e_tag_port =
10515 TOKEN_STRING_INITIALIZER
10516 (struct cmd_config_e_tag_result,
10518 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10519 TOKEN_NUM_INITIALIZER
10520 (struct cmd_config_e_tag_result,
10522 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10523 TOKEN_STRING_INITIALIZER
10524 (struct cmd_config_e_tag_result,
10526 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10527 TOKEN_NUM_INITIALIZER
10528 (struct cmd_config_e_tag_result,
10531 /* E-tag insertion configuration */
10533 cmd_config_e_tag_insertion_en_parsed(
10534 void *parsed_result,
10535 __attribute__((unused)) struct cmdline *cl,
10536 __attribute__((unused)) void *data)
10538 struct cmd_config_e_tag_result *res =
10540 struct rte_eth_l2_tunnel_conf entry;
10542 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10545 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10546 entry.tunnel_id = res->port_tag_id_val;
10547 entry.vf_id = res->vf_id;
10548 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10550 ETH_L2_TUNNEL_INSERTION_MASK,
10555 cmd_config_e_tag_insertion_dis_parsed(
10556 void *parsed_result,
10557 __attribute__((unused)) struct cmdline *cl,
10558 __attribute__((unused)) void *data)
10560 struct cmd_config_e_tag_result *res =
10562 struct rte_eth_l2_tunnel_conf entry;
10564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10567 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10568 entry.vf_id = res->vf_id;
10570 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10572 ETH_L2_TUNNEL_INSERTION_MASK,
10576 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10577 .f = cmd_config_e_tag_insertion_en_parsed,
10579 .help_str = "E-tag ... : E-tag insertion enable",
10581 (void *)&cmd_config_e_tag_e_tag,
10582 (void *)&cmd_config_e_tag_set,
10583 (void *)&cmd_config_e_tag_insertion,
10584 (void *)&cmd_config_e_tag_on,
10585 (void *)&cmd_config_e_tag_port_tag_id,
10586 (void *)&cmd_config_e_tag_port_tag_id_val,
10587 (void *)&cmd_config_e_tag_port,
10588 (void *)&cmd_config_e_tag_port_id,
10589 (void *)&cmd_config_e_tag_vf,
10590 (void *)&cmd_config_e_tag_vf_id,
10595 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10596 .f = cmd_config_e_tag_insertion_dis_parsed,
10598 .help_str = "E-tag ... : E-tag insertion disable",
10600 (void *)&cmd_config_e_tag_e_tag,
10601 (void *)&cmd_config_e_tag_set,
10602 (void *)&cmd_config_e_tag_insertion,
10603 (void *)&cmd_config_e_tag_off,
10604 (void *)&cmd_config_e_tag_port,
10605 (void *)&cmd_config_e_tag_port_id,
10606 (void *)&cmd_config_e_tag_vf,
10607 (void *)&cmd_config_e_tag_vf_id,
10612 /* E-tag stripping configuration */
10614 cmd_config_e_tag_stripping_parsed(
10615 void *parsed_result,
10616 __attribute__((unused)) struct cmdline *cl,
10617 __attribute__((unused)) void *data)
10619 struct cmd_config_e_tag_result *res =
10621 struct rte_eth_l2_tunnel_conf entry;
10623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10626 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10628 if (!strcmp(res->on_off, "on"))
10629 rte_eth_dev_l2_tunnel_offload_set
10632 ETH_L2_TUNNEL_STRIPPING_MASK,
10635 rte_eth_dev_l2_tunnel_offload_set
10638 ETH_L2_TUNNEL_STRIPPING_MASK,
10642 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10643 .f = cmd_config_e_tag_stripping_parsed,
10645 .help_str = "E-tag ... : E-tag stripping enable/disable",
10647 (void *)&cmd_config_e_tag_e_tag,
10648 (void *)&cmd_config_e_tag_set,
10649 (void *)&cmd_config_e_tag_stripping,
10650 (void *)&cmd_config_e_tag_on_off,
10651 (void *)&cmd_config_e_tag_port,
10652 (void *)&cmd_config_e_tag_port_id,
10657 /* E-tag forwarding configuration */
10659 cmd_config_e_tag_forwarding_parsed(
10660 void *parsed_result,
10661 __attribute__((unused)) struct cmdline *cl,
10662 __attribute__((unused)) void *data)
10664 struct cmd_config_e_tag_result *res = parsed_result;
10665 struct rte_eth_l2_tunnel_conf entry;
10667 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10670 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10672 if (!strcmp(res->on_off, "on"))
10673 rte_eth_dev_l2_tunnel_offload_set
10676 ETH_L2_TUNNEL_FORWARDING_MASK,
10679 rte_eth_dev_l2_tunnel_offload_set
10682 ETH_L2_TUNNEL_FORWARDING_MASK,
10686 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10687 .f = cmd_config_e_tag_forwarding_parsed,
10689 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10691 (void *)&cmd_config_e_tag_e_tag,
10692 (void *)&cmd_config_e_tag_set,
10693 (void *)&cmd_config_e_tag_forwarding,
10694 (void *)&cmd_config_e_tag_on_off,
10695 (void *)&cmd_config_e_tag_port,
10696 (void *)&cmd_config_e_tag_port_id,
10701 /* E-tag filter configuration */
10703 cmd_config_e_tag_filter_add_parsed(
10704 void *parsed_result,
10705 __attribute__((unused)) struct cmdline *cl,
10706 __attribute__((unused)) void *data)
10708 struct cmd_config_e_tag_result *res = parsed_result;
10709 struct rte_eth_l2_tunnel_conf entry;
10712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10715 if (res->e_tag_id_val > 0x3fff) {
10716 printf("e-tag-id must be equal or less than 0x3fff.\n");
10720 ret = rte_eth_dev_filter_supported(res->port_id,
10721 RTE_ETH_FILTER_L2_TUNNEL);
10723 printf("E-tag filter is not supported on port %u.\n",
10728 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10729 entry.tunnel_id = res->e_tag_id_val;
10730 entry.pool = res->dst_pool_val;
10732 ret = rte_eth_dev_filter_ctrl(res->port_id,
10733 RTE_ETH_FILTER_L2_TUNNEL,
10734 RTE_ETH_FILTER_ADD,
10737 printf("E-tag filter programming error: (%s)\n",
10741 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10742 .f = cmd_config_e_tag_filter_add_parsed,
10744 .help_str = "E-tag ... : E-tag filter add",
10746 (void *)&cmd_config_e_tag_e_tag,
10747 (void *)&cmd_config_e_tag_set,
10748 (void *)&cmd_config_e_tag_filter,
10749 (void *)&cmd_config_e_tag_add,
10750 (void *)&cmd_config_e_tag_e_tag_id,
10751 (void *)&cmd_config_e_tag_e_tag_id_val,
10752 (void *)&cmd_config_e_tag_dst_pool,
10753 (void *)&cmd_config_e_tag_dst_pool_val,
10754 (void *)&cmd_config_e_tag_port,
10755 (void *)&cmd_config_e_tag_port_id,
10761 cmd_config_e_tag_filter_del_parsed(
10762 void *parsed_result,
10763 __attribute__((unused)) struct cmdline *cl,
10764 __attribute__((unused)) void *data)
10766 struct cmd_config_e_tag_result *res = parsed_result;
10767 struct rte_eth_l2_tunnel_conf entry;
10770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10773 if (res->e_tag_id_val > 0x3fff) {
10774 printf("e-tag-id must be less than 0x3fff.\n");
10778 ret = rte_eth_dev_filter_supported(res->port_id,
10779 RTE_ETH_FILTER_L2_TUNNEL);
10781 printf("E-tag filter is not supported on port %u.\n",
10786 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10787 entry.tunnel_id = res->e_tag_id_val;
10789 ret = rte_eth_dev_filter_ctrl(res->port_id,
10790 RTE_ETH_FILTER_L2_TUNNEL,
10791 RTE_ETH_FILTER_DELETE,
10794 printf("E-tag filter programming error: (%s)\n",
10798 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10799 .f = cmd_config_e_tag_filter_del_parsed,
10801 .help_str = "E-tag ... : E-tag filter delete",
10803 (void *)&cmd_config_e_tag_e_tag,
10804 (void *)&cmd_config_e_tag_set,
10805 (void *)&cmd_config_e_tag_filter,
10806 (void *)&cmd_config_e_tag_del,
10807 (void *)&cmd_config_e_tag_e_tag_id,
10808 (void *)&cmd_config_e_tag_e_tag_id_val,
10809 (void *)&cmd_config_e_tag_port,
10810 (void *)&cmd_config_e_tag_port_id,
10814 #ifdef RTE_LIBRTE_IXGBE_PMD
10816 /* vf vlan anti spoof configuration */
10818 /* Common result structure for vf vlan anti spoof */
10819 struct cmd_vf_vlan_anti_spoof_result {
10820 cmdline_fixed_string_t set;
10821 cmdline_fixed_string_t vf;
10822 cmdline_fixed_string_t vlan;
10823 cmdline_fixed_string_t antispoof;
10826 cmdline_fixed_string_t on_off;
10829 /* Common CLI fields for vf vlan anti spoof enable disable */
10830 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10831 TOKEN_STRING_INITIALIZER
10832 (struct cmd_vf_vlan_anti_spoof_result,
10834 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10835 TOKEN_STRING_INITIALIZER
10836 (struct cmd_vf_vlan_anti_spoof_result,
10838 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10839 TOKEN_STRING_INITIALIZER
10840 (struct cmd_vf_vlan_anti_spoof_result,
10842 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10843 TOKEN_STRING_INITIALIZER
10844 (struct cmd_vf_vlan_anti_spoof_result,
10845 antispoof, "antispoof");
10846 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10847 TOKEN_NUM_INITIALIZER
10848 (struct cmd_vf_vlan_anti_spoof_result,
10850 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10851 TOKEN_NUM_INITIALIZER
10852 (struct cmd_vf_vlan_anti_spoof_result,
10854 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10855 TOKEN_STRING_INITIALIZER
10856 (struct cmd_vf_vlan_anti_spoof_result,
10860 cmd_set_vf_vlan_anti_spoof_parsed(
10861 void *parsed_result,
10862 __attribute__((unused)) struct cmdline *cl,
10863 __attribute__((unused)) void *data)
10865 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10867 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10869 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10875 printf("invalid vf_id %d\n", res->vf_id);
10878 printf("invalid port_id %d\n", res->port_id);
10881 printf("programming error: (%s)\n", strerror(-ret));
10885 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10886 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10888 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10890 (void *)&cmd_vf_vlan_anti_spoof_set,
10891 (void *)&cmd_vf_vlan_anti_spoof_vf,
10892 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10893 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10894 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10895 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10896 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10901 /* vf mac anti spoof configuration */
10903 /* Common result structure for vf mac anti spoof */
10904 struct cmd_vf_mac_anti_spoof_result {
10905 cmdline_fixed_string_t set;
10906 cmdline_fixed_string_t vf;
10907 cmdline_fixed_string_t mac;
10908 cmdline_fixed_string_t antispoof;
10911 cmdline_fixed_string_t on_off;
10914 /* Common CLI fields for vf mac anti spoof enable disable */
10915 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10916 TOKEN_STRING_INITIALIZER
10917 (struct cmd_vf_mac_anti_spoof_result,
10919 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10920 TOKEN_STRING_INITIALIZER
10921 (struct cmd_vf_mac_anti_spoof_result,
10923 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10924 TOKEN_STRING_INITIALIZER
10925 (struct cmd_vf_mac_anti_spoof_result,
10927 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10928 TOKEN_STRING_INITIALIZER
10929 (struct cmd_vf_mac_anti_spoof_result,
10930 antispoof, "antispoof");
10931 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10932 TOKEN_NUM_INITIALIZER
10933 (struct cmd_vf_mac_anti_spoof_result,
10935 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10936 TOKEN_NUM_INITIALIZER
10937 (struct cmd_vf_mac_anti_spoof_result,
10939 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10940 TOKEN_STRING_INITIALIZER
10941 (struct cmd_vf_mac_anti_spoof_result,
10945 cmd_set_vf_mac_anti_spoof_parsed(
10946 void *parsed_result,
10947 __attribute__((unused)) struct cmdline *cl,
10948 __attribute__((unused)) void *data)
10950 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10952 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10954 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10960 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10963 printf("invalid port_id %d\n", res->port_id);
10966 printf("programming error: (%s)\n", strerror(-ret));
10970 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10971 .f = cmd_set_vf_mac_anti_spoof_parsed,
10973 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10975 (void *)&cmd_vf_mac_anti_spoof_set,
10976 (void *)&cmd_vf_mac_anti_spoof_vf,
10977 (void *)&cmd_vf_mac_anti_spoof_mac,
10978 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10979 (void *)&cmd_vf_mac_anti_spoof_port_id,
10980 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10981 (void *)&cmd_vf_mac_anti_spoof_on_off,
10986 /* vf vlan strip queue configuration */
10988 /* Common result structure for vf mac anti spoof */
10989 struct cmd_vf_vlan_stripq_result {
10990 cmdline_fixed_string_t set;
10991 cmdline_fixed_string_t vf;
10992 cmdline_fixed_string_t vlan;
10993 cmdline_fixed_string_t stripq;
10996 cmdline_fixed_string_t on_off;
10999 /* Common CLI fields for vf vlan strip enable disable */
11000 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11001 TOKEN_STRING_INITIALIZER
11002 (struct cmd_vf_vlan_stripq_result,
11004 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11005 TOKEN_STRING_INITIALIZER
11006 (struct cmd_vf_vlan_stripq_result,
11008 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11009 TOKEN_STRING_INITIALIZER
11010 (struct cmd_vf_vlan_stripq_result,
11012 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11013 TOKEN_STRING_INITIALIZER
11014 (struct cmd_vf_vlan_stripq_result,
11016 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11017 TOKEN_NUM_INITIALIZER
11018 (struct cmd_vf_vlan_stripq_result,
11020 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11021 TOKEN_NUM_INITIALIZER
11022 (struct cmd_vf_vlan_stripq_result,
11024 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11025 TOKEN_STRING_INITIALIZER
11026 (struct cmd_vf_vlan_stripq_result,
11030 cmd_set_vf_vlan_stripq_parsed(
11031 void *parsed_result,
11032 __attribute__((unused)) struct cmdline *cl,
11033 __attribute__((unused)) void *data)
11035 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11037 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11039 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11044 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11047 printf("invalid port_id %d\n", res->port_id);
11050 printf("programming error: (%s)\n", strerror(-ret));
11054 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11055 .f = cmd_set_vf_vlan_stripq_parsed,
11057 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11059 (void *)&cmd_vf_vlan_stripq_set,
11060 (void *)&cmd_vf_vlan_stripq_vf,
11061 (void *)&cmd_vf_vlan_stripq_vlan,
11062 (void *)&cmd_vf_vlan_stripq_stripq,
11063 (void *)&cmd_vf_vlan_stripq_port_id,
11064 (void *)&cmd_vf_vlan_stripq_vf_id,
11065 (void *)&cmd_vf_vlan_stripq_on_off,
11070 /* vf vlan insert configuration */
11072 /* Common result structure for vf vlan insert */
11073 struct cmd_vf_vlan_insert_result {
11074 cmdline_fixed_string_t set;
11075 cmdline_fixed_string_t vf;
11076 cmdline_fixed_string_t vlan;
11077 cmdline_fixed_string_t insert;
11083 /* Common CLI fields for vf vlan insert enable disable */
11084 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11085 TOKEN_STRING_INITIALIZER
11086 (struct cmd_vf_vlan_insert_result,
11088 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11089 TOKEN_STRING_INITIALIZER
11090 (struct cmd_vf_vlan_insert_result,
11092 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11093 TOKEN_STRING_INITIALIZER
11094 (struct cmd_vf_vlan_insert_result,
11096 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11097 TOKEN_STRING_INITIALIZER
11098 (struct cmd_vf_vlan_insert_result,
11100 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11101 TOKEN_NUM_INITIALIZER
11102 (struct cmd_vf_vlan_insert_result,
11104 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11105 TOKEN_NUM_INITIALIZER
11106 (struct cmd_vf_vlan_insert_result,
11108 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11109 TOKEN_NUM_INITIALIZER
11110 (struct cmd_vf_vlan_insert_result,
11114 cmd_set_vf_vlan_insert_parsed(
11115 void *parsed_result,
11116 __attribute__((unused)) struct cmdline *cl,
11117 __attribute__((unused)) void *data)
11119 struct cmd_vf_vlan_insert_result *res = parsed_result;
11122 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11127 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11130 printf("invalid port_id %d\n", res->port_id);
11133 printf("programming error: (%s)\n", strerror(-ret));
11137 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11138 .f = cmd_set_vf_vlan_insert_parsed,
11140 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11142 (void *)&cmd_vf_vlan_insert_set,
11143 (void *)&cmd_vf_vlan_insert_vf,
11144 (void *)&cmd_vf_vlan_insert_vlan,
11145 (void *)&cmd_vf_vlan_insert_insert,
11146 (void *)&cmd_vf_vlan_insert_port_id,
11147 (void *)&cmd_vf_vlan_insert_vf_id,
11148 (void *)&cmd_vf_vlan_insert_vlan_id,
11153 /* tx loopback configuration */
11155 /* Common result structure for tx loopback */
11156 struct cmd_tx_loopback_result {
11157 cmdline_fixed_string_t set;
11158 cmdline_fixed_string_t tx;
11159 cmdline_fixed_string_t loopback;
11161 cmdline_fixed_string_t on_off;
11164 /* Common CLI fields for tx loopback enable disable */
11165 cmdline_parse_token_string_t cmd_tx_loopback_set =
11166 TOKEN_STRING_INITIALIZER
11167 (struct cmd_tx_loopback_result,
11169 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11170 TOKEN_STRING_INITIALIZER
11171 (struct cmd_tx_loopback_result,
11173 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_tx_loopback_result,
11176 loopback, "loopback");
11177 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11178 TOKEN_NUM_INITIALIZER
11179 (struct cmd_tx_loopback_result,
11181 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_tx_loopback_result,
11187 cmd_set_tx_loopback_parsed(
11188 void *parsed_result,
11189 __attribute__((unused)) struct cmdline *cl,
11190 __attribute__((unused)) void *data)
11192 struct cmd_tx_loopback_result *res = parsed_result;
11194 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11196 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11201 printf("invalid is_on %d\n", is_on);
11204 printf("invalid port_id %d\n", res->port_id);
11207 printf("programming error: (%s)\n", strerror(-ret));
11211 cmdline_parse_inst_t cmd_set_tx_loopback = {
11212 .f = cmd_set_tx_loopback_parsed,
11214 .help_str = "set tx loopback <port_id> on|off",
11216 (void *)&cmd_tx_loopback_set,
11217 (void *)&cmd_tx_loopback_tx,
11218 (void *)&cmd_tx_loopback_loopback,
11219 (void *)&cmd_tx_loopback_port_id,
11220 (void *)&cmd_tx_loopback_on_off,
11225 /* all queues drop enable configuration */
11227 /* Common result structure for all queues drop enable */
11228 struct cmd_all_queues_drop_en_result {
11229 cmdline_fixed_string_t set;
11230 cmdline_fixed_string_t all;
11231 cmdline_fixed_string_t queues;
11232 cmdline_fixed_string_t drop;
11234 cmdline_fixed_string_t on_off;
11237 /* Common CLI fields for tx loopback enable disable */
11238 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11239 TOKEN_STRING_INITIALIZER
11240 (struct cmd_all_queues_drop_en_result,
11242 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11243 TOKEN_STRING_INITIALIZER
11244 (struct cmd_all_queues_drop_en_result,
11246 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11247 TOKEN_STRING_INITIALIZER
11248 (struct cmd_all_queues_drop_en_result,
11250 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11251 TOKEN_STRING_INITIALIZER
11252 (struct cmd_all_queues_drop_en_result,
11254 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11255 TOKEN_NUM_INITIALIZER
11256 (struct cmd_all_queues_drop_en_result,
11258 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11259 TOKEN_STRING_INITIALIZER
11260 (struct cmd_all_queues_drop_en_result,
11264 cmd_set_all_queues_drop_en_parsed(
11265 void *parsed_result,
11266 __attribute__((unused)) struct cmdline *cl,
11267 __attribute__((unused)) void *data)
11269 struct cmd_all_queues_drop_en_result *res = parsed_result;
11271 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11273 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11278 printf("invalid is_on %d\n", is_on);
11281 printf("invalid port_id %d\n", res->port_id);
11284 printf("programming error: (%s)\n", strerror(-ret));
11288 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11289 .f = cmd_set_all_queues_drop_en_parsed,
11291 .help_str = "set all queues drop <port_id> on|off",
11293 (void *)&cmd_all_queues_drop_en_set,
11294 (void *)&cmd_all_queues_drop_en_all,
11295 (void *)&cmd_all_queues_drop_en_queues,
11296 (void *)&cmd_all_queues_drop_en_drop,
11297 (void *)&cmd_all_queues_drop_en_port_id,
11298 (void *)&cmd_all_queues_drop_en_on_off,
11303 /* vf split drop enable configuration */
11305 /* Common result structure for vf split drop enable */
11306 struct cmd_vf_split_drop_en_result {
11307 cmdline_fixed_string_t set;
11308 cmdline_fixed_string_t vf;
11309 cmdline_fixed_string_t split;
11310 cmdline_fixed_string_t drop;
11313 cmdline_fixed_string_t on_off;
11316 /* Common CLI fields for vf split drop enable disable */
11317 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11318 TOKEN_STRING_INITIALIZER
11319 (struct cmd_vf_split_drop_en_result,
11321 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11322 TOKEN_STRING_INITIALIZER
11323 (struct cmd_vf_split_drop_en_result,
11325 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11326 TOKEN_STRING_INITIALIZER
11327 (struct cmd_vf_split_drop_en_result,
11329 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11330 TOKEN_STRING_INITIALIZER
11331 (struct cmd_vf_split_drop_en_result,
11333 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11334 TOKEN_NUM_INITIALIZER
11335 (struct cmd_vf_split_drop_en_result,
11337 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11338 TOKEN_NUM_INITIALIZER
11339 (struct cmd_vf_split_drop_en_result,
11341 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11342 TOKEN_STRING_INITIALIZER
11343 (struct cmd_vf_split_drop_en_result,
11347 cmd_set_vf_split_drop_en_parsed(
11348 void *parsed_result,
11349 __attribute__((unused)) struct cmdline *cl,
11350 __attribute__((unused)) void *data)
11352 struct cmd_vf_split_drop_en_result *res = parsed_result;
11354 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11356 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11362 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11365 printf("invalid port_id %d\n", res->port_id);
11368 printf("programming error: (%s)\n", strerror(-ret));
11372 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11373 .f = cmd_set_vf_split_drop_en_parsed,
11375 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11377 (void *)&cmd_vf_split_drop_en_set,
11378 (void *)&cmd_vf_split_drop_en_vf,
11379 (void *)&cmd_vf_split_drop_en_split,
11380 (void *)&cmd_vf_split_drop_en_drop,
11381 (void *)&cmd_vf_split_drop_en_port_id,
11382 (void *)&cmd_vf_split_drop_en_vf_id,
11383 (void *)&cmd_vf_split_drop_en_on_off,
11388 /* vf mac address configuration */
11390 /* Common result structure for vf mac address */
11391 struct cmd_set_vf_mac_addr_result {
11392 cmdline_fixed_string_t set;
11393 cmdline_fixed_string_t vf;
11394 cmdline_fixed_string_t mac;
11395 cmdline_fixed_string_t addr;
11398 struct ether_addr mac_addr;
11402 /* Common CLI fields for vf split drop enable disable */
11403 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11404 TOKEN_STRING_INITIALIZER
11405 (struct cmd_set_vf_mac_addr_result,
11407 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11408 TOKEN_STRING_INITIALIZER
11409 (struct cmd_set_vf_mac_addr_result,
11411 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11412 TOKEN_STRING_INITIALIZER
11413 (struct cmd_set_vf_mac_addr_result,
11415 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11416 TOKEN_STRING_INITIALIZER
11417 (struct cmd_set_vf_mac_addr_result,
11419 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11420 TOKEN_NUM_INITIALIZER
11421 (struct cmd_set_vf_mac_addr_result,
11423 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11424 TOKEN_NUM_INITIALIZER
11425 (struct cmd_set_vf_mac_addr_result,
11427 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11428 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11432 cmd_set_vf_mac_addr_parsed(
11433 void *parsed_result,
11434 __attribute__((unused)) struct cmdline *cl,
11435 __attribute__((unused)) void *data)
11437 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11440 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11446 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11449 printf("invalid port_id %d\n", res->port_id);
11452 printf("programming error: (%s)\n", strerror(-ret));
11456 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11457 .f = cmd_set_vf_mac_addr_parsed,
11459 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11461 (void *)&cmd_set_vf_mac_addr_set,
11462 (void *)&cmd_set_vf_mac_addr_vf,
11463 (void *)&cmd_set_vf_mac_addr_mac,
11464 (void *)&cmd_set_vf_mac_addr_addr,
11465 (void *)&cmd_set_vf_mac_addr_port_id,
11466 (void *)&cmd_set_vf_mac_addr_vf_id,
11467 (void *)&cmd_set_vf_mac_addr_mac_addr,
11473 /* ******************************************************************************** */
11475 /* list of instructions */
11476 cmdline_parse_ctx_t main_ctx[] = {
11477 (cmdline_parse_inst_t *)&cmd_help_brief,
11478 (cmdline_parse_inst_t *)&cmd_help_long,
11479 (cmdline_parse_inst_t *)&cmd_quit,
11480 (cmdline_parse_inst_t *)&cmd_showport,
11481 (cmdline_parse_inst_t *)&cmd_showqueue,
11482 (cmdline_parse_inst_t *)&cmd_showportall,
11483 (cmdline_parse_inst_t *)&cmd_showcfg,
11484 (cmdline_parse_inst_t *)&cmd_start,
11485 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11486 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11487 (cmdline_parse_inst_t *)&cmd_set_link_up,
11488 (cmdline_parse_inst_t *)&cmd_set_link_down,
11489 (cmdline_parse_inst_t *)&cmd_reset,
11490 (cmdline_parse_inst_t *)&cmd_set_numbers,
11491 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11492 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11493 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11494 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11495 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11496 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11497 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11498 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11499 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11500 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11501 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11502 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11503 (cmdline_parse_inst_t *)&cmd_set_link_check,
11504 #ifdef RTE_NIC_BYPASS
11505 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11506 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11507 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11508 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11510 #ifdef RTE_LIBRTE_PMD_BOND
11511 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11512 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11513 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11514 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11515 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11516 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11517 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11518 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11519 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11521 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11522 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11523 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11524 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11525 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11526 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11527 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11528 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11529 (cmdline_parse_inst_t *)&cmd_csum_set,
11530 (cmdline_parse_inst_t *)&cmd_csum_show,
11531 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11532 (cmdline_parse_inst_t *)&cmd_tso_set,
11533 (cmdline_parse_inst_t *)&cmd_tso_show,
11534 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11535 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11536 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11537 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11538 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11539 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11540 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11541 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11542 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11543 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11544 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11545 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11546 (cmdline_parse_inst_t *)&cmd_config_dcb,
11547 (cmdline_parse_inst_t *)&cmd_read_reg,
11548 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11549 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11550 (cmdline_parse_inst_t *)&cmd_write_reg,
11551 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11552 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11553 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11554 (cmdline_parse_inst_t *)&cmd_stop,
11555 (cmdline_parse_inst_t *)&cmd_mac_addr,
11556 (cmdline_parse_inst_t *)&cmd_set_qmap,
11557 (cmdline_parse_inst_t *)&cmd_operate_port,
11558 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11559 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11560 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11561 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11562 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11563 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11564 (cmdline_parse_inst_t *)&cmd_config_mtu,
11565 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11566 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11567 (cmdline_parse_inst_t *)&cmd_config_rss,
11568 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11569 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11570 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11571 (cmdline_parse_inst_t *)&cmd_showport_reta,
11572 (cmdline_parse_inst_t *)&cmd_config_burst,
11573 (cmdline_parse_inst_t *)&cmd_config_thresh,
11574 (cmdline_parse_inst_t *)&cmd_config_threshold,
11575 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11576 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11577 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11578 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11579 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11580 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11581 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11582 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11583 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11584 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11585 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11586 (cmdline_parse_inst_t *)&cmd_global_config,
11587 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11588 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11589 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11590 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11591 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11592 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11593 (cmdline_parse_inst_t *)&cmd_dump,
11594 (cmdline_parse_inst_t *)&cmd_dump_one,
11595 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11596 (cmdline_parse_inst_t *)&cmd_syn_filter,
11597 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11598 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11599 (cmdline_parse_inst_t *)&cmd_flex_filter,
11600 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11601 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11602 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11603 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11604 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11605 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11606 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11607 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11608 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11609 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11610 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11611 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11612 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11613 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11614 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11615 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11616 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11617 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11618 (cmdline_parse_inst_t *)&cmd_flow,
11619 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11620 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11621 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11622 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11623 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11624 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11625 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11626 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11627 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11628 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11629 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11630 #ifdef RTE_LIBRTE_IXGBE_PMD
11631 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11632 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11633 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11634 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11635 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11636 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11637 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11638 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11643 /* prompt function, called from main on MASTER lcore */
11647 /* initialize non-constant commands */
11648 cmd_set_fwd_mode_init();
11649 cmd_set_fwd_retry_mode_init();
11651 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11652 if (testpmd_cl == NULL)
11654 cmdline_interact(testpmd_cl);
11655 cmdline_stdin_exit(testpmd_cl);
11661 if (testpmd_cl != NULL)
11662 cmdline_quit(testpmd_cl);
11666 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11668 if (id == (portid_t)RTE_PORT_ALL) {
11671 FOREACH_PORT(pid, ports) {
11672 /* check if need_reconfig has been set to 1 */
11673 if (ports[pid].need_reconfig == 0)
11674 ports[pid].need_reconfig = dev;
11675 /* check if need_reconfig_queues has been set to 1 */
11676 if (ports[pid].need_reconfig_queues == 0)
11677 ports[pid].need_reconfig_queues = queue;
11679 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11680 /* check if need_reconfig has been set to 1 */
11681 if (ports[id].need_reconfig == 0)
11682 ports[id].need_reconfig = dev;
11683 /* check if need_reconfig_queues has been set to 1 */
11684 if (ports[id].need_reconfig_queues == 0)
11685 ports[id].need_reconfig_queues = queue;