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 destroy {port_id} rule {rule_id} [...]\n"
815 " Destroy specific flow rules.\n\n"
817 "flow flush {port_id}\n"
818 " Destroy all flow rules.\n\n"
820 "flow list {port_id} [group {group_id}] [...]\n"
821 " List existing flow rules sorted by priority,"
822 " filtered by group identifiers.\n\n"
827 cmdline_parse_token_string_t cmd_help_long_help =
828 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
830 cmdline_parse_token_string_t cmd_help_long_section =
831 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
832 "all#control#display#config#"
833 "ports#registers#filters");
835 cmdline_parse_inst_t cmd_help_long = {
836 .f = cmd_help_long_parsed,
838 .help_str = "help all|control|display|config|ports|register|filters: "
841 (void *)&cmd_help_long_help,
842 (void *)&cmd_help_long_section,
848 /* *** start/stop/close all ports *** */
849 struct cmd_operate_port_result {
850 cmdline_fixed_string_t keyword;
851 cmdline_fixed_string_t name;
852 cmdline_fixed_string_t value;
855 static void cmd_operate_port_parsed(void *parsed_result,
856 __attribute__((unused)) struct cmdline *cl,
857 __attribute__((unused)) void *data)
859 struct cmd_operate_port_result *res = parsed_result;
861 if (!strcmp(res->name, "start"))
862 start_port(RTE_PORT_ALL);
863 else if (!strcmp(res->name, "stop"))
864 stop_port(RTE_PORT_ALL);
865 else if (!strcmp(res->name, "close"))
866 close_port(RTE_PORT_ALL);
868 printf("Unknown parameter\n");
871 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
874 cmdline_parse_token_string_t cmd_operate_port_all_port =
875 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
877 cmdline_parse_token_string_t cmd_operate_port_all_all =
878 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
880 cmdline_parse_inst_t cmd_operate_port = {
881 .f = cmd_operate_port_parsed,
883 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
885 (void *)&cmd_operate_port_all_cmd,
886 (void *)&cmd_operate_port_all_port,
887 (void *)&cmd_operate_port_all_all,
892 /* *** start/stop/close specific port *** */
893 struct cmd_operate_specific_port_result {
894 cmdline_fixed_string_t keyword;
895 cmdline_fixed_string_t name;
899 static void cmd_operate_specific_port_parsed(void *parsed_result,
900 __attribute__((unused)) struct cmdline *cl,
901 __attribute__((unused)) void *data)
903 struct cmd_operate_specific_port_result *res = parsed_result;
905 if (!strcmp(res->name, "start"))
906 start_port(res->value);
907 else if (!strcmp(res->name, "stop"))
908 stop_port(res->value);
909 else if (!strcmp(res->name, "close"))
910 close_port(res->value);
912 printf("Unknown parameter\n");
915 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
916 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
918 cmdline_parse_token_string_t cmd_operate_specific_port_port =
919 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
920 name, "start#stop#close");
921 cmdline_parse_token_num_t cmd_operate_specific_port_id =
922 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
925 cmdline_parse_inst_t cmd_operate_specific_port = {
926 .f = cmd_operate_specific_port_parsed,
928 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
930 (void *)&cmd_operate_specific_port_cmd,
931 (void *)&cmd_operate_specific_port_port,
932 (void *)&cmd_operate_specific_port_id,
937 /* *** attach a specified port *** */
938 struct cmd_operate_attach_port_result {
939 cmdline_fixed_string_t port;
940 cmdline_fixed_string_t keyword;
941 cmdline_fixed_string_t identifier;
944 static void cmd_operate_attach_port_parsed(void *parsed_result,
945 __attribute__((unused)) struct cmdline *cl,
946 __attribute__((unused)) void *data)
948 struct cmd_operate_attach_port_result *res = parsed_result;
950 if (!strcmp(res->keyword, "attach"))
951 attach_port(res->identifier);
953 printf("Unknown parameter\n");
956 cmdline_parse_token_string_t cmd_operate_attach_port_port =
957 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
959 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
960 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
962 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
963 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
966 cmdline_parse_inst_t cmd_operate_attach_port = {
967 .f = cmd_operate_attach_port_parsed,
969 .help_str = "port attach <identifier>: "
970 "(identifier: pci address or virtual dev name)",
972 (void *)&cmd_operate_attach_port_port,
973 (void *)&cmd_operate_attach_port_keyword,
974 (void *)&cmd_operate_attach_port_identifier,
979 /* *** detach a specified port *** */
980 struct cmd_operate_detach_port_result {
981 cmdline_fixed_string_t port;
982 cmdline_fixed_string_t keyword;
986 static void cmd_operate_detach_port_parsed(void *parsed_result,
987 __attribute__((unused)) struct cmdline *cl,
988 __attribute__((unused)) void *data)
990 struct cmd_operate_detach_port_result *res = parsed_result;
992 if (!strcmp(res->keyword, "detach"))
993 detach_port(res->port_id);
995 printf("Unknown parameter\n");
998 cmdline_parse_token_string_t cmd_operate_detach_port_port =
999 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1001 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1002 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1004 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1005 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1008 cmdline_parse_inst_t cmd_operate_detach_port = {
1009 .f = cmd_operate_detach_port_parsed,
1011 .help_str = "port detach <port_id>",
1013 (void *)&cmd_operate_detach_port_port,
1014 (void *)&cmd_operate_detach_port_keyword,
1015 (void *)&cmd_operate_detach_port_port_id,
1020 /* *** configure speed for all ports *** */
1021 struct cmd_config_speed_all {
1022 cmdline_fixed_string_t port;
1023 cmdline_fixed_string_t keyword;
1024 cmdline_fixed_string_t all;
1025 cmdline_fixed_string_t item1;
1026 cmdline_fixed_string_t item2;
1027 cmdline_fixed_string_t value1;
1028 cmdline_fixed_string_t value2;
1032 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1037 if (!strcmp(duplexstr, "half")) {
1038 duplex = ETH_LINK_HALF_DUPLEX;
1039 } else if (!strcmp(duplexstr, "full")) {
1040 duplex = ETH_LINK_FULL_DUPLEX;
1041 } else if (!strcmp(duplexstr, "auto")) {
1042 duplex = ETH_LINK_FULL_DUPLEX;
1044 printf("Unknown duplex parameter\n");
1048 if (!strcmp(speedstr, "10")) {
1049 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1050 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1051 } else if (!strcmp(speedstr, "100")) {
1052 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1053 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1055 if (duplex != ETH_LINK_FULL_DUPLEX) {
1056 printf("Invalid speed/duplex parameters\n");
1059 if (!strcmp(speedstr, "1000")) {
1060 *speed = ETH_LINK_SPEED_1G;
1061 } else if (!strcmp(speedstr, "10000")) {
1062 *speed = ETH_LINK_SPEED_10G;
1063 } else if (!strcmp(speedstr, "25000")) {
1064 *speed = ETH_LINK_SPEED_25G;
1065 } else if (!strcmp(speedstr, "40000")) {
1066 *speed = ETH_LINK_SPEED_40G;
1067 } else if (!strcmp(speedstr, "50000")) {
1068 *speed = ETH_LINK_SPEED_50G;
1069 } else if (!strcmp(speedstr, "100000")) {
1070 *speed = ETH_LINK_SPEED_100G;
1071 } else if (!strcmp(speedstr, "auto")) {
1072 *speed = ETH_LINK_SPEED_AUTONEG;
1074 printf("Unknown speed parameter\n");
1083 cmd_config_speed_all_parsed(void *parsed_result,
1084 __attribute__((unused)) struct cmdline *cl,
1085 __attribute__((unused)) void *data)
1087 struct cmd_config_speed_all *res = parsed_result;
1088 uint32_t link_speed;
1091 if (!all_ports_stopped()) {
1092 printf("Please stop all ports first\n");
1096 if (parse_and_check_speed_duplex(res->value1, res->value2,
1100 FOREACH_PORT(pid, ports) {
1101 ports[pid].dev_conf.link_speeds = link_speed;
1104 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1107 cmdline_parse_token_string_t cmd_config_speed_all_port =
1108 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1109 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1112 cmdline_parse_token_string_t cmd_config_speed_all_all =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1114 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1115 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1116 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1117 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1118 "10#100#1000#10000#25000#40000#50000#100000#auto");
1119 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1120 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1121 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1122 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1125 cmdline_parse_inst_t cmd_config_speed_all = {
1126 .f = cmd_config_speed_all_parsed,
1128 .help_str = "port config all speed "
1129 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1132 (void *)&cmd_config_speed_all_port,
1133 (void *)&cmd_config_speed_all_keyword,
1134 (void *)&cmd_config_speed_all_all,
1135 (void *)&cmd_config_speed_all_item1,
1136 (void *)&cmd_config_speed_all_value1,
1137 (void *)&cmd_config_speed_all_item2,
1138 (void *)&cmd_config_speed_all_value2,
1143 /* *** configure speed for specific port *** */
1144 struct cmd_config_speed_specific {
1145 cmdline_fixed_string_t port;
1146 cmdline_fixed_string_t keyword;
1148 cmdline_fixed_string_t item1;
1149 cmdline_fixed_string_t item2;
1150 cmdline_fixed_string_t value1;
1151 cmdline_fixed_string_t value2;
1155 cmd_config_speed_specific_parsed(void *parsed_result,
1156 __attribute__((unused)) struct cmdline *cl,
1157 __attribute__((unused)) void *data)
1159 struct cmd_config_speed_specific *res = parsed_result;
1160 uint32_t link_speed;
1162 if (!all_ports_stopped()) {
1163 printf("Please stop all ports first\n");
1167 if (port_id_is_invalid(res->id, ENABLED_WARN))
1170 if (parse_and_check_speed_duplex(res->value1, res->value2,
1174 ports[res->id].dev_conf.link_speeds = link_speed;
1176 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1180 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1183 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1184 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1186 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1187 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1188 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1191 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1193 "10#100#1000#10000#25000#40000#50000#100000#auto");
1194 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1195 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1197 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1201 cmdline_parse_inst_t cmd_config_speed_specific = {
1202 .f = cmd_config_speed_specific_parsed,
1204 .help_str = "port config <port_id> speed "
1205 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1208 (void *)&cmd_config_speed_specific_port,
1209 (void *)&cmd_config_speed_specific_keyword,
1210 (void *)&cmd_config_speed_specific_id,
1211 (void *)&cmd_config_speed_specific_item1,
1212 (void *)&cmd_config_speed_specific_value1,
1213 (void *)&cmd_config_speed_specific_item2,
1214 (void *)&cmd_config_speed_specific_value2,
1219 /* *** configure txq/rxq, txd/rxd *** */
1220 struct cmd_config_rx_tx {
1221 cmdline_fixed_string_t port;
1222 cmdline_fixed_string_t keyword;
1223 cmdline_fixed_string_t all;
1224 cmdline_fixed_string_t name;
1229 cmd_config_rx_tx_parsed(void *parsed_result,
1230 __attribute__((unused)) struct cmdline *cl,
1231 __attribute__((unused)) void *data)
1233 struct cmd_config_rx_tx *res = parsed_result;
1235 if (!all_ports_stopped()) {
1236 printf("Please stop all ports first\n");
1239 if (!strcmp(res->name, "rxq")) {
1240 if (!res->value && !nb_txq) {
1241 printf("Warning: Either rx or tx queues should be non zero\n");
1244 nb_rxq = res->value;
1246 else if (!strcmp(res->name, "txq")) {
1247 if (!res->value && !nb_rxq) {
1248 printf("Warning: Either rx or tx queues should be non zero\n");
1251 nb_txq = res->value;
1253 else if (!strcmp(res->name, "rxd")) {
1254 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1255 printf("rxd %d invalid - must be > 0 && <= %d\n",
1256 res->value, RTE_TEST_RX_DESC_MAX);
1259 nb_rxd = res->value;
1260 } else if (!strcmp(res->name, "txd")) {
1261 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1262 printf("txd %d invalid - must be > 0 && <= %d\n",
1263 res->value, RTE_TEST_TX_DESC_MAX);
1266 nb_txd = res->value;
1268 printf("Unknown parameter\n");
1276 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1279 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1280 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1281 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1282 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1283 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1285 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1286 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1288 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1289 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1291 cmdline_parse_inst_t cmd_config_rx_tx = {
1292 .f = cmd_config_rx_tx_parsed,
1294 .help_str = "port config all rxq|txq|rxd|txd <value>",
1296 (void *)&cmd_config_rx_tx_port,
1297 (void *)&cmd_config_rx_tx_keyword,
1298 (void *)&cmd_config_rx_tx_all,
1299 (void *)&cmd_config_rx_tx_name,
1300 (void *)&cmd_config_rx_tx_value,
1305 /* *** config max packet length *** */
1306 struct cmd_config_max_pkt_len_result {
1307 cmdline_fixed_string_t port;
1308 cmdline_fixed_string_t keyword;
1309 cmdline_fixed_string_t all;
1310 cmdline_fixed_string_t name;
1315 cmd_config_max_pkt_len_parsed(void *parsed_result,
1316 __attribute__((unused)) struct cmdline *cl,
1317 __attribute__((unused)) void *data)
1319 struct cmd_config_max_pkt_len_result *res = parsed_result;
1321 if (!all_ports_stopped()) {
1322 printf("Please stop all ports first\n");
1326 if (!strcmp(res->name, "max-pkt-len")) {
1327 if (res->value < ETHER_MIN_LEN) {
1328 printf("max-pkt-len can not be less than %d\n",
1332 if (res->value == rx_mode.max_rx_pkt_len)
1335 rx_mode.max_rx_pkt_len = res->value;
1336 if (res->value > ETHER_MAX_LEN)
1337 rx_mode.jumbo_frame = 1;
1339 rx_mode.jumbo_frame = 0;
1341 printf("Unknown parameter\n");
1347 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1350 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1353 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1356 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1359 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1360 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1362 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1363 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1366 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1367 .f = cmd_config_max_pkt_len_parsed,
1369 .help_str = "port config all max-pkt-len <value>",
1371 (void *)&cmd_config_max_pkt_len_port,
1372 (void *)&cmd_config_max_pkt_len_keyword,
1373 (void *)&cmd_config_max_pkt_len_all,
1374 (void *)&cmd_config_max_pkt_len_name,
1375 (void *)&cmd_config_max_pkt_len_value,
1380 /* *** configure port MTU *** */
1381 struct cmd_config_mtu_result {
1382 cmdline_fixed_string_t port;
1383 cmdline_fixed_string_t keyword;
1384 cmdline_fixed_string_t mtu;
1390 cmd_config_mtu_parsed(void *parsed_result,
1391 __attribute__((unused)) struct cmdline *cl,
1392 __attribute__((unused)) void *data)
1394 struct cmd_config_mtu_result *res = parsed_result;
1396 if (res->value < ETHER_MIN_LEN) {
1397 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1400 port_mtu_set(res->port_id, res->value);
1403 cmdline_parse_token_string_t cmd_config_mtu_port =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1406 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1409 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1412 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1413 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1414 cmdline_parse_token_num_t cmd_config_mtu_value =
1415 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1417 cmdline_parse_inst_t cmd_config_mtu = {
1418 .f = cmd_config_mtu_parsed,
1420 .help_str = "port config mtu <port_id> <value>",
1422 (void *)&cmd_config_mtu_port,
1423 (void *)&cmd_config_mtu_keyword,
1424 (void *)&cmd_config_mtu_mtu,
1425 (void *)&cmd_config_mtu_port_id,
1426 (void *)&cmd_config_mtu_value,
1431 /* *** configure rx mode *** */
1432 struct cmd_config_rx_mode_flag {
1433 cmdline_fixed_string_t port;
1434 cmdline_fixed_string_t keyword;
1435 cmdline_fixed_string_t all;
1436 cmdline_fixed_string_t name;
1437 cmdline_fixed_string_t value;
1441 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1442 __attribute__((unused)) struct cmdline *cl,
1443 __attribute__((unused)) void *data)
1445 struct cmd_config_rx_mode_flag *res = parsed_result;
1447 if (!all_ports_stopped()) {
1448 printf("Please stop all ports first\n");
1452 if (!strcmp(res->name, "crc-strip")) {
1453 if (!strcmp(res->value, "on"))
1454 rx_mode.hw_strip_crc = 1;
1455 else if (!strcmp(res->value, "off"))
1456 rx_mode.hw_strip_crc = 0;
1458 printf("Unknown parameter\n");
1461 } else if (!strcmp(res->name, "scatter")) {
1462 if (!strcmp(res->value, "on"))
1463 rx_mode.enable_scatter = 1;
1464 else if (!strcmp(res->value, "off"))
1465 rx_mode.enable_scatter = 0;
1467 printf("Unknown parameter\n");
1470 } else if (!strcmp(res->name, "rx-cksum")) {
1471 if (!strcmp(res->value, "on"))
1472 rx_mode.hw_ip_checksum = 1;
1473 else if (!strcmp(res->value, "off"))
1474 rx_mode.hw_ip_checksum = 0;
1476 printf("Unknown parameter\n");
1479 } else if (!strcmp(res->name, "hw-vlan")) {
1480 if (!strcmp(res->value, "on")) {
1481 rx_mode.hw_vlan_filter = 1;
1482 rx_mode.hw_vlan_strip = 1;
1484 else if (!strcmp(res->value, "off")) {
1485 rx_mode.hw_vlan_filter = 0;
1486 rx_mode.hw_vlan_strip = 0;
1489 printf("Unknown parameter\n");
1492 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1493 if (!strcmp(res->value, "on"))
1494 rx_mode.hw_vlan_filter = 1;
1495 else if (!strcmp(res->value, "off"))
1496 rx_mode.hw_vlan_filter = 0;
1498 printf("Unknown parameter\n");
1501 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1502 if (!strcmp(res->value, "on"))
1503 rx_mode.hw_vlan_strip = 1;
1504 else if (!strcmp(res->value, "off"))
1505 rx_mode.hw_vlan_strip = 0;
1507 printf("Unknown parameter\n");
1510 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1511 if (!strcmp(res->value, "on"))
1512 rx_mode.hw_vlan_extend = 1;
1513 else if (!strcmp(res->value, "off"))
1514 rx_mode.hw_vlan_extend = 0;
1516 printf("Unknown parameter\n");
1519 } else if (!strcmp(res->name, "drop-en")) {
1520 if (!strcmp(res->value, "on"))
1522 else if (!strcmp(res->value, "off"))
1525 printf("Unknown parameter\n");
1529 printf("Unknown parameter\n");
1535 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1538 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1539 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1540 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1541 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1543 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1545 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1547 "crc-strip#scatter#rx-cksum#hw-vlan#"
1548 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1549 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1550 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1553 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1554 .f = cmd_config_rx_mode_flag_parsed,
1556 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1557 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1559 (void *)&cmd_config_rx_mode_flag_port,
1560 (void *)&cmd_config_rx_mode_flag_keyword,
1561 (void *)&cmd_config_rx_mode_flag_all,
1562 (void *)&cmd_config_rx_mode_flag_name,
1563 (void *)&cmd_config_rx_mode_flag_value,
1568 /* *** configure rss *** */
1569 struct cmd_config_rss {
1570 cmdline_fixed_string_t port;
1571 cmdline_fixed_string_t keyword;
1572 cmdline_fixed_string_t all;
1573 cmdline_fixed_string_t name;
1574 cmdline_fixed_string_t value;
1578 cmd_config_rss_parsed(void *parsed_result,
1579 __attribute__((unused)) struct cmdline *cl,
1580 __attribute__((unused)) void *data)
1582 struct cmd_config_rss *res = parsed_result;
1583 struct rte_eth_rss_conf rss_conf;
1587 if (!strcmp(res->value, "all"))
1588 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1589 ETH_RSS_UDP | ETH_RSS_SCTP |
1591 else if (!strcmp(res->value, "ip"))
1592 rss_conf.rss_hf = ETH_RSS_IP;
1593 else if (!strcmp(res->value, "udp"))
1594 rss_conf.rss_hf = ETH_RSS_UDP;
1595 else if (!strcmp(res->value, "tcp"))
1596 rss_conf.rss_hf = ETH_RSS_TCP;
1597 else if (!strcmp(res->value, "sctp"))
1598 rss_conf.rss_hf = ETH_RSS_SCTP;
1599 else if (!strcmp(res->value, "ether"))
1600 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1601 else if (!strcmp(res->value, "port"))
1602 rss_conf.rss_hf = ETH_RSS_PORT;
1603 else if (!strcmp(res->value, "vxlan"))
1604 rss_conf.rss_hf = ETH_RSS_VXLAN;
1605 else if (!strcmp(res->value, "geneve"))
1606 rss_conf.rss_hf = ETH_RSS_GENEVE;
1607 else if (!strcmp(res->value, "nvgre"))
1608 rss_conf.rss_hf = ETH_RSS_NVGRE;
1609 else if (!strcmp(res->value, "none"))
1610 rss_conf.rss_hf = 0;
1612 printf("Unknown parameter\n");
1615 rss_conf.rss_key = NULL;
1616 for (i = 0; i < rte_eth_dev_count(); i++) {
1617 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1619 printf("Configuration of RSS hash at ethernet port %d "
1620 "failed with error (%d): %s.\n",
1621 i, -diag, strerror(-diag));
1625 cmdline_parse_token_string_t cmd_config_rss_port =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1627 cmdline_parse_token_string_t cmd_config_rss_keyword =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1629 cmdline_parse_token_string_t cmd_config_rss_all =
1630 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1631 cmdline_parse_token_string_t cmd_config_rss_name =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1633 cmdline_parse_token_string_t cmd_config_rss_value =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1635 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1637 cmdline_parse_inst_t cmd_config_rss = {
1638 .f = cmd_config_rss_parsed,
1640 .help_str = "port config all rss "
1641 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1643 (void *)&cmd_config_rss_port,
1644 (void *)&cmd_config_rss_keyword,
1645 (void *)&cmd_config_rss_all,
1646 (void *)&cmd_config_rss_name,
1647 (void *)&cmd_config_rss_value,
1652 /* *** configure rss hash key *** */
1653 struct cmd_config_rss_hash_key {
1654 cmdline_fixed_string_t port;
1655 cmdline_fixed_string_t config;
1657 cmdline_fixed_string_t rss_hash_key;
1658 cmdline_fixed_string_t rss_type;
1659 cmdline_fixed_string_t key;
1663 hexa_digit_to_value(char hexa_digit)
1665 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1666 return (uint8_t) (hexa_digit - '0');
1667 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1668 return (uint8_t) ((hexa_digit - 'a') + 10);
1669 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1670 return (uint8_t) ((hexa_digit - 'A') + 10);
1671 /* Invalid hexa digit */
1676 parse_and_check_key_hexa_digit(char *key, int idx)
1680 hexa_v = hexa_digit_to_value(key[idx]);
1682 printf("invalid key: character %c at position %d is not a "
1683 "valid hexa digit\n", key[idx], idx);
1688 cmd_config_rss_hash_key_parsed(void *parsed_result,
1689 __attribute__((unused)) struct cmdline *cl,
1690 __attribute__((unused)) void *data)
1692 struct cmd_config_rss_hash_key *res = parsed_result;
1693 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1697 struct rte_eth_dev_info dev_info;
1698 uint8_t hash_key_size;
1701 memset(&dev_info, 0, sizeof(dev_info));
1702 rte_eth_dev_info_get(res->port_id, &dev_info);
1703 if (dev_info.hash_key_size > 0 &&
1704 dev_info.hash_key_size <= sizeof(hash_key))
1705 hash_key_size = dev_info.hash_key_size;
1707 printf("dev_info did not provide a valid hash key size\n");
1710 /* Check the length of the RSS hash key */
1711 key_len = strlen(res->key);
1712 if (key_len != (hash_key_size * 2)) {
1713 printf("key length: %d invalid - key must be a string of %d"
1714 " hexa-decimal numbers\n",
1715 (int) key_len, hash_key_size * 2);
1718 /* Translate RSS hash key into binary representation */
1719 for (i = 0; i < hash_key_size; i++) {
1720 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1723 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1726 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1728 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1732 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1734 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1737 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1738 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1739 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1741 rss_hash_key, "rss-hash-key");
1742 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1744 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1745 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1746 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1747 "ipv6-tcp-ex#ipv6-udp-ex");
1748 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1751 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1752 .f = cmd_config_rss_hash_key_parsed,
1754 .help_str = "port config <port_id> rss-hash-key "
1755 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1756 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1757 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1758 "<string of hex digits (variable length, NIC dependent)>",
1760 (void *)&cmd_config_rss_hash_key_port,
1761 (void *)&cmd_config_rss_hash_key_config,
1762 (void *)&cmd_config_rss_hash_key_port_id,
1763 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1764 (void *)&cmd_config_rss_hash_key_rss_type,
1765 (void *)&cmd_config_rss_hash_key_value,
1770 /* *** configure port rxq/txq start/stop *** */
1771 struct cmd_config_rxtx_queue {
1772 cmdline_fixed_string_t port;
1774 cmdline_fixed_string_t rxtxq;
1776 cmdline_fixed_string_t opname;
1780 cmd_config_rxtx_queue_parsed(void *parsed_result,
1781 __attribute__((unused)) struct cmdline *cl,
1782 __attribute__((unused)) void *data)
1784 struct cmd_config_rxtx_queue *res = parsed_result;
1789 if (test_done == 0) {
1790 printf("Please stop forwarding first\n");
1794 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1797 if (port_is_started(res->portid) != 1) {
1798 printf("Please start port %u first\n", res->portid);
1802 if (!strcmp(res->rxtxq, "rxq"))
1804 else if (!strcmp(res->rxtxq, "txq"))
1807 printf("Unknown parameter\n");
1811 if (isrx && rx_queue_id_is_invalid(res->qid))
1813 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1816 if (!strcmp(res->opname, "start"))
1818 else if (!strcmp(res->opname, "stop"))
1821 printf("Unknown parameter\n");
1825 if (isstart && isrx)
1826 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1827 else if (!isstart && isrx)
1828 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1829 else if (isstart && !isrx)
1830 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1832 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1834 if (ret == -ENOTSUP)
1835 printf("Function not supported in PMD driver\n");
1838 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1840 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1841 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1842 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1844 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1845 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1846 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1850 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1851 .f = cmd_config_rxtx_queue_parsed,
1853 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1855 (void *)&cmd_config_speed_all_port,
1856 (void *)&cmd_config_rxtx_queue_portid,
1857 (void *)&cmd_config_rxtx_queue_rxtxq,
1858 (void *)&cmd_config_rxtx_queue_qid,
1859 (void *)&cmd_config_rxtx_queue_opname,
1864 /* *** Configure RSS RETA *** */
1865 struct cmd_config_rss_reta {
1866 cmdline_fixed_string_t port;
1867 cmdline_fixed_string_t keyword;
1869 cmdline_fixed_string_t name;
1870 cmdline_fixed_string_t list_name;
1871 cmdline_fixed_string_t list_of_items;
1875 parse_reta_config(const char *str,
1876 struct rte_eth_rss_reta_entry64 *reta_conf,
1877 uint16_t nb_entries)
1881 uint16_t hash_index, idx, shift;
1884 const char *p, *p0 = str;
1891 unsigned long int_fld[_NUM_FLD];
1892 char *str_fld[_NUM_FLD];
1894 while ((p = strchr(p0,'(')) != NULL) {
1896 if((p0 = strchr(p,')')) == NULL)
1900 if(size >= sizeof(s))
1903 snprintf(s, sizeof(s), "%.*s", size, p);
1904 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1906 for (i = 0; i < _NUM_FLD; i++) {
1908 int_fld[i] = strtoul(str_fld[i], &end, 0);
1909 if (errno != 0 || end == str_fld[i] ||
1914 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1915 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1917 if (hash_index >= nb_entries) {
1918 printf("Invalid RETA hash index=%d\n", hash_index);
1922 idx = hash_index / RTE_RETA_GROUP_SIZE;
1923 shift = hash_index % RTE_RETA_GROUP_SIZE;
1924 reta_conf[idx].mask |= (1ULL << shift);
1925 reta_conf[idx].reta[shift] = nb_queue;
1932 cmd_set_rss_reta_parsed(void *parsed_result,
1933 __attribute__((unused)) struct cmdline *cl,
1934 __attribute__((unused)) void *data)
1937 struct rte_eth_dev_info dev_info;
1938 struct rte_eth_rss_reta_entry64 reta_conf[8];
1939 struct cmd_config_rss_reta *res = parsed_result;
1941 memset(&dev_info, 0, sizeof(dev_info));
1942 rte_eth_dev_info_get(res->port_id, &dev_info);
1943 if (dev_info.reta_size == 0) {
1944 printf("Redirection table size is 0 which is "
1945 "invalid for RSS\n");
1948 printf("The reta size of port %d is %u\n",
1949 res->port_id, dev_info.reta_size);
1950 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1951 printf("Currently do not support more than %u entries of "
1952 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1956 memset(reta_conf, 0, sizeof(reta_conf));
1957 if (!strcmp(res->list_name, "reta")) {
1958 if (parse_reta_config(res->list_of_items, reta_conf,
1959 dev_info.reta_size)) {
1960 printf("Invalid RSS Redirection Table "
1961 "config entered\n");
1964 ret = rte_eth_dev_rss_reta_update(res->port_id,
1965 reta_conf, dev_info.reta_size);
1967 printf("Bad redirection table parameter, "
1968 "return code = %d \n", ret);
1972 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1974 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1976 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1977 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1978 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1979 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1980 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1981 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1982 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1983 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1985 cmdline_parse_inst_t cmd_config_rss_reta = {
1986 .f = cmd_set_rss_reta_parsed,
1988 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
1990 (void *)&cmd_config_rss_reta_port,
1991 (void *)&cmd_config_rss_reta_keyword,
1992 (void *)&cmd_config_rss_reta_port_id,
1993 (void *)&cmd_config_rss_reta_name,
1994 (void *)&cmd_config_rss_reta_list_name,
1995 (void *)&cmd_config_rss_reta_list_of_items,
2000 /* *** SHOW PORT RETA INFO *** */
2001 struct cmd_showport_reta {
2002 cmdline_fixed_string_t show;
2003 cmdline_fixed_string_t port;
2005 cmdline_fixed_string_t rss;
2006 cmdline_fixed_string_t reta;
2008 cmdline_fixed_string_t list_of_items;
2012 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2013 uint16_t nb_entries,
2017 const char *p, *p0 = str;
2021 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2024 p = strchr(p0, '(');
2028 p0 = strchr(p, ')');
2032 if (size >= sizeof(s)) {
2033 printf("The string size exceeds the internal buffer size\n");
2036 snprintf(s, sizeof(s), "%.*s", size, p);
2037 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2038 if (ret <= 0 || ret != num) {
2039 printf("The bits of masks do not match the number of "
2040 "reta entries: %u\n", num);
2043 for (i = 0; i < ret; i++)
2044 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2050 cmd_showport_reta_parsed(void *parsed_result,
2051 __attribute__((unused)) struct cmdline *cl,
2052 __attribute__((unused)) void *data)
2054 struct cmd_showport_reta *res = parsed_result;
2055 struct rte_eth_rss_reta_entry64 reta_conf[8];
2056 struct rte_eth_dev_info dev_info;
2058 memset(&dev_info, 0, sizeof(dev_info));
2059 rte_eth_dev_info_get(res->port_id, &dev_info);
2060 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2061 res->size > ETH_RSS_RETA_SIZE_512) {
2062 printf("Invalid redirection table size: %u\n", res->size);
2066 memset(reta_conf, 0, sizeof(reta_conf));
2067 if (showport_parse_reta_config(reta_conf, res->size,
2068 res->list_of_items) < 0) {
2069 printf("Invalid string: %s for reta masks\n",
2070 res->list_of_items);
2073 port_rss_reta_info(res->port_id, reta_conf, res->size);
2076 cmdline_parse_token_string_t cmd_showport_reta_show =
2077 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2078 cmdline_parse_token_string_t cmd_showport_reta_port =
2079 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2080 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2081 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2082 cmdline_parse_token_string_t cmd_showport_reta_rss =
2083 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2084 cmdline_parse_token_string_t cmd_showport_reta_reta =
2085 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2086 cmdline_parse_token_num_t cmd_showport_reta_size =
2087 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2088 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2089 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2090 list_of_items, NULL);
2092 cmdline_parse_inst_t cmd_showport_reta = {
2093 .f = cmd_showport_reta_parsed,
2095 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2097 (void *)&cmd_showport_reta_show,
2098 (void *)&cmd_showport_reta_port,
2099 (void *)&cmd_showport_reta_port_id,
2100 (void *)&cmd_showport_reta_rss,
2101 (void *)&cmd_showport_reta_reta,
2102 (void *)&cmd_showport_reta_size,
2103 (void *)&cmd_showport_reta_list_of_items,
2108 /* *** Show RSS hash configuration *** */
2109 struct cmd_showport_rss_hash {
2110 cmdline_fixed_string_t show;
2111 cmdline_fixed_string_t port;
2113 cmdline_fixed_string_t rss_hash;
2114 cmdline_fixed_string_t rss_type;
2115 cmdline_fixed_string_t key; /* optional argument */
2118 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2119 __attribute__((unused)) struct cmdline *cl,
2122 struct cmd_showport_rss_hash *res = parsed_result;
2124 port_rss_hash_conf_show(res->port_id, res->rss_type,
2125 show_rss_key != NULL);
2128 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2129 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2130 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2131 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2132 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2133 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2134 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2135 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2137 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2138 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2139 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2140 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2141 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2142 "ipv6-tcp-ex#ipv6-udp-ex");
2143 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2144 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2146 cmdline_parse_inst_t cmd_showport_rss_hash = {
2147 .f = cmd_showport_rss_hash_parsed,
2149 .help_str = "show port <port_id> rss-hash "
2150 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2151 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2152 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2154 (void *)&cmd_showport_rss_hash_show,
2155 (void *)&cmd_showport_rss_hash_port,
2156 (void *)&cmd_showport_rss_hash_port_id,
2157 (void *)&cmd_showport_rss_hash_rss_hash,
2158 (void *)&cmd_showport_rss_hash_rss_hash_info,
2163 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2164 .f = cmd_showport_rss_hash_parsed,
2166 .help_str = "show port <port_id> rss-hash "
2167 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2168 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2169 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2171 (void *)&cmd_showport_rss_hash_show,
2172 (void *)&cmd_showport_rss_hash_port,
2173 (void *)&cmd_showport_rss_hash_port_id,
2174 (void *)&cmd_showport_rss_hash_rss_hash,
2175 (void *)&cmd_showport_rss_hash_rss_hash_info,
2176 (void *)&cmd_showport_rss_hash_rss_key,
2181 /* *** Configure DCB *** */
2182 struct cmd_config_dcb {
2183 cmdline_fixed_string_t port;
2184 cmdline_fixed_string_t config;
2186 cmdline_fixed_string_t dcb;
2187 cmdline_fixed_string_t vt;
2188 cmdline_fixed_string_t vt_en;
2190 cmdline_fixed_string_t pfc;
2191 cmdline_fixed_string_t pfc_en;
2195 cmd_config_dcb_parsed(void *parsed_result,
2196 __attribute__((unused)) struct cmdline *cl,
2197 __attribute__((unused)) void *data)
2199 struct cmd_config_dcb *res = parsed_result;
2200 portid_t port_id = res->port_id;
2201 struct rte_port *port;
2205 port = &ports[port_id];
2206 /** Check if the port is not started **/
2207 if (port->port_status != RTE_PORT_STOPPED) {
2208 printf("Please stop port %d first\n", port_id);
2212 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2213 printf("The invalid number of traffic class,"
2214 " only 4 or 8 allowed.\n");
2218 if (nb_fwd_lcores < res->num_tcs) {
2219 printf("nb_cores shouldn't be less than number of TCs.\n");
2222 if (!strncmp(res->pfc_en, "on", 2))
2227 /* DCB in VT mode */
2228 if (!strncmp(res->vt_en, "on", 2))
2229 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2230 (enum rte_eth_nb_tcs)res->num_tcs,
2233 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2234 (enum rte_eth_nb_tcs)res->num_tcs,
2239 printf("Cannot initialize network ports.\n");
2243 cmd_reconfig_device_queue(port_id, 1, 1);
2246 cmdline_parse_token_string_t cmd_config_dcb_port =
2247 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2248 cmdline_parse_token_string_t cmd_config_dcb_config =
2249 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2250 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2251 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2252 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2253 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2254 cmdline_parse_token_string_t cmd_config_dcb_vt =
2255 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2256 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2257 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2258 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2259 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2260 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2261 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2262 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2263 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2265 cmdline_parse_inst_t cmd_config_dcb = {
2266 .f = cmd_config_dcb_parsed,
2268 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2270 (void *)&cmd_config_dcb_port,
2271 (void *)&cmd_config_dcb_config,
2272 (void *)&cmd_config_dcb_port_id,
2273 (void *)&cmd_config_dcb_dcb,
2274 (void *)&cmd_config_dcb_vt,
2275 (void *)&cmd_config_dcb_vt_en,
2276 (void *)&cmd_config_dcb_num_tcs,
2277 (void *)&cmd_config_dcb_pfc,
2278 (void *)&cmd_config_dcb_pfc_en,
2283 /* *** configure number of packets per burst *** */
2284 struct cmd_config_burst {
2285 cmdline_fixed_string_t port;
2286 cmdline_fixed_string_t keyword;
2287 cmdline_fixed_string_t all;
2288 cmdline_fixed_string_t name;
2293 cmd_config_burst_parsed(void *parsed_result,
2294 __attribute__((unused)) struct cmdline *cl,
2295 __attribute__((unused)) void *data)
2297 struct cmd_config_burst *res = parsed_result;
2299 if (!all_ports_stopped()) {
2300 printf("Please stop all ports first\n");
2304 if (!strcmp(res->name, "burst")) {
2305 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2306 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2309 nb_pkt_per_burst = res->value;
2311 printf("Unknown parameter\n");
2317 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2320 cmdline_parse_token_string_t cmd_config_burst_port =
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2322 cmdline_parse_token_string_t cmd_config_burst_keyword =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2324 cmdline_parse_token_string_t cmd_config_burst_all =
2325 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2326 cmdline_parse_token_string_t cmd_config_burst_name =
2327 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2328 cmdline_parse_token_num_t cmd_config_burst_value =
2329 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2331 cmdline_parse_inst_t cmd_config_burst = {
2332 .f = cmd_config_burst_parsed,
2334 .help_str = "port config all burst <value>",
2336 (void *)&cmd_config_burst_port,
2337 (void *)&cmd_config_burst_keyword,
2338 (void *)&cmd_config_burst_all,
2339 (void *)&cmd_config_burst_name,
2340 (void *)&cmd_config_burst_value,
2345 /* *** configure rx/tx queues *** */
2346 struct cmd_config_thresh {
2347 cmdline_fixed_string_t port;
2348 cmdline_fixed_string_t keyword;
2349 cmdline_fixed_string_t all;
2350 cmdline_fixed_string_t name;
2355 cmd_config_thresh_parsed(void *parsed_result,
2356 __attribute__((unused)) struct cmdline *cl,
2357 __attribute__((unused)) void *data)
2359 struct cmd_config_thresh *res = parsed_result;
2361 if (!all_ports_stopped()) {
2362 printf("Please stop all ports first\n");
2366 if (!strcmp(res->name, "txpt"))
2367 tx_pthresh = res->value;
2368 else if(!strcmp(res->name, "txht"))
2369 tx_hthresh = res->value;
2370 else if(!strcmp(res->name, "txwt"))
2371 tx_wthresh = res->value;
2372 else if(!strcmp(res->name, "rxpt"))
2373 rx_pthresh = res->value;
2374 else if(!strcmp(res->name, "rxht"))
2375 rx_hthresh = res->value;
2376 else if(!strcmp(res->name, "rxwt"))
2377 rx_wthresh = res->value;
2379 printf("Unknown parameter\n");
2385 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2388 cmdline_parse_token_string_t cmd_config_thresh_port =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2390 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2392 cmdline_parse_token_string_t cmd_config_thresh_all =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2394 cmdline_parse_token_string_t cmd_config_thresh_name =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2396 "txpt#txht#txwt#rxpt#rxht#rxwt");
2397 cmdline_parse_token_num_t cmd_config_thresh_value =
2398 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2400 cmdline_parse_inst_t cmd_config_thresh = {
2401 .f = cmd_config_thresh_parsed,
2403 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2405 (void *)&cmd_config_thresh_port,
2406 (void *)&cmd_config_thresh_keyword,
2407 (void *)&cmd_config_thresh_all,
2408 (void *)&cmd_config_thresh_name,
2409 (void *)&cmd_config_thresh_value,
2414 /* *** configure free/rs threshold *** */
2415 struct cmd_config_threshold {
2416 cmdline_fixed_string_t port;
2417 cmdline_fixed_string_t keyword;
2418 cmdline_fixed_string_t all;
2419 cmdline_fixed_string_t name;
2424 cmd_config_threshold_parsed(void *parsed_result,
2425 __attribute__((unused)) struct cmdline *cl,
2426 __attribute__((unused)) void *data)
2428 struct cmd_config_threshold *res = parsed_result;
2430 if (!all_ports_stopped()) {
2431 printf("Please stop all ports first\n");
2435 if (!strcmp(res->name, "txfreet"))
2436 tx_free_thresh = res->value;
2437 else if (!strcmp(res->name, "txrst"))
2438 tx_rs_thresh = res->value;
2439 else if (!strcmp(res->name, "rxfreet"))
2440 rx_free_thresh = res->value;
2442 printf("Unknown parameter\n");
2448 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2451 cmdline_parse_token_string_t cmd_config_threshold_port =
2452 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2453 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2454 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2456 cmdline_parse_token_string_t cmd_config_threshold_all =
2457 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2458 cmdline_parse_token_string_t cmd_config_threshold_name =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2460 "txfreet#txrst#rxfreet");
2461 cmdline_parse_token_num_t cmd_config_threshold_value =
2462 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2464 cmdline_parse_inst_t cmd_config_threshold = {
2465 .f = cmd_config_threshold_parsed,
2467 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2469 (void *)&cmd_config_threshold_port,
2470 (void *)&cmd_config_threshold_keyword,
2471 (void *)&cmd_config_threshold_all,
2472 (void *)&cmd_config_threshold_name,
2473 (void *)&cmd_config_threshold_value,
2479 struct cmd_stop_result {
2480 cmdline_fixed_string_t stop;
2483 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2484 __attribute__((unused)) struct cmdline *cl,
2485 __attribute__((unused)) void *data)
2487 stop_packet_forwarding();
2490 cmdline_parse_token_string_t cmd_stop_stop =
2491 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2493 cmdline_parse_inst_t cmd_stop = {
2494 .f = cmd_stop_parsed,
2496 .help_str = "stop: Stop packet forwarding",
2498 (void *)&cmd_stop_stop,
2503 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2506 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2507 unsigned int *parsed_items, int check_unique_values)
2509 unsigned int nb_item;
2517 * First parse all items in the list and store their value.
2522 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2524 if ((c >= '0') && (c <= '9')) {
2525 value = (unsigned int) (value * 10 + (c - '0'));
2530 printf("character %c is not a decimal digit\n", c);
2534 printf("No valid value before comma\n");
2537 if (nb_item < max_items) {
2538 parsed_items[nb_item] = value;
2544 if (nb_item >= max_items) {
2545 printf("Number of %s = %u > %u (maximum items)\n",
2546 item_name, nb_item + 1, max_items);
2549 parsed_items[nb_item++] = value;
2550 if (! check_unique_values)
2554 * Then, check that all values in the list are differents.
2555 * No optimization here...
2557 for (i = 0; i < nb_item; i++) {
2558 for (j = i + 1; j < nb_item; j++) {
2559 if (parsed_items[j] == parsed_items[i]) {
2560 printf("duplicated %s %u at index %u and %u\n",
2561 item_name, parsed_items[i], i, j);
2569 struct cmd_set_list_result {
2570 cmdline_fixed_string_t cmd_keyword;
2571 cmdline_fixed_string_t list_name;
2572 cmdline_fixed_string_t list_of_items;
2575 static void cmd_set_list_parsed(void *parsed_result,
2576 __attribute__((unused)) struct cmdline *cl,
2577 __attribute__((unused)) void *data)
2579 struct cmd_set_list_result *res;
2581 unsigned int lcorelist[RTE_MAX_LCORE];
2582 unsigned int portlist[RTE_MAX_ETHPORTS];
2584 unsigned int nb_item;
2586 if (test_done == 0) {
2587 printf("Please stop forwarding first\n");
2591 res = parsed_result;
2592 if (!strcmp(res->list_name, "corelist")) {
2593 nb_item = parse_item_list(res->list_of_items, "core",
2595 parsed_items.lcorelist, 1);
2597 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2602 if (!strcmp(res->list_name, "portlist")) {
2603 nb_item = parse_item_list(res->list_of_items, "port",
2605 parsed_items.portlist, 1);
2607 set_fwd_ports_list(parsed_items.portlist, nb_item);
2613 cmdline_parse_token_string_t cmd_set_list_keyword =
2614 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2616 cmdline_parse_token_string_t cmd_set_list_name =
2617 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2618 "corelist#portlist");
2619 cmdline_parse_token_string_t cmd_set_list_of_items =
2620 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2623 cmdline_parse_inst_t cmd_set_fwd_list = {
2624 .f = cmd_set_list_parsed,
2626 .help_str = "set corelist|portlist <list0[,list1]*>",
2628 (void *)&cmd_set_list_keyword,
2629 (void *)&cmd_set_list_name,
2630 (void *)&cmd_set_list_of_items,
2635 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2637 struct cmd_setmask_result {
2638 cmdline_fixed_string_t set;
2639 cmdline_fixed_string_t mask;
2643 static void cmd_set_mask_parsed(void *parsed_result,
2644 __attribute__((unused)) struct cmdline *cl,
2645 __attribute__((unused)) void *data)
2647 struct cmd_setmask_result *res = parsed_result;
2649 if (test_done == 0) {
2650 printf("Please stop forwarding first\n");
2653 if (!strcmp(res->mask, "coremask")) {
2654 set_fwd_lcores_mask(res->hexavalue);
2656 } else if (!strcmp(res->mask, "portmask")) {
2657 set_fwd_ports_mask(res->hexavalue);
2662 cmdline_parse_token_string_t cmd_setmask_set =
2663 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2664 cmdline_parse_token_string_t cmd_setmask_mask =
2665 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2666 "coremask#portmask");
2667 cmdline_parse_token_num_t cmd_setmask_value =
2668 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2670 cmdline_parse_inst_t cmd_set_fwd_mask = {
2671 .f = cmd_set_mask_parsed,
2673 .help_str = "set coremask|portmask <hexadecimal value>",
2675 (void *)&cmd_setmask_set,
2676 (void *)&cmd_setmask_mask,
2677 (void *)&cmd_setmask_value,
2683 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2685 struct cmd_set_result {
2686 cmdline_fixed_string_t set;
2687 cmdline_fixed_string_t what;
2691 static void cmd_set_parsed(void *parsed_result,
2692 __attribute__((unused)) struct cmdline *cl,
2693 __attribute__((unused)) void *data)
2695 struct cmd_set_result *res = parsed_result;
2696 if (!strcmp(res->what, "nbport")) {
2697 set_fwd_ports_number(res->value);
2699 } else if (!strcmp(res->what, "nbcore")) {
2700 set_fwd_lcores_number(res->value);
2702 } else if (!strcmp(res->what, "burst"))
2703 set_nb_pkt_per_burst(res->value);
2704 else if (!strcmp(res->what, "verbose"))
2705 set_verbose_level(res->value);
2708 cmdline_parse_token_string_t cmd_set_set =
2709 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2710 cmdline_parse_token_string_t cmd_set_what =
2711 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2712 "nbport#nbcore#burst#verbose");
2713 cmdline_parse_token_num_t cmd_set_value =
2714 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2716 cmdline_parse_inst_t cmd_set_numbers = {
2717 .f = cmd_set_parsed,
2719 .help_str = "set nbport|nbcore|burst|verbose <value>",
2721 (void *)&cmd_set_set,
2722 (void *)&cmd_set_what,
2723 (void *)&cmd_set_value,
2728 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2730 struct cmd_set_txpkts_result {
2731 cmdline_fixed_string_t cmd_keyword;
2732 cmdline_fixed_string_t txpkts;
2733 cmdline_fixed_string_t seg_lengths;
2737 cmd_set_txpkts_parsed(void *parsed_result,
2738 __attribute__((unused)) struct cmdline *cl,
2739 __attribute__((unused)) void *data)
2741 struct cmd_set_txpkts_result *res;
2742 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2743 unsigned int nb_segs;
2745 res = parsed_result;
2746 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2747 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2749 set_tx_pkt_segments(seg_lengths, nb_segs);
2752 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2753 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2754 cmd_keyword, "set");
2755 cmdline_parse_token_string_t cmd_set_txpkts_name =
2756 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2758 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2759 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2762 cmdline_parse_inst_t cmd_set_txpkts = {
2763 .f = cmd_set_txpkts_parsed,
2765 .help_str = "set txpkts <len0[,len1]*>",
2767 (void *)&cmd_set_txpkts_keyword,
2768 (void *)&cmd_set_txpkts_name,
2769 (void *)&cmd_set_txpkts_lengths,
2774 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2776 struct cmd_set_txsplit_result {
2777 cmdline_fixed_string_t cmd_keyword;
2778 cmdline_fixed_string_t txsplit;
2779 cmdline_fixed_string_t mode;
2783 cmd_set_txsplit_parsed(void *parsed_result,
2784 __attribute__((unused)) struct cmdline *cl,
2785 __attribute__((unused)) void *data)
2787 struct cmd_set_txsplit_result *res;
2789 res = parsed_result;
2790 set_tx_pkt_split(res->mode);
2793 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2794 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2795 cmd_keyword, "set");
2796 cmdline_parse_token_string_t cmd_set_txsplit_name =
2797 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2798 txsplit, "txsplit");
2799 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2800 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2803 cmdline_parse_inst_t cmd_set_txsplit = {
2804 .f = cmd_set_txsplit_parsed,
2806 .help_str = "set txsplit on|off|rand",
2808 (void *)&cmd_set_txsplit_keyword,
2809 (void *)&cmd_set_txsplit_name,
2810 (void *)&cmd_set_txsplit_mode,
2815 /* *** CONFIG TX QUEUE FLAGS *** */
2817 struct cmd_config_txqflags_result {
2818 cmdline_fixed_string_t port;
2819 cmdline_fixed_string_t config;
2820 cmdline_fixed_string_t all;
2821 cmdline_fixed_string_t what;
2825 static void cmd_config_txqflags_parsed(void *parsed_result,
2826 __attribute__((unused)) struct cmdline *cl,
2827 __attribute__((unused)) void *data)
2829 struct cmd_config_txqflags_result *res = parsed_result;
2831 if (!all_ports_stopped()) {
2832 printf("Please stop all ports first\n");
2836 if (strcmp(res->what, "txqflags")) {
2837 printf("Unknown parameter\n");
2841 if (res->hexvalue >= 0) {
2842 txq_flags = res->hexvalue;
2844 printf("txqflags must be >= 0\n");
2850 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2853 cmdline_parse_token_string_t cmd_config_txqflags_port =
2854 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2856 cmdline_parse_token_string_t cmd_config_txqflags_config =
2857 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2859 cmdline_parse_token_string_t cmd_config_txqflags_all =
2860 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2862 cmdline_parse_token_string_t cmd_config_txqflags_what =
2863 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2865 cmdline_parse_token_num_t cmd_config_txqflags_value =
2866 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2869 cmdline_parse_inst_t cmd_config_txqflags = {
2870 .f = cmd_config_txqflags_parsed,
2872 .help_str = "port config all txqflags <value>",
2874 (void *)&cmd_config_txqflags_port,
2875 (void *)&cmd_config_txqflags_config,
2876 (void *)&cmd_config_txqflags_all,
2877 (void *)&cmd_config_txqflags_what,
2878 (void *)&cmd_config_txqflags_value,
2883 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2884 struct cmd_rx_vlan_filter_all_result {
2885 cmdline_fixed_string_t rx_vlan;
2886 cmdline_fixed_string_t what;
2887 cmdline_fixed_string_t all;
2892 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2893 __attribute__((unused)) struct cmdline *cl,
2894 __attribute__((unused)) void *data)
2896 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2898 if (!strcmp(res->what, "add"))
2899 rx_vlan_all_filter_set(res->port_id, 1);
2901 rx_vlan_all_filter_set(res->port_id, 0);
2904 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2905 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2906 rx_vlan, "rx_vlan");
2907 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2908 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2910 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2911 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2913 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2914 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2917 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2918 .f = cmd_rx_vlan_filter_all_parsed,
2920 .help_str = "rx_vlan add|rm all <port_id>: "
2921 "Add/Remove all identifiers to/from the set of VLAN "
2922 "identifiers filtered by a port",
2924 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2925 (void *)&cmd_rx_vlan_filter_all_what,
2926 (void *)&cmd_rx_vlan_filter_all_all,
2927 (void *)&cmd_rx_vlan_filter_all_portid,
2932 /* *** VLAN OFFLOAD SET ON A PORT *** */
2933 struct cmd_vlan_offload_result {
2934 cmdline_fixed_string_t vlan;
2935 cmdline_fixed_string_t set;
2936 cmdline_fixed_string_t vlan_type;
2937 cmdline_fixed_string_t what;
2938 cmdline_fixed_string_t on;
2939 cmdline_fixed_string_t port_id;
2943 cmd_vlan_offload_parsed(void *parsed_result,
2944 __attribute__((unused)) struct cmdline *cl,
2945 __attribute__((unused)) void *data)
2948 struct cmd_vlan_offload_result *res = parsed_result;
2951 portid_t port_id = 0;
2955 len = strnlen(str, STR_TOKEN_SIZE);
2957 /* Get port_id first */
2965 tmp = strtoul(str, NULL, 0);
2966 /* If port_id greater that what portid_t can represent, return */
2967 if(tmp >= RTE_MAX_ETHPORTS)
2969 port_id = (portid_t)tmp;
2971 if (!strcmp(res->on, "on"))
2976 if (!strcmp(res->what, "strip"))
2977 rx_vlan_strip_set(port_id, on);
2978 else if(!strcmp(res->what, "stripq")){
2979 uint16_t queue_id = 0;
2981 /* No queue_id, return */
2983 printf("must specify (port,queue_id)\n");
2986 tmp = strtoul(str + i + 1, NULL, 0);
2987 /* If queue_id greater that what 16-bits can represent, return */
2991 queue_id = (uint16_t)tmp;
2992 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2994 else if (!strcmp(res->what, "filter"))
2995 rx_vlan_filter_set(port_id, on);
2997 vlan_extend_set(port_id, on);
3002 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3005 cmdline_parse_token_string_t cmd_vlan_offload_set =
3006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3008 cmdline_parse_token_string_t cmd_vlan_offload_what =
3009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3010 what, "strip#filter#qinq#stripq");
3011 cmdline_parse_token_string_t cmd_vlan_offload_on =
3012 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3014 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3015 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3018 cmdline_parse_inst_t cmd_vlan_offload = {
3019 .f = cmd_vlan_offload_parsed,
3021 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3022 "<port_id[,queue_id]>: "
3023 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3025 (void *)&cmd_vlan_offload_vlan,
3026 (void *)&cmd_vlan_offload_set,
3027 (void *)&cmd_vlan_offload_what,
3028 (void *)&cmd_vlan_offload_on,
3029 (void *)&cmd_vlan_offload_portid,
3034 /* *** VLAN TPID SET ON A PORT *** */
3035 struct cmd_vlan_tpid_result {
3036 cmdline_fixed_string_t vlan;
3037 cmdline_fixed_string_t set;
3038 cmdline_fixed_string_t vlan_type;
3039 cmdline_fixed_string_t what;
3045 cmd_vlan_tpid_parsed(void *parsed_result,
3046 __attribute__((unused)) struct cmdline *cl,
3047 __attribute__((unused)) void *data)
3049 struct cmd_vlan_tpid_result *res = parsed_result;
3050 enum rte_vlan_type vlan_type;
3052 if (!strcmp(res->vlan_type, "inner"))
3053 vlan_type = ETH_VLAN_TYPE_INNER;
3054 else if (!strcmp(res->vlan_type, "outer"))
3055 vlan_type = ETH_VLAN_TYPE_OUTER;
3057 printf("Unknown vlan type\n");
3060 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3063 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3064 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3066 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3067 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3069 cmdline_parse_token_string_t cmd_vlan_type =
3070 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3071 vlan_type, "inner#outer");
3072 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3073 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3075 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3076 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3078 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3079 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3082 cmdline_parse_inst_t cmd_vlan_tpid = {
3083 .f = cmd_vlan_tpid_parsed,
3085 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3086 "Set the VLAN Ether type",
3088 (void *)&cmd_vlan_tpid_vlan,
3089 (void *)&cmd_vlan_tpid_set,
3090 (void *)&cmd_vlan_type,
3091 (void *)&cmd_vlan_tpid_what,
3092 (void *)&cmd_vlan_tpid_tpid,
3093 (void *)&cmd_vlan_tpid_portid,
3098 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3099 struct cmd_rx_vlan_filter_result {
3100 cmdline_fixed_string_t rx_vlan;
3101 cmdline_fixed_string_t what;
3107 cmd_rx_vlan_filter_parsed(void *parsed_result,
3108 __attribute__((unused)) struct cmdline *cl,
3109 __attribute__((unused)) void *data)
3111 struct cmd_rx_vlan_filter_result *res = parsed_result;
3113 if (!strcmp(res->what, "add"))
3114 rx_vft_set(res->port_id, res->vlan_id, 1);
3116 rx_vft_set(res->port_id, res->vlan_id, 0);
3119 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3120 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3121 rx_vlan, "rx_vlan");
3122 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3123 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3125 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3126 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3128 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3129 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3132 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3133 .f = cmd_rx_vlan_filter_parsed,
3135 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3136 "Add/Remove a VLAN identifier to/from the set of VLAN "
3137 "identifiers filtered by a port",
3139 (void *)&cmd_rx_vlan_filter_rx_vlan,
3140 (void *)&cmd_rx_vlan_filter_what,
3141 (void *)&cmd_rx_vlan_filter_vlanid,
3142 (void *)&cmd_rx_vlan_filter_portid,
3147 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3148 struct cmd_tx_vlan_set_result {
3149 cmdline_fixed_string_t tx_vlan;
3150 cmdline_fixed_string_t set;
3156 cmd_tx_vlan_set_parsed(void *parsed_result,
3157 __attribute__((unused)) struct cmdline *cl,
3158 __attribute__((unused)) void *data)
3160 struct cmd_tx_vlan_set_result *res = parsed_result;
3162 tx_vlan_set(res->port_id, res->vlan_id);
3165 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3166 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3167 tx_vlan, "tx_vlan");
3168 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3169 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3171 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3174 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3175 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3178 cmdline_parse_inst_t cmd_tx_vlan_set = {
3179 .f = cmd_tx_vlan_set_parsed,
3181 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3182 "Enable hardware insertion of a single VLAN header "
3183 "with a given TAG Identifier in packets sent on a port",
3185 (void *)&cmd_tx_vlan_set_tx_vlan,
3186 (void *)&cmd_tx_vlan_set_set,
3187 (void *)&cmd_tx_vlan_set_portid,
3188 (void *)&cmd_tx_vlan_set_vlanid,
3193 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3194 struct cmd_tx_vlan_set_qinq_result {
3195 cmdline_fixed_string_t tx_vlan;
3196 cmdline_fixed_string_t set;
3199 uint16_t vlan_id_outer;
3203 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3207 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3209 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3212 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3213 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3214 tx_vlan, "tx_vlan");
3215 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3216 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3218 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3219 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3221 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3222 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3224 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3225 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3226 vlan_id_outer, UINT16);
3228 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3229 .f = cmd_tx_vlan_set_qinq_parsed,
3231 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3232 "Enable hardware insertion of double VLAN header "
3233 "with given TAG Identifiers in packets sent on a port",
3235 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3236 (void *)&cmd_tx_vlan_set_qinq_set,
3237 (void *)&cmd_tx_vlan_set_qinq_portid,
3238 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3239 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3244 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3245 struct cmd_tx_vlan_set_pvid_result {
3246 cmdline_fixed_string_t tx_vlan;
3247 cmdline_fixed_string_t set;
3248 cmdline_fixed_string_t pvid;
3251 cmdline_fixed_string_t mode;
3255 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3256 __attribute__((unused)) struct cmdline *cl,
3257 __attribute__((unused)) void *data)
3259 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3261 if (strcmp(res->mode, "on") == 0)
3262 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3264 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3267 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3269 tx_vlan, "tx_vlan");
3270 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3271 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3273 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3274 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3276 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3277 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3279 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3280 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3282 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3283 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3286 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3287 .f = cmd_tx_vlan_set_pvid_parsed,
3289 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3291 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3292 (void *)&cmd_tx_vlan_set_pvid_set,
3293 (void *)&cmd_tx_vlan_set_pvid_pvid,
3294 (void *)&cmd_tx_vlan_set_pvid_port_id,
3295 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3296 (void *)&cmd_tx_vlan_set_pvid_mode,
3301 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3302 struct cmd_tx_vlan_reset_result {
3303 cmdline_fixed_string_t tx_vlan;
3304 cmdline_fixed_string_t reset;
3309 cmd_tx_vlan_reset_parsed(void *parsed_result,
3310 __attribute__((unused)) struct cmdline *cl,
3311 __attribute__((unused)) void *data)
3313 struct cmd_tx_vlan_reset_result *res = parsed_result;
3315 tx_vlan_reset(res->port_id);
3318 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3319 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3320 tx_vlan, "tx_vlan");
3321 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3322 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3324 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3325 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3328 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3329 .f = cmd_tx_vlan_reset_parsed,
3331 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3332 "VLAN header in packets sent on a port",
3334 (void *)&cmd_tx_vlan_reset_tx_vlan,
3335 (void *)&cmd_tx_vlan_reset_reset,
3336 (void *)&cmd_tx_vlan_reset_portid,
3342 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3343 struct cmd_csum_result {
3344 cmdline_fixed_string_t csum;
3345 cmdline_fixed_string_t mode;
3346 cmdline_fixed_string_t proto;
3347 cmdline_fixed_string_t hwsw;
3352 csum_show(int port_id)
3354 struct rte_eth_dev_info dev_info;
3357 ol_flags = ports[port_id].tx_ol_flags;
3358 printf("Parse tunnel is %s\n",
3359 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3360 printf("IP checksum offload is %s\n",
3361 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3362 printf("UDP checksum offload is %s\n",
3363 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3364 printf("TCP checksum offload is %s\n",
3365 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3366 printf("SCTP checksum offload is %s\n",
3367 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3368 printf("Outer-Ip checksum offload is %s\n",
3369 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3371 /* display warnings if configuration is not supported by the NIC */
3372 rte_eth_dev_info_get(port_id, &dev_info);
3373 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3374 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3375 printf("Warning: hardware IP checksum enabled but not "
3376 "supported by port %d\n", port_id);
3378 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3379 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3380 printf("Warning: hardware UDP checksum enabled but not "
3381 "supported by port %d\n", port_id);
3383 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3384 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3385 printf("Warning: hardware TCP checksum enabled but not "
3386 "supported by port %d\n", port_id);
3388 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3389 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3390 printf("Warning: hardware SCTP checksum enabled but not "
3391 "supported by port %d\n", port_id);
3393 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3394 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3395 printf("Warning: hardware outer IP checksum enabled but not "
3396 "supported by port %d\n", port_id);
3401 cmd_csum_parsed(void *parsed_result,
3402 __attribute__((unused)) struct cmdline *cl,
3403 __attribute__((unused)) void *data)
3405 struct cmd_csum_result *res = parsed_result;
3409 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3410 printf("invalid port %d\n", res->port_id);
3414 if (!strcmp(res->mode, "set")) {
3416 if (!strcmp(res->hwsw, "hw"))
3419 if (!strcmp(res->proto, "ip")) {
3420 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3421 } else if (!strcmp(res->proto, "udp")) {
3422 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3423 } else if (!strcmp(res->proto, "tcp")) {
3424 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3425 } else if (!strcmp(res->proto, "sctp")) {
3426 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3427 } else if (!strcmp(res->proto, "outer-ip")) {
3428 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3432 ports[res->port_id].tx_ol_flags |= mask;
3434 ports[res->port_id].tx_ol_flags &= (~mask);
3436 csum_show(res->port_id);
3439 cmdline_parse_token_string_t cmd_csum_csum =
3440 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3442 cmdline_parse_token_string_t cmd_csum_mode =
3443 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3445 cmdline_parse_token_string_t cmd_csum_proto =
3446 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3447 proto, "ip#tcp#udp#sctp#outer-ip");
3448 cmdline_parse_token_string_t cmd_csum_hwsw =
3449 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3451 cmdline_parse_token_num_t cmd_csum_portid =
3452 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3455 cmdline_parse_inst_t cmd_csum_set = {
3456 .f = cmd_csum_parsed,
3458 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3459 "Enable/Disable hardware calculation of L3/L4 checksum when "
3460 "using csum forward engine",
3462 (void *)&cmd_csum_csum,
3463 (void *)&cmd_csum_mode,
3464 (void *)&cmd_csum_proto,
3465 (void *)&cmd_csum_hwsw,
3466 (void *)&cmd_csum_portid,
3471 cmdline_parse_token_string_t cmd_csum_mode_show =
3472 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3475 cmdline_parse_inst_t cmd_csum_show = {
3476 .f = cmd_csum_parsed,
3478 .help_str = "csum show <port_id>: Show checksum offload configuration",
3480 (void *)&cmd_csum_csum,
3481 (void *)&cmd_csum_mode_show,
3482 (void *)&cmd_csum_portid,
3487 /* Enable/disable tunnel parsing */
3488 struct cmd_csum_tunnel_result {
3489 cmdline_fixed_string_t csum;
3490 cmdline_fixed_string_t parse;
3491 cmdline_fixed_string_t onoff;
3496 cmd_csum_tunnel_parsed(void *parsed_result,
3497 __attribute__((unused)) struct cmdline *cl,
3498 __attribute__((unused)) void *data)
3500 struct cmd_csum_tunnel_result *res = parsed_result;
3502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3505 if (!strcmp(res->onoff, "on"))
3506 ports[res->port_id].tx_ol_flags |=
3507 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3509 ports[res->port_id].tx_ol_flags &=
3510 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3512 csum_show(res->port_id);
3515 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3516 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3518 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3519 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3520 parse, "parse_tunnel");
3521 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3522 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3524 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3525 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3528 cmdline_parse_inst_t cmd_csum_tunnel = {
3529 .f = cmd_csum_tunnel_parsed,
3531 .help_str = "csum parse_tunnel on|off <port_id>: "
3532 "Enable/Disable parsing of tunnels for csum engine",
3534 (void *)&cmd_csum_tunnel_csum,
3535 (void *)&cmd_csum_tunnel_parse,
3536 (void *)&cmd_csum_tunnel_onoff,
3537 (void *)&cmd_csum_tunnel_portid,
3542 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3543 struct cmd_tso_set_result {
3544 cmdline_fixed_string_t tso;
3545 cmdline_fixed_string_t mode;
3551 cmd_tso_set_parsed(void *parsed_result,
3552 __attribute__((unused)) struct cmdline *cl,
3553 __attribute__((unused)) void *data)
3555 struct cmd_tso_set_result *res = parsed_result;
3556 struct rte_eth_dev_info dev_info;
3558 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3561 if (!strcmp(res->mode, "set"))
3562 ports[res->port_id].tso_segsz = res->tso_segsz;
3564 if (ports[res->port_id].tso_segsz == 0)
3565 printf("TSO for non-tunneled packets is disabled\n");
3567 printf("TSO segment size for non-tunneled packets is %d\n",
3568 ports[res->port_id].tso_segsz);
3570 /* display warnings if configuration is not supported by the NIC */
3571 rte_eth_dev_info_get(res->port_id, &dev_info);
3572 if ((ports[res->port_id].tso_segsz != 0) &&
3573 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3574 printf("Warning: TSO enabled but not "
3575 "supported by port %d\n", res->port_id);
3579 cmdline_parse_token_string_t cmd_tso_set_tso =
3580 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3582 cmdline_parse_token_string_t cmd_tso_set_mode =
3583 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3585 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3586 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3588 cmdline_parse_token_num_t cmd_tso_set_portid =
3589 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3592 cmdline_parse_inst_t cmd_tso_set = {
3593 .f = cmd_tso_set_parsed,
3595 .help_str = "tso set <tso_segsz> <port_id>: "
3596 "Set TSO segment size of non-tunneled packets for csum engine "
3599 (void *)&cmd_tso_set_tso,
3600 (void *)&cmd_tso_set_mode,
3601 (void *)&cmd_tso_set_tso_segsz,
3602 (void *)&cmd_tso_set_portid,
3607 cmdline_parse_token_string_t cmd_tso_show_mode =
3608 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3612 cmdline_parse_inst_t cmd_tso_show = {
3613 .f = cmd_tso_set_parsed,
3615 .help_str = "tso show <port_id>: "
3616 "Show TSO segment size of non-tunneled packets for csum engine",
3618 (void *)&cmd_tso_set_tso,
3619 (void *)&cmd_tso_show_mode,
3620 (void *)&cmd_tso_set_portid,
3625 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3626 struct cmd_tunnel_tso_set_result {
3627 cmdline_fixed_string_t tso;
3628 cmdline_fixed_string_t mode;
3634 check_tunnel_tso_nic_support(uint8_t port_id)
3636 struct rte_eth_dev_info dev_info;
3638 rte_eth_dev_info_get(port_id, &dev_info);
3639 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3640 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3641 "supported by port %d\n", port_id);
3642 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3643 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3644 "supported by port %d\n", port_id);
3645 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3646 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3647 "supported by port %d\n", port_id);
3648 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3649 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3650 "supported by port %d\n", port_id);
3654 cmd_tunnel_tso_set_parsed(void *parsed_result,
3655 __attribute__((unused)) struct cmdline *cl,
3656 __attribute__((unused)) void *data)
3658 struct cmd_tunnel_tso_set_result *res = parsed_result;
3660 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3663 if (!strcmp(res->mode, "set"))
3664 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3666 if (ports[res->port_id].tunnel_tso_segsz == 0)
3667 printf("TSO for tunneled packets is disabled\n");
3669 printf("TSO segment size for tunneled packets is %d\n",
3670 ports[res->port_id].tunnel_tso_segsz);
3672 /* Below conditions are needed to make it work:
3673 * (1) tunnel TSO is supported by the NIC;
3674 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3676 * (3) for tunneled pkts with outer L3 of IPv4,
3677 * "csum set outer-ip" must be set to hw, because after tso,
3678 * total_len of outer IP header is changed, and the checksum
3679 * of outer IP header calculated by sw should be wrong; that
3680 * is not necessary for IPv6 tunneled pkts because there's no
3681 * checksum in IP header anymore.
3683 check_tunnel_tso_nic_support(res->port_id);
3685 if (!(ports[res->port_id].tx_ol_flags &
3686 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3687 printf("Warning: csum parse_tunnel must be set "
3688 "so that tunneled packets are recognized\n");
3689 if (!(ports[res->port_id].tx_ol_flags &
3690 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3691 printf("Warning: csum set outer-ip must be set to hw "
3692 "if outer L3 is IPv4; not necessary for IPv6\n");
3696 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3697 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3699 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3700 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3702 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3703 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3705 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3706 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3709 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3710 .f = cmd_tunnel_tso_set_parsed,
3712 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3713 "Set TSO segment size of tunneled packets for csum engine "
3716 (void *)&cmd_tunnel_tso_set_tso,
3717 (void *)&cmd_tunnel_tso_set_mode,
3718 (void *)&cmd_tunnel_tso_set_tso_segsz,
3719 (void *)&cmd_tunnel_tso_set_portid,
3724 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3725 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3729 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3730 .f = cmd_tunnel_tso_set_parsed,
3732 .help_str = "tunnel_tso show <port_id> "
3733 "Show TSO segment size of tunneled packets for csum engine",
3735 (void *)&cmd_tunnel_tso_set_tso,
3736 (void *)&cmd_tunnel_tso_show_mode,
3737 (void *)&cmd_tunnel_tso_set_portid,
3742 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3743 struct cmd_set_flush_rx {
3744 cmdline_fixed_string_t set;
3745 cmdline_fixed_string_t flush_rx;
3746 cmdline_fixed_string_t mode;
3750 cmd_set_flush_rx_parsed(void *parsed_result,
3751 __attribute__((unused)) struct cmdline *cl,
3752 __attribute__((unused)) void *data)
3754 struct cmd_set_flush_rx *res = parsed_result;
3755 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3758 cmdline_parse_token_string_t cmd_setflushrx_set =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3761 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3763 flush_rx, "flush_rx");
3764 cmdline_parse_token_string_t cmd_setflushrx_mode =
3765 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3769 cmdline_parse_inst_t cmd_set_flush_rx = {
3770 .f = cmd_set_flush_rx_parsed,
3771 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3774 (void *)&cmd_setflushrx_set,
3775 (void *)&cmd_setflushrx_flush_rx,
3776 (void *)&cmd_setflushrx_mode,
3781 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3782 struct cmd_set_link_check {
3783 cmdline_fixed_string_t set;
3784 cmdline_fixed_string_t link_check;
3785 cmdline_fixed_string_t mode;
3789 cmd_set_link_check_parsed(void *parsed_result,
3790 __attribute__((unused)) struct cmdline *cl,
3791 __attribute__((unused)) void *data)
3793 struct cmd_set_link_check *res = parsed_result;
3794 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3797 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3800 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3802 link_check, "link_check");
3803 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3808 cmdline_parse_inst_t cmd_set_link_check = {
3809 .f = cmd_set_link_check_parsed,
3810 .help_str = "set link_check on|off: Enable/Disable link status check "
3811 "when starting/stopping a port",
3814 (void *)&cmd_setlinkcheck_set,
3815 (void *)&cmd_setlinkcheck_link_check,
3816 (void *)&cmd_setlinkcheck_mode,
3821 #ifdef RTE_NIC_BYPASS
3822 /* *** SET NIC BYPASS MODE *** */
3823 struct cmd_set_bypass_mode_result {
3824 cmdline_fixed_string_t set;
3825 cmdline_fixed_string_t bypass;
3826 cmdline_fixed_string_t mode;
3827 cmdline_fixed_string_t value;
3832 cmd_set_bypass_mode_parsed(void *parsed_result,
3833 __attribute__((unused)) struct cmdline *cl,
3834 __attribute__((unused)) void *data)
3836 struct cmd_set_bypass_mode_result *res = parsed_result;
3837 portid_t port_id = res->port_id;
3838 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3840 if (!strcmp(res->value, "bypass"))
3841 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3842 else if (!strcmp(res->value, "isolate"))
3843 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3845 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3847 /* Set the bypass mode for the relevant port. */
3848 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3849 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3853 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3856 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3859 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3860 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3862 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3864 value, "normal#bypass#isolate");
3865 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3866 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3869 cmdline_parse_inst_t cmd_set_bypass_mode = {
3870 .f = cmd_set_bypass_mode_parsed,
3871 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3872 "Set the NIC bypass mode for port_id",
3875 (void *)&cmd_setbypass_mode_set,
3876 (void *)&cmd_setbypass_mode_bypass,
3877 (void *)&cmd_setbypass_mode_mode,
3878 (void *)&cmd_setbypass_mode_value,
3879 (void *)&cmd_setbypass_mode_port,
3884 /* *** SET NIC BYPASS EVENT *** */
3885 struct cmd_set_bypass_event_result {
3886 cmdline_fixed_string_t set;
3887 cmdline_fixed_string_t bypass;
3888 cmdline_fixed_string_t event;
3889 cmdline_fixed_string_t event_value;
3890 cmdline_fixed_string_t mode;
3891 cmdline_fixed_string_t mode_value;
3896 cmd_set_bypass_event_parsed(void *parsed_result,
3897 __attribute__((unused)) struct cmdline *cl,
3898 __attribute__((unused)) void *data)
3901 struct cmd_set_bypass_event_result *res = parsed_result;
3902 portid_t port_id = res->port_id;
3903 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3904 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3906 if (!strcmp(res->event_value, "timeout"))
3907 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3908 else if (!strcmp(res->event_value, "os_on"))
3909 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3910 else if (!strcmp(res->event_value, "os_off"))
3911 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3912 else if (!strcmp(res->event_value, "power_on"))
3913 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3914 else if (!strcmp(res->event_value, "power_off"))
3915 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3917 bypass_event = RTE_BYPASS_EVENT_NONE;
3919 if (!strcmp(res->mode_value, "bypass"))
3920 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3921 else if (!strcmp(res->mode_value, "isolate"))
3922 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3924 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3926 /* Set the watchdog timeout. */
3927 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3930 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3931 (rc = rte_eth_dev_wd_timeout_store(port_id,
3932 bypass_timeout)) != 0) {
3933 printf("Failed to set timeout value %u "
3934 "for port %d, errto code: %d.\n",
3935 bypass_timeout, port_id, rc);
3939 /* Set the bypass event to transition to bypass mode. */
3940 if (0 != rte_eth_dev_bypass_event_store(port_id,
3941 bypass_event, bypass_mode)) {
3942 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3947 cmdline_parse_token_string_t cmd_setbypass_event_set =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3950 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3953 cmdline_parse_token_string_t cmd_setbypass_event_event =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3956 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3958 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3959 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3962 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3964 mode_value, "normal#bypass#isolate");
3965 cmdline_parse_token_num_t cmd_setbypass_event_port =
3966 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3969 cmdline_parse_inst_t cmd_set_bypass_event = {
3970 .f = cmd_set_bypass_event_parsed,
3971 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
3972 "power_off mode normal|bypass|isolate <port_id>: "
3973 "Set the NIC bypass event mode for port_id",
3976 (void *)&cmd_setbypass_event_set,
3977 (void *)&cmd_setbypass_event_bypass,
3978 (void *)&cmd_setbypass_event_event,
3979 (void *)&cmd_setbypass_event_event_value,
3980 (void *)&cmd_setbypass_event_mode,
3981 (void *)&cmd_setbypass_event_mode_value,
3982 (void *)&cmd_setbypass_event_port,
3988 /* *** SET NIC BYPASS TIMEOUT *** */
3989 struct cmd_set_bypass_timeout_result {
3990 cmdline_fixed_string_t set;
3991 cmdline_fixed_string_t bypass;
3992 cmdline_fixed_string_t timeout;
3993 cmdline_fixed_string_t value;
3997 cmd_set_bypass_timeout_parsed(void *parsed_result,
3998 __attribute__((unused)) struct cmdline *cl,
3999 __attribute__((unused)) void *data)
4001 struct cmd_set_bypass_timeout_result *res = parsed_result;
4003 if (!strcmp(res->value, "1.5"))
4004 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4005 else if (!strcmp(res->value, "2"))
4006 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4007 else if (!strcmp(res->value, "3"))
4008 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4009 else if (!strcmp(res->value, "4"))
4010 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4011 else if (!strcmp(res->value, "8"))
4012 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4013 else if (!strcmp(res->value, "16"))
4014 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4015 else if (!strcmp(res->value, "32"))
4016 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4018 bypass_timeout = RTE_BYPASS_TMT_OFF;
4021 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4024 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4027 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4029 timeout, "timeout");
4030 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4032 value, "0#1.5#2#3#4#8#16#32");
4034 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4035 .f = cmd_set_bypass_timeout_parsed,
4036 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4037 "Set the NIC bypass watchdog timeout in seconds",
4040 (void *)&cmd_setbypass_timeout_set,
4041 (void *)&cmd_setbypass_timeout_bypass,
4042 (void *)&cmd_setbypass_timeout_timeout,
4043 (void *)&cmd_setbypass_timeout_value,
4048 /* *** SHOW NIC BYPASS MODE *** */
4049 struct cmd_show_bypass_config_result {
4050 cmdline_fixed_string_t show;
4051 cmdline_fixed_string_t bypass;
4052 cmdline_fixed_string_t config;
4057 cmd_show_bypass_config_parsed(void *parsed_result,
4058 __attribute__((unused)) struct cmdline *cl,
4059 __attribute__((unused)) void *data)
4061 struct cmd_show_bypass_config_result *res = parsed_result;
4062 uint32_t event_mode;
4063 uint32_t bypass_mode;
4064 portid_t port_id = res->port_id;
4065 uint32_t timeout = bypass_timeout;
4068 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4069 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4070 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4071 {"UNKNOWN", "normal", "bypass", "isolate"};
4072 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4079 int num_events = (sizeof events) / (sizeof events[0]);
4081 /* Display the bypass mode.*/
4082 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4083 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4087 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4088 bypass_mode = RTE_BYPASS_MODE_NONE;
4090 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4093 /* Display the bypass timeout.*/
4094 if (!RTE_BYPASS_TMT_VALID(timeout))
4095 timeout = RTE_BYPASS_TMT_OFF;
4097 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4099 /* Display the bypass events and associated modes. */
4100 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4102 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4103 printf("\tFailed to get bypass mode for event = %s\n",
4106 if (!RTE_BYPASS_MODE_VALID(event_mode))
4107 event_mode = RTE_BYPASS_MODE_NONE;
4109 printf("\tbypass event: %-16s = %s\n", events[i],
4115 cmdline_parse_token_string_t cmd_showbypass_config_show =
4116 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4118 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4119 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4121 cmdline_parse_token_string_t cmd_showbypass_config_config =
4122 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4124 cmdline_parse_token_num_t cmd_showbypass_config_port =
4125 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4128 cmdline_parse_inst_t cmd_show_bypass_config = {
4129 .f = cmd_show_bypass_config_parsed,
4130 .help_str = "show bypass config <port_id>: "
4131 "Show the NIC bypass config for port_id",
4134 (void *)&cmd_showbypass_config_show,
4135 (void *)&cmd_showbypass_config_bypass,
4136 (void *)&cmd_showbypass_config_config,
4137 (void *)&cmd_showbypass_config_port,
4143 #ifdef RTE_LIBRTE_PMD_BOND
4144 /* *** SET BONDING MODE *** */
4145 struct cmd_set_bonding_mode_result {
4146 cmdline_fixed_string_t set;
4147 cmdline_fixed_string_t bonding;
4148 cmdline_fixed_string_t mode;
4153 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4154 __attribute__((unused)) struct cmdline *cl,
4155 __attribute__((unused)) void *data)
4157 struct cmd_set_bonding_mode_result *res = parsed_result;
4158 portid_t port_id = res->port_id;
4160 /* Set the bonding mode for the relevant port. */
4161 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4162 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4165 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4168 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4170 bonding, "bonding");
4171 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4172 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4174 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4175 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4177 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4178 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4181 cmdline_parse_inst_t cmd_set_bonding_mode = {
4182 .f = cmd_set_bonding_mode_parsed,
4183 .help_str = "set bonding mode <mode_value> <port_id>: "
4184 "Set the bonding mode for port_id",
4187 (void *) &cmd_setbonding_mode_set,
4188 (void *) &cmd_setbonding_mode_bonding,
4189 (void *) &cmd_setbonding_mode_mode,
4190 (void *) &cmd_setbonding_mode_value,
4191 (void *) &cmd_setbonding_mode_port,
4196 /* *** SET BALANCE XMIT POLICY *** */
4197 struct cmd_set_bonding_balance_xmit_policy_result {
4198 cmdline_fixed_string_t set;
4199 cmdline_fixed_string_t bonding;
4200 cmdline_fixed_string_t balance_xmit_policy;
4202 cmdline_fixed_string_t policy;
4205 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4206 __attribute__((unused)) struct cmdline *cl,
4207 __attribute__((unused)) void *data)
4209 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4210 portid_t port_id = res->port_id;
4213 if (!strcmp(res->policy, "l2")) {
4214 policy = BALANCE_XMIT_POLICY_LAYER2;
4215 } else if (!strcmp(res->policy, "l23")) {
4216 policy = BALANCE_XMIT_POLICY_LAYER23;
4217 } else if (!strcmp(res->policy, "l34")) {
4218 policy = BALANCE_XMIT_POLICY_LAYER34;
4220 printf("\t Invalid xmit policy selection");
4224 /* Set the bonding mode for the relevant port. */
4225 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4226 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4231 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4234 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4235 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4236 bonding, "bonding");
4237 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4238 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4239 balance_xmit_policy, "balance_xmit_policy");
4240 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4241 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4243 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4244 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4245 policy, "l2#l23#l34");
4247 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4248 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4249 .help_str = "set bonding balance_xmit_policy <port_id> "
4251 "Set the bonding balance_xmit_policy for port_id",
4254 (void *)&cmd_setbonding_balance_xmit_policy_set,
4255 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4256 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4257 (void *)&cmd_setbonding_balance_xmit_policy_port,
4258 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4263 /* *** SHOW NIC BONDING CONFIGURATION *** */
4264 struct cmd_show_bonding_config_result {
4265 cmdline_fixed_string_t show;
4266 cmdline_fixed_string_t bonding;
4267 cmdline_fixed_string_t config;
4271 static void cmd_show_bonding_config_parsed(void *parsed_result,
4272 __attribute__((unused)) struct cmdline *cl,
4273 __attribute__((unused)) void *data)
4275 struct cmd_show_bonding_config_result *res = parsed_result;
4277 uint8_t slaves[RTE_MAX_ETHPORTS];
4278 int num_slaves, num_active_slaves;
4281 portid_t port_id = res->port_id;
4283 /* Display the bonding mode.*/
4284 bonding_mode = rte_eth_bond_mode_get(port_id);
4285 if (bonding_mode < 0) {
4286 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4289 printf("\tBonding mode: %d\n", bonding_mode);
4291 if (bonding_mode == BONDING_MODE_BALANCE) {
4292 int balance_xmit_policy;
4294 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4295 if (balance_xmit_policy < 0) {
4296 printf("\tFailed to get balance xmit policy for port = %d\n",
4300 printf("\tBalance Xmit Policy: ");
4302 switch (balance_xmit_policy) {
4303 case BALANCE_XMIT_POLICY_LAYER2:
4304 printf("BALANCE_XMIT_POLICY_LAYER2");
4306 case BALANCE_XMIT_POLICY_LAYER23:
4307 printf("BALANCE_XMIT_POLICY_LAYER23");
4309 case BALANCE_XMIT_POLICY_LAYER34:
4310 printf("BALANCE_XMIT_POLICY_LAYER34");
4317 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4319 if (num_slaves < 0) {
4320 printf("\tFailed to get slave list for port = %d\n", port_id);
4323 if (num_slaves > 0) {
4324 printf("\tSlaves (%d): [", num_slaves);
4325 for (i = 0; i < num_slaves - 1; i++)
4326 printf("%d ", slaves[i]);
4328 printf("%d]\n", slaves[num_slaves - 1]);
4330 printf("\tSlaves: []\n");
4334 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4337 if (num_active_slaves < 0) {
4338 printf("\tFailed to get active slave list for port = %d\n", port_id);
4341 if (num_active_slaves > 0) {
4342 printf("\tActive Slaves (%d): [", num_active_slaves);
4343 for (i = 0; i < num_active_slaves - 1; i++)
4344 printf("%d ", slaves[i]);
4346 printf("%d]\n", slaves[num_active_slaves - 1]);
4349 printf("\tActive Slaves: []\n");
4353 primary_id = rte_eth_bond_primary_get(port_id);
4354 if (primary_id < 0) {
4355 printf("\tFailed to get primary slave for port = %d\n", port_id);
4358 printf("\tPrimary: [%d]\n", primary_id);
4362 cmdline_parse_token_string_t cmd_showbonding_config_show =
4363 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4365 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4366 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4367 bonding, "bonding");
4368 cmdline_parse_token_string_t cmd_showbonding_config_config =
4369 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4371 cmdline_parse_token_num_t cmd_showbonding_config_port =
4372 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4375 cmdline_parse_inst_t cmd_show_bonding_config = {
4376 .f = cmd_show_bonding_config_parsed,
4377 .help_str = "show bonding config <port_id>: "
4378 "Show the bonding config for port_id",
4381 (void *)&cmd_showbonding_config_show,
4382 (void *)&cmd_showbonding_config_bonding,
4383 (void *)&cmd_showbonding_config_config,
4384 (void *)&cmd_showbonding_config_port,
4389 /* *** SET BONDING PRIMARY *** */
4390 struct cmd_set_bonding_primary_result {
4391 cmdline_fixed_string_t set;
4392 cmdline_fixed_string_t bonding;
4393 cmdline_fixed_string_t primary;
4398 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4399 __attribute__((unused)) struct cmdline *cl,
4400 __attribute__((unused)) void *data)
4402 struct cmd_set_bonding_primary_result *res = parsed_result;
4403 portid_t master_port_id = res->port_id;
4404 portid_t slave_port_id = res->slave_id;
4406 /* Set the primary slave for a bonded device. */
4407 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4408 printf("\t Failed to set primary slave for port = %d.\n",
4415 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4418 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4420 bonding, "bonding");
4421 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4422 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4423 primary, "primary");
4424 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4425 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4427 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4428 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4431 cmdline_parse_inst_t cmd_set_bonding_primary = {
4432 .f = cmd_set_bonding_primary_parsed,
4433 .help_str = "set bonding primary <slave_id> <port_id>: "
4434 "Set the primary slave for port_id",
4437 (void *)&cmd_setbonding_primary_set,
4438 (void *)&cmd_setbonding_primary_bonding,
4439 (void *)&cmd_setbonding_primary_primary,
4440 (void *)&cmd_setbonding_primary_slave,
4441 (void *)&cmd_setbonding_primary_port,
4446 /* *** ADD SLAVE *** */
4447 struct cmd_add_bonding_slave_result {
4448 cmdline_fixed_string_t add;
4449 cmdline_fixed_string_t bonding;
4450 cmdline_fixed_string_t slave;
4455 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4456 __attribute__((unused)) struct cmdline *cl,
4457 __attribute__((unused)) void *data)
4459 struct cmd_add_bonding_slave_result *res = parsed_result;
4460 portid_t master_port_id = res->port_id;
4461 portid_t slave_port_id = res->slave_id;
4463 /* Set the primary slave for a bonded device. */
4464 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4465 printf("\t Failed to add slave %d to master port = %d.\n",
4466 slave_port_id, master_port_id);
4470 set_port_slave_flag(slave_port_id);
4473 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4474 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4476 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4477 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4478 bonding, "bonding");
4479 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4480 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4482 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4483 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4485 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4486 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4489 cmdline_parse_inst_t cmd_add_bonding_slave = {
4490 .f = cmd_add_bonding_slave_parsed,
4491 .help_str = "add bonding slave <slave_id> <port_id>: "
4492 "Add a slave device to a bonded device",
4495 (void *)&cmd_addbonding_slave_add,
4496 (void *)&cmd_addbonding_slave_bonding,
4497 (void *)&cmd_addbonding_slave_slave,
4498 (void *)&cmd_addbonding_slave_slaveid,
4499 (void *)&cmd_addbonding_slave_port,
4504 /* *** REMOVE SLAVE *** */
4505 struct cmd_remove_bonding_slave_result {
4506 cmdline_fixed_string_t remove;
4507 cmdline_fixed_string_t bonding;
4508 cmdline_fixed_string_t slave;
4513 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4514 __attribute__((unused)) struct cmdline *cl,
4515 __attribute__((unused)) void *data)
4517 struct cmd_remove_bonding_slave_result *res = parsed_result;
4518 portid_t master_port_id = res->port_id;
4519 portid_t slave_port_id = res->slave_id;
4521 /* Set the primary slave for a bonded device. */
4522 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4523 printf("\t Failed to remove slave %d from master port = %d.\n",
4524 slave_port_id, master_port_id);
4528 clear_port_slave_flag(slave_port_id);
4531 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4532 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4534 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4535 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4536 bonding, "bonding");
4537 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4538 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4540 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4541 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4543 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4544 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4547 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4548 .f = cmd_remove_bonding_slave_parsed,
4549 .help_str = "remove bonding slave <slave_id> <port_id>: "
4550 "Remove a slave device from a bonded device",
4553 (void *)&cmd_removebonding_slave_remove,
4554 (void *)&cmd_removebonding_slave_bonding,
4555 (void *)&cmd_removebonding_slave_slave,
4556 (void *)&cmd_removebonding_slave_slaveid,
4557 (void *)&cmd_removebonding_slave_port,
4562 /* *** CREATE BONDED DEVICE *** */
4563 struct cmd_create_bonded_device_result {
4564 cmdline_fixed_string_t create;
4565 cmdline_fixed_string_t bonded;
4566 cmdline_fixed_string_t device;
4571 static int bond_dev_num = 0;
4573 static void cmd_create_bonded_device_parsed(void *parsed_result,
4574 __attribute__((unused)) struct cmdline *cl,
4575 __attribute__((unused)) void *data)
4577 struct cmd_create_bonded_device_result *res = parsed_result;
4578 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4581 if (test_done == 0) {
4582 printf("Please stop forwarding first\n");
4586 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4589 /* Create a new bonded device. */
4590 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4592 printf("\t Failed to create bonded device.\n");
4595 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4598 /* Update number of ports */
4599 nb_ports = rte_eth_dev_count();
4600 reconfig(port_id, res->socket);
4601 rte_eth_promiscuous_enable(port_id);
4602 ports[port_id].enabled = 1;
4607 cmdline_parse_token_string_t cmd_createbonded_device_create =
4608 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4610 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4611 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4613 cmdline_parse_token_string_t cmd_createbonded_device_device =
4614 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4616 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4617 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4619 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4620 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4623 cmdline_parse_inst_t cmd_create_bonded_device = {
4624 .f = cmd_create_bonded_device_parsed,
4625 .help_str = "create bonded device <mode> <socket>: "
4626 "Create a new bonded device with specific bonding mode and socket",
4629 (void *)&cmd_createbonded_device_create,
4630 (void *)&cmd_createbonded_device_bonded,
4631 (void *)&cmd_createbonded_device_device,
4632 (void *)&cmd_createbonded_device_mode,
4633 (void *)&cmd_createbonded_device_socket,
4638 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4639 struct cmd_set_bond_mac_addr_result {
4640 cmdline_fixed_string_t set;
4641 cmdline_fixed_string_t bonding;
4642 cmdline_fixed_string_t mac_addr;
4644 struct ether_addr address;
4647 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4648 __attribute__((unused)) struct cmdline *cl,
4649 __attribute__((unused)) void *data)
4651 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4654 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4657 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4659 /* check the return value and print it if is < 0 */
4661 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4664 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4665 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4666 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4667 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4669 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4670 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4672 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4673 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4674 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4675 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4677 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4678 .f = cmd_set_bond_mac_addr_parsed,
4680 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4682 (void *)&cmd_set_bond_mac_addr_set,
4683 (void *)&cmd_set_bond_mac_addr_bonding,
4684 (void *)&cmd_set_bond_mac_addr_mac,
4685 (void *)&cmd_set_bond_mac_addr_portnum,
4686 (void *)&cmd_set_bond_mac_addr_addr,
4692 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4693 struct cmd_set_bond_mon_period_result {
4694 cmdline_fixed_string_t set;
4695 cmdline_fixed_string_t bonding;
4696 cmdline_fixed_string_t mon_period;
4701 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4702 __attribute__((unused)) struct cmdline *cl,
4703 __attribute__((unused)) void *data)
4705 struct cmd_set_bond_mon_period_result *res = parsed_result;
4708 if (res->port_num >= nb_ports) {
4709 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4713 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4715 /* check the return value and print it if is < 0 */
4717 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4720 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4723 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4725 bonding, "bonding");
4726 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4727 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4728 mon_period, "mon_period");
4729 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4730 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4732 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4733 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4736 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4737 .f = cmd_set_bond_mon_period_parsed,
4739 .help_str = "set bonding mon_period <port_id> <period_ms>",
4741 (void *)&cmd_set_bond_mon_period_set,
4742 (void *)&cmd_set_bond_mon_period_bonding,
4743 (void *)&cmd_set_bond_mon_period_mon_period,
4744 (void *)&cmd_set_bond_mon_period_portnum,
4745 (void *)&cmd_set_bond_mon_period_period_ms,
4750 #endif /* RTE_LIBRTE_PMD_BOND */
4752 /* *** SET FORWARDING MODE *** */
4753 struct cmd_set_fwd_mode_result {
4754 cmdline_fixed_string_t set;
4755 cmdline_fixed_string_t fwd;
4756 cmdline_fixed_string_t mode;
4759 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4760 __attribute__((unused)) struct cmdline *cl,
4761 __attribute__((unused)) void *data)
4763 struct cmd_set_fwd_mode_result *res = parsed_result;
4766 set_pkt_forwarding_mode(res->mode);
4769 cmdline_parse_token_string_t cmd_setfwd_set =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4771 cmdline_parse_token_string_t cmd_setfwd_fwd =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4773 cmdline_parse_token_string_t cmd_setfwd_mode =
4774 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4775 "" /* defined at init */);
4777 cmdline_parse_inst_t cmd_set_fwd_mode = {
4778 .f = cmd_set_fwd_mode_parsed,
4780 .help_str = NULL, /* defined at init */
4782 (void *)&cmd_setfwd_set,
4783 (void *)&cmd_setfwd_fwd,
4784 (void *)&cmd_setfwd_mode,
4789 static void cmd_set_fwd_mode_init(void)
4792 static char token[128];
4793 static char help[256];
4794 cmdline_parse_token_string_t *token_struct;
4796 modes = list_pkt_forwarding_modes();
4797 snprintf(help, sizeof(help), "set fwd %s: "
4798 "Set packet forwarding mode", modes);
4799 cmd_set_fwd_mode.help_str = help;
4801 /* string token separator is # */
4802 for (c = token; *modes != '\0'; modes++)
4807 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4808 token_struct->string_data.str = token;
4811 /* *** SET RETRY FORWARDING MODE *** */
4812 struct cmd_set_fwd_retry_mode_result {
4813 cmdline_fixed_string_t set;
4814 cmdline_fixed_string_t fwd;
4815 cmdline_fixed_string_t mode;
4816 cmdline_fixed_string_t retry;
4819 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4820 __attribute__((unused)) struct cmdline *cl,
4821 __attribute__((unused)) void *data)
4823 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4826 set_pkt_forwarding_mode(res->mode);
4829 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4832 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4833 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4835 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4836 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4838 "" /* defined at init */);
4839 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4843 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4844 .f = cmd_set_fwd_retry_mode_parsed,
4846 .help_str = NULL, /* defined at init */
4848 (void *)&cmd_setfwd_retry_set,
4849 (void *)&cmd_setfwd_retry_fwd,
4850 (void *)&cmd_setfwd_retry_mode,
4851 (void *)&cmd_setfwd_retry_retry,
4856 static void cmd_set_fwd_retry_mode_init(void)
4859 static char token[128];
4860 static char help[256];
4861 cmdline_parse_token_string_t *token_struct;
4863 modes = list_pkt_forwarding_retry_modes();
4864 snprintf(help, sizeof(help), "set fwd %s retry: "
4865 "Set packet forwarding mode with retry", modes);
4866 cmd_set_fwd_retry_mode.help_str = help;
4868 /* string token separator is # */
4869 for (c = token; *modes != '\0'; modes++)
4874 token_struct = (cmdline_parse_token_string_t *)
4875 cmd_set_fwd_retry_mode.tokens[2];
4876 token_struct->string_data.str = token;
4879 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4880 struct cmd_set_burst_tx_retry_result {
4881 cmdline_fixed_string_t set;
4882 cmdline_fixed_string_t burst;
4883 cmdline_fixed_string_t tx;
4884 cmdline_fixed_string_t delay;
4886 cmdline_fixed_string_t retry;
4890 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4891 __attribute__((unused)) struct cmdline *cl,
4892 __attribute__((unused)) void *data)
4894 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4896 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4897 && !strcmp(res->tx, "tx")) {
4898 if (!strcmp(res->delay, "delay"))
4899 burst_tx_delay_time = res->time;
4900 if (!strcmp(res->retry, "retry"))
4901 burst_tx_retry_num = res->retry_num;
4906 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4907 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4908 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4909 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4911 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4912 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4913 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4915 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4916 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4917 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4918 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4919 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4920 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4922 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4923 .f = cmd_set_burst_tx_retry_parsed,
4924 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4926 (void *)&cmd_set_burst_tx_retry_set,
4927 (void *)&cmd_set_burst_tx_retry_burst,
4928 (void *)&cmd_set_burst_tx_retry_tx,
4929 (void *)&cmd_set_burst_tx_retry_delay,
4930 (void *)&cmd_set_burst_tx_retry_time,
4931 (void *)&cmd_set_burst_tx_retry_retry,
4932 (void *)&cmd_set_burst_tx_retry_retry_num,
4937 /* *** SET PROMISC MODE *** */
4938 struct cmd_set_promisc_mode_result {
4939 cmdline_fixed_string_t set;
4940 cmdline_fixed_string_t promisc;
4941 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4942 uint8_t port_num; /* valid if "allports" argument == 0 */
4943 cmdline_fixed_string_t mode;
4946 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4947 __attribute__((unused)) struct cmdline *cl,
4950 struct cmd_set_promisc_mode_result *res = parsed_result;
4954 if (!strcmp(res->mode, "on"))
4961 FOREACH_PORT(i, ports) {
4963 rte_eth_promiscuous_enable(i);
4965 rte_eth_promiscuous_disable(i);
4970 rte_eth_promiscuous_enable(res->port_num);
4972 rte_eth_promiscuous_disable(res->port_num);
4976 cmdline_parse_token_string_t cmd_setpromisc_set =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4978 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4979 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4981 cmdline_parse_token_string_t cmd_setpromisc_portall =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4984 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4985 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4987 cmdline_parse_token_string_t cmd_setpromisc_mode =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4991 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4992 .f = cmd_set_promisc_mode_parsed,
4994 .help_str = "set promisc all on|off: Set promisc mode for all ports",
4996 (void *)&cmd_setpromisc_set,
4997 (void *)&cmd_setpromisc_promisc,
4998 (void *)&cmd_setpromisc_portall,
4999 (void *)&cmd_setpromisc_mode,
5004 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5005 .f = cmd_set_promisc_mode_parsed,
5007 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5009 (void *)&cmd_setpromisc_set,
5010 (void *)&cmd_setpromisc_promisc,
5011 (void *)&cmd_setpromisc_portnum,
5012 (void *)&cmd_setpromisc_mode,
5017 /* *** SET ALLMULTI MODE *** */
5018 struct cmd_set_allmulti_mode_result {
5019 cmdline_fixed_string_t set;
5020 cmdline_fixed_string_t allmulti;
5021 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5022 uint8_t port_num; /* valid if "allports" argument == 0 */
5023 cmdline_fixed_string_t mode;
5026 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5030 struct cmd_set_allmulti_mode_result *res = parsed_result;
5034 if (!strcmp(res->mode, "on"))
5041 FOREACH_PORT(i, ports) {
5043 rte_eth_allmulticast_enable(i);
5045 rte_eth_allmulticast_disable(i);
5050 rte_eth_allmulticast_enable(res->port_num);
5052 rte_eth_allmulticast_disable(res->port_num);
5056 cmdline_parse_token_string_t cmd_setallmulti_set =
5057 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5058 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5059 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5061 cmdline_parse_token_string_t cmd_setallmulti_portall =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5064 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5065 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5067 cmdline_parse_token_string_t cmd_setallmulti_mode =
5068 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5071 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5072 .f = cmd_set_allmulti_mode_parsed,
5074 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5076 (void *)&cmd_setallmulti_set,
5077 (void *)&cmd_setallmulti_allmulti,
5078 (void *)&cmd_setallmulti_portall,
5079 (void *)&cmd_setallmulti_mode,
5084 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5085 .f = cmd_set_allmulti_mode_parsed,
5087 .help_str = "set allmulti <port_id> on|off: "
5088 "Set allmulti mode on port_id",
5090 (void *)&cmd_setallmulti_set,
5091 (void *)&cmd_setallmulti_allmulti,
5092 (void *)&cmd_setallmulti_portnum,
5093 (void *)&cmd_setallmulti_mode,
5098 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5099 struct cmd_link_flow_ctrl_set_result {
5100 cmdline_fixed_string_t set;
5101 cmdline_fixed_string_t flow_ctrl;
5102 cmdline_fixed_string_t rx;
5103 cmdline_fixed_string_t rx_lfc_mode;
5104 cmdline_fixed_string_t tx;
5105 cmdline_fixed_string_t tx_lfc_mode;
5106 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5107 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5108 cmdline_fixed_string_t autoneg_str;
5109 cmdline_fixed_string_t autoneg;
5110 cmdline_fixed_string_t hw_str;
5111 uint32_t high_water;
5112 cmdline_fixed_string_t lw_str;
5114 cmdline_fixed_string_t pt_str;
5115 uint16_t pause_time;
5116 cmdline_fixed_string_t xon_str;
5121 cmdline_parse_token_string_t cmd_lfc_set_set =
5122 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5124 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5126 flow_ctrl, "flow_ctrl");
5127 cmdline_parse_token_string_t cmd_lfc_set_rx =
5128 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5130 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5132 rx_lfc_mode, "on#off");
5133 cmdline_parse_token_string_t cmd_lfc_set_tx =
5134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5136 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5137 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5138 tx_lfc_mode, "on#off");
5139 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5140 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5141 hw_str, "high_water");
5142 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5143 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5144 high_water, UINT32);
5145 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5146 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5147 lw_str, "low_water");
5148 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5149 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5151 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5152 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5153 pt_str, "pause_time");
5154 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5155 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5156 pause_time, UINT16);
5157 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5159 xon_str, "send_xon");
5160 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5161 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5163 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5166 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 mac_ctrl_frame_fwd_mode, "on#off");
5169 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5171 autoneg_str, "autoneg");
5172 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5175 cmdline_parse_token_num_t cmd_lfc_set_portid =
5176 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5179 /* forward declaration */
5181 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5184 cmdline_parse_inst_t cmd_link_flow_control_set = {
5185 .f = cmd_link_flow_ctrl_set_parsed,
5187 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5188 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5189 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5191 (void *)&cmd_lfc_set_set,
5192 (void *)&cmd_lfc_set_flow_ctrl,
5193 (void *)&cmd_lfc_set_rx,
5194 (void *)&cmd_lfc_set_rx_mode,
5195 (void *)&cmd_lfc_set_tx,
5196 (void *)&cmd_lfc_set_tx_mode,
5197 (void *)&cmd_lfc_set_high_water,
5198 (void *)&cmd_lfc_set_low_water,
5199 (void *)&cmd_lfc_set_pause_time,
5200 (void *)&cmd_lfc_set_send_xon,
5201 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5202 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5203 (void *)&cmd_lfc_set_autoneg_str,
5204 (void *)&cmd_lfc_set_autoneg,
5205 (void *)&cmd_lfc_set_portid,
5210 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5211 .f = cmd_link_flow_ctrl_set_parsed,
5212 .data = (void *)&cmd_link_flow_control_set_rx,
5213 .help_str = "set flow_ctrl rx on|off <port_id>: "
5214 "Change rx flow control parameter",
5216 (void *)&cmd_lfc_set_set,
5217 (void *)&cmd_lfc_set_flow_ctrl,
5218 (void *)&cmd_lfc_set_rx,
5219 (void *)&cmd_lfc_set_rx_mode,
5220 (void *)&cmd_lfc_set_portid,
5225 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5226 .f = cmd_link_flow_ctrl_set_parsed,
5227 .data = (void *)&cmd_link_flow_control_set_tx,
5228 .help_str = "set flow_ctrl tx on|off <port_id>: "
5229 "Change tx flow control parameter",
5231 (void *)&cmd_lfc_set_set,
5232 (void *)&cmd_lfc_set_flow_ctrl,
5233 (void *)&cmd_lfc_set_tx,
5234 (void *)&cmd_lfc_set_tx_mode,
5235 (void *)&cmd_lfc_set_portid,
5240 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5241 .f = cmd_link_flow_ctrl_set_parsed,
5242 .data = (void *)&cmd_link_flow_control_set_hw,
5243 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5244 "Change high water flow control parameter",
5246 (void *)&cmd_lfc_set_set,
5247 (void *)&cmd_lfc_set_flow_ctrl,
5248 (void *)&cmd_lfc_set_high_water_str,
5249 (void *)&cmd_lfc_set_high_water,
5250 (void *)&cmd_lfc_set_portid,
5255 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5256 .f = cmd_link_flow_ctrl_set_parsed,
5257 .data = (void *)&cmd_link_flow_control_set_lw,
5258 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5259 "Change low water flow control parameter",
5261 (void *)&cmd_lfc_set_set,
5262 (void *)&cmd_lfc_set_flow_ctrl,
5263 (void *)&cmd_lfc_set_low_water_str,
5264 (void *)&cmd_lfc_set_low_water,
5265 (void *)&cmd_lfc_set_portid,
5270 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5271 .f = cmd_link_flow_ctrl_set_parsed,
5272 .data = (void *)&cmd_link_flow_control_set_pt,
5273 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5274 "Change pause time flow control parameter",
5276 (void *)&cmd_lfc_set_set,
5277 (void *)&cmd_lfc_set_flow_ctrl,
5278 (void *)&cmd_lfc_set_pause_time_str,
5279 (void *)&cmd_lfc_set_pause_time,
5280 (void *)&cmd_lfc_set_portid,
5285 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5286 .f = cmd_link_flow_ctrl_set_parsed,
5287 .data = (void *)&cmd_link_flow_control_set_xon,
5288 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5289 "Change send_xon flow control parameter",
5291 (void *)&cmd_lfc_set_set,
5292 (void *)&cmd_lfc_set_flow_ctrl,
5293 (void *)&cmd_lfc_set_send_xon_str,
5294 (void *)&cmd_lfc_set_send_xon,
5295 (void *)&cmd_lfc_set_portid,
5300 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5301 .f = cmd_link_flow_ctrl_set_parsed,
5302 .data = (void *)&cmd_link_flow_control_set_macfwd,
5303 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5304 "Change mac ctrl fwd flow control parameter",
5306 (void *)&cmd_lfc_set_set,
5307 (void *)&cmd_lfc_set_flow_ctrl,
5308 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5309 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5310 (void *)&cmd_lfc_set_portid,
5315 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5316 .f = cmd_link_flow_ctrl_set_parsed,
5317 .data = (void *)&cmd_link_flow_control_set_autoneg,
5318 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5319 "Change autoneg flow control parameter",
5321 (void *)&cmd_lfc_set_set,
5322 (void *)&cmd_lfc_set_flow_ctrl,
5323 (void *)&cmd_lfc_set_autoneg_str,
5324 (void *)&cmd_lfc_set_autoneg,
5325 (void *)&cmd_lfc_set_portid,
5331 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5332 __attribute__((unused)) struct cmdline *cl,
5335 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5336 cmdline_parse_inst_t *cmd = data;
5337 struct rte_eth_fc_conf fc_conf;
5343 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5344 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5345 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5346 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5348 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5349 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5352 /* Partial command line, retrieve current configuration */
5354 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5356 printf("cannot get current flow ctrl parameters, return"
5357 "code = %d\n", ret);
5361 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5362 (fc_conf.mode == RTE_FC_FULL))
5364 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5365 (fc_conf.mode == RTE_FC_FULL))
5369 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5370 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5372 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5373 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5375 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5377 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5378 fc_conf.high_water = res->high_water;
5380 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5381 fc_conf.low_water = res->low_water;
5383 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5384 fc_conf.pause_time = res->pause_time;
5386 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5387 fc_conf.send_xon = res->send_xon;
5389 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5390 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5391 fc_conf.mac_ctrl_frame_fwd = 1;
5393 fc_conf.mac_ctrl_frame_fwd = 0;
5396 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5397 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5399 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5401 printf("bad flow contrl parameter, return code = %d \n", ret);
5404 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5405 struct cmd_priority_flow_ctrl_set_result {
5406 cmdline_fixed_string_t set;
5407 cmdline_fixed_string_t pfc_ctrl;
5408 cmdline_fixed_string_t rx;
5409 cmdline_fixed_string_t rx_pfc_mode;
5410 cmdline_fixed_string_t tx;
5411 cmdline_fixed_string_t tx_pfc_mode;
5412 uint32_t high_water;
5414 uint16_t pause_time;
5420 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5421 __attribute__((unused)) struct cmdline *cl,
5422 __attribute__((unused)) void *data)
5424 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5425 struct rte_eth_pfc_conf pfc_conf;
5426 int rx_fc_enable, tx_fc_enable;
5430 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5431 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5432 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5433 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5435 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5436 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5439 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5440 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5441 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5442 pfc_conf.fc.high_water = res->high_water;
5443 pfc_conf.fc.low_water = res->low_water;
5444 pfc_conf.fc.pause_time = res->pause_time;
5445 pfc_conf.priority = res->priority;
5447 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5449 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5452 cmdline_parse_token_string_t cmd_pfc_set_set =
5453 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5455 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5456 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5457 pfc_ctrl, "pfc_ctrl");
5458 cmdline_parse_token_string_t cmd_pfc_set_rx =
5459 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5461 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5462 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5463 rx_pfc_mode, "on#off");
5464 cmdline_parse_token_string_t cmd_pfc_set_tx =
5465 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5467 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5468 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5469 tx_pfc_mode, "on#off");
5470 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5471 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5472 high_water, UINT32);
5473 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5474 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5476 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5477 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5478 pause_time, UINT16);
5479 cmdline_parse_token_num_t cmd_pfc_set_priority =
5480 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5482 cmdline_parse_token_num_t cmd_pfc_set_portid =
5483 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5486 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5487 .f = cmd_priority_flow_ctrl_set_parsed,
5489 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5490 "<pause_time> <priority> <port_id>: "
5491 "Configure the Ethernet priority flow control",
5493 (void *)&cmd_pfc_set_set,
5494 (void *)&cmd_pfc_set_flow_ctrl,
5495 (void *)&cmd_pfc_set_rx,
5496 (void *)&cmd_pfc_set_rx_mode,
5497 (void *)&cmd_pfc_set_tx,
5498 (void *)&cmd_pfc_set_tx_mode,
5499 (void *)&cmd_pfc_set_high_water,
5500 (void *)&cmd_pfc_set_low_water,
5501 (void *)&cmd_pfc_set_pause_time,
5502 (void *)&cmd_pfc_set_priority,
5503 (void *)&cmd_pfc_set_portid,
5508 /* *** RESET CONFIGURATION *** */
5509 struct cmd_reset_result {
5510 cmdline_fixed_string_t reset;
5511 cmdline_fixed_string_t def;
5514 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5516 __attribute__((unused)) void *data)
5518 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5519 set_def_fwd_config();
5522 cmdline_parse_token_string_t cmd_reset_set =
5523 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5524 cmdline_parse_token_string_t cmd_reset_def =
5525 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5528 cmdline_parse_inst_t cmd_reset = {
5529 .f = cmd_reset_parsed,
5531 .help_str = "set default: Reset default forwarding configuration",
5533 (void *)&cmd_reset_set,
5534 (void *)&cmd_reset_def,
5539 /* *** START FORWARDING *** */
5540 struct cmd_start_result {
5541 cmdline_fixed_string_t start;
5544 cmdline_parse_token_string_t cmd_start_start =
5545 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5547 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5548 __attribute__((unused)) struct cmdline *cl,
5549 __attribute__((unused)) void *data)
5551 start_packet_forwarding(0);
5554 cmdline_parse_inst_t cmd_start = {
5555 .f = cmd_start_parsed,
5557 .help_str = "start: Start packet forwarding",
5559 (void *)&cmd_start_start,
5564 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5565 struct cmd_start_tx_first_result {
5566 cmdline_fixed_string_t start;
5567 cmdline_fixed_string_t tx_first;
5571 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5572 __attribute__((unused)) struct cmdline *cl,
5573 __attribute__((unused)) void *data)
5575 start_packet_forwarding(1);
5578 cmdline_parse_token_string_t cmd_start_tx_first_start =
5579 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5581 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5582 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5583 tx_first, "tx_first");
5585 cmdline_parse_inst_t cmd_start_tx_first = {
5586 .f = cmd_start_tx_first_parsed,
5588 .help_str = "start tx_first: Start packet forwarding, "
5589 "after sending 1 burst of packets",
5591 (void *)&cmd_start_tx_first_start,
5592 (void *)&cmd_start_tx_first_tx_first,
5597 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5598 struct cmd_start_tx_first_n_result {
5599 cmdline_fixed_string_t start;
5600 cmdline_fixed_string_t tx_first;
5605 cmd_start_tx_first_n_parsed(void *parsed_result,
5606 __attribute__((unused)) struct cmdline *cl,
5607 __attribute__((unused)) void *data)
5609 struct cmd_start_tx_first_n_result *res = parsed_result;
5611 start_packet_forwarding(res->tx_num);
5614 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5615 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5617 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5618 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5619 tx_first, "tx_first");
5620 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5621 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5624 cmdline_parse_inst_t cmd_start_tx_first_n = {
5625 .f = cmd_start_tx_first_n_parsed,
5627 .help_str = "start tx_first <num>: "
5628 "packet forwarding, after sending <num> bursts of packets",
5630 (void *)&cmd_start_tx_first_n_start,
5631 (void *)&cmd_start_tx_first_n_tx_first,
5632 (void *)&cmd_start_tx_first_n_tx_num,
5637 /* *** SET LINK UP *** */
5638 struct cmd_set_link_up_result {
5639 cmdline_fixed_string_t set;
5640 cmdline_fixed_string_t link_up;
5641 cmdline_fixed_string_t port;
5645 cmdline_parse_token_string_t cmd_set_link_up_set =
5646 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5647 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5650 cmdline_parse_token_string_t cmd_set_link_up_port =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5652 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5653 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5655 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5656 __attribute__((unused)) struct cmdline *cl,
5657 __attribute__((unused)) void *data)
5659 struct cmd_set_link_up_result *res = parsed_result;
5660 dev_set_link_up(res->port_id);
5663 cmdline_parse_inst_t cmd_set_link_up = {
5664 .f = cmd_set_link_up_parsed,
5666 .help_str = "set link-up port <port id>",
5668 (void *)&cmd_set_link_up_set,
5669 (void *)&cmd_set_link_up_link_up,
5670 (void *)&cmd_set_link_up_port,
5671 (void *)&cmd_set_link_up_port_id,
5676 /* *** SET LINK DOWN *** */
5677 struct cmd_set_link_down_result {
5678 cmdline_fixed_string_t set;
5679 cmdline_fixed_string_t link_down;
5680 cmdline_fixed_string_t port;
5684 cmdline_parse_token_string_t cmd_set_link_down_set =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5686 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5689 cmdline_parse_token_string_t cmd_set_link_down_port =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5691 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5694 static void cmd_set_link_down_parsed(
5695 __attribute__((unused)) void *parsed_result,
5696 __attribute__((unused)) struct cmdline *cl,
5697 __attribute__((unused)) void *data)
5699 struct cmd_set_link_down_result *res = parsed_result;
5700 dev_set_link_down(res->port_id);
5703 cmdline_parse_inst_t cmd_set_link_down = {
5704 .f = cmd_set_link_down_parsed,
5706 .help_str = "set link-down port <port id>",
5708 (void *)&cmd_set_link_down_set,
5709 (void *)&cmd_set_link_down_link_down,
5710 (void *)&cmd_set_link_down_port,
5711 (void *)&cmd_set_link_down_port_id,
5716 /* *** SHOW CFG *** */
5717 struct cmd_showcfg_result {
5718 cmdline_fixed_string_t show;
5719 cmdline_fixed_string_t cfg;
5720 cmdline_fixed_string_t what;
5723 static void cmd_showcfg_parsed(void *parsed_result,
5724 __attribute__((unused)) struct cmdline *cl,
5725 __attribute__((unused)) void *data)
5727 struct cmd_showcfg_result *res = parsed_result;
5728 if (!strcmp(res->what, "rxtx"))
5729 rxtx_config_display();
5730 else if (!strcmp(res->what, "cores"))
5731 fwd_lcores_config_display();
5732 else if (!strcmp(res->what, "fwd"))
5733 pkt_fwd_config_display(&cur_fwd_config);
5734 else if (!strcmp(res->what, "txpkts"))
5735 show_tx_pkt_segments();
5738 cmdline_parse_token_string_t cmd_showcfg_show =
5739 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5740 cmdline_parse_token_string_t cmd_showcfg_port =
5741 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5742 cmdline_parse_token_string_t cmd_showcfg_what =
5743 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5744 "rxtx#cores#fwd#txpkts");
5746 cmdline_parse_inst_t cmd_showcfg = {
5747 .f = cmd_showcfg_parsed,
5749 .help_str = "show config rxtx|cores|fwd|txpkts",
5751 (void *)&cmd_showcfg_show,
5752 (void *)&cmd_showcfg_port,
5753 (void *)&cmd_showcfg_what,
5758 /* *** SHOW ALL PORT INFO *** */
5759 struct cmd_showportall_result {
5760 cmdline_fixed_string_t show;
5761 cmdline_fixed_string_t port;
5762 cmdline_fixed_string_t what;
5763 cmdline_fixed_string_t all;
5766 static void cmd_showportall_parsed(void *parsed_result,
5767 __attribute__((unused)) struct cmdline *cl,
5768 __attribute__((unused)) void *data)
5772 struct cmd_showportall_result *res = parsed_result;
5773 if (!strcmp(res->show, "clear")) {
5774 if (!strcmp(res->what, "stats"))
5775 FOREACH_PORT(i, ports)
5777 else if (!strcmp(res->what, "xstats"))
5778 FOREACH_PORT(i, ports)
5779 nic_xstats_clear(i);
5780 } else if (!strcmp(res->what, "info"))
5781 FOREACH_PORT(i, ports)
5782 port_infos_display(i);
5783 else if (!strcmp(res->what, "stats"))
5784 FOREACH_PORT(i, ports)
5785 nic_stats_display(i);
5786 else if (!strcmp(res->what, "xstats"))
5787 FOREACH_PORT(i, ports)
5788 nic_xstats_display(i);
5789 else if (!strcmp(res->what, "fdir"))
5790 FOREACH_PORT(i, ports)
5792 else if (!strcmp(res->what, "stat_qmap"))
5793 FOREACH_PORT(i, ports)
5794 nic_stats_mapping_display(i);
5795 else if (!strcmp(res->what, "dcb_tc"))
5796 FOREACH_PORT(i, ports)
5797 port_dcb_info_display(i);
5800 cmdline_parse_token_string_t cmd_showportall_show =
5801 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5803 cmdline_parse_token_string_t cmd_showportall_port =
5804 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5805 cmdline_parse_token_string_t cmd_showportall_what =
5806 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5807 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5808 cmdline_parse_token_string_t cmd_showportall_all =
5809 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5810 cmdline_parse_inst_t cmd_showportall = {
5811 .f = cmd_showportall_parsed,
5813 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5815 (void *)&cmd_showportall_show,
5816 (void *)&cmd_showportall_port,
5817 (void *)&cmd_showportall_what,
5818 (void *)&cmd_showportall_all,
5823 /* *** SHOW PORT INFO *** */
5824 struct cmd_showport_result {
5825 cmdline_fixed_string_t show;
5826 cmdline_fixed_string_t port;
5827 cmdline_fixed_string_t what;
5831 static void cmd_showport_parsed(void *parsed_result,
5832 __attribute__((unused)) struct cmdline *cl,
5833 __attribute__((unused)) void *data)
5835 struct cmd_showport_result *res = parsed_result;
5836 if (!strcmp(res->show, "clear")) {
5837 if (!strcmp(res->what, "stats"))
5838 nic_stats_clear(res->portnum);
5839 else if (!strcmp(res->what, "xstats"))
5840 nic_xstats_clear(res->portnum);
5841 } else if (!strcmp(res->what, "info"))
5842 port_infos_display(res->portnum);
5843 else if (!strcmp(res->what, "stats"))
5844 nic_stats_display(res->portnum);
5845 else if (!strcmp(res->what, "xstats"))
5846 nic_xstats_display(res->portnum);
5847 else if (!strcmp(res->what, "fdir"))
5848 fdir_get_infos(res->portnum);
5849 else if (!strcmp(res->what, "stat_qmap"))
5850 nic_stats_mapping_display(res->portnum);
5851 else if (!strcmp(res->what, "dcb_tc"))
5852 port_dcb_info_display(res->portnum);
5855 cmdline_parse_token_string_t cmd_showport_show =
5856 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5858 cmdline_parse_token_string_t cmd_showport_port =
5859 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5860 cmdline_parse_token_string_t cmd_showport_what =
5861 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5862 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5863 cmdline_parse_token_num_t cmd_showport_portnum =
5864 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5866 cmdline_parse_inst_t cmd_showport = {
5867 .f = cmd_showport_parsed,
5869 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5872 (void *)&cmd_showport_show,
5873 (void *)&cmd_showport_port,
5874 (void *)&cmd_showport_what,
5875 (void *)&cmd_showport_portnum,
5880 /* *** SHOW QUEUE INFO *** */
5881 struct cmd_showqueue_result {
5882 cmdline_fixed_string_t show;
5883 cmdline_fixed_string_t type;
5884 cmdline_fixed_string_t what;
5890 cmd_showqueue_parsed(void *parsed_result,
5891 __attribute__((unused)) struct cmdline *cl,
5892 __attribute__((unused)) void *data)
5894 struct cmd_showqueue_result *res = parsed_result;
5896 if (!strcmp(res->type, "rxq"))
5897 rx_queue_infos_display(res->portnum, res->queuenum);
5898 else if (!strcmp(res->type, "txq"))
5899 tx_queue_infos_display(res->portnum, res->queuenum);
5902 cmdline_parse_token_string_t cmd_showqueue_show =
5903 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5904 cmdline_parse_token_string_t cmd_showqueue_type =
5905 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5906 cmdline_parse_token_string_t cmd_showqueue_what =
5907 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5908 cmdline_parse_token_num_t cmd_showqueue_portnum =
5909 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5910 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5911 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5913 cmdline_parse_inst_t cmd_showqueue = {
5914 .f = cmd_showqueue_parsed,
5916 .help_str = "show rxq|txq info <port_id> <queue_id>",
5918 (void *)&cmd_showqueue_show,
5919 (void *)&cmd_showqueue_type,
5920 (void *)&cmd_showqueue_what,
5921 (void *)&cmd_showqueue_portnum,
5922 (void *)&cmd_showqueue_queuenum,
5927 /* *** READ PORT REGISTER *** */
5928 struct cmd_read_reg_result {
5929 cmdline_fixed_string_t read;
5930 cmdline_fixed_string_t reg;
5936 cmd_read_reg_parsed(void *parsed_result,
5937 __attribute__((unused)) struct cmdline *cl,
5938 __attribute__((unused)) void *data)
5940 struct cmd_read_reg_result *res = parsed_result;
5941 port_reg_display(res->port_id, res->reg_off);
5944 cmdline_parse_token_string_t cmd_read_reg_read =
5945 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5946 cmdline_parse_token_string_t cmd_read_reg_reg =
5947 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5948 cmdline_parse_token_num_t cmd_read_reg_port_id =
5949 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5950 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5951 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5953 cmdline_parse_inst_t cmd_read_reg = {
5954 .f = cmd_read_reg_parsed,
5956 .help_str = "read reg <port_id> <reg_off>",
5958 (void *)&cmd_read_reg_read,
5959 (void *)&cmd_read_reg_reg,
5960 (void *)&cmd_read_reg_port_id,
5961 (void *)&cmd_read_reg_reg_off,
5966 /* *** READ PORT REGISTER BIT FIELD *** */
5967 struct cmd_read_reg_bit_field_result {
5968 cmdline_fixed_string_t read;
5969 cmdline_fixed_string_t regfield;
5977 cmd_read_reg_bit_field_parsed(void *parsed_result,
5978 __attribute__((unused)) struct cmdline *cl,
5979 __attribute__((unused)) void *data)
5981 struct cmd_read_reg_bit_field_result *res = parsed_result;
5982 port_reg_bit_field_display(res->port_id, res->reg_off,
5983 res->bit1_pos, res->bit2_pos);
5986 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5987 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5989 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5990 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5991 regfield, "regfield");
5992 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5993 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5995 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5996 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5998 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5999 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6001 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6005 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6006 .f = cmd_read_reg_bit_field_parsed,
6008 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6009 "Read register bit field between bit_x and bit_y included",
6011 (void *)&cmd_read_reg_bit_field_read,
6012 (void *)&cmd_read_reg_bit_field_regfield,
6013 (void *)&cmd_read_reg_bit_field_port_id,
6014 (void *)&cmd_read_reg_bit_field_reg_off,
6015 (void *)&cmd_read_reg_bit_field_bit1_pos,
6016 (void *)&cmd_read_reg_bit_field_bit2_pos,
6021 /* *** READ PORT REGISTER BIT *** */
6022 struct cmd_read_reg_bit_result {
6023 cmdline_fixed_string_t read;
6024 cmdline_fixed_string_t regbit;
6031 cmd_read_reg_bit_parsed(void *parsed_result,
6032 __attribute__((unused)) struct cmdline *cl,
6033 __attribute__((unused)) void *data)
6035 struct cmd_read_reg_bit_result *res = parsed_result;
6036 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6039 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6040 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6041 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6042 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6044 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6045 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6046 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6047 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6048 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6049 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6051 cmdline_parse_inst_t cmd_read_reg_bit = {
6052 .f = cmd_read_reg_bit_parsed,
6054 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6056 (void *)&cmd_read_reg_bit_read,
6057 (void *)&cmd_read_reg_bit_regbit,
6058 (void *)&cmd_read_reg_bit_port_id,
6059 (void *)&cmd_read_reg_bit_reg_off,
6060 (void *)&cmd_read_reg_bit_bit_pos,
6065 /* *** WRITE PORT REGISTER *** */
6066 struct cmd_write_reg_result {
6067 cmdline_fixed_string_t write;
6068 cmdline_fixed_string_t reg;
6075 cmd_write_reg_parsed(void *parsed_result,
6076 __attribute__((unused)) struct cmdline *cl,
6077 __attribute__((unused)) void *data)
6079 struct cmd_write_reg_result *res = parsed_result;
6080 port_reg_set(res->port_id, res->reg_off, res->value);
6083 cmdline_parse_token_string_t cmd_write_reg_write =
6084 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6085 cmdline_parse_token_string_t cmd_write_reg_reg =
6086 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6087 cmdline_parse_token_num_t cmd_write_reg_port_id =
6088 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6089 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6090 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6091 cmdline_parse_token_num_t cmd_write_reg_value =
6092 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6094 cmdline_parse_inst_t cmd_write_reg = {
6095 .f = cmd_write_reg_parsed,
6097 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6099 (void *)&cmd_write_reg_write,
6100 (void *)&cmd_write_reg_reg,
6101 (void *)&cmd_write_reg_port_id,
6102 (void *)&cmd_write_reg_reg_off,
6103 (void *)&cmd_write_reg_value,
6108 /* *** WRITE PORT REGISTER BIT FIELD *** */
6109 struct cmd_write_reg_bit_field_result {
6110 cmdline_fixed_string_t write;
6111 cmdline_fixed_string_t regfield;
6120 cmd_write_reg_bit_field_parsed(void *parsed_result,
6121 __attribute__((unused)) struct cmdline *cl,
6122 __attribute__((unused)) void *data)
6124 struct cmd_write_reg_bit_field_result *res = parsed_result;
6125 port_reg_bit_field_set(res->port_id, res->reg_off,
6126 res->bit1_pos, res->bit2_pos, res->value);
6129 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6130 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6132 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6133 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6134 regfield, "regfield");
6135 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6138 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6139 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6141 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6142 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6144 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6145 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6147 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6148 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6151 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6152 .f = cmd_write_reg_bit_field_parsed,
6154 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6156 "Set register bit field between bit_x and bit_y included",
6158 (void *)&cmd_write_reg_bit_field_write,
6159 (void *)&cmd_write_reg_bit_field_regfield,
6160 (void *)&cmd_write_reg_bit_field_port_id,
6161 (void *)&cmd_write_reg_bit_field_reg_off,
6162 (void *)&cmd_write_reg_bit_field_bit1_pos,
6163 (void *)&cmd_write_reg_bit_field_bit2_pos,
6164 (void *)&cmd_write_reg_bit_field_value,
6169 /* *** WRITE PORT REGISTER BIT *** */
6170 struct cmd_write_reg_bit_result {
6171 cmdline_fixed_string_t write;
6172 cmdline_fixed_string_t regbit;
6180 cmd_write_reg_bit_parsed(void *parsed_result,
6181 __attribute__((unused)) struct cmdline *cl,
6182 __attribute__((unused)) void *data)
6184 struct cmd_write_reg_bit_result *res = parsed_result;
6185 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6188 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6189 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6191 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6192 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6194 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6195 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6196 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6198 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6199 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6200 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6201 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6203 cmdline_parse_inst_t cmd_write_reg_bit = {
6204 .f = cmd_write_reg_bit_parsed,
6206 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6209 (void *)&cmd_write_reg_bit_write,
6210 (void *)&cmd_write_reg_bit_regbit,
6211 (void *)&cmd_write_reg_bit_port_id,
6212 (void *)&cmd_write_reg_bit_reg_off,
6213 (void *)&cmd_write_reg_bit_bit_pos,
6214 (void *)&cmd_write_reg_bit_value,
6219 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6220 struct cmd_read_rxd_txd_result {
6221 cmdline_fixed_string_t read;
6222 cmdline_fixed_string_t rxd_txd;
6229 cmd_read_rxd_txd_parsed(void *parsed_result,
6230 __attribute__((unused)) struct cmdline *cl,
6231 __attribute__((unused)) void *data)
6233 struct cmd_read_rxd_txd_result *res = parsed_result;
6235 if (!strcmp(res->rxd_txd, "rxd"))
6236 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6237 else if (!strcmp(res->rxd_txd, "txd"))
6238 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6241 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6242 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6243 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6244 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6246 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6247 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6248 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6249 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6250 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6251 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6253 cmdline_parse_inst_t cmd_read_rxd_txd = {
6254 .f = cmd_read_rxd_txd_parsed,
6256 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6258 (void *)&cmd_read_rxd_txd_read,
6259 (void *)&cmd_read_rxd_txd_rxd_txd,
6260 (void *)&cmd_read_rxd_txd_port_id,
6261 (void *)&cmd_read_rxd_txd_queue_id,
6262 (void *)&cmd_read_rxd_txd_desc_id,
6268 struct cmd_quit_result {
6269 cmdline_fixed_string_t quit;
6272 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6274 __attribute__((unused)) void *data)
6280 cmdline_parse_token_string_t cmd_quit_quit =
6281 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6283 cmdline_parse_inst_t cmd_quit = {
6284 .f = cmd_quit_parsed,
6286 .help_str = "quit: Exit application",
6288 (void *)&cmd_quit_quit,
6293 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6294 struct cmd_mac_addr_result {
6295 cmdline_fixed_string_t mac_addr_cmd;
6296 cmdline_fixed_string_t what;
6298 struct ether_addr address;
6301 static void cmd_mac_addr_parsed(void *parsed_result,
6302 __attribute__((unused)) struct cmdline *cl,
6303 __attribute__((unused)) void *data)
6305 struct cmd_mac_addr_result *res = parsed_result;
6308 if (strcmp(res->what, "add") == 0)
6309 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6311 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6313 /* check the return value and print it if is < 0 */
6315 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6319 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6320 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6322 cmdline_parse_token_string_t cmd_mac_addr_what =
6323 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6325 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6326 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6327 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6330 cmdline_parse_inst_t cmd_mac_addr = {
6331 .f = cmd_mac_addr_parsed,
6333 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6334 "Add/Remove MAC address on port_id",
6336 (void *)&cmd_mac_addr_cmd,
6337 (void *)&cmd_mac_addr_what,
6338 (void *)&cmd_mac_addr_portnum,
6339 (void *)&cmd_mac_addr_addr,
6345 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6346 struct cmd_set_qmap_result {
6347 cmdline_fixed_string_t set;
6348 cmdline_fixed_string_t qmap;
6349 cmdline_fixed_string_t what;
6356 cmd_set_qmap_parsed(void *parsed_result,
6357 __attribute__((unused)) struct cmdline *cl,
6358 __attribute__((unused)) void *data)
6360 struct cmd_set_qmap_result *res = parsed_result;
6361 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6363 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6366 cmdline_parse_token_string_t cmd_setqmap_set =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6369 cmdline_parse_token_string_t cmd_setqmap_qmap =
6370 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6372 cmdline_parse_token_string_t cmd_setqmap_what =
6373 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6375 cmdline_parse_token_num_t cmd_setqmap_portid =
6376 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6378 cmdline_parse_token_num_t cmd_setqmap_queueid =
6379 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6381 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6382 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6385 cmdline_parse_inst_t cmd_set_qmap = {
6386 .f = cmd_set_qmap_parsed,
6388 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6389 "Set statistics mapping value on tx|rx queue_id of port_id",
6391 (void *)&cmd_setqmap_set,
6392 (void *)&cmd_setqmap_qmap,
6393 (void *)&cmd_setqmap_what,
6394 (void *)&cmd_setqmap_portid,
6395 (void *)&cmd_setqmap_queueid,
6396 (void *)&cmd_setqmap_mapvalue,
6401 /* *** CONFIGURE UNICAST HASH TABLE *** */
6402 struct cmd_set_uc_hash_table {
6403 cmdline_fixed_string_t set;
6404 cmdline_fixed_string_t port;
6406 cmdline_fixed_string_t what;
6407 struct ether_addr address;
6408 cmdline_fixed_string_t mode;
6412 cmd_set_uc_hash_parsed(void *parsed_result,
6413 __attribute__((unused)) struct cmdline *cl,
6414 __attribute__((unused)) void *data)
6417 struct cmd_set_uc_hash_table *res = parsed_result;
6419 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6421 if (strcmp(res->what, "uta") == 0)
6422 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6423 &res->address,(uint8_t)is_on);
6425 printf("bad unicast hash table parameter, return code = %d \n", ret);
6429 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6430 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6432 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6435 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6436 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6438 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6441 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6442 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6444 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6448 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6449 .f = cmd_set_uc_hash_parsed,
6451 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6453 (void *)&cmd_set_uc_hash_set,
6454 (void *)&cmd_set_uc_hash_port,
6455 (void *)&cmd_set_uc_hash_portid,
6456 (void *)&cmd_set_uc_hash_what,
6457 (void *)&cmd_set_uc_hash_mac,
6458 (void *)&cmd_set_uc_hash_mode,
6463 struct cmd_set_uc_all_hash_table {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t port;
6467 cmdline_fixed_string_t what;
6468 cmdline_fixed_string_t value;
6469 cmdline_fixed_string_t mode;
6473 cmd_set_uc_all_hash_parsed(void *parsed_result,
6474 __attribute__((unused)) struct cmdline *cl,
6475 __attribute__((unused)) void *data)
6478 struct cmd_set_uc_all_hash_table *res = parsed_result;
6480 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6482 if ((strcmp(res->what, "uta") == 0) &&
6483 (strcmp(res->value, "all") == 0))
6484 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6486 printf("bad unicast hash table parameter,"
6487 "return code = %d \n", ret);
6490 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6493 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6496 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6497 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6499 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6502 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6505 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6509 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6510 .f = cmd_set_uc_all_hash_parsed,
6512 .help_str = "set port <port_id> uta all on|off",
6514 (void *)&cmd_set_uc_all_hash_set,
6515 (void *)&cmd_set_uc_all_hash_port,
6516 (void *)&cmd_set_uc_all_hash_portid,
6517 (void *)&cmd_set_uc_all_hash_what,
6518 (void *)&cmd_set_uc_all_hash_value,
6519 (void *)&cmd_set_uc_all_hash_mode,
6524 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6525 struct cmd_set_vf_macvlan_filter {
6526 cmdline_fixed_string_t set;
6527 cmdline_fixed_string_t port;
6529 cmdline_fixed_string_t vf;
6531 struct ether_addr address;
6532 cmdline_fixed_string_t filter_type;
6533 cmdline_fixed_string_t mode;
6537 cmd_set_vf_macvlan_parsed(void *parsed_result,
6538 __attribute__((unused)) struct cmdline *cl,
6539 __attribute__((unused)) void *data)
6542 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6543 struct rte_eth_mac_filter filter;
6545 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6547 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6549 /* set VF MAC filter */
6553 filter.dst_id = res->vf_id;
6555 if (!strcmp(res->filter_type, "exact-mac"))
6556 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6557 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6558 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6559 else if (!strcmp(res->filter_type, "hashmac"))
6560 filter.filter_type = RTE_MAC_HASH_MATCH;
6561 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6562 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6564 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6567 ret = rte_eth_dev_filter_ctrl(res->port_id,
6568 RTE_ETH_FILTER_MACVLAN,
6572 ret = rte_eth_dev_filter_ctrl(res->port_id,
6573 RTE_ETH_FILTER_MACVLAN,
6574 RTE_ETH_FILTER_DELETE,
6578 printf("bad set MAC hash parameter, return code = %d\n", ret);
6582 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6585 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6588 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6589 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6591 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6594 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6595 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6597 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6598 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6600 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6602 filter_type, "exact-mac#exact-mac-vlan"
6603 "#hashmac#hashmac-vlan");
6604 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6605 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6608 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6609 .f = cmd_set_vf_macvlan_parsed,
6611 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6612 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6613 "Exact match rule: exact match of MAC or MAC and VLAN; "
6614 "hash match rule: hash match of MAC and exact match of VLAN",
6616 (void *)&cmd_set_vf_macvlan_set,
6617 (void *)&cmd_set_vf_macvlan_port,
6618 (void *)&cmd_set_vf_macvlan_portid,
6619 (void *)&cmd_set_vf_macvlan_vf,
6620 (void *)&cmd_set_vf_macvlan_vf_id,
6621 (void *)&cmd_set_vf_macvlan_mac,
6622 (void *)&cmd_set_vf_macvlan_filter_type,
6623 (void *)&cmd_set_vf_macvlan_mode,
6628 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6629 struct cmd_set_vf_traffic {
6630 cmdline_fixed_string_t set;
6631 cmdline_fixed_string_t port;
6633 cmdline_fixed_string_t vf;
6635 cmdline_fixed_string_t what;
6636 cmdline_fixed_string_t mode;
6640 cmd_set_vf_traffic_parsed(void *parsed_result,
6641 __attribute__((unused)) struct cmdline *cl,
6642 __attribute__((unused)) void *data)
6644 struct cmd_set_vf_traffic *res = parsed_result;
6645 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6646 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6648 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6651 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6652 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6654 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6657 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6658 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6660 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6663 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6664 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6666 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6669 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6673 cmdline_parse_inst_t cmd_set_vf_traffic = {
6674 .f = cmd_set_vf_traffic_parsed,
6676 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6678 (void *)&cmd_setvf_traffic_set,
6679 (void *)&cmd_setvf_traffic_port,
6680 (void *)&cmd_setvf_traffic_portid,
6681 (void *)&cmd_setvf_traffic_vf,
6682 (void *)&cmd_setvf_traffic_vfid,
6683 (void *)&cmd_setvf_traffic_what,
6684 (void *)&cmd_setvf_traffic_mode,
6689 /* *** CONFIGURE VF RECEIVE MODE *** */
6690 struct cmd_set_vf_rxmode {
6691 cmdline_fixed_string_t set;
6692 cmdline_fixed_string_t port;
6694 cmdline_fixed_string_t vf;
6696 cmdline_fixed_string_t what;
6697 cmdline_fixed_string_t mode;
6698 cmdline_fixed_string_t on;
6702 cmd_set_vf_rxmode_parsed(void *parsed_result,
6703 __attribute__((unused)) struct cmdline *cl,
6704 __attribute__((unused)) void *data)
6707 uint16_t rx_mode = 0;
6708 struct cmd_set_vf_rxmode *res = parsed_result;
6710 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6711 if (!strcmp(res->what,"rxmode")) {
6712 if (!strcmp(res->mode, "AUPE"))
6713 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6714 else if (!strcmp(res->mode, "ROPE"))
6715 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6716 else if (!strcmp(res->mode, "BAM"))
6717 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6718 else if (!strncmp(res->mode, "MPE",3))
6719 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6722 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6724 printf("bad VF receive mode parameter, return code = %d \n",
6728 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6731 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6734 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6735 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6737 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6740 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6741 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6743 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6746 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6748 mode, "AUPE#ROPE#BAM#MPE");
6749 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6750 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6753 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6754 .f = cmd_set_vf_rxmode_parsed,
6756 .help_str = "set port <port_id> vf <vf_id> rxmode "
6757 "AUPE|ROPE|BAM|MPE on|off",
6759 (void *)&cmd_set_vf_rxmode_set,
6760 (void *)&cmd_set_vf_rxmode_port,
6761 (void *)&cmd_set_vf_rxmode_portid,
6762 (void *)&cmd_set_vf_rxmode_vf,
6763 (void *)&cmd_set_vf_rxmode_vfid,
6764 (void *)&cmd_set_vf_rxmode_what,
6765 (void *)&cmd_set_vf_rxmode_mode,
6766 (void *)&cmd_set_vf_rxmode_on,
6771 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6772 struct cmd_vf_mac_addr_result {
6773 cmdline_fixed_string_t mac_addr_cmd;
6774 cmdline_fixed_string_t what;
6775 cmdline_fixed_string_t port;
6777 cmdline_fixed_string_t vf;
6779 struct ether_addr address;
6782 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6783 __attribute__((unused)) struct cmdline *cl,
6784 __attribute__((unused)) void *data)
6786 struct cmd_vf_mac_addr_result *res = parsed_result;
6789 if (strcmp(res->what, "add") == 0)
6790 ret = rte_eth_dev_mac_addr_add(res->port_num,
6791 &res->address, res->vf_num);
6793 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6797 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6798 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6799 mac_addr_cmd,"mac_addr");
6800 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6801 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6803 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6804 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6806 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6807 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6809 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6810 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6812 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6813 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6815 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6816 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6819 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6820 .f = cmd_vf_mac_addr_parsed,
6822 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6823 "Add MAC address filtering for a VF on port_id",
6825 (void *)&cmd_vf_mac_addr_cmd,
6826 (void *)&cmd_vf_mac_addr_what,
6827 (void *)&cmd_vf_mac_addr_port,
6828 (void *)&cmd_vf_mac_addr_portnum,
6829 (void *)&cmd_vf_mac_addr_vf,
6830 (void *)&cmd_vf_mac_addr_vfnum,
6831 (void *)&cmd_vf_mac_addr_addr,
6836 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6837 struct cmd_vf_rx_vlan_filter {
6838 cmdline_fixed_string_t rx_vlan;
6839 cmdline_fixed_string_t what;
6841 cmdline_fixed_string_t port;
6843 cmdline_fixed_string_t vf;
6848 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6849 __attribute__((unused)) struct cmdline *cl,
6850 __attribute__((unused)) void *data)
6852 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6854 if (!strcmp(res->what, "add"))
6855 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6857 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6860 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6861 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6862 rx_vlan, "rx_vlan");
6863 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6864 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6866 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6867 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6869 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6870 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6872 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6873 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6875 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6876 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6878 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6879 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6882 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6883 .f = cmd_vf_rx_vlan_filter_parsed,
6885 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6886 "(vf_mask = hexadecimal VF mask)",
6888 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6889 (void *)&cmd_vf_rx_vlan_filter_what,
6890 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6891 (void *)&cmd_vf_rx_vlan_filter_port,
6892 (void *)&cmd_vf_rx_vlan_filter_portid,
6893 (void *)&cmd_vf_rx_vlan_filter_vf,
6894 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6899 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6900 struct cmd_queue_rate_limit_result {
6901 cmdline_fixed_string_t set;
6902 cmdline_fixed_string_t port;
6904 cmdline_fixed_string_t queue;
6906 cmdline_fixed_string_t rate;
6910 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6911 __attribute__((unused)) struct cmdline *cl,
6912 __attribute__((unused)) void *data)
6914 struct cmd_queue_rate_limit_result *res = parsed_result;
6917 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6918 && (strcmp(res->queue, "queue") == 0)
6919 && (strcmp(res->rate, "rate") == 0))
6920 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6923 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6927 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6928 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6930 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6931 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6933 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6934 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6936 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6937 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6939 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6940 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6942 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6943 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6945 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6946 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6949 cmdline_parse_inst_t cmd_queue_rate_limit = {
6950 .f = cmd_queue_rate_limit_parsed,
6952 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6953 "Set rate limit for a queue on port_id",
6955 (void *)&cmd_queue_rate_limit_set,
6956 (void *)&cmd_queue_rate_limit_port,
6957 (void *)&cmd_queue_rate_limit_portnum,
6958 (void *)&cmd_queue_rate_limit_queue,
6959 (void *)&cmd_queue_rate_limit_queuenum,
6960 (void *)&cmd_queue_rate_limit_rate,
6961 (void *)&cmd_queue_rate_limit_ratenum,
6966 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6967 struct cmd_vf_rate_limit_result {
6968 cmdline_fixed_string_t set;
6969 cmdline_fixed_string_t port;
6971 cmdline_fixed_string_t vf;
6973 cmdline_fixed_string_t rate;
6975 cmdline_fixed_string_t q_msk;
6979 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6980 __attribute__((unused)) struct cmdline *cl,
6981 __attribute__((unused)) void *data)
6983 struct cmd_vf_rate_limit_result *res = parsed_result;
6986 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6987 && (strcmp(res->vf, "vf") == 0)
6988 && (strcmp(res->rate, "rate") == 0)
6989 && (strcmp(res->q_msk, "queue_mask") == 0))
6990 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6991 res->rate_num, res->q_msk_val);
6993 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6997 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6998 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7000 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7001 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7003 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7004 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7006 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7009 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7010 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7012 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7013 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7015 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7016 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7018 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7019 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7020 q_msk, "queue_mask");
7021 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7022 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7025 cmdline_parse_inst_t cmd_vf_rate_limit = {
7026 .f = cmd_vf_rate_limit_parsed,
7028 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7029 "queue_mask <queue_mask_value>: "
7030 "Set rate limit for queues of VF on port_id",
7032 (void *)&cmd_vf_rate_limit_set,
7033 (void *)&cmd_vf_rate_limit_port,
7034 (void *)&cmd_vf_rate_limit_portnum,
7035 (void *)&cmd_vf_rate_limit_vf,
7036 (void *)&cmd_vf_rate_limit_vfnum,
7037 (void *)&cmd_vf_rate_limit_rate,
7038 (void *)&cmd_vf_rate_limit_ratenum,
7039 (void *)&cmd_vf_rate_limit_q_msk,
7040 (void *)&cmd_vf_rate_limit_q_msk_val,
7045 /* *** ADD TUNNEL FILTER OF A PORT *** */
7046 struct cmd_tunnel_filter_result {
7047 cmdline_fixed_string_t cmd;
7048 cmdline_fixed_string_t what;
7050 struct ether_addr outer_mac;
7051 struct ether_addr inner_mac;
7052 cmdline_ipaddr_t ip_value;
7053 uint16_t inner_vlan;
7054 cmdline_fixed_string_t tunnel_type;
7055 cmdline_fixed_string_t filter_type;
7061 cmd_tunnel_filter_parsed(void *parsed_result,
7062 __attribute__((unused)) struct cmdline *cl,
7063 __attribute__((unused)) void *data)
7065 struct cmd_tunnel_filter_result *res = parsed_result;
7066 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7069 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7071 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7072 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7073 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7075 if (res->ip_value.family == AF_INET) {
7076 tunnel_filter_conf.ip_addr.ipv4_addr =
7077 res->ip_value.addr.ipv4.s_addr;
7078 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7080 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7081 &(res->ip_value.addr.ipv6),
7082 sizeof(struct in6_addr));
7083 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7086 if (!strcmp(res->filter_type, "imac-ivlan"))
7087 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7088 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7089 tunnel_filter_conf.filter_type =
7090 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7091 else if (!strcmp(res->filter_type, "imac-tenid"))
7092 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7093 else if (!strcmp(res->filter_type, "imac"))
7094 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7095 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7096 tunnel_filter_conf.filter_type =
7097 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7098 else if (!strcmp(res->filter_type, "oip"))
7099 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7100 else if (!strcmp(res->filter_type, "iip"))
7101 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7103 printf("The filter type is not supported");
7107 if (!strcmp(res->tunnel_type, "vxlan"))
7108 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7109 else if (!strcmp(res->tunnel_type, "nvgre"))
7110 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7111 else if (!strcmp(res->tunnel_type, "ipingre"))
7112 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7114 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7118 tunnel_filter_conf.tenant_id = res->tenant_id;
7119 tunnel_filter_conf.queue_id = res->queue_num;
7120 if (!strcmp(res->what, "add"))
7121 ret = rte_eth_dev_filter_ctrl(res->port_id,
7122 RTE_ETH_FILTER_TUNNEL,
7124 &tunnel_filter_conf);
7126 ret = rte_eth_dev_filter_ctrl(res->port_id,
7127 RTE_ETH_FILTER_TUNNEL,
7128 RTE_ETH_FILTER_DELETE,
7129 &tunnel_filter_conf);
7131 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7135 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7136 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7137 cmd, "tunnel_filter");
7138 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7139 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7141 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7142 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7144 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7145 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7147 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7148 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7150 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7151 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7152 inner_vlan, UINT16);
7153 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7154 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7156 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7157 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7158 tunnel_type, "vxlan#nvgre#ipingre");
7160 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7161 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7162 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7163 "imac#omac-imac-tenid");
7164 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7165 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7167 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7168 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7171 cmdline_parse_inst_t cmd_tunnel_filter = {
7172 .f = cmd_tunnel_filter_parsed,
7174 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7175 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7176 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7177 "<queue_id>: Add/Rm tunnel filter of a port",
7179 (void *)&cmd_tunnel_filter_cmd,
7180 (void *)&cmd_tunnel_filter_what,
7181 (void *)&cmd_tunnel_filter_port_id,
7182 (void *)&cmd_tunnel_filter_outer_mac,
7183 (void *)&cmd_tunnel_filter_inner_mac,
7184 (void *)&cmd_tunnel_filter_ip_value,
7185 (void *)&cmd_tunnel_filter_innner_vlan,
7186 (void *)&cmd_tunnel_filter_tunnel_type,
7187 (void *)&cmd_tunnel_filter_filter_type,
7188 (void *)&cmd_tunnel_filter_tenant_id,
7189 (void *)&cmd_tunnel_filter_queue_num,
7194 /* *** CONFIGURE TUNNEL UDP PORT *** */
7195 struct cmd_tunnel_udp_config {
7196 cmdline_fixed_string_t cmd;
7197 cmdline_fixed_string_t what;
7203 cmd_tunnel_udp_config_parsed(void *parsed_result,
7204 __attribute__((unused)) struct cmdline *cl,
7205 __attribute__((unused)) void *data)
7207 struct cmd_tunnel_udp_config *res = parsed_result;
7208 struct rte_eth_udp_tunnel tunnel_udp;
7211 tunnel_udp.udp_port = res->udp_port;
7213 if (!strcmp(res->cmd, "rx_vxlan_port"))
7214 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7216 if (!strcmp(res->what, "add"))
7217 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7220 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7224 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7227 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7229 cmd, "rx_vxlan_port");
7230 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7231 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7233 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7234 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7236 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7237 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7240 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7241 .f = cmd_tunnel_udp_config_parsed,
7243 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7244 "Add/Remove a tunneling UDP port filter",
7246 (void *)&cmd_tunnel_udp_config_cmd,
7247 (void *)&cmd_tunnel_udp_config_what,
7248 (void *)&cmd_tunnel_udp_config_udp_port,
7249 (void *)&cmd_tunnel_udp_config_port_id,
7254 /* *** GLOBAL CONFIG *** */
7255 struct cmd_global_config_result {
7256 cmdline_fixed_string_t cmd;
7258 cmdline_fixed_string_t cfg_type;
7263 cmd_global_config_parsed(void *parsed_result,
7264 __attribute__((unused)) struct cmdline *cl,
7265 __attribute__((unused)) void *data)
7267 struct cmd_global_config_result *res = parsed_result;
7268 struct rte_eth_global_cfg conf;
7271 memset(&conf, 0, sizeof(conf));
7272 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7273 conf.cfg.gre_key_len = res->len;
7274 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7275 RTE_ETH_FILTER_SET, &conf);
7277 printf("Global config error\n");
7280 cmdline_parse_token_string_t cmd_global_config_cmd =
7281 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7283 cmdline_parse_token_num_t cmd_global_config_port_id =
7284 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7285 cmdline_parse_token_string_t cmd_global_config_type =
7286 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7287 cfg_type, "gre-key-len");
7288 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7289 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7292 cmdline_parse_inst_t cmd_global_config = {
7293 .f = cmd_global_config_parsed,
7294 .data = (void *)NULL,
7295 .help_str = "global_config <port_id> gre-key-len <key_len>",
7297 (void *)&cmd_global_config_cmd,
7298 (void *)&cmd_global_config_port_id,
7299 (void *)&cmd_global_config_type,
7300 (void *)&cmd_global_config_gre_key_len,
7305 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7306 struct cmd_set_mirror_mask_result {
7307 cmdline_fixed_string_t set;
7308 cmdline_fixed_string_t port;
7310 cmdline_fixed_string_t mirror;
7312 cmdline_fixed_string_t what;
7313 cmdline_fixed_string_t value;
7314 cmdline_fixed_string_t dstpool;
7316 cmdline_fixed_string_t on;
7319 cmdline_parse_token_string_t cmd_mirror_mask_set =
7320 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7322 cmdline_parse_token_string_t cmd_mirror_mask_port =
7323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7325 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7326 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7328 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7330 mirror, "mirror-rule");
7331 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7332 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7334 cmdline_parse_token_string_t cmd_mirror_mask_what =
7335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7336 what, "pool-mirror-up#pool-mirror-down"
7338 cmdline_parse_token_string_t cmd_mirror_mask_value =
7339 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7341 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7343 dstpool, "dst-pool");
7344 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7345 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7347 cmdline_parse_token_string_t cmd_mirror_mask_on =
7348 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7352 cmd_set_mirror_mask_parsed(void *parsed_result,
7353 __attribute__((unused)) struct cmdline *cl,
7354 __attribute__((unused)) void *data)
7357 struct cmd_set_mirror_mask_result *res = parsed_result;
7358 struct rte_eth_mirror_conf mr_conf;
7360 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7362 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7364 mr_conf.dst_pool = res->dstpool_id;
7366 if (!strcmp(res->what, "pool-mirror-up")) {
7367 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7368 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7369 } else if (!strcmp(res->what, "pool-mirror-down")) {
7370 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7371 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7372 } else if (!strcmp(res->what, "vlan-mirror")) {
7373 mr_conf.rule_type = ETH_MIRROR_VLAN;
7374 nb_item = parse_item_list(res->value, "vlan",
7375 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7379 for (i = 0; i < nb_item; i++) {
7380 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7381 printf("Invalid vlan_id: must be < 4096\n");
7385 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7386 mr_conf.vlan.vlan_mask |= 1ULL << i;
7390 if (!strcmp(res->on, "on"))
7391 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7394 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7397 printf("mirror rule add error: (%s)\n", strerror(-ret));
7400 cmdline_parse_inst_t cmd_set_mirror_mask = {
7401 .f = cmd_set_mirror_mask_parsed,
7403 .help_str = "set port <port_id> mirror-rule <rule_id> "
7404 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7405 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7407 (void *)&cmd_mirror_mask_set,
7408 (void *)&cmd_mirror_mask_port,
7409 (void *)&cmd_mirror_mask_portid,
7410 (void *)&cmd_mirror_mask_mirror,
7411 (void *)&cmd_mirror_mask_ruleid,
7412 (void *)&cmd_mirror_mask_what,
7413 (void *)&cmd_mirror_mask_value,
7414 (void *)&cmd_mirror_mask_dstpool,
7415 (void *)&cmd_mirror_mask_poolid,
7416 (void *)&cmd_mirror_mask_on,
7421 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7422 struct cmd_set_mirror_link_result {
7423 cmdline_fixed_string_t set;
7424 cmdline_fixed_string_t port;
7426 cmdline_fixed_string_t mirror;
7428 cmdline_fixed_string_t what;
7429 cmdline_fixed_string_t dstpool;
7431 cmdline_fixed_string_t on;
7434 cmdline_parse_token_string_t cmd_mirror_link_set =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7437 cmdline_parse_token_string_t cmd_mirror_link_port =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7440 cmdline_parse_token_num_t cmd_mirror_link_portid =
7441 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7443 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7444 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7445 mirror, "mirror-rule");
7446 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7447 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7449 cmdline_parse_token_string_t cmd_mirror_link_what =
7450 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7451 what, "uplink-mirror#downlink-mirror");
7452 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7453 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7454 dstpool, "dst-pool");
7455 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7456 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7458 cmdline_parse_token_string_t cmd_mirror_link_on =
7459 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7463 cmd_set_mirror_link_parsed(void *parsed_result,
7464 __attribute__((unused)) struct cmdline *cl,
7465 __attribute__((unused)) void *data)
7468 struct cmd_set_mirror_link_result *res = parsed_result;
7469 struct rte_eth_mirror_conf mr_conf;
7471 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7472 if (!strcmp(res->what, "uplink-mirror"))
7473 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7475 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7477 mr_conf.dst_pool = res->dstpool_id;
7479 if (!strcmp(res->on, "on"))
7480 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7483 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7486 /* check the return value and print it if is < 0 */
7488 printf("mirror rule add error: (%s)\n", strerror(-ret));
7492 cmdline_parse_inst_t cmd_set_mirror_link = {
7493 .f = cmd_set_mirror_link_parsed,
7495 .help_str = "set port <port_id> mirror-rule <rule_id> "
7496 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7498 (void *)&cmd_mirror_link_set,
7499 (void *)&cmd_mirror_link_port,
7500 (void *)&cmd_mirror_link_portid,
7501 (void *)&cmd_mirror_link_mirror,
7502 (void *)&cmd_mirror_link_ruleid,
7503 (void *)&cmd_mirror_link_what,
7504 (void *)&cmd_mirror_link_dstpool,
7505 (void *)&cmd_mirror_link_poolid,
7506 (void *)&cmd_mirror_link_on,
7511 /* *** RESET VM MIRROR RULE *** */
7512 struct cmd_rm_mirror_rule_result {
7513 cmdline_fixed_string_t reset;
7514 cmdline_fixed_string_t port;
7516 cmdline_fixed_string_t mirror;
7520 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7521 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7523 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7524 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7526 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7527 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7529 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7530 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7531 mirror, "mirror-rule");
7532 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7533 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7537 cmd_reset_mirror_rule_parsed(void *parsed_result,
7538 __attribute__((unused)) struct cmdline *cl,
7539 __attribute__((unused)) void *data)
7542 struct cmd_set_mirror_link_result *res = parsed_result;
7544 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7546 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7549 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7550 .f = cmd_reset_mirror_rule_parsed,
7552 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7554 (void *)&cmd_rm_mirror_rule_reset,
7555 (void *)&cmd_rm_mirror_rule_port,
7556 (void *)&cmd_rm_mirror_rule_portid,
7557 (void *)&cmd_rm_mirror_rule_mirror,
7558 (void *)&cmd_rm_mirror_rule_ruleid,
7563 /* ******************************************************************************** */
7565 struct cmd_dump_result {
7566 cmdline_fixed_string_t dump;
7570 dump_struct_sizes(void)
7572 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7573 DUMP_SIZE(struct rte_mbuf);
7574 DUMP_SIZE(struct rte_mempool);
7575 DUMP_SIZE(struct rte_ring);
7579 static void cmd_dump_parsed(void *parsed_result,
7580 __attribute__((unused)) struct cmdline *cl,
7581 __attribute__((unused)) void *data)
7583 struct cmd_dump_result *res = parsed_result;
7585 if (!strcmp(res->dump, "dump_physmem"))
7586 rte_dump_physmem_layout(stdout);
7587 else if (!strcmp(res->dump, "dump_memzone"))
7588 rte_memzone_dump(stdout);
7589 else if (!strcmp(res->dump, "dump_struct_sizes"))
7590 dump_struct_sizes();
7591 else if (!strcmp(res->dump, "dump_ring"))
7592 rte_ring_list_dump(stdout);
7593 else if (!strcmp(res->dump, "dump_mempool"))
7594 rte_mempool_list_dump(stdout);
7595 else if (!strcmp(res->dump, "dump_devargs"))
7596 rte_eal_devargs_dump(stdout);
7599 cmdline_parse_token_string_t cmd_dump_dump =
7600 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7603 "dump_struct_sizes#"
7608 cmdline_parse_inst_t cmd_dump = {
7609 .f = cmd_dump_parsed, /* function to call */
7610 .data = NULL, /* 2nd arg of func */
7611 .help_str = "Dump status",
7612 .tokens = { /* token list, NULL terminated */
7613 (void *)&cmd_dump_dump,
7618 /* ******************************************************************************** */
7620 struct cmd_dump_one_result {
7621 cmdline_fixed_string_t dump;
7622 cmdline_fixed_string_t name;
7625 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7626 __attribute__((unused)) void *data)
7628 struct cmd_dump_one_result *res = parsed_result;
7630 if (!strcmp(res->dump, "dump_ring")) {
7632 r = rte_ring_lookup(res->name);
7634 cmdline_printf(cl, "Cannot find ring\n");
7637 rte_ring_dump(stdout, r);
7638 } else if (!strcmp(res->dump, "dump_mempool")) {
7639 struct rte_mempool *mp;
7640 mp = rte_mempool_lookup(res->name);
7642 cmdline_printf(cl, "Cannot find mempool\n");
7645 rte_mempool_dump(stdout, mp);
7649 cmdline_parse_token_string_t cmd_dump_one_dump =
7650 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7651 "dump_ring#dump_mempool");
7653 cmdline_parse_token_string_t cmd_dump_one_name =
7654 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7656 cmdline_parse_inst_t cmd_dump_one = {
7657 .f = cmd_dump_one_parsed, /* function to call */
7658 .data = NULL, /* 2nd arg of func */
7659 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7660 .tokens = { /* token list, NULL terminated */
7661 (void *)&cmd_dump_one_dump,
7662 (void *)&cmd_dump_one_name,
7667 /* *** Add/Del syn filter *** */
7668 struct cmd_syn_filter_result {
7669 cmdline_fixed_string_t filter;
7671 cmdline_fixed_string_t ops;
7672 cmdline_fixed_string_t priority;
7673 cmdline_fixed_string_t high;
7674 cmdline_fixed_string_t queue;
7679 cmd_syn_filter_parsed(void *parsed_result,
7680 __attribute__((unused)) struct cmdline *cl,
7681 __attribute__((unused)) void *data)
7683 struct cmd_syn_filter_result *res = parsed_result;
7684 struct rte_eth_syn_filter syn_filter;
7687 ret = rte_eth_dev_filter_supported(res->port_id,
7688 RTE_ETH_FILTER_SYN);
7690 printf("syn filter is not supported on port %u.\n",
7695 memset(&syn_filter, 0, sizeof(syn_filter));
7697 if (!strcmp(res->ops, "add")) {
7698 if (!strcmp(res->high, "high"))
7699 syn_filter.hig_pri = 1;
7701 syn_filter.hig_pri = 0;
7703 syn_filter.queue = res->queue_id;
7704 ret = rte_eth_dev_filter_ctrl(res->port_id,
7709 ret = rte_eth_dev_filter_ctrl(res->port_id,
7711 RTE_ETH_FILTER_DELETE,
7715 printf("syn filter programming error: (%s)\n",
7719 cmdline_parse_token_string_t cmd_syn_filter_filter =
7720 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7721 filter, "syn_filter");
7722 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7723 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7725 cmdline_parse_token_string_t cmd_syn_filter_ops =
7726 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7728 cmdline_parse_token_string_t cmd_syn_filter_priority =
7729 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7730 priority, "priority");
7731 cmdline_parse_token_string_t cmd_syn_filter_high =
7732 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7734 cmdline_parse_token_string_t cmd_syn_filter_queue =
7735 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7737 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7738 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7741 cmdline_parse_inst_t cmd_syn_filter = {
7742 .f = cmd_syn_filter_parsed,
7744 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7745 "<queue_id>: Add/Delete syn filter",
7747 (void *)&cmd_syn_filter_filter,
7748 (void *)&cmd_syn_filter_port_id,
7749 (void *)&cmd_syn_filter_ops,
7750 (void *)&cmd_syn_filter_priority,
7751 (void *)&cmd_syn_filter_high,
7752 (void *)&cmd_syn_filter_queue,
7753 (void *)&cmd_syn_filter_queue_id,
7758 /* *** ADD/REMOVE A 2tuple FILTER *** */
7759 struct cmd_2tuple_filter_result {
7760 cmdline_fixed_string_t filter;
7762 cmdline_fixed_string_t ops;
7763 cmdline_fixed_string_t dst_port;
7764 uint16_t dst_port_value;
7765 cmdline_fixed_string_t protocol;
7766 uint8_t protocol_value;
7767 cmdline_fixed_string_t mask;
7769 cmdline_fixed_string_t tcp_flags;
7770 uint8_t tcp_flags_value;
7771 cmdline_fixed_string_t priority;
7772 uint8_t priority_value;
7773 cmdline_fixed_string_t queue;
7778 cmd_2tuple_filter_parsed(void *parsed_result,
7779 __attribute__((unused)) struct cmdline *cl,
7780 __attribute__((unused)) void *data)
7782 struct rte_eth_ntuple_filter filter;
7783 struct cmd_2tuple_filter_result *res = parsed_result;
7786 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7788 printf("ntuple filter is not supported on port %u.\n",
7793 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7795 filter.flags = RTE_2TUPLE_FLAGS;
7796 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7797 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7798 filter.proto = res->protocol_value;
7799 filter.priority = res->priority_value;
7800 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7801 printf("nonzero tcp_flags is only meaningful"
7802 " when protocol is TCP.\n");
7805 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7806 printf("invalid TCP flags.\n");
7810 if (res->tcp_flags_value != 0) {
7811 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7812 filter.tcp_flags = res->tcp_flags_value;
7815 /* need convert to big endian. */
7816 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7817 filter.queue = res->queue_id;
7819 if (!strcmp(res->ops, "add"))
7820 ret = rte_eth_dev_filter_ctrl(res->port_id,
7821 RTE_ETH_FILTER_NTUPLE,
7825 ret = rte_eth_dev_filter_ctrl(res->port_id,
7826 RTE_ETH_FILTER_NTUPLE,
7827 RTE_ETH_FILTER_DELETE,
7830 printf("2tuple filter programming error: (%s)\n",
7835 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7836 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7837 filter, "2tuple_filter");
7838 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7839 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7841 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7842 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7844 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7845 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7846 dst_port, "dst_port");
7847 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7848 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7849 dst_port_value, UINT16);
7850 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7851 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7852 protocol, "protocol");
7853 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7854 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7855 protocol_value, UINT8);
7856 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7857 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7859 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7860 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7862 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7863 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7864 tcp_flags, "tcp_flags");
7865 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7866 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7867 tcp_flags_value, UINT8);
7868 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7869 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7870 priority, "priority");
7871 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7872 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7873 priority_value, UINT8);
7874 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7875 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7877 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7878 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7881 cmdline_parse_inst_t cmd_2tuple_filter = {
7882 .f = cmd_2tuple_filter_parsed,
7884 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7885 "<value> mask <value> tcp_flags <value> priority <value> queue "
7886 "<queue_id>: Add a 2tuple filter",
7888 (void *)&cmd_2tuple_filter_filter,
7889 (void *)&cmd_2tuple_filter_port_id,
7890 (void *)&cmd_2tuple_filter_ops,
7891 (void *)&cmd_2tuple_filter_dst_port,
7892 (void *)&cmd_2tuple_filter_dst_port_value,
7893 (void *)&cmd_2tuple_filter_protocol,
7894 (void *)&cmd_2tuple_filter_protocol_value,
7895 (void *)&cmd_2tuple_filter_mask,
7896 (void *)&cmd_2tuple_filter_mask_value,
7897 (void *)&cmd_2tuple_filter_tcp_flags,
7898 (void *)&cmd_2tuple_filter_tcp_flags_value,
7899 (void *)&cmd_2tuple_filter_priority,
7900 (void *)&cmd_2tuple_filter_priority_value,
7901 (void *)&cmd_2tuple_filter_queue,
7902 (void *)&cmd_2tuple_filter_queue_id,
7907 /* *** ADD/REMOVE A 5tuple FILTER *** */
7908 struct cmd_5tuple_filter_result {
7909 cmdline_fixed_string_t filter;
7911 cmdline_fixed_string_t ops;
7912 cmdline_fixed_string_t dst_ip;
7913 cmdline_ipaddr_t dst_ip_value;
7914 cmdline_fixed_string_t src_ip;
7915 cmdline_ipaddr_t src_ip_value;
7916 cmdline_fixed_string_t dst_port;
7917 uint16_t dst_port_value;
7918 cmdline_fixed_string_t src_port;
7919 uint16_t src_port_value;
7920 cmdline_fixed_string_t protocol;
7921 uint8_t protocol_value;
7922 cmdline_fixed_string_t mask;
7924 cmdline_fixed_string_t tcp_flags;
7925 uint8_t tcp_flags_value;
7926 cmdline_fixed_string_t priority;
7927 uint8_t priority_value;
7928 cmdline_fixed_string_t queue;
7933 cmd_5tuple_filter_parsed(void *parsed_result,
7934 __attribute__((unused)) struct cmdline *cl,
7935 __attribute__((unused)) void *data)
7937 struct rte_eth_ntuple_filter filter;
7938 struct cmd_5tuple_filter_result *res = parsed_result;
7941 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7943 printf("ntuple filter is not supported on port %u.\n",
7948 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7950 filter.flags = RTE_5TUPLE_FLAGS;
7951 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7952 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7953 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7954 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7955 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7956 filter.proto = res->protocol_value;
7957 filter.priority = res->priority_value;
7958 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7959 printf("nonzero tcp_flags is only meaningful"
7960 " when protocol is TCP.\n");
7963 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7964 printf("invalid TCP flags.\n");
7968 if (res->tcp_flags_value != 0) {
7969 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7970 filter.tcp_flags = res->tcp_flags_value;
7973 if (res->dst_ip_value.family == AF_INET)
7974 /* no need to convert, already big endian. */
7975 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7977 if (filter.dst_ip_mask == 0) {
7978 printf("can not support ipv6 involved compare.\n");
7984 if (res->src_ip_value.family == AF_INET)
7985 /* no need to convert, already big endian. */
7986 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7988 if (filter.src_ip_mask == 0) {
7989 printf("can not support ipv6 involved compare.\n");
7994 /* need convert to big endian. */
7995 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7996 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7997 filter.queue = res->queue_id;
7999 if (!strcmp(res->ops, "add"))
8000 ret = rte_eth_dev_filter_ctrl(res->port_id,
8001 RTE_ETH_FILTER_NTUPLE,
8005 ret = rte_eth_dev_filter_ctrl(res->port_id,
8006 RTE_ETH_FILTER_NTUPLE,
8007 RTE_ETH_FILTER_DELETE,
8010 printf("5tuple filter programming error: (%s)\n",
8014 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8015 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8016 filter, "5tuple_filter");
8017 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8018 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8020 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8021 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8023 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8024 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8026 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8027 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8029 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8030 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8032 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8033 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8035 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8036 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8037 dst_port, "dst_port");
8038 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8039 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8040 dst_port_value, UINT16);
8041 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8042 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8043 src_port, "src_port");
8044 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8045 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8046 src_port_value, UINT16);
8047 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8048 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8049 protocol, "protocol");
8050 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8051 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8052 protocol_value, UINT8);
8053 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8054 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8056 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8057 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8059 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8060 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8061 tcp_flags, "tcp_flags");
8062 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8063 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8064 tcp_flags_value, UINT8);
8065 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8067 priority, "priority");
8068 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8069 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8070 priority_value, UINT8);
8071 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8072 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8074 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8075 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8078 cmdline_parse_inst_t cmd_5tuple_filter = {
8079 .f = cmd_5tuple_filter_parsed,
8081 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8082 "src_ip <value> dst_port <value> src_port <value> "
8083 "protocol <value> mask <value> tcp_flags <value> "
8084 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8086 (void *)&cmd_5tuple_filter_filter,
8087 (void *)&cmd_5tuple_filter_port_id,
8088 (void *)&cmd_5tuple_filter_ops,
8089 (void *)&cmd_5tuple_filter_dst_ip,
8090 (void *)&cmd_5tuple_filter_dst_ip_value,
8091 (void *)&cmd_5tuple_filter_src_ip,
8092 (void *)&cmd_5tuple_filter_src_ip_value,
8093 (void *)&cmd_5tuple_filter_dst_port,
8094 (void *)&cmd_5tuple_filter_dst_port_value,
8095 (void *)&cmd_5tuple_filter_src_port,
8096 (void *)&cmd_5tuple_filter_src_port_value,
8097 (void *)&cmd_5tuple_filter_protocol,
8098 (void *)&cmd_5tuple_filter_protocol_value,
8099 (void *)&cmd_5tuple_filter_mask,
8100 (void *)&cmd_5tuple_filter_mask_value,
8101 (void *)&cmd_5tuple_filter_tcp_flags,
8102 (void *)&cmd_5tuple_filter_tcp_flags_value,
8103 (void *)&cmd_5tuple_filter_priority,
8104 (void *)&cmd_5tuple_filter_priority_value,
8105 (void *)&cmd_5tuple_filter_queue,
8106 (void *)&cmd_5tuple_filter_queue_id,
8111 /* *** ADD/REMOVE A flex FILTER *** */
8112 struct cmd_flex_filter_result {
8113 cmdline_fixed_string_t filter;
8114 cmdline_fixed_string_t ops;
8116 cmdline_fixed_string_t len;
8118 cmdline_fixed_string_t bytes;
8119 cmdline_fixed_string_t bytes_value;
8120 cmdline_fixed_string_t mask;
8121 cmdline_fixed_string_t mask_value;
8122 cmdline_fixed_string_t priority;
8123 uint8_t priority_value;
8124 cmdline_fixed_string_t queue;
8128 static int xdigit2val(unsigned char c)
8133 else if (isupper(c))
8141 cmd_flex_filter_parsed(void *parsed_result,
8142 __attribute__((unused)) struct cmdline *cl,
8143 __attribute__((unused)) void *data)
8146 struct rte_eth_flex_filter filter;
8147 struct cmd_flex_filter_result *res = parsed_result;
8148 char *bytes_ptr, *mask_ptr;
8149 uint16_t len, i, j = 0;
8154 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8155 printf("the len exceed the max length 128\n");
8158 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8159 filter.len = res->len_value;
8160 filter.priority = res->priority_value;
8161 filter.queue = res->queue_id;
8162 bytes_ptr = res->bytes_value;
8163 mask_ptr = res->mask_value;
8165 /* translate bytes string to array. */
8166 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8167 (bytes_ptr[1] == 'X')))
8169 len = strnlen(bytes_ptr, res->len_value * 2);
8170 if (len == 0 || (len % 8 != 0)) {
8171 printf("please check len and bytes input\n");
8174 for (i = 0; i < len; i++) {
8176 if (isxdigit(c) == 0) {
8177 /* invalid characters. */
8178 printf("invalid input\n");
8181 val = xdigit2val(c);
8184 filter.bytes[j] = byte;
8185 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8192 /* translate mask string to uint8_t array. */
8193 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8194 (mask_ptr[1] == 'X')))
8196 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8198 printf("invalid input\n");
8203 for (i = 0; i < len; i++) {
8205 if (isxdigit(c) == 0) {
8206 /* invalid characters. */
8207 printf("invalid input\n");
8210 val = xdigit2val(c);
8213 filter.mask[j] = byte;
8214 printf("mask[%d]:%02x ", j, filter.mask[j]);
8222 if (!strcmp(res->ops, "add"))
8223 ret = rte_eth_dev_filter_ctrl(res->port_id,
8224 RTE_ETH_FILTER_FLEXIBLE,
8228 ret = rte_eth_dev_filter_ctrl(res->port_id,
8229 RTE_ETH_FILTER_FLEXIBLE,
8230 RTE_ETH_FILTER_DELETE,
8234 printf("flex filter setting error: (%s)\n", strerror(-ret));
8237 cmdline_parse_token_string_t cmd_flex_filter_filter =
8238 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8239 filter, "flex_filter");
8240 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8241 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8243 cmdline_parse_token_string_t cmd_flex_filter_ops =
8244 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8246 cmdline_parse_token_string_t cmd_flex_filter_len =
8247 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8249 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8250 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8252 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8253 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8255 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8256 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8258 cmdline_parse_token_string_t cmd_flex_filter_mask =
8259 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8261 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8262 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8264 cmdline_parse_token_string_t cmd_flex_filter_priority =
8265 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8266 priority, "priority");
8267 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8268 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8269 priority_value, UINT8);
8270 cmdline_parse_token_string_t cmd_flex_filter_queue =
8271 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8273 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8274 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8276 cmdline_parse_inst_t cmd_flex_filter = {
8277 .f = cmd_flex_filter_parsed,
8279 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8280 "<value> mask <value> priority <value> queue <queue_id>: "
8281 "Add/Del a flex filter",
8283 (void *)&cmd_flex_filter_filter,
8284 (void *)&cmd_flex_filter_port_id,
8285 (void *)&cmd_flex_filter_ops,
8286 (void *)&cmd_flex_filter_len,
8287 (void *)&cmd_flex_filter_len_value,
8288 (void *)&cmd_flex_filter_bytes,
8289 (void *)&cmd_flex_filter_bytes_value,
8290 (void *)&cmd_flex_filter_mask,
8291 (void *)&cmd_flex_filter_mask_value,
8292 (void *)&cmd_flex_filter_priority,
8293 (void *)&cmd_flex_filter_priority_value,
8294 (void *)&cmd_flex_filter_queue,
8295 (void *)&cmd_flex_filter_queue_id,
8300 /* *** Filters Control *** */
8302 /* *** deal with ethertype filter *** */
8303 struct cmd_ethertype_filter_result {
8304 cmdline_fixed_string_t filter;
8306 cmdline_fixed_string_t ops;
8307 cmdline_fixed_string_t mac;
8308 struct ether_addr mac_addr;
8309 cmdline_fixed_string_t ethertype;
8310 uint16_t ethertype_value;
8311 cmdline_fixed_string_t drop;
8312 cmdline_fixed_string_t queue;
8316 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8317 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8318 filter, "ethertype_filter");
8319 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8320 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8322 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8323 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8325 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8326 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8327 mac, "mac_addr#mac_ignr");
8328 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8329 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8331 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8332 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8333 ethertype, "ethertype");
8334 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8335 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8336 ethertype_value, UINT16);
8337 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8338 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8340 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8341 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8343 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8344 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8348 cmd_ethertype_filter_parsed(void *parsed_result,
8349 __attribute__((unused)) struct cmdline *cl,
8350 __attribute__((unused)) void *data)
8352 struct cmd_ethertype_filter_result *res = parsed_result;
8353 struct rte_eth_ethertype_filter filter;
8356 ret = rte_eth_dev_filter_supported(res->port_id,
8357 RTE_ETH_FILTER_ETHERTYPE);
8359 printf("ethertype filter is not supported on port %u.\n",
8364 memset(&filter, 0, sizeof(filter));
8365 if (!strcmp(res->mac, "mac_addr")) {
8366 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8367 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8368 sizeof(struct ether_addr));
8370 if (!strcmp(res->drop, "drop"))
8371 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8372 filter.ether_type = res->ethertype_value;
8373 filter.queue = res->queue_id;
8375 if (!strcmp(res->ops, "add"))
8376 ret = rte_eth_dev_filter_ctrl(res->port_id,
8377 RTE_ETH_FILTER_ETHERTYPE,
8381 ret = rte_eth_dev_filter_ctrl(res->port_id,
8382 RTE_ETH_FILTER_ETHERTYPE,
8383 RTE_ETH_FILTER_DELETE,
8386 printf("ethertype filter programming error: (%s)\n",
8390 cmdline_parse_inst_t cmd_ethertype_filter = {
8391 .f = cmd_ethertype_filter_parsed,
8393 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8394 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8395 "Add or delete an ethertype filter entry",
8397 (void *)&cmd_ethertype_filter_filter,
8398 (void *)&cmd_ethertype_filter_port_id,
8399 (void *)&cmd_ethertype_filter_ops,
8400 (void *)&cmd_ethertype_filter_mac,
8401 (void *)&cmd_ethertype_filter_mac_addr,
8402 (void *)&cmd_ethertype_filter_ethertype,
8403 (void *)&cmd_ethertype_filter_ethertype_value,
8404 (void *)&cmd_ethertype_filter_drop,
8405 (void *)&cmd_ethertype_filter_queue,
8406 (void *)&cmd_ethertype_filter_queue_id,
8411 /* *** deal with flow director filter *** */
8412 struct cmd_flow_director_result {
8413 cmdline_fixed_string_t flow_director_filter;
8415 cmdline_fixed_string_t mode;
8416 cmdline_fixed_string_t mode_value;
8417 cmdline_fixed_string_t ops;
8418 cmdline_fixed_string_t flow;
8419 cmdline_fixed_string_t flow_type;
8420 cmdline_fixed_string_t ether;
8421 uint16_t ether_type;
8422 cmdline_fixed_string_t src;
8423 cmdline_ipaddr_t ip_src;
8425 cmdline_fixed_string_t dst;
8426 cmdline_ipaddr_t ip_dst;
8428 cmdline_fixed_string_t verify_tag;
8429 uint32_t verify_tag_value;
8430 cmdline_ipaddr_t tos;
8432 cmdline_ipaddr_t proto;
8433 uint8_t proto_value;
8434 cmdline_ipaddr_t ttl;
8436 cmdline_fixed_string_t vlan;
8437 uint16_t vlan_value;
8438 cmdline_fixed_string_t flexbytes;
8439 cmdline_fixed_string_t flexbytes_value;
8440 cmdline_fixed_string_t pf_vf;
8441 cmdline_fixed_string_t drop;
8442 cmdline_fixed_string_t queue;
8444 cmdline_fixed_string_t fd_id;
8445 uint32_t fd_id_value;
8446 cmdline_fixed_string_t mac;
8447 struct ether_addr mac_addr;
8448 cmdline_fixed_string_t tunnel;
8449 cmdline_fixed_string_t tunnel_type;
8450 cmdline_fixed_string_t tunnel_id;
8451 uint32_t tunnel_id_value;
8455 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8458 const char *p, *p0 = q_arg;
8460 unsigned long int_fld;
8461 char *str_fld[max_num];
8466 p = strchr(p0, '(');
8470 p0 = strchr(p, ')');
8475 if (size >= sizeof(s))
8478 snprintf(s, sizeof(s), "%.*s", size, p);
8479 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8480 if (ret < 0 || ret > max_num)
8482 for (i = 0; i < ret; i++) {
8484 int_fld = strtoul(str_fld[i], &end, 0);
8485 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8487 flexbytes[i] = (uint8_t)int_fld;
8493 str2flowtype(char *string)
8496 static const struct {
8499 } flowtype_str[] = {
8500 {"raw", RTE_ETH_FLOW_RAW},
8501 {"ipv4", RTE_ETH_FLOW_IPV4},
8502 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8503 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8504 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8505 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8506 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8507 {"ipv6", RTE_ETH_FLOW_IPV6},
8508 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8509 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8510 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8511 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8512 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8513 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8516 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8517 if (!strcmp(flowtype_str[i].str, string))
8518 return flowtype_str[i].type;
8520 return RTE_ETH_FLOW_UNKNOWN;
8523 static enum rte_eth_fdir_tunnel_type
8524 str2fdir_tunneltype(char *string)
8528 static const struct {
8530 enum rte_eth_fdir_tunnel_type type;
8531 } tunneltype_str[] = {
8532 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8533 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8536 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8537 if (!strcmp(tunneltype_str[i].str, string))
8538 return tunneltype_str[i].type;
8540 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8543 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8545 if ((ip_addr).family == AF_INET) \
8546 (ip) = (ip_addr).addr.ipv4.s_addr; \
8548 printf("invalid parameter.\n"); \
8553 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8555 if ((ip_addr).family == AF_INET6) \
8556 (void)rte_memcpy(&(ip), \
8557 &((ip_addr).addr.ipv6), \
8558 sizeof(struct in6_addr)); \
8560 printf("invalid parameter.\n"); \
8566 cmd_flow_director_filter_parsed(void *parsed_result,
8567 __attribute__((unused)) struct cmdline *cl,
8568 __attribute__((unused)) void *data)
8570 struct cmd_flow_director_result *res = parsed_result;
8571 struct rte_eth_fdir_filter entry;
8572 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8574 unsigned long vf_id;
8577 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8579 printf("flow director is not supported on port %u.\n",
8583 memset(flexbytes, 0, sizeof(flexbytes));
8584 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8586 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8587 if (strcmp(res->mode_value, "MAC-VLAN")) {
8588 printf("Please set mode to MAC-VLAN.\n");
8591 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8592 if (strcmp(res->mode_value, "Tunnel")) {
8593 printf("Please set mode to Tunnel.\n");
8597 if (strcmp(res->mode_value, "IP")) {
8598 printf("Please set mode to IP.\n");
8601 entry.input.flow_type = str2flowtype(res->flow_type);
8604 ret = parse_flexbytes(res->flexbytes_value,
8606 RTE_ETH_FDIR_MAX_FLEXLEN);
8608 printf("error: Cannot parse flexbytes input.\n");
8612 switch (entry.input.flow_type) {
8613 case RTE_ETH_FLOW_FRAG_IPV4:
8614 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8615 entry.input.flow.ip4_flow.proto = res->proto_value;
8616 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8617 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8618 IPV4_ADDR_TO_UINT(res->ip_dst,
8619 entry.input.flow.ip4_flow.dst_ip);
8620 IPV4_ADDR_TO_UINT(res->ip_src,
8621 entry.input.flow.ip4_flow.src_ip);
8622 entry.input.flow.ip4_flow.tos = res->tos_value;
8623 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8624 /* need convert to big endian. */
8625 entry.input.flow.udp4_flow.dst_port =
8626 rte_cpu_to_be_16(res->port_dst);
8627 entry.input.flow.udp4_flow.src_port =
8628 rte_cpu_to_be_16(res->port_src);
8630 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8631 IPV4_ADDR_TO_UINT(res->ip_dst,
8632 entry.input.flow.sctp4_flow.ip.dst_ip);
8633 IPV4_ADDR_TO_UINT(res->ip_src,
8634 entry.input.flow.sctp4_flow.ip.src_ip);
8635 entry.input.flow.ip4_flow.tos = res->tos_value;
8636 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8637 /* need convert to big endian. */
8638 entry.input.flow.sctp4_flow.dst_port =
8639 rte_cpu_to_be_16(res->port_dst);
8640 entry.input.flow.sctp4_flow.src_port =
8641 rte_cpu_to_be_16(res->port_src);
8642 entry.input.flow.sctp4_flow.verify_tag =
8643 rte_cpu_to_be_32(res->verify_tag_value);
8645 case RTE_ETH_FLOW_FRAG_IPV6:
8646 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8647 entry.input.flow.ipv6_flow.proto = res->proto_value;
8648 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8649 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8650 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8651 entry.input.flow.ipv6_flow.dst_ip);
8652 IPV6_ADDR_TO_ARRAY(res->ip_src,
8653 entry.input.flow.ipv6_flow.src_ip);
8654 entry.input.flow.ipv6_flow.tc = res->tos_value;
8655 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8656 /* need convert to big endian. */
8657 entry.input.flow.udp6_flow.dst_port =
8658 rte_cpu_to_be_16(res->port_dst);
8659 entry.input.flow.udp6_flow.src_port =
8660 rte_cpu_to_be_16(res->port_src);
8662 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8663 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8664 entry.input.flow.sctp6_flow.ip.dst_ip);
8665 IPV6_ADDR_TO_ARRAY(res->ip_src,
8666 entry.input.flow.sctp6_flow.ip.src_ip);
8667 entry.input.flow.ipv6_flow.tc = res->tos_value;
8668 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8669 /* need convert to big endian. */
8670 entry.input.flow.sctp6_flow.dst_port =
8671 rte_cpu_to_be_16(res->port_dst);
8672 entry.input.flow.sctp6_flow.src_port =
8673 rte_cpu_to_be_16(res->port_src);
8674 entry.input.flow.sctp6_flow.verify_tag =
8675 rte_cpu_to_be_32(res->verify_tag_value);
8677 case RTE_ETH_FLOW_L2_PAYLOAD:
8678 entry.input.flow.l2_flow.ether_type =
8679 rte_cpu_to_be_16(res->ether_type);
8685 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8686 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8688 sizeof(struct ether_addr));
8690 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8691 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8693 sizeof(struct ether_addr));
8694 entry.input.flow.tunnel_flow.tunnel_type =
8695 str2fdir_tunneltype(res->tunnel_type);
8696 entry.input.flow.tunnel_flow.tunnel_id =
8697 rte_cpu_to_be_32(res->tunnel_id_value);
8700 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8702 RTE_ETH_FDIR_MAX_FLEXLEN);
8704 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8706 entry.action.flex_off = 0; /*use 0 by default */
8707 if (!strcmp(res->drop, "drop"))
8708 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8710 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8712 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8713 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8714 if (!strcmp(res->pf_vf, "pf"))
8715 entry.input.flow_ext.is_vf = 0;
8716 else if (!strncmp(res->pf_vf, "vf", 2)) {
8717 struct rte_eth_dev_info dev_info;
8719 memset(&dev_info, 0, sizeof(dev_info));
8720 rte_eth_dev_info_get(res->port_id, &dev_info);
8722 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8723 if (errno != 0 || *end != '\0' ||
8724 vf_id >= dev_info.max_vfs) {
8725 printf("invalid parameter %s.\n", res->pf_vf);
8728 entry.input.flow_ext.is_vf = 1;
8729 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8731 printf("invalid parameter %s.\n", res->pf_vf);
8736 /* set to report FD ID by default */
8737 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8738 entry.action.rx_queue = res->queue_id;
8739 entry.soft_id = res->fd_id_value;
8740 if (!strcmp(res->ops, "add"))
8741 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8742 RTE_ETH_FILTER_ADD, &entry);
8743 else if (!strcmp(res->ops, "del"))
8744 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8745 RTE_ETH_FILTER_DELETE, &entry);
8747 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8748 RTE_ETH_FILTER_UPDATE, &entry);
8750 printf("flow director programming error: (%s)\n",
8754 cmdline_parse_token_string_t cmd_flow_director_filter =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8756 flow_director_filter, "flow_director_filter");
8757 cmdline_parse_token_num_t cmd_flow_director_port_id =
8758 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8760 cmdline_parse_token_string_t cmd_flow_director_ops =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8762 ops, "add#del#update");
8763 cmdline_parse_token_string_t cmd_flow_director_flow =
8764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8766 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8768 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8769 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8770 cmdline_parse_token_string_t cmd_flow_director_ether =
8771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8773 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8774 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8775 ether_type, UINT16);
8776 cmdline_parse_token_string_t cmd_flow_director_src =
8777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8779 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8780 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8782 cmdline_parse_token_num_t cmd_flow_director_port_src =
8783 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8785 cmdline_parse_token_string_t cmd_flow_director_dst =
8786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8788 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8789 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8791 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8792 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8794 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8796 verify_tag, "verify_tag");
8797 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8798 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8799 verify_tag_value, UINT32);
8800 cmdline_parse_token_string_t cmd_flow_director_tos =
8801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8803 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8804 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8806 cmdline_parse_token_string_t cmd_flow_director_proto =
8807 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8809 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8810 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8811 proto_value, UINT8);
8812 cmdline_parse_token_string_t cmd_flow_director_ttl =
8813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8815 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8818 cmdline_parse_token_string_t cmd_flow_director_vlan =
8819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8821 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8823 vlan_value, UINT16);
8824 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8826 flexbytes, "flexbytes");
8827 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8829 flexbytes_value, NULL);
8830 cmdline_parse_token_string_t cmd_flow_director_drop =
8831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8836 cmdline_parse_token_string_t cmd_flow_director_queue =
8837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8842 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8847 fd_id_value, UINT32);
8849 cmdline_parse_token_string_t cmd_flow_director_mode =
8850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8852 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8855 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8857 mode_value, "MAC-VLAN");
8858 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8860 mode_value, "Tunnel");
8861 cmdline_parse_token_string_t cmd_flow_director_mac =
8862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8864 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8865 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8867 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8870 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8872 tunnel_type, "NVGRE#VxLAN");
8873 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8875 tunnel_id, "tunnel-id");
8876 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8878 tunnel_id_value, UINT32);
8880 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8881 .f = cmd_flow_director_filter_parsed,
8883 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8884 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8885 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8886 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8887 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8888 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8889 "fd_id <fd_id_value>: "
8890 "Add or delete an ip flow director entry on NIC",
8892 (void *)&cmd_flow_director_filter,
8893 (void *)&cmd_flow_director_port_id,
8894 (void *)&cmd_flow_director_mode,
8895 (void *)&cmd_flow_director_mode_ip,
8896 (void *)&cmd_flow_director_ops,
8897 (void *)&cmd_flow_director_flow,
8898 (void *)&cmd_flow_director_flow_type,
8899 (void *)&cmd_flow_director_src,
8900 (void *)&cmd_flow_director_ip_src,
8901 (void *)&cmd_flow_director_dst,
8902 (void *)&cmd_flow_director_ip_dst,
8903 (void *)&cmd_flow_director_tos,
8904 (void *)&cmd_flow_director_tos_value,
8905 (void *)&cmd_flow_director_proto,
8906 (void *)&cmd_flow_director_proto_value,
8907 (void *)&cmd_flow_director_ttl,
8908 (void *)&cmd_flow_director_ttl_value,
8909 (void *)&cmd_flow_director_vlan,
8910 (void *)&cmd_flow_director_vlan_value,
8911 (void *)&cmd_flow_director_flexbytes,
8912 (void *)&cmd_flow_director_flexbytes_value,
8913 (void *)&cmd_flow_director_drop,
8914 (void *)&cmd_flow_director_pf_vf,
8915 (void *)&cmd_flow_director_queue,
8916 (void *)&cmd_flow_director_queue_id,
8917 (void *)&cmd_flow_director_fd_id,
8918 (void *)&cmd_flow_director_fd_id_value,
8923 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8924 .f = cmd_flow_director_filter_parsed,
8926 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8927 "director entry on NIC",
8929 (void *)&cmd_flow_director_filter,
8930 (void *)&cmd_flow_director_port_id,
8931 (void *)&cmd_flow_director_mode,
8932 (void *)&cmd_flow_director_mode_ip,
8933 (void *)&cmd_flow_director_ops,
8934 (void *)&cmd_flow_director_flow,
8935 (void *)&cmd_flow_director_flow_type,
8936 (void *)&cmd_flow_director_src,
8937 (void *)&cmd_flow_director_ip_src,
8938 (void *)&cmd_flow_director_port_src,
8939 (void *)&cmd_flow_director_dst,
8940 (void *)&cmd_flow_director_ip_dst,
8941 (void *)&cmd_flow_director_port_dst,
8942 (void *)&cmd_flow_director_tos,
8943 (void *)&cmd_flow_director_tos_value,
8944 (void *)&cmd_flow_director_ttl,
8945 (void *)&cmd_flow_director_ttl_value,
8946 (void *)&cmd_flow_director_vlan,
8947 (void *)&cmd_flow_director_vlan_value,
8948 (void *)&cmd_flow_director_flexbytes,
8949 (void *)&cmd_flow_director_flexbytes_value,
8950 (void *)&cmd_flow_director_drop,
8951 (void *)&cmd_flow_director_pf_vf,
8952 (void *)&cmd_flow_director_queue,
8953 (void *)&cmd_flow_director_queue_id,
8954 (void *)&cmd_flow_director_fd_id,
8955 (void *)&cmd_flow_director_fd_id_value,
8960 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8961 .f = cmd_flow_director_filter_parsed,
8963 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
8964 "director entry on NIC",
8966 (void *)&cmd_flow_director_filter,
8967 (void *)&cmd_flow_director_port_id,
8968 (void *)&cmd_flow_director_mode,
8969 (void *)&cmd_flow_director_mode_ip,
8970 (void *)&cmd_flow_director_ops,
8971 (void *)&cmd_flow_director_flow,
8972 (void *)&cmd_flow_director_flow_type,
8973 (void *)&cmd_flow_director_src,
8974 (void *)&cmd_flow_director_ip_src,
8975 (void *)&cmd_flow_director_port_dst,
8976 (void *)&cmd_flow_director_dst,
8977 (void *)&cmd_flow_director_ip_dst,
8978 (void *)&cmd_flow_director_port_dst,
8979 (void *)&cmd_flow_director_verify_tag,
8980 (void *)&cmd_flow_director_verify_tag_value,
8981 (void *)&cmd_flow_director_tos,
8982 (void *)&cmd_flow_director_tos_value,
8983 (void *)&cmd_flow_director_ttl,
8984 (void *)&cmd_flow_director_ttl_value,
8985 (void *)&cmd_flow_director_vlan,
8986 (void *)&cmd_flow_director_vlan_value,
8987 (void *)&cmd_flow_director_flexbytes,
8988 (void *)&cmd_flow_director_flexbytes_value,
8989 (void *)&cmd_flow_director_drop,
8990 (void *)&cmd_flow_director_pf_vf,
8991 (void *)&cmd_flow_director_queue,
8992 (void *)&cmd_flow_director_queue_id,
8993 (void *)&cmd_flow_director_fd_id,
8994 (void *)&cmd_flow_director_fd_id_value,
8999 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9000 .f = cmd_flow_director_filter_parsed,
9002 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9003 "director entry on NIC",
9005 (void *)&cmd_flow_director_filter,
9006 (void *)&cmd_flow_director_port_id,
9007 (void *)&cmd_flow_director_mode,
9008 (void *)&cmd_flow_director_mode_ip,
9009 (void *)&cmd_flow_director_ops,
9010 (void *)&cmd_flow_director_flow,
9011 (void *)&cmd_flow_director_flow_type,
9012 (void *)&cmd_flow_director_ether,
9013 (void *)&cmd_flow_director_ether_type,
9014 (void *)&cmd_flow_director_flexbytes,
9015 (void *)&cmd_flow_director_flexbytes_value,
9016 (void *)&cmd_flow_director_drop,
9017 (void *)&cmd_flow_director_pf_vf,
9018 (void *)&cmd_flow_director_queue,
9019 (void *)&cmd_flow_director_queue_id,
9020 (void *)&cmd_flow_director_fd_id,
9021 (void *)&cmd_flow_director_fd_id_value,
9026 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9027 .f = cmd_flow_director_filter_parsed,
9029 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9030 "director entry on NIC",
9032 (void *)&cmd_flow_director_filter,
9033 (void *)&cmd_flow_director_port_id,
9034 (void *)&cmd_flow_director_mode,
9035 (void *)&cmd_flow_director_mode_mac_vlan,
9036 (void *)&cmd_flow_director_ops,
9037 (void *)&cmd_flow_director_mac,
9038 (void *)&cmd_flow_director_mac_addr,
9039 (void *)&cmd_flow_director_vlan,
9040 (void *)&cmd_flow_director_vlan_value,
9041 (void *)&cmd_flow_director_flexbytes,
9042 (void *)&cmd_flow_director_flexbytes_value,
9043 (void *)&cmd_flow_director_drop,
9044 (void *)&cmd_flow_director_queue,
9045 (void *)&cmd_flow_director_queue_id,
9046 (void *)&cmd_flow_director_fd_id,
9047 (void *)&cmd_flow_director_fd_id_value,
9052 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9053 .f = cmd_flow_director_filter_parsed,
9055 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9056 "director entry on NIC",
9058 (void *)&cmd_flow_director_filter,
9059 (void *)&cmd_flow_director_port_id,
9060 (void *)&cmd_flow_director_mode,
9061 (void *)&cmd_flow_director_mode_tunnel,
9062 (void *)&cmd_flow_director_ops,
9063 (void *)&cmd_flow_director_mac,
9064 (void *)&cmd_flow_director_mac_addr,
9065 (void *)&cmd_flow_director_vlan,
9066 (void *)&cmd_flow_director_vlan_value,
9067 (void *)&cmd_flow_director_tunnel,
9068 (void *)&cmd_flow_director_tunnel_type,
9069 (void *)&cmd_flow_director_tunnel_id,
9070 (void *)&cmd_flow_director_tunnel_id_value,
9071 (void *)&cmd_flow_director_flexbytes,
9072 (void *)&cmd_flow_director_flexbytes_value,
9073 (void *)&cmd_flow_director_drop,
9074 (void *)&cmd_flow_director_queue,
9075 (void *)&cmd_flow_director_queue_id,
9076 (void *)&cmd_flow_director_fd_id,
9077 (void *)&cmd_flow_director_fd_id_value,
9082 struct cmd_flush_flow_director_result {
9083 cmdline_fixed_string_t flush_flow_director;
9087 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9088 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9089 flush_flow_director, "flush_flow_director");
9090 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9091 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9095 cmd_flush_flow_director_parsed(void *parsed_result,
9096 __attribute__((unused)) struct cmdline *cl,
9097 __attribute__((unused)) void *data)
9099 struct cmd_flow_director_result *res = parsed_result;
9102 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9104 printf("flow director is not supported on port %u.\n",
9109 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9110 RTE_ETH_FILTER_FLUSH, NULL);
9112 printf("flow director table flushing error: (%s)\n",
9116 cmdline_parse_inst_t cmd_flush_flow_director = {
9117 .f = cmd_flush_flow_director_parsed,
9119 .help_str = "flush_flow_director <port_id>: "
9120 "Flush all flow director entries of a device on NIC",
9122 (void *)&cmd_flush_flow_director_flush,
9123 (void *)&cmd_flush_flow_director_port_id,
9128 /* *** deal with flow director mask *** */
9129 struct cmd_flow_director_mask_result {
9130 cmdline_fixed_string_t flow_director_mask;
9132 cmdline_fixed_string_t mode;
9133 cmdline_fixed_string_t mode_value;
9134 cmdline_fixed_string_t vlan;
9136 cmdline_fixed_string_t src_mask;
9137 cmdline_ipaddr_t ipv4_src;
9138 cmdline_ipaddr_t ipv6_src;
9140 cmdline_fixed_string_t dst_mask;
9141 cmdline_ipaddr_t ipv4_dst;
9142 cmdline_ipaddr_t ipv6_dst;
9144 cmdline_fixed_string_t mac;
9145 uint8_t mac_addr_byte_mask;
9146 cmdline_fixed_string_t tunnel_id;
9147 uint32_t tunnel_id_mask;
9148 cmdline_fixed_string_t tunnel_type;
9149 uint8_t tunnel_type_mask;
9153 cmd_flow_director_mask_parsed(void *parsed_result,
9154 __attribute__((unused)) struct cmdline *cl,
9155 __attribute__((unused)) void *data)
9157 struct cmd_flow_director_mask_result *res = parsed_result;
9158 struct rte_eth_fdir_masks *mask;
9159 struct rte_port *port;
9161 if (res->port_id > nb_ports) {
9162 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9166 port = &ports[res->port_id];
9167 /** Check if the port is not started **/
9168 if (port->port_status != RTE_PORT_STOPPED) {
9169 printf("Please stop port %d first\n", res->port_id);
9173 mask = &port->dev_conf.fdir_conf.mask;
9175 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9176 if (strcmp(res->mode_value, "MAC-VLAN")) {
9177 printf("Please set mode to MAC-VLAN.\n");
9181 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9182 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9183 if (strcmp(res->mode_value, "Tunnel")) {
9184 printf("Please set mode to Tunnel.\n");
9188 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9189 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9190 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9191 mask->tunnel_type_mask = res->tunnel_type_mask;
9193 if (strcmp(res->mode_value, "IP")) {
9194 printf("Please set mode to IP.\n");
9198 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9199 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9200 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9201 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9202 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9203 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9204 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9207 cmd_reconfig_device_queue(res->port_id, 1, 1);
9210 cmdline_parse_token_string_t cmd_flow_director_mask =
9211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9212 flow_director_mask, "flow_director_mask");
9213 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9214 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9216 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9219 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9220 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9222 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9223 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9224 src_mask, "src_mask");
9225 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9226 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9228 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9229 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9231 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9232 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9234 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9236 dst_mask, "dst_mask");
9237 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9238 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9240 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9241 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9243 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9244 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9247 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9250 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9253 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9255 mode_value, "MAC-VLAN");
9256 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9258 mode_value, "Tunnel");
9259 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9262 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9263 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9264 mac_addr_byte_mask, UINT8);
9265 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9267 tunnel_type, "tunnel-type");
9268 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9270 tunnel_type_mask, UINT8);
9271 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9273 tunnel_id, "tunnel-id");
9274 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9275 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9276 tunnel_id_mask, UINT32);
9278 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9279 .f = cmd_flow_director_mask_parsed,
9281 .help_str = "flow_director_mask ... : "
9282 "Set IP mode flow director's mask on NIC",
9284 (void *)&cmd_flow_director_mask,
9285 (void *)&cmd_flow_director_mask_port_id,
9286 (void *)&cmd_flow_director_mask_mode,
9287 (void *)&cmd_flow_director_mask_mode_ip,
9288 (void *)&cmd_flow_director_mask_vlan,
9289 (void *)&cmd_flow_director_mask_vlan_value,
9290 (void *)&cmd_flow_director_mask_src,
9291 (void *)&cmd_flow_director_mask_ipv4_src,
9292 (void *)&cmd_flow_director_mask_ipv6_src,
9293 (void *)&cmd_flow_director_mask_port_src,
9294 (void *)&cmd_flow_director_mask_dst,
9295 (void *)&cmd_flow_director_mask_ipv4_dst,
9296 (void *)&cmd_flow_director_mask_ipv6_dst,
9297 (void *)&cmd_flow_director_mask_port_dst,
9302 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9303 .f = cmd_flow_director_mask_parsed,
9305 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9306 "flow director's mask on NIC",
9308 (void *)&cmd_flow_director_mask,
9309 (void *)&cmd_flow_director_mask_port_id,
9310 (void *)&cmd_flow_director_mask_mode,
9311 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9312 (void *)&cmd_flow_director_mask_vlan,
9313 (void *)&cmd_flow_director_mask_vlan_value,
9318 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9319 .f = cmd_flow_director_mask_parsed,
9321 .help_str = "flow_director_mask ... : Set tunnel mode "
9322 "flow director's mask on NIC",
9324 (void *)&cmd_flow_director_mask,
9325 (void *)&cmd_flow_director_mask_port_id,
9326 (void *)&cmd_flow_director_mask_mode,
9327 (void *)&cmd_flow_director_mask_mode_tunnel,
9328 (void *)&cmd_flow_director_mask_vlan,
9329 (void *)&cmd_flow_director_mask_vlan_value,
9330 (void *)&cmd_flow_director_mask_mac,
9331 (void *)&cmd_flow_director_mask_mac_value,
9332 (void *)&cmd_flow_director_mask_tunnel_type,
9333 (void *)&cmd_flow_director_mask_tunnel_type_value,
9334 (void *)&cmd_flow_director_mask_tunnel_id,
9335 (void *)&cmd_flow_director_mask_tunnel_id_value,
9340 /* *** deal with flow director mask on flexible payload *** */
9341 struct cmd_flow_director_flex_mask_result {
9342 cmdline_fixed_string_t flow_director_flexmask;
9344 cmdline_fixed_string_t flow;
9345 cmdline_fixed_string_t flow_type;
9346 cmdline_fixed_string_t mask;
9350 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9351 __attribute__((unused)) struct cmdline *cl,
9352 __attribute__((unused)) void *data)
9354 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9355 struct rte_eth_fdir_info fdir_info;
9356 struct rte_eth_fdir_flex_mask flex_mask;
9357 struct rte_port *port;
9358 uint32_t flow_type_mask;
9362 if (res->port_id > nb_ports) {
9363 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9367 port = &ports[res->port_id];
9368 /** Check if the port is not started **/
9369 if (port->port_status != RTE_PORT_STOPPED) {
9370 printf("Please stop port %d first\n", res->port_id);
9374 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9375 ret = parse_flexbytes(res->mask,
9377 RTE_ETH_FDIR_MAX_FLEXLEN);
9379 printf("error: Cannot parse mask input.\n");
9383 memset(&fdir_info, 0, sizeof(fdir_info));
9384 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9385 RTE_ETH_FILTER_INFO, &fdir_info);
9387 printf("Cannot get FDir filter info\n");
9391 if (!strcmp(res->flow_type, "none")) {
9392 /* means don't specify the flow type */
9393 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9394 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9395 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9396 0, sizeof(struct rte_eth_fdir_flex_mask));
9397 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9398 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9400 sizeof(struct rte_eth_fdir_flex_mask));
9401 cmd_reconfig_device_queue(res->port_id, 1, 1);
9404 flow_type_mask = fdir_info.flow_types_mask[0];
9405 if (!strcmp(res->flow_type, "all")) {
9406 if (!flow_type_mask) {
9407 printf("No flow type supported\n");
9410 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9411 if (flow_type_mask & (1 << i)) {
9412 flex_mask.flow_type = i;
9413 fdir_set_flex_mask(res->port_id, &flex_mask);
9416 cmd_reconfig_device_queue(res->port_id, 1, 1);
9419 flex_mask.flow_type = str2flowtype(res->flow_type);
9420 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9421 printf("Flow type %s not supported on port %d\n",
9422 res->flow_type, res->port_id);
9425 fdir_set_flex_mask(res->port_id, &flex_mask);
9426 cmd_reconfig_device_queue(res->port_id, 1, 1);
9429 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9431 flow_director_flexmask,
9432 "flow_director_flex_mask");
9433 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9434 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9436 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9439 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9441 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9442 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9443 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9447 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9448 .f = cmd_flow_director_flex_mask_parsed,
9450 .help_str = "flow_director_flex_mask ... : "
9451 "Set flow director's flex mask on NIC",
9453 (void *)&cmd_flow_director_flexmask,
9454 (void *)&cmd_flow_director_flexmask_port_id,
9455 (void *)&cmd_flow_director_flexmask_flow,
9456 (void *)&cmd_flow_director_flexmask_flow_type,
9457 (void *)&cmd_flow_director_flexmask_mask,
9462 /* *** deal with flow director flexible payload configuration *** */
9463 struct cmd_flow_director_flexpayload_result {
9464 cmdline_fixed_string_t flow_director_flexpayload;
9466 cmdline_fixed_string_t payload_layer;
9467 cmdline_fixed_string_t payload_cfg;
9471 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9474 const char *p, *p0 = q_arg;
9476 unsigned long int_fld;
9477 char *str_fld[max_num];
9482 p = strchr(p0, '(');
9486 p0 = strchr(p, ')');
9491 if (size >= sizeof(s))
9494 snprintf(s, sizeof(s), "%.*s", size, p);
9495 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9496 if (ret < 0 || ret > max_num)
9498 for (i = 0; i < ret; i++) {
9500 int_fld = strtoul(str_fld[i], &end, 0);
9501 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9503 offsets[i] = (uint16_t)int_fld;
9509 cmd_flow_director_flxpld_parsed(void *parsed_result,
9510 __attribute__((unused)) struct cmdline *cl,
9511 __attribute__((unused)) void *data)
9513 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9514 struct rte_eth_flex_payload_cfg flex_cfg;
9515 struct rte_port *port;
9518 if (res->port_id > nb_ports) {
9519 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9523 port = &ports[res->port_id];
9524 /** Check if the port is not started **/
9525 if (port->port_status != RTE_PORT_STOPPED) {
9526 printf("Please stop port %d first\n", res->port_id);
9530 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9532 if (!strcmp(res->payload_layer, "raw"))
9533 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9534 else if (!strcmp(res->payload_layer, "l2"))
9535 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9536 else if (!strcmp(res->payload_layer, "l3"))
9537 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9538 else if (!strcmp(res->payload_layer, "l4"))
9539 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9541 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9542 RTE_ETH_FDIR_MAX_FLEXLEN);
9544 printf("error: Cannot parse flex payload input.\n");
9548 fdir_set_flex_payload(res->port_id, &flex_cfg);
9549 cmd_reconfig_device_queue(res->port_id, 1, 1);
9552 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9554 flow_director_flexpayload,
9555 "flow_director_flex_payload");
9556 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9557 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9559 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9561 payload_layer, "raw#l2#l3#l4");
9562 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9566 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9567 .f = cmd_flow_director_flxpld_parsed,
9569 .help_str = "flow_director_flexpayload ... : "
9570 "Set flow director's flex payload on NIC",
9572 (void *)&cmd_flow_director_flexpayload,
9573 (void *)&cmd_flow_director_flexpayload_port_id,
9574 (void *)&cmd_flow_director_flexpayload_payload_layer,
9575 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9580 /* Generic flow interface command. */
9581 extern cmdline_parse_inst_t cmd_flow;
9583 /* *** Classification Filters Control *** */
9584 /* *** Get symmetric hash enable per port *** */
9585 struct cmd_get_sym_hash_ena_per_port_result {
9586 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9591 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9592 __rte_unused struct cmdline *cl,
9593 __rte_unused void *data)
9595 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9596 struct rte_eth_hash_filter_info info;
9599 if (rte_eth_dev_filter_supported(res->port_id,
9600 RTE_ETH_FILTER_HASH) < 0) {
9601 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9606 memset(&info, 0, sizeof(info));
9607 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9608 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9609 RTE_ETH_FILTER_GET, &info);
9612 printf("Cannot get symmetric hash enable per port "
9613 "on port %u\n", res->port_id);
9617 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9618 "enabled" : "disabled", res->port_id);
9621 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9622 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9623 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9624 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9625 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9628 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9629 .f = cmd_get_sym_hash_per_port_parsed,
9631 .help_str = "get_sym_hash_ena_per_port <port_id>",
9633 (void *)&cmd_get_sym_hash_ena_per_port_all,
9634 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9639 /* *** Set symmetric hash enable per port *** */
9640 struct cmd_set_sym_hash_ena_per_port_result {
9641 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9642 cmdline_fixed_string_t enable;
9647 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9648 __rte_unused struct cmdline *cl,
9649 __rte_unused void *data)
9651 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9652 struct rte_eth_hash_filter_info info;
9655 if (rte_eth_dev_filter_supported(res->port_id,
9656 RTE_ETH_FILTER_HASH) < 0) {
9657 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9662 memset(&info, 0, sizeof(info));
9663 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9664 if (!strcmp(res->enable, "enable"))
9665 info.info.enable = 1;
9666 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9667 RTE_ETH_FILTER_SET, &info);
9669 printf("Cannot set symmetric hash enable per port on "
9670 "port %u\n", res->port_id);
9673 printf("Symmetric hash has been set to %s on port %u\n",
9674 res->enable, res->port_id);
9677 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9678 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9679 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9680 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9681 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9683 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9684 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9685 enable, "enable#disable");
9687 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9688 .f = cmd_set_sym_hash_per_port_parsed,
9690 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9692 (void *)&cmd_set_sym_hash_ena_per_port_all,
9693 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9694 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9699 /* Get global config of hash function */
9700 struct cmd_get_hash_global_config_result {
9701 cmdline_fixed_string_t get_hash_global_config;
9706 flowtype_to_str(uint16_t ftype)
9713 {"ipv4", RTE_ETH_FLOW_IPV4},
9714 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9715 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9716 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9717 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9718 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9719 {"ipv6", RTE_ETH_FLOW_IPV6},
9720 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9721 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9722 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9723 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9724 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9725 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9726 {"port", RTE_ETH_FLOW_PORT},
9727 {"vxlan", RTE_ETH_FLOW_VXLAN},
9728 {"geneve", RTE_ETH_FLOW_GENEVE},
9729 {"nvgre", RTE_ETH_FLOW_NVGRE},
9732 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9733 if (ftype_table[i].ftype == ftype)
9734 return ftype_table[i].str;
9741 cmd_get_hash_global_config_parsed(void *parsed_result,
9742 __rte_unused struct cmdline *cl,
9743 __rte_unused void *data)
9745 struct cmd_get_hash_global_config_result *res = parsed_result;
9746 struct rte_eth_hash_filter_info info;
9747 uint32_t idx, offset;
9752 if (rte_eth_dev_filter_supported(res->port_id,
9753 RTE_ETH_FILTER_HASH) < 0) {
9754 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9759 memset(&info, 0, sizeof(info));
9760 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9761 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9762 RTE_ETH_FILTER_GET, &info);
9764 printf("Cannot get hash global configurations by port %d\n",
9769 switch (info.info.global_conf.hash_func) {
9770 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9771 printf("Hash function is Toeplitz\n");
9773 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9774 printf("Hash function is Simple XOR\n");
9777 printf("Unknown hash function\n");
9781 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9782 idx = i / UINT32_BIT;
9783 offset = i % UINT32_BIT;
9784 if (!(info.info.global_conf.valid_bit_mask[idx] &
9787 str = flowtype_to_str(i);
9790 printf("Symmetric hash is %s globally for flow type %s "
9792 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9793 (1UL << offset)) ? "enabled" : "disabled"), str,
9798 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9799 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9800 get_hash_global_config, "get_hash_global_config");
9801 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9802 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9805 cmdline_parse_inst_t cmd_get_hash_global_config = {
9806 .f = cmd_get_hash_global_config_parsed,
9808 .help_str = "get_hash_global_config <port_id>",
9810 (void *)&cmd_get_hash_global_config_all,
9811 (void *)&cmd_get_hash_global_config_port_id,
9816 /* Set global config of hash function */
9817 struct cmd_set_hash_global_config_result {
9818 cmdline_fixed_string_t set_hash_global_config;
9820 cmdline_fixed_string_t hash_func;
9821 cmdline_fixed_string_t flow_type;
9822 cmdline_fixed_string_t enable;
9826 cmd_set_hash_global_config_parsed(void *parsed_result,
9827 __rte_unused struct cmdline *cl,
9828 __rte_unused void *data)
9830 struct cmd_set_hash_global_config_result *res = parsed_result;
9831 struct rte_eth_hash_filter_info info;
9832 uint32_t ftype, idx, offset;
9835 if (rte_eth_dev_filter_supported(res->port_id,
9836 RTE_ETH_FILTER_HASH) < 0) {
9837 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9841 memset(&info, 0, sizeof(info));
9842 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9843 if (!strcmp(res->hash_func, "toeplitz"))
9844 info.info.global_conf.hash_func =
9845 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9846 else if (!strcmp(res->hash_func, "simple_xor"))
9847 info.info.global_conf.hash_func =
9848 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9849 else if (!strcmp(res->hash_func, "default"))
9850 info.info.global_conf.hash_func =
9851 RTE_ETH_HASH_FUNCTION_DEFAULT;
9853 ftype = str2flowtype(res->flow_type);
9854 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9855 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9856 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9857 if (!strcmp(res->enable, "enable"))
9858 info.info.global_conf.sym_hash_enable_mask[idx] |=
9860 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9861 RTE_ETH_FILTER_SET, &info);
9863 printf("Cannot set global hash configurations by port %d\n",
9866 printf("Global hash configurations have been set "
9867 "succcessfully by port %d\n", res->port_id);
9870 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9871 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9872 set_hash_global_config, "set_hash_global_config");
9873 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9874 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9876 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9877 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9878 hash_func, "toeplitz#simple_xor#default");
9879 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9880 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9882 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9883 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9884 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9885 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9886 enable, "enable#disable");
9888 cmdline_parse_inst_t cmd_set_hash_global_config = {
9889 .f = cmd_set_hash_global_config_parsed,
9891 .help_str = "set_hash_global_config <port_id> "
9892 "toeplitz|simple_xor|default "
9893 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9894 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9895 "l2_payload enable|disable",
9897 (void *)&cmd_set_hash_global_config_all,
9898 (void *)&cmd_set_hash_global_config_port_id,
9899 (void *)&cmd_set_hash_global_config_hash_func,
9900 (void *)&cmd_set_hash_global_config_flow_type,
9901 (void *)&cmd_set_hash_global_config_enable,
9906 /* Set hash input set */
9907 struct cmd_set_hash_input_set_result {
9908 cmdline_fixed_string_t set_hash_input_set;
9910 cmdline_fixed_string_t flow_type;
9911 cmdline_fixed_string_t inset_field;
9912 cmdline_fixed_string_t select;
9915 static enum rte_eth_input_set_field
9916 str2inset(char *string)
9920 static const struct {
9922 enum rte_eth_input_set_field inset;
9924 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9925 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9926 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9927 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9928 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9929 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9930 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9931 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9932 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9933 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9934 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9935 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9936 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9937 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9938 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9939 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9940 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9941 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9942 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9943 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9944 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9945 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9946 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9947 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9948 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9949 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9950 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9951 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9952 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9953 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9954 {"none", RTE_ETH_INPUT_SET_NONE},
9957 for (i = 0; i < RTE_DIM(inset_table); i++) {
9958 if (!strcmp(string, inset_table[i].str))
9959 return inset_table[i].inset;
9962 return RTE_ETH_INPUT_SET_UNKNOWN;
9966 cmd_set_hash_input_set_parsed(void *parsed_result,
9967 __rte_unused struct cmdline *cl,
9968 __rte_unused void *data)
9970 struct cmd_set_hash_input_set_result *res = parsed_result;
9971 struct rte_eth_hash_filter_info info;
9973 memset(&info, 0, sizeof(info));
9974 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9975 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9976 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9977 info.info.input_set_conf.inset_size = 1;
9978 if (!strcmp(res->select, "select"))
9979 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9980 else if (!strcmp(res->select, "add"))
9981 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9982 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9983 RTE_ETH_FILTER_SET, &info);
9986 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9987 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9988 set_hash_input_set, "set_hash_input_set");
9989 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9990 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9992 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9993 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9995 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9996 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9997 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9998 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10000 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10001 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10002 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10003 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10004 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10006 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10007 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10008 select, "select#add");
10010 cmdline_parse_inst_t cmd_set_hash_input_set = {
10011 .f = cmd_set_hash_input_set_parsed,
10013 .help_str = "set_hash_input_set <port_id> "
10014 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10015 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10016 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10017 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10018 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10019 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10020 "fld-7th|fld-8th|none select|add",
10022 (void *)&cmd_set_hash_input_set_cmd,
10023 (void *)&cmd_set_hash_input_set_port_id,
10024 (void *)&cmd_set_hash_input_set_flow_type,
10025 (void *)&cmd_set_hash_input_set_field,
10026 (void *)&cmd_set_hash_input_set_select,
10031 /* Set flow director input set */
10032 struct cmd_set_fdir_input_set_result {
10033 cmdline_fixed_string_t set_fdir_input_set;
10035 cmdline_fixed_string_t flow_type;
10036 cmdline_fixed_string_t inset_field;
10037 cmdline_fixed_string_t select;
10041 cmd_set_fdir_input_set_parsed(void *parsed_result,
10042 __rte_unused struct cmdline *cl,
10043 __rte_unused void *data)
10045 struct cmd_set_fdir_input_set_result *res = parsed_result;
10046 struct rte_eth_fdir_filter_info info;
10048 memset(&info, 0, sizeof(info));
10049 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10050 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10051 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10052 info.info.input_set_conf.inset_size = 1;
10053 if (!strcmp(res->select, "select"))
10054 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10055 else if (!strcmp(res->select, "add"))
10056 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10057 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10058 RTE_ETH_FILTER_SET, &info);
10061 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10062 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10063 set_fdir_input_set, "set_fdir_input_set");
10064 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10065 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10067 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10068 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10070 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10071 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10072 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10073 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10075 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10076 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10077 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10078 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10079 "sctp-veri-tag#none");
10080 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10081 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10082 select, "select#add");
10084 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10085 .f = cmd_set_fdir_input_set_parsed,
10087 .help_str = "set_fdir_input_set <port_id> "
10088 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10089 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10090 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10091 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10092 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10093 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10094 "sctp-veri-tag|none select|add",
10096 (void *)&cmd_set_fdir_input_set_cmd,
10097 (void *)&cmd_set_fdir_input_set_port_id,
10098 (void *)&cmd_set_fdir_input_set_flow_type,
10099 (void *)&cmd_set_fdir_input_set_field,
10100 (void *)&cmd_set_fdir_input_set_select,
10105 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10106 struct cmd_mcast_addr_result {
10107 cmdline_fixed_string_t mcast_addr_cmd;
10108 cmdline_fixed_string_t what;
10110 struct ether_addr mc_addr;
10113 static void cmd_mcast_addr_parsed(void *parsed_result,
10114 __attribute__((unused)) struct cmdline *cl,
10115 __attribute__((unused)) void *data)
10117 struct cmd_mcast_addr_result *res = parsed_result;
10119 if (!is_multicast_ether_addr(&res->mc_addr)) {
10120 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10121 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10122 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10123 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10126 if (strcmp(res->what, "add") == 0)
10127 mcast_addr_add(res->port_num, &res->mc_addr);
10129 mcast_addr_remove(res->port_num, &res->mc_addr);
10132 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10133 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10134 mcast_addr_cmd, "mcast_addr");
10135 cmdline_parse_token_string_t cmd_mcast_addr_what =
10136 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10138 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10139 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10140 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10141 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10143 cmdline_parse_inst_t cmd_mcast_addr = {
10144 .f = cmd_mcast_addr_parsed,
10146 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10147 "Add/Remove multicast MAC address on port_id",
10149 (void *)&cmd_mcast_addr_cmd,
10150 (void *)&cmd_mcast_addr_what,
10151 (void *)&cmd_mcast_addr_portnum,
10152 (void *)&cmd_mcast_addr_addr,
10157 /* l2 tunnel config
10158 * only support E-tag now.
10161 /* Ether type config */
10162 struct cmd_config_l2_tunnel_eth_type_result {
10163 cmdline_fixed_string_t port;
10164 cmdline_fixed_string_t config;
10165 cmdline_fixed_string_t all;
10167 cmdline_fixed_string_t l2_tunnel;
10168 cmdline_fixed_string_t l2_tunnel_type;
10169 cmdline_fixed_string_t eth_type;
10170 uint16_t eth_type_val;
10173 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10174 TOKEN_STRING_INITIALIZER
10175 (struct cmd_config_l2_tunnel_eth_type_result,
10177 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10178 TOKEN_STRING_INITIALIZER
10179 (struct cmd_config_l2_tunnel_eth_type_result,
10181 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10182 TOKEN_STRING_INITIALIZER
10183 (struct cmd_config_l2_tunnel_eth_type_result,
10185 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10186 TOKEN_NUM_INITIALIZER
10187 (struct cmd_config_l2_tunnel_eth_type_result,
10189 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10190 TOKEN_STRING_INITIALIZER
10191 (struct cmd_config_l2_tunnel_eth_type_result,
10192 l2_tunnel, "l2-tunnel");
10193 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10194 TOKEN_STRING_INITIALIZER
10195 (struct cmd_config_l2_tunnel_eth_type_result,
10196 l2_tunnel_type, "E-tag");
10197 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10198 TOKEN_STRING_INITIALIZER
10199 (struct cmd_config_l2_tunnel_eth_type_result,
10200 eth_type, "ether-type");
10201 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10202 TOKEN_NUM_INITIALIZER
10203 (struct cmd_config_l2_tunnel_eth_type_result,
10204 eth_type_val, UINT16);
10206 static enum rte_eth_tunnel_type
10207 str2fdir_l2_tunnel_type(char *string)
10211 static const struct {
10213 enum rte_eth_tunnel_type type;
10214 } l2_tunnel_type_str[] = {
10215 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10218 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10219 if (!strcmp(l2_tunnel_type_str[i].str, string))
10220 return l2_tunnel_type_str[i].type;
10222 return RTE_TUNNEL_TYPE_NONE;
10225 /* ether type config for all ports */
10227 cmd_config_l2_tunnel_eth_type_all_parsed
10228 (void *parsed_result,
10229 __attribute__((unused)) struct cmdline *cl,
10230 __attribute__((unused)) void *data)
10232 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10233 struct rte_eth_l2_tunnel_conf entry;
10236 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10237 entry.ether_type = res->eth_type_val;
10239 FOREACH_PORT(pid, ports) {
10240 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10244 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10245 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10247 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10249 (void *)&cmd_config_l2_tunnel_eth_type_port,
10250 (void *)&cmd_config_l2_tunnel_eth_type_config,
10251 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10252 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10253 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10254 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10255 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10260 /* ether type config for a specific port */
10262 cmd_config_l2_tunnel_eth_type_specific_parsed(
10263 void *parsed_result,
10264 __attribute__((unused)) struct cmdline *cl,
10265 __attribute__((unused)) void *data)
10267 struct cmd_config_l2_tunnel_eth_type_result *res =
10269 struct rte_eth_l2_tunnel_conf entry;
10271 if (port_id_is_invalid(res->id, ENABLED_WARN))
10274 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10275 entry.ether_type = res->eth_type_val;
10277 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10280 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10281 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10283 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10285 (void *)&cmd_config_l2_tunnel_eth_type_port,
10286 (void *)&cmd_config_l2_tunnel_eth_type_config,
10287 (void *)&cmd_config_l2_tunnel_eth_type_id,
10288 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10289 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10290 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10291 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10296 /* Enable/disable l2 tunnel */
10297 struct cmd_config_l2_tunnel_en_dis_result {
10298 cmdline_fixed_string_t port;
10299 cmdline_fixed_string_t config;
10300 cmdline_fixed_string_t all;
10302 cmdline_fixed_string_t l2_tunnel;
10303 cmdline_fixed_string_t l2_tunnel_type;
10304 cmdline_fixed_string_t en_dis;
10307 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10308 TOKEN_STRING_INITIALIZER
10309 (struct cmd_config_l2_tunnel_en_dis_result,
10311 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10312 TOKEN_STRING_INITIALIZER
10313 (struct cmd_config_l2_tunnel_en_dis_result,
10315 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10316 TOKEN_STRING_INITIALIZER
10317 (struct cmd_config_l2_tunnel_en_dis_result,
10319 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10320 TOKEN_NUM_INITIALIZER
10321 (struct cmd_config_l2_tunnel_en_dis_result,
10323 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10324 TOKEN_STRING_INITIALIZER
10325 (struct cmd_config_l2_tunnel_en_dis_result,
10326 l2_tunnel, "l2-tunnel");
10327 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10328 TOKEN_STRING_INITIALIZER
10329 (struct cmd_config_l2_tunnel_en_dis_result,
10330 l2_tunnel_type, "E-tag");
10331 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10332 TOKEN_STRING_INITIALIZER
10333 (struct cmd_config_l2_tunnel_en_dis_result,
10334 en_dis, "enable#disable");
10336 /* enable/disable l2 tunnel for all ports */
10338 cmd_config_l2_tunnel_en_dis_all_parsed(
10339 void *parsed_result,
10340 __attribute__((unused)) struct cmdline *cl,
10341 __attribute__((unused)) void *data)
10343 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10344 struct rte_eth_l2_tunnel_conf entry;
10348 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10350 if (!strcmp("enable", res->en_dis))
10355 FOREACH_PORT(pid, ports) {
10356 rte_eth_dev_l2_tunnel_offload_set(pid,
10358 ETH_L2_TUNNEL_ENABLE_MASK,
10363 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10364 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10366 .help_str = "port config all l2-tunnel E-tag enable|disable",
10368 (void *)&cmd_config_l2_tunnel_en_dis_port,
10369 (void *)&cmd_config_l2_tunnel_en_dis_config,
10370 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10371 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10372 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10373 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10378 /* enable/disable l2 tunnel for a port */
10380 cmd_config_l2_tunnel_en_dis_specific_parsed(
10381 void *parsed_result,
10382 __attribute__((unused)) struct cmdline *cl,
10383 __attribute__((unused)) void *data)
10385 struct cmd_config_l2_tunnel_en_dis_result *res =
10387 struct rte_eth_l2_tunnel_conf entry;
10389 if (port_id_is_invalid(res->id, ENABLED_WARN))
10392 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10394 if (!strcmp("enable", res->en_dis))
10395 rte_eth_dev_l2_tunnel_offload_set(res->id,
10397 ETH_L2_TUNNEL_ENABLE_MASK,
10400 rte_eth_dev_l2_tunnel_offload_set(res->id,
10402 ETH_L2_TUNNEL_ENABLE_MASK,
10406 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10407 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10409 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10411 (void *)&cmd_config_l2_tunnel_en_dis_port,
10412 (void *)&cmd_config_l2_tunnel_en_dis_config,
10413 (void *)&cmd_config_l2_tunnel_en_dis_id,
10414 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10415 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10416 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10421 /* E-tag configuration */
10423 /* Common result structure for all E-tag configuration */
10424 struct cmd_config_e_tag_result {
10425 cmdline_fixed_string_t e_tag;
10426 cmdline_fixed_string_t set;
10427 cmdline_fixed_string_t insertion;
10428 cmdline_fixed_string_t stripping;
10429 cmdline_fixed_string_t forwarding;
10430 cmdline_fixed_string_t filter;
10431 cmdline_fixed_string_t add;
10432 cmdline_fixed_string_t del;
10433 cmdline_fixed_string_t on;
10434 cmdline_fixed_string_t off;
10435 cmdline_fixed_string_t on_off;
10436 cmdline_fixed_string_t port_tag_id;
10437 uint32_t port_tag_id_val;
10438 cmdline_fixed_string_t e_tag_id;
10439 uint16_t e_tag_id_val;
10440 cmdline_fixed_string_t dst_pool;
10441 uint8_t dst_pool_val;
10442 cmdline_fixed_string_t port;
10444 cmdline_fixed_string_t vf;
10448 /* Common CLI fields for all E-tag configuration */
10449 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10450 TOKEN_STRING_INITIALIZER
10451 (struct cmd_config_e_tag_result,
10453 cmdline_parse_token_string_t cmd_config_e_tag_set =
10454 TOKEN_STRING_INITIALIZER
10455 (struct cmd_config_e_tag_result,
10457 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10458 TOKEN_STRING_INITIALIZER
10459 (struct cmd_config_e_tag_result,
10460 insertion, "insertion");
10461 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10462 TOKEN_STRING_INITIALIZER
10463 (struct cmd_config_e_tag_result,
10464 stripping, "stripping");
10465 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10466 TOKEN_STRING_INITIALIZER
10467 (struct cmd_config_e_tag_result,
10468 forwarding, "forwarding");
10469 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10470 TOKEN_STRING_INITIALIZER
10471 (struct cmd_config_e_tag_result,
10473 cmdline_parse_token_string_t cmd_config_e_tag_add =
10474 TOKEN_STRING_INITIALIZER
10475 (struct cmd_config_e_tag_result,
10477 cmdline_parse_token_string_t cmd_config_e_tag_del =
10478 TOKEN_STRING_INITIALIZER
10479 (struct cmd_config_e_tag_result,
10481 cmdline_parse_token_string_t cmd_config_e_tag_on =
10482 TOKEN_STRING_INITIALIZER
10483 (struct cmd_config_e_tag_result,
10485 cmdline_parse_token_string_t cmd_config_e_tag_off =
10486 TOKEN_STRING_INITIALIZER
10487 (struct cmd_config_e_tag_result,
10489 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10490 TOKEN_STRING_INITIALIZER
10491 (struct cmd_config_e_tag_result,
10493 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10494 TOKEN_STRING_INITIALIZER
10495 (struct cmd_config_e_tag_result,
10496 port_tag_id, "port-tag-id");
10497 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10498 TOKEN_NUM_INITIALIZER
10499 (struct cmd_config_e_tag_result,
10500 port_tag_id_val, UINT32);
10501 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10502 TOKEN_STRING_INITIALIZER
10503 (struct cmd_config_e_tag_result,
10504 e_tag_id, "e-tag-id");
10505 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10506 TOKEN_NUM_INITIALIZER
10507 (struct cmd_config_e_tag_result,
10508 e_tag_id_val, UINT16);
10509 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10510 TOKEN_STRING_INITIALIZER
10511 (struct cmd_config_e_tag_result,
10512 dst_pool, "dst-pool");
10513 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10514 TOKEN_NUM_INITIALIZER
10515 (struct cmd_config_e_tag_result,
10516 dst_pool_val, UINT8);
10517 cmdline_parse_token_string_t cmd_config_e_tag_port =
10518 TOKEN_STRING_INITIALIZER
10519 (struct cmd_config_e_tag_result,
10521 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10522 TOKEN_NUM_INITIALIZER
10523 (struct cmd_config_e_tag_result,
10525 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10526 TOKEN_STRING_INITIALIZER
10527 (struct cmd_config_e_tag_result,
10529 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10530 TOKEN_NUM_INITIALIZER
10531 (struct cmd_config_e_tag_result,
10534 /* E-tag insertion configuration */
10536 cmd_config_e_tag_insertion_en_parsed(
10537 void *parsed_result,
10538 __attribute__((unused)) struct cmdline *cl,
10539 __attribute__((unused)) void *data)
10541 struct cmd_config_e_tag_result *res =
10543 struct rte_eth_l2_tunnel_conf entry;
10545 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10548 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10549 entry.tunnel_id = res->port_tag_id_val;
10550 entry.vf_id = res->vf_id;
10551 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10553 ETH_L2_TUNNEL_INSERTION_MASK,
10558 cmd_config_e_tag_insertion_dis_parsed(
10559 void *parsed_result,
10560 __attribute__((unused)) struct cmdline *cl,
10561 __attribute__((unused)) void *data)
10563 struct cmd_config_e_tag_result *res =
10565 struct rte_eth_l2_tunnel_conf entry;
10567 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10570 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10571 entry.vf_id = res->vf_id;
10573 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10575 ETH_L2_TUNNEL_INSERTION_MASK,
10579 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10580 .f = cmd_config_e_tag_insertion_en_parsed,
10582 .help_str = "E-tag ... : E-tag insertion enable",
10584 (void *)&cmd_config_e_tag_e_tag,
10585 (void *)&cmd_config_e_tag_set,
10586 (void *)&cmd_config_e_tag_insertion,
10587 (void *)&cmd_config_e_tag_on,
10588 (void *)&cmd_config_e_tag_port_tag_id,
10589 (void *)&cmd_config_e_tag_port_tag_id_val,
10590 (void *)&cmd_config_e_tag_port,
10591 (void *)&cmd_config_e_tag_port_id,
10592 (void *)&cmd_config_e_tag_vf,
10593 (void *)&cmd_config_e_tag_vf_id,
10598 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10599 .f = cmd_config_e_tag_insertion_dis_parsed,
10601 .help_str = "E-tag ... : E-tag insertion disable",
10603 (void *)&cmd_config_e_tag_e_tag,
10604 (void *)&cmd_config_e_tag_set,
10605 (void *)&cmd_config_e_tag_insertion,
10606 (void *)&cmd_config_e_tag_off,
10607 (void *)&cmd_config_e_tag_port,
10608 (void *)&cmd_config_e_tag_port_id,
10609 (void *)&cmd_config_e_tag_vf,
10610 (void *)&cmd_config_e_tag_vf_id,
10615 /* E-tag stripping configuration */
10617 cmd_config_e_tag_stripping_parsed(
10618 void *parsed_result,
10619 __attribute__((unused)) struct cmdline *cl,
10620 __attribute__((unused)) void *data)
10622 struct cmd_config_e_tag_result *res =
10624 struct rte_eth_l2_tunnel_conf entry;
10626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10629 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10631 if (!strcmp(res->on_off, "on"))
10632 rte_eth_dev_l2_tunnel_offload_set
10635 ETH_L2_TUNNEL_STRIPPING_MASK,
10638 rte_eth_dev_l2_tunnel_offload_set
10641 ETH_L2_TUNNEL_STRIPPING_MASK,
10645 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10646 .f = cmd_config_e_tag_stripping_parsed,
10648 .help_str = "E-tag ... : E-tag stripping enable/disable",
10650 (void *)&cmd_config_e_tag_e_tag,
10651 (void *)&cmd_config_e_tag_set,
10652 (void *)&cmd_config_e_tag_stripping,
10653 (void *)&cmd_config_e_tag_on_off,
10654 (void *)&cmd_config_e_tag_port,
10655 (void *)&cmd_config_e_tag_port_id,
10660 /* E-tag forwarding configuration */
10662 cmd_config_e_tag_forwarding_parsed(
10663 void *parsed_result,
10664 __attribute__((unused)) struct cmdline *cl,
10665 __attribute__((unused)) void *data)
10667 struct cmd_config_e_tag_result *res = parsed_result;
10668 struct rte_eth_l2_tunnel_conf entry;
10670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10673 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10675 if (!strcmp(res->on_off, "on"))
10676 rte_eth_dev_l2_tunnel_offload_set
10679 ETH_L2_TUNNEL_FORWARDING_MASK,
10682 rte_eth_dev_l2_tunnel_offload_set
10685 ETH_L2_TUNNEL_FORWARDING_MASK,
10689 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10690 .f = cmd_config_e_tag_forwarding_parsed,
10692 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10694 (void *)&cmd_config_e_tag_e_tag,
10695 (void *)&cmd_config_e_tag_set,
10696 (void *)&cmd_config_e_tag_forwarding,
10697 (void *)&cmd_config_e_tag_on_off,
10698 (void *)&cmd_config_e_tag_port,
10699 (void *)&cmd_config_e_tag_port_id,
10704 /* E-tag filter configuration */
10706 cmd_config_e_tag_filter_add_parsed(
10707 void *parsed_result,
10708 __attribute__((unused)) struct cmdline *cl,
10709 __attribute__((unused)) void *data)
10711 struct cmd_config_e_tag_result *res = parsed_result;
10712 struct rte_eth_l2_tunnel_conf entry;
10715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10718 if (res->e_tag_id_val > 0x3fff) {
10719 printf("e-tag-id must be equal or less than 0x3fff.\n");
10723 ret = rte_eth_dev_filter_supported(res->port_id,
10724 RTE_ETH_FILTER_L2_TUNNEL);
10726 printf("E-tag filter is not supported on port %u.\n",
10731 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10732 entry.tunnel_id = res->e_tag_id_val;
10733 entry.pool = res->dst_pool_val;
10735 ret = rte_eth_dev_filter_ctrl(res->port_id,
10736 RTE_ETH_FILTER_L2_TUNNEL,
10737 RTE_ETH_FILTER_ADD,
10740 printf("E-tag filter programming error: (%s)\n",
10744 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10745 .f = cmd_config_e_tag_filter_add_parsed,
10747 .help_str = "E-tag ... : E-tag filter add",
10749 (void *)&cmd_config_e_tag_e_tag,
10750 (void *)&cmd_config_e_tag_set,
10751 (void *)&cmd_config_e_tag_filter,
10752 (void *)&cmd_config_e_tag_add,
10753 (void *)&cmd_config_e_tag_e_tag_id,
10754 (void *)&cmd_config_e_tag_e_tag_id_val,
10755 (void *)&cmd_config_e_tag_dst_pool,
10756 (void *)&cmd_config_e_tag_dst_pool_val,
10757 (void *)&cmd_config_e_tag_port,
10758 (void *)&cmd_config_e_tag_port_id,
10764 cmd_config_e_tag_filter_del_parsed(
10765 void *parsed_result,
10766 __attribute__((unused)) struct cmdline *cl,
10767 __attribute__((unused)) void *data)
10769 struct cmd_config_e_tag_result *res = parsed_result;
10770 struct rte_eth_l2_tunnel_conf entry;
10773 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10776 if (res->e_tag_id_val > 0x3fff) {
10777 printf("e-tag-id must be less than 0x3fff.\n");
10781 ret = rte_eth_dev_filter_supported(res->port_id,
10782 RTE_ETH_FILTER_L2_TUNNEL);
10784 printf("E-tag filter is not supported on port %u.\n",
10789 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10790 entry.tunnel_id = res->e_tag_id_val;
10792 ret = rte_eth_dev_filter_ctrl(res->port_id,
10793 RTE_ETH_FILTER_L2_TUNNEL,
10794 RTE_ETH_FILTER_DELETE,
10797 printf("E-tag filter programming error: (%s)\n",
10801 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10802 .f = cmd_config_e_tag_filter_del_parsed,
10804 .help_str = "E-tag ... : E-tag filter delete",
10806 (void *)&cmd_config_e_tag_e_tag,
10807 (void *)&cmd_config_e_tag_set,
10808 (void *)&cmd_config_e_tag_filter,
10809 (void *)&cmd_config_e_tag_del,
10810 (void *)&cmd_config_e_tag_e_tag_id,
10811 (void *)&cmd_config_e_tag_e_tag_id_val,
10812 (void *)&cmd_config_e_tag_port,
10813 (void *)&cmd_config_e_tag_port_id,
10817 #ifdef RTE_LIBRTE_IXGBE_PMD
10819 /* vf vlan anti spoof configuration */
10821 /* Common result structure for vf vlan anti spoof */
10822 struct cmd_vf_vlan_anti_spoof_result {
10823 cmdline_fixed_string_t set;
10824 cmdline_fixed_string_t vf;
10825 cmdline_fixed_string_t vlan;
10826 cmdline_fixed_string_t antispoof;
10829 cmdline_fixed_string_t on_off;
10832 /* Common CLI fields for vf vlan anti spoof enable disable */
10833 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10834 TOKEN_STRING_INITIALIZER
10835 (struct cmd_vf_vlan_anti_spoof_result,
10837 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10838 TOKEN_STRING_INITIALIZER
10839 (struct cmd_vf_vlan_anti_spoof_result,
10841 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10842 TOKEN_STRING_INITIALIZER
10843 (struct cmd_vf_vlan_anti_spoof_result,
10845 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10846 TOKEN_STRING_INITIALIZER
10847 (struct cmd_vf_vlan_anti_spoof_result,
10848 antispoof, "antispoof");
10849 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10850 TOKEN_NUM_INITIALIZER
10851 (struct cmd_vf_vlan_anti_spoof_result,
10853 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10854 TOKEN_NUM_INITIALIZER
10855 (struct cmd_vf_vlan_anti_spoof_result,
10857 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10858 TOKEN_STRING_INITIALIZER
10859 (struct cmd_vf_vlan_anti_spoof_result,
10863 cmd_set_vf_vlan_anti_spoof_parsed(
10864 void *parsed_result,
10865 __attribute__((unused)) struct cmdline *cl,
10866 __attribute__((unused)) void *data)
10868 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10870 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10872 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10878 printf("invalid vf_id %d\n", res->vf_id);
10881 printf("invalid port_id %d\n", res->port_id);
10884 printf("programming error: (%s)\n", strerror(-ret));
10888 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10889 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10891 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10893 (void *)&cmd_vf_vlan_anti_spoof_set,
10894 (void *)&cmd_vf_vlan_anti_spoof_vf,
10895 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10896 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10897 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10898 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10899 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10904 /* vf mac anti spoof configuration */
10906 /* Common result structure for vf mac anti spoof */
10907 struct cmd_vf_mac_anti_spoof_result {
10908 cmdline_fixed_string_t set;
10909 cmdline_fixed_string_t vf;
10910 cmdline_fixed_string_t mac;
10911 cmdline_fixed_string_t antispoof;
10914 cmdline_fixed_string_t on_off;
10917 /* Common CLI fields for vf mac anti spoof enable disable */
10918 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10919 TOKEN_STRING_INITIALIZER
10920 (struct cmd_vf_mac_anti_spoof_result,
10922 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10923 TOKEN_STRING_INITIALIZER
10924 (struct cmd_vf_mac_anti_spoof_result,
10926 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_vf_mac_anti_spoof_result,
10930 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10931 TOKEN_STRING_INITIALIZER
10932 (struct cmd_vf_mac_anti_spoof_result,
10933 antispoof, "antispoof");
10934 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10935 TOKEN_NUM_INITIALIZER
10936 (struct cmd_vf_mac_anti_spoof_result,
10938 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10939 TOKEN_NUM_INITIALIZER
10940 (struct cmd_vf_mac_anti_spoof_result,
10942 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10943 TOKEN_STRING_INITIALIZER
10944 (struct cmd_vf_mac_anti_spoof_result,
10948 cmd_set_vf_mac_anti_spoof_parsed(
10949 void *parsed_result,
10950 __attribute__((unused)) struct cmdline *cl,
10951 __attribute__((unused)) void *data)
10953 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10955 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10957 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10963 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10966 printf("invalid port_id %d\n", res->port_id);
10969 printf("programming error: (%s)\n", strerror(-ret));
10973 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10974 .f = cmd_set_vf_mac_anti_spoof_parsed,
10976 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10978 (void *)&cmd_vf_mac_anti_spoof_set,
10979 (void *)&cmd_vf_mac_anti_spoof_vf,
10980 (void *)&cmd_vf_mac_anti_spoof_mac,
10981 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10982 (void *)&cmd_vf_mac_anti_spoof_port_id,
10983 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10984 (void *)&cmd_vf_mac_anti_spoof_on_off,
10989 /* vf vlan strip queue configuration */
10991 /* Common result structure for vf mac anti spoof */
10992 struct cmd_vf_vlan_stripq_result {
10993 cmdline_fixed_string_t set;
10994 cmdline_fixed_string_t vf;
10995 cmdline_fixed_string_t vlan;
10996 cmdline_fixed_string_t stripq;
10999 cmdline_fixed_string_t on_off;
11002 /* Common CLI fields for vf vlan strip enable disable */
11003 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11004 TOKEN_STRING_INITIALIZER
11005 (struct cmd_vf_vlan_stripq_result,
11007 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11008 TOKEN_STRING_INITIALIZER
11009 (struct cmd_vf_vlan_stripq_result,
11011 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11012 TOKEN_STRING_INITIALIZER
11013 (struct cmd_vf_vlan_stripq_result,
11015 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11016 TOKEN_STRING_INITIALIZER
11017 (struct cmd_vf_vlan_stripq_result,
11019 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11020 TOKEN_NUM_INITIALIZER
11021 (struct cmd_vf_vlan_stripq_result,
11023 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11024 TOKEN_NUM_INITIALIZER
11025 (struct cmd_vf_vlan_stripq_result,
11027 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11028 TOKEN_STRING_INITIALIZER
11029 (struct cmd_vf_vlan_stripq_result,
11033 cmd_set_vf_vlan_stripq_parsed(
11034 void *parsed_result,
11035 __attribute__((unused)) struct cmdline *cl,
11036 __attribute__((unused)) void *data)
11038 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11040 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11042 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11047 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11050 printf("invalid port_id %d\n", res->port_id);
11053 printf("programming error: (%s)\n", strerror(-ret));
11057 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11058 .f = cmd_set_vf_vlan_stripq_parsed,
11060 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11062 (void *)&cmd_vf_vlan_stripq_set,
11063 (void *)&cmd_vf_vlan_stripq_vf,
11064 (void *)&cmd_vf_vlan_stripq_vlan,
11065 (void *)&cmd_vf_vlan_stripq_stripq,
11066 (void *)&cmd_vf_vlan_stripq_port_id,
11067 (void *)&cmd_vf_vlan_stripq_vf_id,
11068 (void *)&cmd_vf_vlan_stripq_on_off,
11073 /* vf vlan insert configuration */
11075 /* Common result structure for vf vlan insert */
11076 struct cmd_vf_vlan_insert_result {
11077 cmdline_fixed_string_t set;
11078 cmdline_fixed_string_t vf;
11079 cmdline_fixed_string_t vlan;
11080 cmdline_fixed_string_t insert;
11086 /* Common CLI fields for vf vlan insert enable disable */
11087 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11088 TOKEN_STRING_INITIALIZER
11089 (struct cmd_vf_vlan_insert_result,
11091 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11092 TOKEN_STRING_INITIALIZER
11093 (struct cmd_vf_vlan_insert_result,
11095 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11096 TOKEN_STRING_INITIALIZER
11097 (struct cmd_vf_vlan_insert_result,
11099 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11100 TOKEN_STRING_INITIALIZER
11101 (struct cmd_vf_vlan_insert_result,
11103 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11104 TOKEN_NUM_INITIALIZER
11105 (struct cmd_vf_vlan_insert_result,
11107 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11108 TOKEN_NUM_INITIALIZER
11109 (struct cmd_vf_vlan_insert_result,
11111 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11112 TOKEN_NUM_INITIALIZER
11113 (struct cmd_vf_vlan_insert_result,
11117 cmd_set_vf_vlan_insert_parsed(
11118 void *parsed_result,
11119 __attribute__((unused)) struct cmdline *cl,
11120 __attribute__((unused)) void *data)
11122 struct cmd_vf_vlan_insert_result *res = parsed_result;
11125 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11130 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11133 printf("invalid port_id %d\n", res->port_id);
11136 printf("programming error: (%s)\n", strerror(-ret));
11140 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11141 .f = cmd_set_vf_vlan_insert_parsed,
11143 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11145 (void *)&cmd_vf_vlan_insert_set,
11146 (void *)&cmd_vf_vlan_insert_vf,
11147 (void *)&cmd_vf_vlan_insert_vlan,
11148 (void *)&cmd_vf_vlan_insert_insert,
11149 (void *)&cmd_vf_vlan_insert_port_id,
11150 (void *)&cmd_vf_vlan_insert_vf_id,
11151 (void *)&cmd_vf_vlan_insert_vlan_id,
11156 /* tx loopback configuration */
11158 /* Common result structure for tx loopback */
11159 struct cmd_tx_loopback_result {
11160 cmdline_fixed_string_t set;
11161 cmdline_fixed_string_t tx;
11162 cmdline_fixed_string_t loopback;
11164 cmdline_fixed_string_t on_off;
11167 /* Common CLI fields for tx loopback enable disable */
11168 cmdline_parse_token_string_t cmd_tx_loopback_set =
11169 TOKEN_STRING_INITIALIZER
11170 (struct cmd_tx_loopback_result,
11172 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11173 TOKEN_STRING_INITIALIZER
11174 (struct cmd_tx_loopback_result,
11176 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11177 TOKEN_STRING_INITIALIZER
11178 (struct cmd_tx_loopback_result,
11179 loopback, "loopback");
11180 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11181 TOKEN_NUM_INITIALIZER
11182 (struct cmd_tx_loopback_result,
11184 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11185 TOKEN_STRING_INITIALIZER
11186 (struct cmd_tx_loopback_result,
11190 cmd_set_tx_loopback_parsed(
11191 void *parsed_result,
11192 __attribute__((unused)) struct cmdline *cl,
11193 __attribute__((unused)) void *data)
11195 struct cmd_tx_loopback_result *res = parsed_result;
11197 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11199 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11204 printf("invalid is_on %d\n", is_on);
11207 printf("invalid port_id %d\n", res->port_id);
11210 printf("programming error: (%s)\n", strerror(-ret));
11214 cmdline_parse_inst_t cmd_set_tx_loopback = {
11215 .f = cmd_set_tx_loopback_parsed,
11217 .help_str = "set tx loopback <port_id> on|off",
11219 (void *)&cmd_tx_loopback_set,
11220 (void *)&cmd_tx_loopback_tx,
11221 (void *)&cmd_tx_loopback_loopback,
11222 (void *)&cmd_tx_loopback_port_id,
11223 (void *)&cmd_tx_loopback_on_off,
11228 /* all queues drop enable configuration */
11230 /* Common result structure for all queues drop enable */
11231 struct cmd_all_queues_drop_en_result {
11232 cmdline_fixed_string_t set;
11233 cmdline_fixed_string_t all;
11234 cmdline_fixed_string_t queues;
11235 cmdline_fixed_string_t drop;
11237 cmdline_fixed_string_t on_off;
11240 /* Common CLI fields for tx loopback enable disable */
11241 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11242 TOKEN_STRING_INITIALIZER
11243 (struct cmd_all_queues_drop_en_result,
11245 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11246 TOKEN_STRING_INITIALIZER
11247 (struct cmd_all_queues_drop_en_result,
11249 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11250 TOKEN_STRING_INITIALIZER
11251 (struct cmd_all_queues_drop_en_result,
11253 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11254 TOKEN_STRING_INITIALIZER
11255 (struct cmd_all_queues_drop_en_result,
11257 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11258 TOKEN_NUM_INITIALIZER
11259 (struct cmd_all_queues_drop_en_result,
11261 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11262 TOKEN_STRING_INITIALIZER
11263 (struct cmd_all_queues_drop_en_result,
11267 cmd_set_all_queues_drop_en_parsed(
11268 void *parsed_result,
11269 __attribute__((unused)) struct cmdline *cl,
11270 __attribute__((unused)) void *data)
11272 struct cmd_all_queues_drop_en_result *res = parsed_result;
11274 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11276 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11281 printf("invalid is_on %d\n", is_on);
11284 printf("invalid port_id %d\n", res->port_id);
11287 printf("programming error: (%s)\n", strerror(-ret));
11291 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11292 .f = cmd_set_all_queues_drop_en_parsed,
11294 .help_str = "set all queues drop <port_id> on|off",
11296 (void *)&cmd_all_queues_drop_en_set,
11297 (void *)&cmd_all_queues_drop_en_all,
11298 (void *)&cmd_all_queues_drop_en_queues,
11299 (void *)&cmd_all_queues_drop_en_drop,
11300 (void *)&cmd_all_queues_drop_en_port_id,
11301 (void *)&cmd_all_queues_drop_en_on_off,
11306 /* vf split drop enable configuration */
11308 /* Common result structure for vf split drop enable */
11309 struct cmd_vf_split_drop_en_result {
11310 cmdline_fixed_string_t set;
11311 cmdline_fixed_string_t vf;
11312 cmdline_fixed_string_t split;
11313 cmdline_fixed_string_t drop;
11316 cmdline_fixed_string_t on_off;
11319 /* Common CLI fields for vf split drop enable disable */
11320 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_vf_split_drop_en_result,
11324 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11325 TOKEN_STRING_INITIALIZER
11326 (struct cmd_vf_split_drop_en_result,
11328 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11329 TOKEN_STRING_INITIALIZER
11330 (struct cmd_vf_split_drop_en_result,
11332 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11333 TOKEN_STRING_INITIALIZER
11334 (struct cmd_vf_split_drop_en_result,
11336 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11337 TOKEN_NUM_INITIALIZER
11338 (struct cmd_vf_split_drop_en_result,
11340 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11341 TOKEN_NUM_INITIALIZER
11342 (struct cmd_vf_split_drop_en_result,
11344 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11345 TOKEN_STRING_INITIALIZER
11346 (struct cmd_vf_split_drop_en_result,
11350 cmd_set_vf_split_drop_en_parsed(
11351 void *parsed_result,
11352 __attribute__((unused)) struct cmdline *cl,
11353 __attribute__((unused)) void *data)
11355 struct cmd_vf_split_drop_en_result *res = parsed_result;
11357 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11359 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11365 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11368 printf("invalid port_id %d\n", res->port_id);
11371 printf("programming error: (%s)\n", strerror(-ret));
11375 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11376 .f = cmd_set_vf_split_drop_en_parsed,
11378 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11380 (void *)&cmd_vf_split_drop_en_set,
11381 (void *)&cmd_vf_split_drop_en_vf,
11382 (void *)&cmd_vf_split_drop_en_split,
11383 (void *)&cmd_vf_split_drop_en_drop,
11384 (void *)&cmd_vf_split_drop_en_port_id,
11385 (void *)&cmd_vf_split_drop_en_vf_id,
11386 (void *)&cmd_vf_split_drop_en_on_off,
11391 /* vf mac address configuration */
11393 /* Common result structure for vf mac address */
11394 struct cmd_set_vf_mac_addr_result {
11395 cmdline_fixed_string_t set;
11396 cmdline_fixed_string_t vf;
11397 cmdline_fixed_string_t mac;
11398 cmdline_fixed_string_t addr;
11401 struct ether_addr mac_addr;
11405 /* Common CLI fields for vf split drop enable disable */
11406 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11407 TOKEN_STRING_INITIALIZER
11408 (struct cmd_set_vf_mac_addr_result,
11410 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_set_vf_mac_addr_result,
11414 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11415 TOKEN_STRING_INITIALIZER
11416 (struct cmd_set_vf_mac_addr_result,
11418 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_set_vf_mac_addr_result,
11422 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11423 TOKEN_NUM_INITIALIZER
11424 (struct cmd_set_vf_mac_addr_result,
11426 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11427 TOKEN_NUM_INITIALIZER
11428 (struct cmd_set_vf_mac_addr_result,
11430 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11431 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11435 cmd_set_vf_mac_addr_parsed(
11436 void *parsed_result,
11437 __attribute__((unused)) struct cmdline *cl,
11438 __attribute__((unused)) void *data)
11440 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11443 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11449 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11452 printf("invalid port_id %d\n", res->port_id);
11455 printf("programming error: (%s)\n", strerror(-ret));
11459 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11460 .f = cmd_set_vf_mac_addr_parsed,
11462 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11464 (void *)&cmd_set_vf_mac_addr_set,
11465 (void *)&cmd_set_vf_mac_addr_vf,
11466 (void *)&cmd_set_vf_mac_addr_mac,
11467 (void *)&cmd_set_vf_mac_addr_addr,
11468 (void *)&cmd_set_vf_mac_addr_port_id,
11469 (void *)&cmd_set_vf_mac_addr_vf_id,
11470 (void *)&cmd_set_vf_mac_addr_mac_addr,
11476 /* ******************************************************************************** */
11478 /* list of instructions */
11479 cmdline_parse_ctx_t main_ctx[] = {
11480 (cmdline_parse_inst_t *)&cmd_help_brief,
11481 (cmdline_parse_inst_t *)&cmd_help_long,
11482 (cmdline_parse_inst_t *)&cmd_quit,
11483 (cmdline_parse_inst_t *)&cmd_showport,
11484 (cmdline_parse_inst_t *)&cmd_showqueue,
11485 (cmdline_parse_inst_t *)&cmd_showportall,
11486 (cmdline_parse_inst_t *)&cmd_showcfg,
11487 (cmdline_parse_inst_t *)&cmd_start,
11488 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11489 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11490 (cmdline_parse_inst_t *)&cmd_set_link_up,
11491 (cmdline_parse_inst_t *)&cmd_set_link_down,
11492 (cmdline_parse_inst_t *)&cmd_reset,
11493 (cmdline_parse_inst_t *)&cmd_set_numbers,
11494 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11495 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11496 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11497 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11498 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11499 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11500 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11501 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11502 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11503 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11504 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11505 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11506 (cmdline_parse_inst_t *)&cmd_set_link_check,
11507 #ifdef RTE_NIC_BYPASS
11508 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11509 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11510 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11511 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11513 #ifdef RTE_LIBRTE_PMD_BOND
11514 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11515 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11516 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11517 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11518 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11519 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11520 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11521 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11522 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11524 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11525 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11526 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11527 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11528 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11529 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11530 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11531 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11532 (cmdline_parse_inst_t *)&cmd_csum_set,
11533 (cmdline_parse_inst_t *)&cmd_csum_show,
11534 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11535 (cmdline_parse_inst_t *)&cmd_tso_set,
11536 (cmdline_parse_inst_t *)&cmd_tso_show,
11537 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11538 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11539 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11540 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11541 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11542 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11543 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11544 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11545 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11546 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11547 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11548 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11549 (cmdline_parse_inst_t *)&cmd_config_dcb,
11550 (cmdline_parse_inst_t *)&cmd_read_reg,
11551 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11552 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11553 (cmdline_parse_inst_t *)&cmd_write_reg,
11554 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11555 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11556 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11557 (cmdline_parse_inst_t *)&cmd_stop,
11558 (cmdline_parse_inst_t *)&cmd_mac_addr,
11559 (cmdline_parse_inst_t *)&cmd_set_qmap,
11560 (cmdline_parse_inst_t *)&cmd_operate_port,
11561 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11562 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11563 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11564 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11565 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11566 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11567 (cmdline_parse_inst_t *)&cmd_config_mtu,
11568 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11569 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11570 (cmdline_parse_inst_t *)&cmd_config_rss,
11571 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11572 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11573 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11574 (cmdline_parse_inst_t *)&cmd_showport_reta,
11575 (cmdline_parse_inst_t *)&cmd_config_burst,
11576 (cmdline_parse_inst_t *)&cmd_config_thresh,
11577 (cmdline_parse_inst_t *)&cmd_config_threshold,
11578 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11579 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11580 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11581 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11582 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11583 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11584 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11585 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11586 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11587 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11588 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11589 (cmdline_parse_inst_t *)&cmd_global_config,
11590 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11591 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11592 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11593 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11594 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11595 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11596 (cmdline_parse_inst_t *)&cmd_dump,
11597 (cmdline_parse_inst_t *)&cmd_dump_one,
11598 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11599 (cmdline_parse_inst_t *)&cmd_syn_filter,
11600 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11601 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11602 (cmdline_parse_inst_t *)&cmd_flex_filter,
11603 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11604 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11605 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11606 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11607 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11608 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11609 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11610 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11611 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11612 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11613 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11614 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11615 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11616 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11617 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11618 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11619 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11620 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11621 (cmdline_parse_inst_t *)&cmd_flow,
11622 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11623 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11624 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11625 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11626 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11627 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11628 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11629 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11630 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11631 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11632 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11633 #ifdef RTE_LIBRTE_IXGBE_PMD
11634 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11635 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11636 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11637 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11638 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11639 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11640 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11641 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11646 /* prompt function, called from main on MASTER lcore */
11650 /* initialize non-constant commands */
11651 cmd_set_fwd_mode_init();
11652 cmd_set_fwd_retry_mode_init();
11654 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11655 if (testpmd_cl == NULL)
11657 cmdline_interact(testpmd_cl);
11658 cmdline_stdin_exit(testpmd_cl);
11664 if (testpmd_cl != NULL)
11665 cmdline_quit(testpmd_cl);
11669 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11671 if (id == (portid_t)RTE_PORT_ALL) {
11674 FOREACH_PORT(pid, ports) {
11675 /* check if need_reconfig has been set to 1 */
11676 if (ports[pid].need_reconfig == 0)
11677 ports[pid].need_reconfig = dev;
11678 /* check if need_reconfig_queues has been set to 1 */
11679 if (ports[pid].need_reconfig_queues == 0)
11680 ports[pid].need_reconfig_queues = queue;
11682 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11683 /* check if need_reconfig has been set to 1 */
11684 if (ports[id].need_reconfig == 0)
11685 ports[id].need_reconfig = dev;
11686 /* check if need_reconfig_queues has been set to 1 */
11687 if (ports[id].need_reconfig_queues == 0)
11688 ports[id].need_reconfig_queues = queue;