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 list {port_id} [group {group_id}] [...]\n"
815 " List existing flow rules sorted by priority,"
816 " filtered by group identifiers.\n\n"
821 cmdline_parse_token_string_t cmd_help_long_help =
822 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
824 cmdline_parse_token_string_t cmd_help_long_section =
825 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
826 "all#control#display#config#"
827 "ports#registers#filters");
829 cmdline_parse_inst_t cmd_help_long = {
830 .f = cmd_help_long_parsed,
832 .help_str = "help all|control|display|config|ports|register|filters: "
835 (void *)&cmd_help_long_help,
836 (void *)&cmd_help_long_section,
842 /* *** start/stop/close all ports *** */
843 struct cmd_operate_port_result {
844 cmdline_fixed_string_t keyword;
845 cmdline_fixed_string_t name;
846 cmdline_fixed_string_t value;
849 static void cmd_operate_port_parsed(void *parsed_result,
850 __attribute__((unused)) struct cmdline *cl,
851 __attribute__((unused)) void *data)
853 struct cmd_operate_port_result *res = parsed_result;
855 if (!strcmp(res->name, "start"))
856 start_port(RTE_PORT_ALL);
857 else if (!strcmp(res->name, "stop"))
858 stop_port(RTE_PORT_ALL);
859 else if (!strcmp(res->name, "close"))
860 close_port(RTE_PORT_ALL);
862 printf("Unknown parameter\n");
865 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
866 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
868 cmdline_parse_token_string_t cmd_operate_port_all_port =
869 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
871 cmdline_parse_token_string_t cmd_operate_port_all_all =
872 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
874 cmdline_parse_inst_t cmd_operate_port = {
875 .f = cmd_operate_port_parsed,
877 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
879 (void *)&cmd_operate_port_all_cmd,
880 (void *)&cmd_operate_port_all_port,
881 (void *)&cmd_operate_port_all_all,
886 /* *** start/stop/close specific port *** */
887 struct cmd_operate_specific_port_result {
888 cmdline_fixed_string_t keyword;
889 cmdline_fixed_string_t name;
893 static void cmd_operate_specific_port_parsed(void *parsed_result,
894 __attribute__((unused)) struct cmdline *cl,
895 __attribute__((unused)) void *data)
897 struct cmd_operate_specific_port_result *res = parsed_result;
899 if (!strcmp(res->name, "start"))
900 start_port(res->value);
901 else if (!strcmp(res->name, "stop"))
902 stop_port(res->value);
903 else if (!strcmp(res->name, "close"))
904 close_port(res->value);
906 printf("Unknown parameter\n");
909 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
910 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
912 cmdline_parse_token_string_t cmd_operate_specific_port_port =
913 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
914 name, "start#stop#close");
915 cmdline_parse_token_num_t cmd_operate_specific_port_id =
916 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
919 cmdline_parse_inst_t cmd_operate_specific_port = {
920 .f = cmd_operate_specific_port_parsed,
922 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
924 (void *)&cmd_operate_specific_port_cmd,
925 (void *)&cmd_operate_specific_port_port,
926 (void *)&cmd_operate_specific_port_id,
931 /* *** attach a specified port *** */
932 struct cmd_operate_attach_port_result {
933 cmdline_fixed_string_t port;
934 cmdline_fixed_string_t keyword;
935 cmdline_fixed_string_t identifier;
938 static void cmd_operate_attach_port_parsed(void *parsed_result,
939 __attribute__((unused)) struct cmdline *cl,
940 __attribute__((unused)) void *data)
942 struct cmd_operate_attach_port_result *res = parsed_result;
944 if (!strcmp(res->keyword, "attach"))
945 attach_port(res->identifier);
947 printf("Unknown parameter\n");
950 cmdline_parse_token_string_t cmd_operate_attach_port_port =
951 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
953 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
954 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
956 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
957 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
960 cmdline_parse_inst_t cmd_operate_attach_port = {
961 .f = cmd_operate_attach_port_parsed,
963 .help_str = "port attach <identifier>: "
964 "(identifier: pci address or virtual dev name)",
966 (void *)&cmd_operate_attach_port_port,
967 (void *)&cmd_operate_attach_port_keyword,
968 (void *)&cmd_operate_attach_port_identifier,
973 /* *** detach a specified port *** */
974 struct cmd_operate_detach_port_result {
975 cmdline_fixed_string_t port;
976 cmdline_fixed_string_t keyword;
980 static void cmd_operate_detach_port_parsed(void *parsed_result,
981 __attribute__((unused)) struct cmdline *cl,
982 __attribute__((unused)) void *data)
984 struct cmd_operate_detach_port_result *res = parsed_result;
986 if (!strcmp(res->keyword, "detach"))
987 detach_port(res->port_id);
989 printf("Unknown parameter\n");
992 cmdline_parse_token_string_t cmd_operate_detach_port_port =
993 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
995 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
996 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
998 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
999 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1002 cmdline_parse_inst_t cmd_operate_detach_port = {
1003 .f = cmd_operate_detach_port_parsed,
1005 .help_str = "port detach <port_id>",
1007 (void *)&cmd_operate_detach_port_port,
1008 (void *)&cmd_operate_detach_port_keyword,
1009 (void *)&cmd_operate_detach_port_port_id,
1014 /* *** configure speed for all ports *** */
1015 struct cmd_config_speed_all {
1016 cmdline_fixed_string_t port;
1017 cmdline_fixed_string_t keyword;
1018 cmdline_fixed_string_t all;
1019 cmdline_fixed_string_t item1;
1020 cmdline_fixed_string_t item2;
1021 cmdline_fixed_string_t value1;
1022 cmdline_fixed_string_t value2;
1026 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1031 if (!strcmp(duplexstr, "half")) {
1032 duplex = ETH_LINK_HALF_DUPLEX;
1033 } else if (!strcmp(duplexstr, "full")) {
1034 duplex = ETH_LINK_FULL_DUPLEX;
1035 } else if (!strcmp(duplexstr, "auto")) {
1036 duplex = ETH_LINK_FULL_DUPLEX;
1038 printf("Unknown duplex parameter\n");
1042 if (!strcmp(speedstr, "10")) {
1043 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1044 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1045 } else if (!strcmp(speedstr, "100")) {
1046 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1047 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1049 if (duplex != ETH_LINK_FULL_DUPLEX) {
1050 printf("Invalid speed/duplex parameters\n");
1053 if (!strcmp(speedstr, "1000")) {
1054 *speed = ETH_LINK_SPEED_1G;
1055 } else if (!strcmp(speedstr, "10000")) {
1056 *speed = ETH_LINK_SPEED_10G;
1057 } else if (!strcmp(speedstr, "25000")) {
1058 *speed = ETH_LINK_SPEED_25G;
1059 } else if (!strcmp(speedstr, "40000")) {
1060 *speed = ETH_LINK_SPEED_40G;
1061 } else if (!strcmp(speedstr, "50000")) {
1062 *speed = ETH_LINK_SPEED_50G;
1063 } else if (!strcmp(speedstr, "100000")) {
1064 *speed = ETH_LINK_SPEED_100G;
1065 } else if (!strcmp(speedstr, "auto")) {
1066 *speed = ETH_LINK_SPEED_AUTONEG;
1068 printf("Unknown speed parameter\n");
1077 cmd_config_speed_all_parsed(void *parsed_result,
1078 __attribute__((unused)) struct cmdline *cl,
1079 __attribute__((unused)) void *data)
1081 struct cmd_config_speed_all *res = parsed_result;
1082 uint32_t link_speed;
1085 if (!all_ports_stopped()) {
1086 printf("Please stop all ports first\n");
1090 if (parse_and_check_speed_duplex(res->value1, res->value2,
1094 FOREACH_PORT(pid, ports) {
1095 ports[pid].dev_conf.link_speeds = link_speed;
1098 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1101 cmdline_parse_token_string_t cmd_config_speed_all_port =
1102 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1103 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1104 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1106 cmdline_parse_token_string_t cmd_config_speed_all_all =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1108 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1109 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1110 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1111 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1112 "10#100#1000#10000#25000#40000#50000#100000#auto");
1113 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1114 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1115 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1119 cmdline_parse_inst_t cmd_config_speed_all = {
1120 .f = cmd_config_speed_all_parsed,
1122 .help_str = "port config all speed "
1123 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1126 (void *)&cmd_config_speed_all_port,
1127 (void *)&cmd_config_speed_all_keyword,
1128 (void *)&cmd_config_speed_all_all,
1129 (void *)&cmd_config_speed_all_item1,
1130 (void *)&cmd_config_speed_all_value1,
1131 (void *)&cmd_config_speed_all_item2,
1132 (void *)&cmd_config_speed_all_value2,
1137 /* *** configure speed for specific port *** */
1138 struct cmd_config_speed_specific {
1139 cmdline_fixed_string_t port;
1140 cmdline_fixed_string_t keyword;
1142 cmdline_fixed_string_t item1;
1143 cmdline_fixed_string_t item2;
1144 cmdline_fixed_string_t value1;
1145 cmdline_fixed_string_t value2;
1149 cmd_config_speed_specific_parsed(void *parsed_result,
1150 __attribute__((unused)) struct cmdline *cl,
1151 __attribute__((unused)) void *data)
1153 struct cmd_config_speed_specific *res = parsed_result;
1154 uint32_t link_speed;
1156 if (!all_ports_stopped()) {
1157 printf("Please stop all ports first\n");
1161 if (port_id_is_invalid(res->id, ENABLED_WARN))
1164 if (parse_and_check_speed_duplex(res->value1, res->value2,
1168 ports[res->id].dev_conf.link_speeds = link_speed;
1170 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1174 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1175 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1177 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1180 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1181 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1182 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1185 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1187 "10#100#1000#10000#25000#40000#50000#100000#auto");
1188 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1191 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1192 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1195 cmdline_parse_inst_t cmd_config_speed_specific = {
1196 .f = cmd_config_speed_specific_parsed,
1198 .help_str = "port config <port_id> speed "
1199 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1202 (void *)&cmd_config_speed_specific_port,
1203 (void *)&cmd_config_speed_specific_keyword,
1204 (void *)&cmd_config_speed_specific_id,
1205 (void *)&cmd_config_speed_specific_item1,
1206 (void *)&cmd_config_speed_specific_value1,
1207 (void *)&cmd_config_speed_specific_item2,
1208 (void *)&cmd_config_speed_specific_value2,
1213 /* *** configure txq/rxq, txd/rxd *** */
1214 struct cmd_config_rx_tx {
1215 cmdline_fixed_string_t port;
1216 cmdline_fixed_string_t keyword;
1217 cmdline_fixed_string_t all;
1218 cmdline_fixed_string_t name;
1223 cmd_config_rx_tx_parsed(void *parsed_result,
1224 __attribute__((unused)) struct cmdline *cl,
1225 __attribute__((unused)) void *data)
1227 struct cmd_config_rx_tx *res = parsed_result;
1229 if (!all_ports_stopped()) {
1230 printf("Please stop all ports first\n");
1233 if (!strcmp(res->name, "rxq")) {
1234 if (!res->value && !nb_txq) {
1235 printf("Warning: Either rx or tx queues should be non zero\n");
1238 nb_rxq = res->value;
1240 else if (!strcmp(res->name, "txq")) {
1241 if (!res->value && !nb_rxq) {
1242 printf("Warning: Either rx or tx queues should be non zero\n");
1245 nb_txq = res->value;
1247 else if (!strcmp(res->name, "rxd")) {
1248 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1249 printf("rxd %d invalid - must be > 0 && <= %d\n",
1250 res->value, RTE_TEST_RX_DESC_MAX);
1253 nb_rxd = res->value;
1254 } else if (!strcmp(res->name, "txd")) {
1255 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1256 printf("txd %d invalid - must be > 0 && <= %d\n",
1257 res->value, RTE_TEST_TX_DESC_MAX);
1260 nb_txd = res->value;
1262 printf("Unknown parameter\n");
1270 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1273 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1274 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1275 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1276 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1277 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1278 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1279 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1280 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1282 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1283 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1285 cmdline_parse_inst_t cmd_config_rx_tx = {
1286 .f = cmd_config_rx_tx_parsed,
1288 .help_str = "port config all rxq|txq|rxd|txd <value>",
1290 (void *)&cmd_config_rx_tx_port,
1291 (void *)&cmd_config_rx_tx_keyword,
1292 (void *)&cmd_config_rx_tx_all,
1293 (void *)&cmd_config_rx_tx_name,
1294 (void *)&cmd_config_rx_tx_value,
1299 /* *** config max packet length *** */
1300 struct cmd_config_max_pkt_len_result {
1301 cmdline_fixed_string_t port;
1302 cmdline_fixed_string_t keyword;
1303 cmdline_fixed_string_t all;
1304 cmdline_fixed_string_t name;
1309 cmd_config_max_pkt_len_parsed(void *parsed_result,
1310 __attribute__((unused)) struct cmdline *cl,
1311 __attribute__((unused)) void *data)
1313 struct cmd_config_max_pkt_len_result *res = parsed_result;
1315 if (!all_ports_stopped()) {
1316 printf("Please stop all ports first\n");
1320 if (!strcmp(res->name, "max-pkt-len")) {
1321 if (res->value < ETHER_MIN_LEN) {
1322 printf("max-pkt-len can not be less than %d\n",
1326 if (res->value == rx_mode.max_rx_pkt_len)
1329 rx_mode.max_rx_pkt_len = res->value;
1330 if (res->value > ETHER_MAX_LEN)
1331 rx_mode.jumbo_frame = 1;
1333 rx_mode.jumbo_frame = 0;
1335 printf("Unknown parameter\n");
1341 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1344 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1345 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1347 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1350 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1353 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1356 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1357 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1360 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1361 .f = cmd_config_max_pkt_len_parsed,
1363 .help_str = "port config all max-pkt-len <value>",
1365 (void *)&cmd_config_max_pkt_len_port,
1366 (void *)&cmd_config_max_pkt_len_keyword,
1367 (void *)&cmd_config_max_pkt_len_all,
1368 (void *)&cmd_config_max_pkt_len_name,
1369 (void *)&cmd_config_max_pkt_len_value,
1374 /* *** configure port MTU *** */
1375 struct cmd_config_mtu_result {
1376 cmdline_fixed_string_t port;
1377 cmdline_fixed_string_t keyword;
1378 cmdline_fixed_string_t mtu;
1384 cmd_config_mtu_parsed(void *parsed_result,
1385 __attribute__((unused)) struct cmdline *cl,
1386 __attribute__((unused)) void *data)
1388 struct cmd_config_mtu_result *res = parsed_result;
1390 if (res->value < ETHER_MIN_LEN) {
1391 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1394 port_mtu_set(res->port_id, res->value);
1397 cmdline_parse_token_string_t cmd_config_mtu_port =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1400 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1403 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1406 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1408 cmdline_parse_token_num_t cmd_config_mtu_value =
1409 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1411 cmdline_parse_inst_t cmd_config_mtu = {
1412 .f = cmd_config_mtu_parsed,
1414 .help_str = "port config mtu <port_id> <value>",
1416 (void *)&cmd_config_mtu_port,
1417 (void *)&cmd_config_mtu_keyword,
1418 (void *)&cmd_config_mtu_mtu,
1419 (void *)&cmd_config_mtu_port_id,
1420 (void *)&cmd_config_mtu_value,
1425 /* *** configure rx mode *** */
1426 struct cmd_config_rx_mode_flag {
1427 cmdline_fixed_string_t port;
1428 cmdline_fixed_string_t keyword;
1429 cmdline_fixed_string_t all;
1430 cmdline_fixed_string_t name;
1431 cmdline_fixed_string_t value;
1435 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1436 __attribute__((unused)) struct cmdline *cl,
1437 __attribute__((unused)) void *data)
1439 struct cmd_config_rx_mode_flag *res = parsed_result;
1441 if (!all_ports_stopped()) {
1442 printf("Please stop all ports first\n");
1446 if (!strcmp(res->name, "crc-strip")) {
1447 if (!strcmp(res->value, "on"))
1448 rx_mode.hw_strip_crc = 1;
1449 else if (!strcmp(res->value, "off"))
1450 rx_mode.hw_strip_crc = 0;
1452 printf("Unknown parameter\n");
1455 } else if (!strcmp(res->name, "scatter")) {
1456 if (!strcmp(res->value, "on"))
1457 rx_mode.enable_scatter = 1;
1458 else if (!strcmp(res->value, "off"))
1459 rx_mode.enable_scatter = 0;
1461 printf("Unknown parameter\n");
1464 } else if (!strcmp(res->name, "rx-cksum")) {
1465 if (!strcmp(res->value, "on"))
1466 rx_mode.hw_ip_checksum = 1;
1467 else if (!strcmp(res->value, "off"))
1468 rx_mode.hw_ip_checksum = 0;
1470 printf("Unknown parameter\n");
1473 } else if (!strcmp(res->name, "hw-vlan")) {
1474 if (!strcmp(res->value, "on")) {
1475 rx_mode.hw_vlan_filter = 1;
1476 rx_mode.hw_vlan_strip = 1;
1478 else if (!strcmp(res->value, "off")) {
1479 rx_mode.hw_vlan_filter = 0;
1480 rx_mode.hw_vlan_strip = 0;
1483 printf("Unknown parameter\n");
1486 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1487 if (!strcmp(res->value, "on"))
1488 rx_mode.hw_vlan_filter = 1;
1489 else if (!strcmp(res->value, "off"))
1490 rx_mode.hw_vlan_filter = 0;
1492 printf("Unknown parameter\n");
1495 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1496 if (!strcmp(res->value, "on"))
1497 rx_mode.hw_vlan_strip = 1;
1498 else if (!strcmp(res->value, "off"))
1499 rx_mode.hw_vlan_strip = 0;
1501 printf("Unknown parameter\n");
1504 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1505 if (!strcmp(res->value, "on"))
1506 rx_mode.hw_vlan_extend = 1;
1507 else if (!strcmp(res->value, "off"))
1508 rx_mode.hw_vlan_extend = 0;
1510 printf("Unknown parameter\n");
1513 } else if (!strcmp(res->name, "drop-en")) {
1514 if (!strcmp(res->value, "on"))
1516 else if (!strcmp(res->value, "off"))
1519 printf("Unknown parameter\n");
1523 printf("Unknown parameter\n");
1529 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1532 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1534 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1535 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1537 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1539 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1540 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1541 "crc-strip#scatter#rx-cksum#hw-vlan#"
1542 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1543 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1547 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1548 .f = cmd_config_rx_mode_flag_parsed,
1550 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1551 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1553 (void *)&cmd_config_rx_mode_flag_port,
1554 (void *)&cmd_config_rx_mode_flag_keyword,
1555 (void *)&cmd_config_rx_mode_flag_all,
1556 (void *)&cmd_config_rx_mode_flag_name,
1557 (void *)&cmd_config_rx_mode_flag_value,
1562 /* *** configure rss *** */
1563 struct cmd_config_rss {
1564 cmdline_fixed_string_t port;
1565 cmdline_fixed_string_t keyword;
1566 cmdline_fixed_string_t all;
1567 cmdline_fixed_string_t name;
1568 cmdline_fixed_string_t value;
1572 cmd_config_rss_parsed(void *parsed_result,
1573 __attribute__((unused)) struct cmdline *cl,
1574 __attribute__((unused)) void *data)
1576 struct cmd_config_rss *res = parsed_result;
1577 struct rte_eth_rss_conf rss_conf;
1581 if (!strcmp(res->value, "all"))
1582 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1583 ETH_RSS_UDP | ETH_RSS_SCTP |
1585 else if (!strcmp(res->value, "ip"))
1586 rss_conf.rss_hf = ETH_RSS_IP;
1587 else if (!strcmp(res->value, "udp"))
1588 rss_conf.rss_hf = ETH_RSS_UDP;
1589 else if (!strcmp(res->value, "tcp"))
1590 rss_conf.rss_hf = ETH_RSS_TCP;
1591 else if (!strcmp(res->value, "sctp"))
1592 rss_conf.rss_hf = ETH_RSS_SCTP;
1593 else if (!strcmp(res->value, "ether"))
1594 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1595 else if (!strcmp(res->value, "port"))
1596 rss_conf.rss_hf = ETH_RSS_PORT;
1597 else if (!strcmp(res->value, "vxlan"))
1598 rss_conf.rss_hf = ETH_RSS_VXLAN;
1599 else if (!strcmp(res->value, "geneve"))
1600 rss_conf.rss_hf = ETH_RSS_GENEVE;
1601 else if (!strcmp(res->value, "nvgre"))
1602 rss_conf.rss_hf = ETH_RSS_NVGRE;
1603 else if (!strcmp(res->value, "none"))
1604 rss_conf.rss_hf = 0;
1606 printf("Unknown parameter\n");
1609 rss_conf.rss_key = NULL;
1610 for (i = 0; i < rte_eth_dev_count(); i++) {
1611 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1613 printf("Configuration of RSS hash at ethernet port %d "
1614 "failed with error (%d): %s.\n",
1615 i, -diag, strerror(-diag));
1619 cmdline_parse_token_string_t cmd_config_rss_port =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1621 cmdline_parse_token_string_t cmd_config_rss_keyword =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1623 cmdline_parse_token_string_t cmd_config_rss_all =
1624 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1625 cmdline_parse_token_string_t cmd_config_rss_name =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1627 cmdline_parse_token_string_t cmd_config_rss_value =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1629 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1631 cmdline_parse_inst_t cmd_config_rss = {
1632 .f = cmd_config_rss_parsed,
1634 .help_str = "port config all rss "
1635 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1637 (void *)&cmd_config_rss_port,
1638 (void *)&cmd_config_rss_keyword,
1639 (void *)&cmd_config_rss_all,
1640 (void *)&cmd_config_rss_name,
1641 (void *)&cmd_config_rss_value,
1646 /* *** configure rss hash key *** */
1647 struct cmd_config_rss_hash_key {
1648 cmdline_fixed_string_t port;
1649 cmdline_fixed_string_t config;
1651 cmdline_fixed_string_t rss_hash_key;
1652 cmdline_fixed_string_t rss_type;
1653 cmdline_fixed_string_t key;
1657 hexa_digit_to_value(char hexa_digit)
1659 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1660 return (uint8_t) (hexa_digit - '0');
1661 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1662 return (uint8_t) ((hexa_digit - 'a') + 10);
1663 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1664 return (uint8_t) ((hexa_digit - 'A') + 10);
1665 /* Invalid hexa digit */
1670 parse_and_check_key_hexa_digit(char *key, int idx)
1674 hexa_v = hexa_digit_to_value(key[idx]);
1676 printf("invalid key: character %c at position %d is not a "
1677 "valid hexa digit\n", key[idx], idx);
1682 cmd_config_rss_hash_key_parsed(void *parsed_result,
1683 __attribute__((unused)) struct cmdline *cl,
1684 __attribute__((unused)) void *data)
1686 struct cmd_config_rss_hash_key *res = parsed_result;
1687 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1691 struct rte_eth_dev_info dev_info;
1692 uint8_t hash_key_size;
1695 memset(&dev_info, 0, sizeof(dev_info));
1696 rte_eth_dev_info_get(res->port_id, &dev_info);
1697 if (dev_info.hash_key_size > 0 &&
1698 dev_info.hash_key_size <= sizeof(hash_key))
1699 hash_key_size = dev_info.hash_key_size;
1701 printf("dev_info did not provide a valid hash key size\n");
1704 /* Check the length of the RSS hash key */
1705 key_len = strlen(res->key);
1706 if (key_len != (hash_key_size * 2)) {
1707 printf("key length: %d invalid - key must be a string of %d"
1708 " hexa-decimal numbers\n",
1709 (int) key_len, hash_key_size * 2);
1712 /* Translate RSS hash key into binary representation */
1713 for (i = 0; i < hash_key_size; i++) {
1714 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1717 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1720 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1722 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1726 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1728 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1731 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1732 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1733 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1735 rss_hash_key, "rss-hash-key");
1736 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1738 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1739 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1740 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1741 "ipv6-tcp-ex#ipv6-udp-ex");
1742 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1743 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1745 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1746 .f = cmd_config_rss_hash_key_parsed,
1748 .help_str = "port config <port_id> rss-hash-key "
1749 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1750 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1751 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1752 "<string of hex digits (variable length, NIC dependent)>",
1754 (void *)&cmd_config_rss_hash_key_port,
1755 (void *)&cmd_config_rss_hash_key_config,
1756 (void *)&cmd_config_rss_hash_key_port_id,
1757 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1758 (void *)&cmd_config_rss_hash_key_rss_type,
1759 (void *)&cmd_config_rss_hash_key_value,
1764 /* *** configure port rxq/txq start/stop *** */
1765 struct cmd_config_rxtx_queue {
1766 cmdline_fixed_string_t port;
1768 cmdline_fixed_string_t rxtxq;
1770 cmdline_fixed_string_t opname;
1774 cmd_config_rxtx_queue_parsed(void *parsed_result,
1775 __attribute__((unused)) struct cmdline *cl,
1776 __attribute__((unused)) void *data)
1778 struct cmd_config_rxtx_queue *res = parsed_result;
1783 if (test_done == 0) {
1784 printf("Please stop forwarding first\n");
1788 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1791 if (port_is_started(res->portid) != 1) {
1792 printf("Please start port %u first\n", res->portid);
1796 if (!strcmp(res->rxtxq, "rxq"))
1798 else if (!strcmp(res->rxtxq, "txq"))
1801 printf("Unknown parameter\n");
1805 if (isrx && rx_queue_id_is_invalid(res->qid))
1807 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1810 if (!strcmp(res->opname, "start"))
1812 else if (!strcmp(res->opname, "stop"))
1815 printf("Unknown parameter\n");
1819 if (isstart && isrx)
1820 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1821 else if (!isstart && isrx)
1822 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1823 else if (isstart && !isrx)
1824 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1826 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1828 if (ret == -ENOTSUP)
1829 printf("Function not supported in PMD driver\n");
1832 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1834 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1835 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1836 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1838 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1839 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1840 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1844 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1845 .f = cmd_config_rxtx_queue_parsed,
1847 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1849 (void *)&cmd_config_speed_all_port,
1850 (void *)&cmd_config_rxtx_queue_portid,
1851 (void *)&cmd_config_rxtx_queue_rxtxq,
1852 (void *)&cmd_config_rxtx_queue_qid,
1853 (void *)&cmd_config_rxtx_queue_opname,
1858 /* *** Configure RSS RETA *** */
1859 struct cmd_config_rss_reta {
1860 cmdline_fixed_string_t port;
1861 cmdline_fixed_string_t keyword;
1863 cmdline_fixed_string_t name;
1864 cmdline_fixed_string_t list_name;
1865 cmdline_fixed_string_t list_of_items;
1869 parse_reta_config(const char *str,
1870 struct rte_eth_rss_reta_entry64 *reta_conf,
1871 uint16_t nb_entries)
1875 uint16_t hash_index, idx, shift;
1878 const char *p, *p0 = str;
1885 unsigned long int_fld[_NUM_FLD];
1886 char *str_fld[_NUM_FLD];
1888 while ((p = strchr(p0,'(')) != NULL) {
1890 if((p0 = strchr(p,')')) == NULL)
1894 if(size >= sizeof(s))
1897 snprintf(s, sizeof(s), "%.*s", size, p);
1898 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1900 for (i = 0; i < _NUM_FLD; i++) {
1902 int_fld[i] = strtoul(str_fld[i], &end, 0);
1903 if (errno != 0 || end == str_fld[i] ||
1908 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1909 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1911 if (hash_index >= nb_entries) {
1912 printf("Invalid RETA hash index=%d\n", hash_index);
1916 idx = hash_index / RTE_RETA_GROUP_SIZE;
1917 shift = hash_index % RTE_RETA_GROUP_SIZE;
1918 reta_conf[idx].mask |= (1ULL << shift);
1919 reta_conf[idx].reta[shift] = nb_queue;
1926 cmd_set_rss_reta_parsed(void *parsed_result,
1927 __attribute__((unused)) struct cmdline *cl,
1928 __attribute__((unused)) void *data)
1931 struct rte_eth_dev_info dev_info;
1932 struct rte_eth_rss_reta_entry64 reta_conf[8];
1933 struct cmd_config_rss_reta *res = parsed_result;
1935 memset(&dev_info, 0, sizeof(dev_info));
1936 rte_eth_dev_info_get(res->port_id, &dev_info);
1937 if (dev_info.reta_size == 0) {
1938 printf("Redirection table size is 0 which is "
1939 "invalid for RSS\n");
1942 printf("The reta size of port %d is %u\n",
1943 res->port_id, dev_info.reta_size);
1944 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1945 printf("Currently do not support more than %u entries of "
1946 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1950 memset(reta_conf, 0, sizeof(reta_conf));
1951 if (!strcmp(res->list_name, "reta")) {
1952 if (parse_reta_config(res->list_of_items, reta_conf,
1953 dev_info.reta_size)) {
1954 printf("Invalid RSS Redirection Table "
1955 "config entered\n");
1958 ret = rte_eth_dev_rss_reta_update(res->port_id,
1959 reta_conf, dev_info.reta_size);
1961 printf("Bad redirection table parameter, "
1962 "return code = %d \n", ret);
1966 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1968 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1970 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1971 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1972 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1974 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1976 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1979 cmdline_parse_inst_t cmd_config_rss_reta = {
1980 .f = cmd_set_rss_reta_parsed,
1982 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
1984 (void *)&cmd_config_rss_reta_port,
1985 (void *)&cmd_config_rss_reta_keyword,
1986 (void *)&cmd_config_rss_reta_port_id,
1987 (void *)&cmd_config_rss_reta_name,
1988 (void *)&cmd_config_rss_reta_list_name,
1989 (void *)&cmd_config_rss_reta_list_of_items,
1994 /* *** SHOW PORT RETA INFO *** */
1995 struct cmd_showport_reta {
1996 cmdline_fixed_string_t show;
1997 cmdline_fixed_string_t port;
1999 cmdline_fixed_string_t rss;
2000 cmdline_fixed_string_t reta;
2002 cmdline_fixed_string_t list_of_items;
2006 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2007 uint16_t nb_entries,
2011 const char *p, *p0 = str;
2015 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2018 p = strchr(p0, '(');
2022 p0 = strchr(p, ')');
2026 if (size >= sizeof(s)) {
2027 printf("The string size exceeds the internal buffer size\n");
2030 snprintf(s, sizeof(s), "%.*s", size, p);
2031 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2032 if (ret <= 0 || ret != num) {
2033 printf("The bits of masks do not match the number of "
2034 "reta entries: %u\n", num);
2037 for (i = 0; i < ret; i++)
2038 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2044 cmd_showport_reta_parsed(void *parsed_result,
2045 __attribute__((unused)) struct cmdline *cl,
2046 __attribute__((unused)) void *data)
2048 struct cmd_showport_reta *res = parsed_result;
2049 struct rte_eth_rss_reta_entry64 reta_conf[8];
2050 struct rte_eth_dev_info dev_info;
2052 memset(&dev_info, 0, sizeof(dev_info));
2053 rte_eth_dev_info_get(res->port_id, &dev_info);
2054 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2055 res->size > ETH_RSS_RETA_SIZE_512) {
2056 printf("Invalid redirection table size: %u\n", res->size);
2060 memset(reta_conf, 0, sizeof(reta_conf));
2061 if (showport_parse_reta_config(reta_conf, res->size,
2062 res->list_of_items) < 0) {
2063 printf("Invalid string: %s for reta masks\n",
2064 res->list_of_items);
2067 port_rss_reta_info(res->port_id, reta_conf, res->size);
2070 cmdline_parse_token_string_t cmd_showport_reta_show =
2071 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2072 cmdline_parse_token_string_t cmd_showport_reta_port =
2073 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2074 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2075 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2076 cmdline_parse_token_string_t cmd_showport_reta_rss =
2077 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2078 cmdline_parse_token_string_t cmd_showport_reta_reta =
2079 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2080 cmdline_parse_token_num_t cmd_showport_reta_size =
2081 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2082 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2083 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2084 list_of_items, NULL);
2086 cmdline_parse_inst_t cmd_showport_reta = {
2087 .f = cmd_showport_reta_parsed,
2089 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2091 (void *)&cmd_showport_reta_show,
2092 (void *)&cmd_showport_reta_port,
2093 (void *)&cmd_showport_reta_port_id,
2094 (void *)&cmd_showport_reta_rss,
2095 (void *)&cmd_showport_reta_reta,
2096 (void *)&cmd_showport_reta_size,
2097 (void *)&cmd_showport_reta_list_of_items,
2102 /* *** Show RSS hash configuration *** */
2103 struct cmd_showport_rss_hash {
2104 cmdline_fixed_string_t show;
2105 cmdline_fixed_string_t port;
2107 cmdline_fixed_string_t rss_hash;
2108 cmdline_fixed_string_t rss_type;
2109 cmdline_fixed_string_t key; /* optional argument */
2112 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2113 __attribute__((unused)) struct cmdline *cl,
2116 struct cmd_showport_rss_hash *res = parsed_result;
2118 port_rss_hash_conf_show(res->port_id, res->rss_type,
2119 show_rss_key != NULL);
2122 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2123 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2124 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2125 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2126 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2127 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2128 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2129 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2131 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2132 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2133 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2134 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2135 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2136 "ipv6-tcp-ex#ipv6-udp-ex");
2137 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2138 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2140 cmdline_parse_inst_t cmd_showport_rss_hash = {
2141 .f = cmd_showport_rss_hash_parsed,
2143 .help_str = "show port <port_id> rss-hash "
2144 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2145 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2146 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2148 (void *)&cmd_showport_rss_hash_show,
2149 (void *)&cmd_showport_rss_hash_port,
2150 (void *)&cmd_showport_rss_hash_port_id,
2151 (void *)&cmd_showport_rss_hash_rss_hash,
2152 (void *)&cmd_showport_rss_hash_rss_hash_info,
2157 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2158 .f = cmd_showport_rss_hash_parsed,
2160 .help_str = "show port <port_id> rss-hash "
2161 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2162 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2163 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2165 (void *)&cmd_showport_rss_hash_show,
2166 (void *)&cmd_showport_rss_hash_port,
2167 (void *)&cmd_showport_rss_hash_port_id,
2168 (void *)&cmd_showport_rss_hash_rss_hash,
2169 (void *)&cmd_showport_rss_hash_rss_hash_info,
2170 (void *)&cmd_showport_rss_hash_rss_key,
2175 /* *** Configure DCB *** */
2176 struct cmd_config_dcb {
2177 cmdline_fixed_string_t port;
2178 cmdline_fixed_string_t config;
2180 cmdline_fixed_string_t dcb;
2181 cmdline_fixed_string_t vt;
2182 cmdline_fixed_string_t vt_en;
2184 cmdline_fixed_string_t pfc;
2185 cmdline_fixed_string_t pfc_en;
2189 cmd_config_dcb_parsed(void *parsed_result,
2190 __attribute__((unused)) struct cmdline *cl,
2191 __attribute__((unused)) void *data)
2193 struct cmd_config_dcb *res = parsed_result;
2194 portid_t port_id = res->port_id;
2195 struct rte_port *port;
2199 port = &ports[port_id];
2200 /** Check if the port is not started **/
2201 if (port->port_status != RTE_PORT_STOPPED) {
2202 printf("Please stop port %d first\n", port_id);
2206 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2207 printf("The invalid number of traffic class,"
2208 " only 4 or 8 allowed.\n");
2212 if (nb_fwd_lcores < res->num_tcs) {
2213 printf("nb_cores shouldn't be less than number of TCs.\n");
2216 if (!strncmp(res->pfc_en, "on", 2))
2221 /* DCB in VT mode */
2222 if (!strncmp(res->vt_en, "on", 2))
2223 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2224 (enum rte_eth_nb_tcs)res->num_tcs,
2227 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2228 (enum rte_eth_nb_tcs)res->num_tcs,
2233 printf("Cannot initialize network ports.\n");
2237 cmd_reconfig_device_queue(port_id, 1, 1);
2240 cmdline_parse_token_string_t cmd_config_dcb_port =
2241 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2242 cmdline_parse_token_string_t cmd_config_dcb_config =
2243 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2244 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2245 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2246 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2247 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2248 cmdline_parse_token_string_t cmd_config_dcb_vt =
2249 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2250 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2251 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2252 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2253 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2254 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2255 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2256 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2257 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2259 cmdline_parse_inst_t cmd_config_dcb = {
2260 .f = cmd_config_dcb_parsed,
2262 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2264 (void *)&cmd_config_dcb_port,
2265 (void *)&cmd_config_dcb_config,
2266 (void *)&cmd_config_dcb_port_id,
2267 (void *)&cmd_config_dcb_dcb,
2268 (void *)&cmd_config_dcb_vt,
2269 (void *)&cmd_config_dcb_vt_en,
2270 (void *)&cmd_config_dcb_num_tcs,
2271 (void *)&cmd_config_dcb_pfc,
2272 (void *)&cmd_config_dcb_pfc_en,
2277 /* *** configure number of packets per burst *** */
2278 struct cmd_config_burst {
2279 cmdline_fixed_string_t port;
2280 cmdline_fixed_string_t keyword;
2281 cmdline_fixed_string_t all;
2282 cmdline_fixed_string_t name;
2287 cmd_config_burst_parsed(void *parsed_result,
2288 __attribute__((unused)) struct cmdline *cl,
2289 __attribute__((unused)) void *data)
2291 struct cmd_config_burst *res = parsed_result;
2293 if (!all_ports_stopped()) {
2294 printf("Please stop all ports first\n");
2298 if (!strcmp(res->name, "burst")) {
2299 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2300 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2303 nb_pkt_per_burst = res->value;
2305 printf("Unknown parameter\n");
2311 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2314 cmdline_parse_token_string_t cmd_config_burst_port =
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2316 cmdline_parse_token_string_t cmd_config_burst_keyword =
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2318 cmdline_parse_token_string_t cmd_config_burst_all =
2319 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2320 cmdline_parse_token_string_t cmd_config_burst_name =
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2322 cmdline_parse_token_num_t cmd_config_burst_value =
2323 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2325 cmdline_parse_inst_t cmd_config_burst = {
2326 .f = cmd_config_burst_parsed,
2328 .help_str = "port config all burst <value>",
2330 (void *)&cmd_config_burst_port,
2331 (void *)&cmd_config_burst_keyword,
2332 (void *)&cmd_config_burst_all,
2333 (void *)&cmd_config_burst_name,
2334 (void *)&cmd_config_burst_value,
2339 /* *** configure rx/tx queues *** */
2340 struct cmd_config_thresh {
2341 cmdline_fixed_string_t port;
2342 cmdline_fixed_string_t keyword;
2343 cmdline_fixed_string_t all;
2344 cmdline_fixed_string_t name;
2349 cmd_config_thresh_parsed(void *parsed_result,
2350 __attribute__((unused)) struct cmdline *cl,
2351 __attribute__((unused)) void *data)
2353 struct cmd_config_thresh *res = parsed_result;
2355 if (!all_ports_stopped()) {
2356 printf("Please stop all ports first\n");
2360 if (!strcmp(res->name, "txpt"))
2361 tx_pthresh = res->value;
2362 else if(!strcmp(res->name, "txht"))
2363 tx_hthresh = res->value;
2364 else if(!strcmp(res->name, "txwt"))
2365 tx_wthresh = res->value;
2366 else if(!strcmp(res->name, "rxpt"))
2367 rx_pthresh = res->value;
2368 else if(!strcmp(res->name, "rxht"))
2369 rx_hthresh = res->value;
2370 else if(!strcmp(res->name, "rxwt"))
2371 rx_wthresh = res->value;
2373 printf("Unknown parameter\n");
2379 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2382 cmdline_parse_token_string_t cmd_config_thresh_port =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2384 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2386 cmdline_parse_token_string_t cmd_config_thresh_all =
2387 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2388 cmdline_parse_token_string_t cmd_config_thresh_name =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2390 "txpt#txht#txwt#rxpt#rxht#rxwt");
2391 cmdline_parse_token_num_t cmd_config_thresh_value =
2392 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2394 cmdline_parse_inst_t cmd_config_thresh = {
2395 .f = cmd_config_thresh_parsed,
2397 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2399 (void *)&cmd_config_thresh_port,
2400 (void *)&cmd_config_thresh_keyword,
2401 (void *)&cmd_config_thresh_all,
2402 (void *)&cmd_config_thresh_name,
2403 (void *)&cmd_config_thresh_value,
2408 /* *** configure free/rs threshold *** */
2409 struct cmd_config_threshold {
2410 cmdline_fixed_string_t port;
2411 cmdline_fixed_string_t keyword;
2412 cmdline_fixed_string_t all;
2413 cmdline_fixed_string_t name;
2418 cmd_config_threshold_parsed(void *parsed_result,
2419 __attribute__((unused)) struct cmdline *cl,
2420 __attribute__((unused)) void *data)
2422 struct cmd_config_threshold *res = parsed_result;
2424 if (!all_ports_stopped()) {
2425 printf("Please stop all ports first\n");
2429 if (!strcmp(res->name, "txfreet"))
2430 tx_free_thresh = res->value;
2431 else if (!strcmp(res->name, "txrst"))
2432 tx_rs_thresh = res->value;
2433 else if (!strcmp(res->name, "rxfreet"))
2434 rx_free_thresh = res->value;
2436 printf("Unknown parameter\n");
2442 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2445 cmdline_parse_token_string_t cmd_config_threshold_port =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2447 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2448 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2450 cmdline_parse_token_string_t cmd_config_threshold_all =
2451 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2452 cmdline_parse_token_string_t cmd_config_threshold_name =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2454 "txfreet#txrst#rxfreet");
2455 cmdline_parse_token_num_t cmd_config_threshold_value =
2456 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2458 cmdline_parse_inst_t cmd_config_threshold = {
2459 .f = cmd_config_threshold_parsed,
2461 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2463 (void *)&cmd_config_threshold_port,
2464 (void *)&cmd_config_threshold_keyword,
2465 (void *)&cmd_config_threshold_all,
2466 (void *)&cmd_config_threshold_name,
2467 (void *)&cmd_config_threshold_value,
2473 struct cmd_stop_result {
2474 cmdline_fixed_string_t stop;
2477 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2478 __attribute__((unused)) struct cmdline *cl,
2479 __attribute__((unused)) void *data)
2481 stop_packet_forwarding();
2484 cmdline_parse_token_string_t cmd_stop_stop =
2485 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2487 cmdline_parse_inst_t cmd_stop = {
2488 .f = cmd_stop_parsed,
2490 .help_str = "stop: Stop packet forwarding",
2492 (void *)&cmd_stop_stop,
2497 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2500 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2501 unsigned int *parsed_items, int check_unique_values)
2503 unsigned int nb_item;
2511 * First parse all items in the list and store their value.
2516 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2518 if ((c >= '0') && (c <= '9')) {
2519 value = (unsigned int) (value * 10 + (c - '0'));
2524 printf("character %c is not a decimal digit\n", c);
2528 printf("No valid value before comma\n");
2531 if (nb_item < max_items) {
2532 parsed_items[nb_item] = value;
2538 if (nb_item >= max_items) {
2539 printf("Number of %s = %u > %u (maximum items)\n",
2540 item_name, nb_item + 1, max_items);
2543 parsed_items[nb_item++] = value;
2544 if (! check_unique_values)
2548 * Then, check that all values in the list are differents.
2549 * No optimization here...
2551 for (i = 0; i < nb_item; i++) {
2552 for (j = i + 1; j < nb_item; j++) {
2553 if (parsed_items[j] == parsed_items[i]) {
2554 printf("duplicated %s %u at index %u and %u\n",
2555 item_name, parsed_items[i], i, j);
2563 struct cmd_set_list_result {
2564 cmdline_fixed_string_t cmd_keyword;
2565 cmdline_fixed_string_t list_name;
2566 cmdline_fixed_string_t list_of_items;
2569 static void cmd_set_list_parsed(void *parsed_result,
2570 __attribute__((unused)) struct cmdline *cl,
2571 __attribute__((unused)) void *data)
2573 struct cmd_set_list_result *res;
2575 unsigned int lcorelist[RTE_MAX_LCORE];
2576 unsigned int portlist[RTE_MAX_ETHPORTS];
2578 unsigned int nb_item;
2580 if (test_done == 0) {
2581 printf("Please stop forwarding first\n");
2585 res = parsed_result;
2586 if (!strcmp(res->list_name, "corelist")) {
2587 nb_item = parse_item_list(res->list_of_items, "core",
2589 parsed_items.lcorelist, 1);
2591 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2596 if (!strcmp(res->list_name, "portlist")) {
2597 nb_item = parse_item_list(res->list_of_items, "port",
2599 parsed_items.portlist, 1);
2601 set_fwd_ports_list(parsed_items.portlist, nb_item);
2607 cmdline_parse_token_string_t cmd_set_list_keyword =
2608 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2610 cmdline_parse_token_string_t cmd_set_list_name =
2611 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2612 "corelist#portlist");
2613 cmdline_parse_token_string_t cmd_set_list_of_items =
2614 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2617 cmdline_parse_inst_t cmd_set_fwd_list = {
2618 .f = cmd_set_list_parsed,
2620 .help_str = "set corelist|portlist <list0[,list1]*>",
2622 (void *)&cmd_set_list_keyword,
2623 (void *)&cmd_set_list_name,
2624 (void *)&cmd_set_list_of_items,
2629 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2631 struct cmd_setmask_result {
2632 cmdline_fixed_string_t set;
2633 cmdline_fixed_string_t mask;
2637 static void cmd_set_mask_parsed(void *parsed_result,
2638 __attribute__((unused)) struct cmdline *cl,
2639 __attribute__((unused)) void *data)
2641 struct cmd_setmask_result *res = parsed_result;
2643 if (test_done == 0) {
2644 printf("Please stop forwarding first\n");
2647 if (!strcmp(res->mask, "coremask")) {
2648 set_fwd_lcores_mask(res->hexavalue);
2650 } else if (!strcmp(res->mask, "portmask")) {
2651 set_fwd_ports_mask(res->hexavalue);
2656 cmdline_parse_token_string_t cmd_setmask_set =
2657 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2658 cmdline_parse_token_string_t cmd_setmask_mask =
2659 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2660 "coremask#portmask");
2661 cmdline_parse_token_num_t cmd_setmask_value =
2662 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2664 cmdline_parse_inst_t cmd_set_fwd_mask = {
2665 .f = cmd_set_mask_parsed,
2667 .help_str = "set coremask|portmask <hexadecimal value>",
2669 (void *)&cmd_setmask_set,
2670 (void *)&cmd_setmask_mask,
2671 (void *)&cmd_setmask_value,
2677 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2679 struct cmd_set_result {
2680 cmdline_fixed_string_t set;
2681 cmdline_fixed_string_t what;
2685 static void cmd_set_parsed(void *parsed_result,
2686 __attribute__((unused)) struct cmdline *cl,
2687 __attribute__((unused)) void *data)
2689 struct cmd_set_result *res = parsed_result;
2690 if (!strcmp(res->what, "nbport")) {
2691 set_fwd_ports_number(res->value);
2693 } else if (!strcmp(res->what, "nbcore")) {
2694 set_fwd_lcores_number(res->value);
2696 } else if (!strcmp(res->what, "burst"))
2697 set_nb_pkt_per_burst(res->value);
2698 else if (!strcmp(res->what, "verbose"))
2699 set_verbose_level(res->value);
2702 cmdline_parse_token_string_t cmd_set_set =
2703 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2704 cmdline_parse_token_string_t cmd_set_what =
2705 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2706 "nbport#nbcore#burst#verbose");
2707 cmdline_parse_token_num_t cmd_set_value =
2708 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2710 cmdline_parse_inst_t cmd_set_numbers = {
2711 .f = cmd_set_parsed,
2713 .help_str = "set nbport|nbcore|burst|verbose <value>",
2715 (void *)&cmd_set_set,
2716 (void *)&cmd_set_what,
2717 (void *)&cmd_set_value,
2722 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2724 struct cmd_set_txpkts_result {
2725 cmdline_fixed_string_t cmd_keyword;
2726 cmdline_fixed_string_t txpkts;
2727 cmdline_fixed_string_t seg_lengths;
2731 cmd_set_txpkts_parsed(void *parsed_result,
2732 __attribute__((unused)) struct cmdline *cl,
2733 __attribute__((unused)) void *data)
2735 struct cmd_set_txpkts_result *res;
2736 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2737 unsigned int nb_segs;
2739 res = parsed_result;
2740 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2741 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2743 set_tx_pkt_segments(seg_lengths, nb_segs);
2746 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2747 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2748 cmd_keyword, "set");
2749 cmdline_parse_token_string_t cmd_set_txpkts_name =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2752 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2753 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2756 cmdline_parse_inst_t cmd_set_txpkts = {
2757 .f = cmd_set_txpkts_parsed,
2759 .help_str = "set txpkts <len0[,len1]*>",
2761 (void *)&cmd_set_txpkts_keyword,
2762 (void *)&cmd_set_txpkts_name,
2763 (void *)&cmd_set_txpkts_lengths,
2768 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2770 struct cmd_set_txsplit_result {
2771 cmdline_fixed_string_t cmd_keyword;
2772 cmdline_fixed_string_t txsplit;
2773 cmdline_fixed_string_t mode;
2777 cmd_set_txsplit_parsed(void *parsed_result,
2778 __attribute__((unused)) struct cmdline *cl,
2779 __attribute__((unused)) void *data)
2781 struct cmd_set_txsplit_result *res;
2783 res = parsed_result;
2784 set_tx_pkt_split(res->mode);
2787 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2788 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2789 cmd_keyword, "set");
2790 cmdline_parse_token_string_t cmd_set_txsplit_name =
2791 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2792 txsplit, "txsplit");
2793 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2794 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2797 cmdline_parse_inst_t cmd_set_txsplit = {
2798 .f = cmd_set_txsplit_parsed,
2800 .help_str = "set txsplit on|off|rand",
2802 (void *)&cmd_set_txsplit_keyword,
2803 (void *)&cmd_set_txsplit_name,
2804 (void *)&cmd_set_txsplit_mode,
2809 /* *** CONFIG TX QUEUE FLAGS *** */
2811 struct cmd_config_txqflags_result {
2812 cmdline_fixed_string_t port;
2813 cmdline_fixed_string_t config;
2814 cmdline_fixed_string_t all;
2815 cmdline_fixed_string_t what;
2819 static void cmd_config_txqflags_parsed(void *parsed_result,
2820 __attribute__((unused)) struct cmdline *cl,
2821 __attribute__((unused)) void *data)
2823 struct cmd_config_txqflags_result *res = parsed_result;
2825 if (!all_ports_stopped()) {
2826 printf("Please stop all ports first\n");
2830 if (strcmp(res->what, "txqflags")) {
2831 printf("Unknown parameter\n");
2835 if (res->hexvalue >= 0) {
2836 txq_flags = res->hexvalue;
2838 printf("txqflags must be >= 0\n");
2844 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2847 cmdline_parse_token_string_t cmd_config_txqflags_port =
2848 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2850 cmdline_parse_token_string_t cmd_config_txqflags_config =
2851 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2853 cmdline_parse_token_string_t cmd_config_txqflags_all =
2854 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2856 cmdline_parse_token_string_t cmd_config_txqflags_what =
2857 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2859 cmdline_parse_token_num_t cmd_config_txqflags_value =
2860 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2863 cmdline_parse_inst_t cmd_config_txqflags = {
2864 .f = cmd_config_txqflags_parsed,
2866 .help_str = "port config all txqflags <value>",
2868 (void *)&cmd_config_txqflags_port,
2869 (void *)&cmd_config_txqflags_config,
2870 (void *)&cmd_config_txqflags_all,
2871 (void *)&cmd_config_txqflags_what,
2872 (void *)&cmd_config_txqflags_value,
2877 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2878 struct cmd_rx_vlan_filter_all_result {
2879 cmdline_fixed_string_t rx_vlan;
2880 cmdline_fixed_string_t what;
2881 cmdline_fixed_string_t all;
2886 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2887 __attribute__((unused)) struct cmdline *cl,
2888 __attribute__((unused)) void *data)
2890 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2892 if (!strcmp(res->what, "add"))
2893 rx_vlan_all_filter_set(res->port_id, 1);
2895 rx_vlan_all_filter_set(res->port_id, 0);
2898 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2899 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2900 rx_vlan, "rx_vlan");
2901 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2902 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2904 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2905 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2907 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2908 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2911 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2912 .f = cmd_rx_vlan_filter_all_parsed,
2914 .help_str = "rx_vlan add|rm all <port_id>: "
2915 "Add/Remove all identifiers to/from the set of VLAN "
2916 "identifiers filtered by a port",
2918 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2919 (void *)&cmd_rx_vlan_filter_all_what,
2920 (void *)&cmd_rx_vlan_filter_all_all,
2921 (void *)&cmd_rx_vlan_filter_all_portid,
2926 /* *** VLAN OFFLOAD SET ON A PORT *** */
2927 struct cmd_vlan_offload_result {
2928 cmdline_fixed_string_t vlan;
2929 cmdline_fixed_string_t set;
2930 cmdline_fixed_string_t vlan_type;
2931 cmdline_fixed_string_t what;
2932 cmdline_fixed_string_t on;
2933 cmdline_fixed_string_t port_id;
2937 cmd_vlan_offload_parsed(void *parsed_result,
2938 __attribute__((unused)) struct cmdline *cl,
2939 __attribute__((unused)) void *data)
2942 struct cmd_vlan_offload_result *res = parsed_result;
2945 portid_t port_id = 0;
2949 len = strnlen(str, STR_TOKEN_SIZE);
2951 /* Get port_id first */
2959 tmp = strtoul(str, NULL, 0);
2960 /* If port_id greater that what portid_t can represent, return */
2961 if(tmp >= RTE_MAX_ETHPORTS)
2963 port_id = (portid_t)tmp;
2965 if (!strcmp(res->on, "on"))
2970 if (!strcmp(res->what, "strip"))
2971 rx_vlan_strip_set(port_id, on);
2972 else if(!strcmp(res->what, "stripq")){
2973 uint16_t queue_id = 0;
2975 /* No queue_id, return */
2977 printf("must specify (port,queue_id)\n");
2980 tmp = strtoul(str + i + 1, NULL, 0);
2981 /* If queue_id greater that what 16-bits can represent, return */
2985 queue_id = (uint16_t)tmp;
2986 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2988 else if (!strcmp(res->what, "filter"))
2989 rx_vlan_filter_set(port_id, on);
2991 vlan_extend_set(port_id, on);
2996 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2997 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2999 cmdline_parse_token_string_t cmd_vlan_offload_set =
3000 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3002 cmdline_parse_token_string_t cmd_vlan_offload_what =
3003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3004 what, "strip#filter#qinq#stripq");
3005 cmdline_parse_token_string_t cmd_vlan_offload_on =
3006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3008 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3012 cmdline_parse_inst_t cmd_vlan_offload = {
3013 .f = cmd_vlan_offload_parsed,
3015 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3016 "<port_id[,queue_id]>: "
3017 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3019 (void *)&cmd_vlan_offload_vlan,
3020 (void *)&cmd_vlan_offload_set,
3021 (void *)&cmd_vlan_offload_what,
3022 (void *)&cmd_vlan_offload_on,
3023 (void *)&cmd_vlan_offload_portid,
3028 /* *** VLAN TPID SET ON A PORT *** */
3029 struct cmd_vlan_tpid_result {
3030 cmdline_fixed_string_t vlan;
3031 cmdline_fixed_string_t set;
3032 cmdline_fixed_string_t vlan_type;
3033 cmdline_fixed_string_t what;
3039 cmd_vlan_tpid_parsed(void *parsed_result,
3040 __attribute__((unused)) struct cmdline *cl,
3041 __attribute__((unused)) void *data)
3043 struct cmd_vlan_tpid_result *res = parsed_result;
3044 enum rte_vlan_type vlan_type;
3046 if (!strcmp(res->vlan_type, "inner"))
3047 vlan_type = ETH_VLAN_TYPE_INNER;
3048 else if (!strcmp(res->vlan_type, "outer"))
3049 vlan_type = ETH_VLAN_TYPE_OUTER;
3051 printf("Unknown vlan type\n");
3054 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3057 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3058 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3060 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3061 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3063 cmdline_parse_token_string_t cmd_vlan_type =
3064 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3065 vlan_type, "inner#outer");
3066 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3067 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3069 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3070 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3072 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3073 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3076 cmdline_parse_inst_t cmd_vlan_tpid = {
3077 .f = cmd_vlan_tpid_parsed,
3079 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3080 "Set the VLAN Ether type",
3082 (void *)&cmd_vlan_tpid_vlan,
3083 (void *)&cmd_vlan_tpid_set,
3084 (void *)&cmd_vlan_type,
3085 (void *)&cmd_vlan_tpid_what,
3086 (void *)&cmd_vlan_tpid_tpid,
3087 (void *)&cmd_vlan_tpid_portid,
3092 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3093 struct cmd_rx_vlan_filter_result {
3094 cmdline_fixed_string_t rx_vlan;
3095 cmdline_fixed_string_t what;
3101 cmd_rx_vlan_filter_parsed(void *parsed_result,
3102 __attribute__((unused)) struct cmdline *cl,
3103 __attribute__((unused)) void *data)
3105 struct cmd_rx_vlan_filter_result *res = parsed_result;
3107 if (!strcmp(res->what, "add"))
3108 rx_vft_set(res->port_id, res->vlan_id, 1);
3110 rx_vft_set(res->port_id, res->vlan_id, 0);
3113 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3114 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3115 rx_vlan, "rx_vlan");
3116 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3117 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3119 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3120 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3122 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3123 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3126 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3127 .f = cmd_rx_vlan_filter_parsed,
3129 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3130 "Add/Remove a VLAN identifier to/from the set of VLAN "
3131 "identifiers filtered by a port",
3133 (void *)&cmd_rx_vlan_filter_rx_vlan,
3134 (void *)&cmd_rx_vlan_filter_what,
3135 (void *)&cmd_rx_vlan_filter_vlanid,
3136 (void *)&cmd_rx_vlan_filter_portid,
3141 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3142 struct cmd_tx_vlan_set_result {
3143 cmdline_fixed_string_t tx_vlan;
3144 cmdline_fixed_string_t set;
3150 cmd_tx_vlan_set_parsed(void *parsed_result,
3151 __attribute__((unused)) struct cmdline *cl,
3152 __attribute__((unused)) void *data)
3154 struct cmd_tx_vlan_set_result *res = parsed_result;
3156 tx_vlan_set(res->port_id, res->vlan_id);
3159 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3160 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3161 tx_vlan, "tx_vlan");
3162 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3163 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3165 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3166 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3168 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3169 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3172 cmdline_parse_inst_t cmd_tx_vlan_set = {
3173 .f = cmd_tx_vlan_set_parsed,
3175 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3176 "Enable hardware insertion of a single VLAN header "
3177 "with a given TAG Identifier in packets sent on a port",
3179 (void *)&cmd_tx_vlan_set_tx_vlan,
3180 (void *)&cmd_tx_vlan_set_set,
3181 (void *)&cmd_tx_vlan_set_portid,
3182 (void *)&cmd_tx_vlan_set_vlanid,
3187 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3188 struct cmd_tx_vlan_set_qinq_result {
3189 cmdline_fixed_string_t tx_vlan;
3190 cmdline_fixed_string_t set;
3193 uint16_t vlan_id_outer;
3197 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3198 __attribute__((unused)) struct cmdline *cl,
3199 __attribute__((unused)) void *data)
3201 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3203 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3206 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3207 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3208 tx_vlan, "tx_vlan");
3209 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3210 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3212 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3213 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3215 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3216 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3218 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3219 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3220 vlan_id_outer, UINT16);
3222 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3223 .f = cmd_tx_vlan_set_qinq_parsed,
3225 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3226 "Enable hardware insertion of double VLAN header "
3227 "with given TAG Identifiers in packets sent on a port",
3229 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3230 (void *)&cmd_tx_vlan_set_qinq_set,
3231 (void *)&cmd_tx_vlan_set_qinq_portid,
3232 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3233 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3238 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3239 struct cmd_tx_vlan_set_pvid_result {
3240 cmdline_fixed_string_t tx_vlan;
3241 cmdline_fixed_string_t set;
3242 cmdline_fixed_string_t pvid;
3245 cmdline_fixed_string_t mode;
3249 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3250 __attribute__((unused)) struct cmdline *cl,
3251 __attribute__((unused)) void *data)
3253 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3255 if (strcmp(res->mode, "on") == 0)
3256 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3258 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3261 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3262 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3263 tx_vlan, "tx_vlan");
3264 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3265 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3267 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3270 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3271 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3273 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3274 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3276 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3277 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3280 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3281 .f = cmd_tx_vlan_set_pvid_parsed,
3283 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3285 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3286 (void *)&cmd_tx_vlan_set_pvid_set,
3287 (void *)&cmd_tx_vlan_set_pvid_pvid,
3288 (void *)&cmd_tx_vlan_set_pvid_port_id,
3289 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3290 (void *)&cmd_tx_vlan_set_pvid_mode,
3295 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3296 struct cmd_tx_vlan_reset_result {
3297 cmdline_fixed_string_t tx_vlan;
3298 cmdline_fixed_string_t reset;
3303 cmd_tx_vlan_reset_parsed(void *parsed_result,
3304 __attribute__((unused)) struct cmdline *cl,
3305 __attribute__((unused)) void *data)
3307 struct cmd_tx_vlan_reset_result *res = parsed_result;
3309 tx_vlan_reset(res->port_id);
3312 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3314 tx_vlan, "tx_vlan");
3315 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3316 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3318 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3319 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3322 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3323 .f = cmd_tx_vlan_reset_parsed,
3325 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3326 "VLAN header in packets sent on a port",
3328 (void *)&cmd_tx_vlan_reset_tx_vlan,
3329 (void *)&cmd_tx_vlan_reset_reset,
3330 (void *)&cmd_tx_vlan_reset_portid,
3336 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3337 struct cmd_csum_result {
3338 cmdline_fixed_string_t csum;
3339 cmdline_fixed_string_t mode;
3340 cmdline_fixed_string_t proto;
3341 cmdline_fixed_string_t hwsw;
3346 csum_show(int port_id)
3348 struct rte_eth_dev_info dev_info;
3351 ol_flags = ports[port_id].tx_ol_flags;
3352 printf("Parse tunnel is %s\n",
3353 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3354 printf("IP checksum offload is %s\n",
3355 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3356 printf("UDP checksum offload is %s\n",
3357 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3358 printf("TCP checksum offload is %s\n",
3359 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3360 printf("SCTP checksum offload is %s\n",
3361 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3362 printf("Outer-Ip checksum offload is %s\n",
3363 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3365 /* display warnings if configuration is not supported by the NIC */
3366 rte_eth_dev_info_get(port_id, &dev_info);
3367 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3368 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3369 printf("Warning: hardware IP checksum enabled but not "
3370 "supported by port %d\n", port_id);
3372 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3373 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3374 printf("Warning: hardware UDP checksum enabled but not "
3375 "supported by port %d\n", port_id);
3377 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3378 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3379 printf("Warning: hardware TCP checksum enabled but not "
3380 "supported by port %d\n", port_id);
3382 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3383 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3384 printf("Warning: hardware SCTP checksum enabled but not "
3385 "supported by port %d\n", port_id);
3387 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3388 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3389 printf("Warning: hardware outer IP checksum enabled but not "
3390 "supported by port %d\n", port_id);
3395 cmd_csum_parsed(void *parsed_result,
3396 __attribute__((unused)) struct cmdline *cl,
3397 __attribute__((unused)) void *data)
3399 struct cmd_csum_result *res = parsed_result;
3403 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3404 printf("invalid port %d\n", res->port_id);
3408 if (!strcmp(res->mode, "set")) {
3410 if (!strcmp(res->hwsw, "hw"))
3413 if (!strcmp(res->proto, "ip")) {
3414 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3415 } else if (!strcmp(res->proto, "udp")) {
3416 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3417 } else if (!strcmp(res->proto, "tcp")) {
3418 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3419 } else if (!strcmp(res->proto, "sctp")) {
3420 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3421 } else if (!strcmp(res->proto, "outer-ip")) {
3422 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3426 ports[res->port_id].tx_ol_flags |= mask;
3428 ports[res->port_id].tx_ol_flags &= (~mask);
3430 csum_show(res->port_id);
3433 cmdline_parse_token_string_t cmd_csum_csum =
3434 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3436 cmdline_parse_token_string_t cmd_csum_mode =
3437 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3439 cmdline_parse_token_string_t cmd_csum_proto =
3440 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3441 proto, "ip#tcp#udp#sctp#outer-ip");
3442 cmdline_parse_token_string_t cmd_csum_hwsw =
3443 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3445 cmdline_parse_token_num_t cmd_csum_portid =
3446 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3449 cmdline_parse_inst_t cmd_csum_set = {
3450 .f = cmd_csum_parsed,
3452 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3453 "Enable/Disable hardware calculation of L3/L4 checksum when "
3454 "using csum forward engine",
3456 (void *)&cmd_csum_csum,
3457 (void *)&cmd_csum_mode,
3458 (void *)&cmd_csum_proto,
3459 (void *)&cmd_csum_hwsw,
3460 (void *)&cmd_csum_portid,
3465 cmdline_parse_token_string_t cmd_csum_mode_show =
3466 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3469 cmdline_parse_inst_t cmd_csum_show = {
3470 .f = cmd_csum_parsed,
3472 .help_str = "csum show <port_id>: Show checksum offload configuration",
3474 (void *)&cmd_csum_csum,
3475 (void *)&cmd_csum_mode_show,
3476 (void *)&cmd_csum_portid,
3481 /* Enable/disable tunnel parsing */
3482 struct cmd_csum_tunnel_result {
3483 cmdline_fixed_string_t csum;
3484 cmdline_fixed_string_t parse;
3485 cmdline_fixed_string_t onoff;
3490 cmd_csum_tunnel_parsed(void *parsed_result,
3491 __attribute__((unused)) struct cmdline *cl,
3492 __attribute__((unused)) void *data)
3494 struct cmd_csum_tunnel_result *res = parsed_result;
3496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3499 if (!strcmp(res->onoff, "on"))
3500 ports[res->port_id].tx_ol_flags |=
3501 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3503 ports[res->port_id].tx_ol_flags &=
3504 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3506 csum_show(res->port_id);
3509 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3510 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3512 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3513 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3514 parse, "parse_tunnel");
3515 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3516 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3518 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3519 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3522 cmdline_parse_inst_t cmd_csum_tunnel = {
3523 .f = cmd_csum_tunnel_parsed,
3525 .help_str = "csum parse_tunnel on|off <port_id>: "
3526 "Enable/Disable parsing of tunnels for csum engine",
3528 (void *)&cmd_csum_tunnel_csum,
3529 (void *)&cmd_csum_tunnel_parse,
3530 (void *)&cmd_csum_tunnel_onoff,
3531 (void *)&cmd_csum_tunnel_portid,
3536 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3537 struct cmd_tso_set_result {
3538 cmdline_fixed_string_t tso;
3539 cmdline_fixed_string_t mode;
3545 cmd_tso_set_parsed(void *parsed_result,
3546 __attribute__((unused)) struct cmdline *cl,
3547 __attribute__((unused)) void *data)
3549 struct cmd_tso_set_result *res = parsed_result;
3550 struct rte_eth_dev_info dev_info;
3552 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3555 if (!strcmp(res->mode, "set"))
3556 ports[res->port_id].tso_segsz = res->tso_segsz;
3558 if (ports[res->port_id].tso_segsz == 0)
3559 printf("TSO for non-tunneled packets is disabled\n");
3561 printf("TSO segment size for non-tunneled packets is %d\n",
3562 ports[res->port_id].tso_segsz);
3564 /* display warnings if configuration is not supported by the NIC */
3565 rte_eth_dev_info_get(res->port_id, &dev_info);
3566 if ((ports[res->port_id].tso_segsz != 0) &&
3567 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3568 printf("Warning: TSO enabled but not "
3569 "supported by port %d\n", res->port_id);
3573 cmdline_parse_token_string_t cmd_tso_set_tso =
3574 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3576 cmdline_parse_token_string_t cmd_tso_set_mode =
3577 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3579 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3580 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3582 cmdline_parse_token_num_t cmd_tso_set_portid =
3583 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3586 cmdline_parse_inst_t cmd_tso_set = {
3587 .f = cmd_tso_set_parsed,
3589 .help_str = "tso set <tso_segsz> <port_id>: "
3590 "Set TSO segment size of non-tunneled packets for csum engine "
3593 (void *)&cmd_tso_set_tso,
3594 (void *)&cmd_tso_set_mode,
3595 (void *)&cmd_tso_set_tso_segsz,
3596 (void *)&cmd_tso_set_portid,
3601 cmdline_parse_token_string_t cmd_tso_show_mode =
3602 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3606 cmdline_parse_inst_t cmd_tso_show = {
3607 .f = cmd_tso_set_parsed,
3609 .help_str = "tso show <port_id>: "
3610 "Show TSO segment size of non-tunneled packets for csum engine",
3612 (void *)&cmd_tso_set_tso,
3613 (void *)&cmd_tso_show_mode,
3614 (void *)&cmd_tso_set_portid,
3619 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3620 struct cmd_tunnel_tso_set_result {
3621 cmdline_fixed_string_t tso;
3622 cmdline_fixed_string_t mode;
3628 check_tunnel_tso_nic_support(uint8_t port_id)
3630 struct rte_eth_dev_info dev_info;
3632 rte_eth_dev_info_get(port_id, &dev_info);
3633 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3634 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3635 "supported by port %d\n", port_id);
3636 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3637 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3638 "supported by port %d\n", port_id);
3639 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3640 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3641 "supported by port %d\n", port_id);
3642 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3643 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3644 "supported by port %d\n", port_id);
3648 cmd_tunnel_tso_set_parsed(void *parsed_result,
3649 __attribute__((unused)) struct cmdline *cl,
3650 __attribute__((unused)) void *data)
3652 struct cmd_tunnel_tso_set_result *res = parsed_result;
3654 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3657 if (!strcmp(res->mode, "set"))
3658 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3660 if (ports[res->port_id].tunnel_tso_segsz == 0)
3661 printf("TSO for tunneled packets is disabled\n");
3663 printf("TSO segment size for tunneled packets is %d\n",
3664 ports[res->port_id].tunnel_tso_segsz);
3666 /* Below conditions are needed to make it work:
3667 * (1) tunnel TSO is supported by the NIC;
3668 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3670 * (3) for tunneled pkts with outer L3 of IPv4,
3671 * "csum set outer-ip" must be set to hw, because after tso,
3672 * total_len of outer IP header is changed, and the checksum
3673 * of outer IP header calculated by sw should be wrong; that
3674 * is not necessary for IPv6 tunneled pkts because there's no
3675 * checksum in IP header anymore.
3677 check_tunnel_tso_nic_support(res->port_id);
3679 if (!(ports[res->port_id].tx_ol_flags &
3680 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3681 printf("Warning: csum parse_tunnel must be set "
3682 "so that tunneled packets are recognized\n");
3683 if (!(ports[res->port_id].tx_ol_flags &
3684 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3685 printf("Warning: csum set outer-ip must be set to hw "
3686 "if outer L3 is IPv4; not necessary for IPv6\n");
3690 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3691 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3693 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3694 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3696 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3697 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3699 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3700 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3703 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3704 .f = cmd_tunnel_tso_set_parsed,
3706 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3707 "Set TSO segment size of tunneled packets for csum engine "
3710 (void *)&cmd_tunnel_tso_set_tso,
3711 (void *)&cmd_tunnel_tso_set_mode,
3712 (void *)&cmd_tunnel_tso_set_tso_segsz,
3713 (void *)&cmd_tunnel_tso_set_portid,
3718 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3719 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3723 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3724 .f = cmd_tunnel_tso_set_parsed,
3726 .help_str = "tunnel_tso show <port_id> "
3727 "Show TSO segment size of tunneled packets for csum engine",
3729 (void *)&cmd_tunnel_tso_set_tso,
3730 (void *)&cmd_tunnel_tso_show_mode,
3731 (void *)&cmd_tunnel_tso_set_portid,
3736 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3737 struct cmd_set_flush_rx {
3738 cmdline_fixed_string_t set;
3739 cmdline_fixed_string_t flush_rx;
3740 cmdline_fixed_string_t mode;
3744 cmd_set_flush_rx_parsed(void *parsed_result,
3745 __attribute__((unused)) struct cmdline *cl,
3746 __attribute__((unused)) void *data)
3748 struct cmd_set_flush_rx *res = parsed_result;
3749 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3752 cmdline_parse_token_string_t cmd_setflushrx_set =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3755 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3756 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3757 flush_rx, "flush_rx");
3758 cmdline_parse_token_string_t cmd_setflushrx_mode =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3763 cmdline_parse_inst_t cmd_set_flush_rx = {
3764 .f = cmd_set_flush_rx_parsed,
3765 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3768 (void *)&cmd_setflushrx_set,
3769 (void *)&cmd_setflushrx_flush_rx,
3770 (void *)&cmd_setflushrx_mode,
3775 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3776 struct cmd_set_link_check {
3777 cmdline_fixed_string_t set;
3778 cmdline_fixed_string_t link_check;
3779 cmdline_fixed_string_t mode;
3783 cmd_set_link_check_parsed(void *parsed_result,
3784 __attribute__((unused)) struct cmdline *cl,
3785 __attribute__((unused)) void *data)
3787 struct cmd_set_link_check *res = parsed_result;
3788 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3791 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3794 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3795 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3796 link_check, "link_check");
3797 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3802 cmdline_parse_inst_t cmd_set_link_check = {
3803 .f = cmd_set_link_check_parsed,
3804 .help_str = "set link_check on|off: Enable/Disable link status check "
3805 "when starting/stopping a port",
3808 (void *)&cmd_setlinkcheck_set,
3809 (void *)&cmd_setlinkcheck_link_check,
3810 (void *)&cmd_setlinkcheck_mode,
3815 #ifdef RTE_NIC_BYPASS
3816 /* *** SET NIC BYPASS MODE *** */
3817 struct cmd_set_bypass_mode_result {
3818 cmdline_fixed_string_t set;
3819 cmdline_fixed_string_t bypass;
3820 cmdline_fixed_string_t mode;
3821 cmdline_fixed_string_t value;
3826 cmd_set_bypass_mode_parsed(void *parsed_result,
3827 __attribute__((unused)) struct cmdline *cl,
3828 __attribute__((unused)) void *data)
3830 struct cmd_set_bypass_mode_result *res = parsed_result;
3831 portid_t port_id = res->port_id;
3832 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3834 if (!strcmp(res->value, "bypass"))
3835 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3836 else if (!strcmp(res->value, "isolate"))
3837 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3839 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3841 /* Set the bypass mode for the relevant port. */
3842 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3843 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3847 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3850 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3853 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3856 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3857 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3858 value, "normal#bypass#isolate");
3859 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3860 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3863 cmdline_parse_inst_t cmd_set_bypass_mode = {
3864 .f = cmd_set_bypass_mode_parsed,
3865 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3866 "Set the NIC bypass mode for port_id",
3869 (void *)&cmd_setbypass_mode_set,
3870 (void *)&cmd_setbypass_mode_bypass,
3871 (void *)&cmd_setbypass_mode_mode,
3872 (void *)&cmd_setbypass_mode_value,
3873 (void *)&cmd_setbypass_mode_port,
3878 /* *** SET NIC BYPASS EVENT *** */
3879 struct cmd_set_bypass_event_result {
3880 cmdline_fixed_string_t set;
3881 cmdline_fixed_string_t bypass;
3882 cmdline_fixed_string_t event;
3883 cmdline_fixed_string_t event_value;
3884 cmdline_fixed_string_t mode;
3885 cmdline_fixed_string_t mode_value;
3890 cmd_set_bypass_event_parsed(void *parsed_result,
3891 __attribute__((unused)) struct cmdline *cl,
3892 __attribute__((unused)) void *data)
3895 struct cmd_set_bypass_event_result *res = parsed_result;
3896 portid_t port_id = res->port_id;
3897 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3898 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3900 if (!strcmp(res->event_value, "timeout"))
3901 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3902 else if (!strcmp(res->event_value, "os_on"))
3903 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3904 else if (!strcmp(res->event_value, "os_off"))
3905 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3906 else if (!strcmp(res->event_value, "power_on"))
3907 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3908 else if (!strcmp(res->event_value, "power_off"))
3909 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3911 bypass_event = RTE_BYPASS_EVENT_NONE;
3913 if (!strcmp(res->mode_value, "bypass"))
3914 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3915 else if (!strcmp(res->mode_value, "isolate"))
3916 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3918 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3920 /* Set the watchdog timeout. */
3921 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3924 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3925 (rc = rte_eth_dev_wd_timeout_store(port_id,
3926 bypass_timeout)) != 0) {
3927 printf("Failed to set timeout value %u "
3928 "for port %d, errto code: %d.\n",
3929 bypass_timeout, port_id, rc);
3933 /* Set the bypass event to transition to bypass mode. */
3934 if (0 != rte_eth_dev_bypass_event_store(port_id,
3935 bypass_event, bypass_mode)) {
3936 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3941 cmdline_parse_token_string_t cmd_setbypass_event_set =
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3944 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3947 cmdline_parse_token_string_t cmd_setbypass_event_event =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3950 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3952 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3953 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3956 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3958 mode_value, "normal#bypass#isolate");
3959 cmdline_parse_token_num_t cmd_setbypass_event_port =
3960 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3963 cmdline_parse_inst_t cmd_set_bypass_event = {
3964 .f = cmd_set_bypass_event_parsed,
3965 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
3966 "power_off mode normal|bypass|isolate <port_id>: "
3967 "Set the NIC bypass event mode for port_id",
3970 (void *)&cmd_setbypass_event_set,
3971 (void *)&cmd_setbypass_event_bypass,
3972 (void *)&cmd_setbypass_event_event,
3973 (void *)&cmd_setbypass_event_event_value,
3974 (void *)&cmd_setbypass_event_mode,
3975 (void *)&cmd_setbypass_event_mode_value,
3976 (void *)&cmd_setbypass_event_port,
3982 /* *** SET NIC BYPASS TIMEOUT *** */
3983 struct cmd_set_bypass_timeout_result {
3984 cmdline_fixed_string_t set;
3985 cmdline_fixed_string_t bypass;
3986 cmdline_fixed_string_t timeout;
3987 cmdline_fixed_string_t value;
3991 cmd_set_bypass_timeout_parsed(void *parsed_result,
3992 __attribute__((unused)) struct cmdline *cl,
3993 __attribute__((unused)) void *data)
3995 struct cmd_set_bypass_timeout_result *res = parsed_result;
3997 if (!strcmp(res->value, "1.5"))
3998 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3999 else if (!strcmp(res->value, "2"))
4000 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4001 else if (!strcmp(res->value, "3"))
4002 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4003 else if (!strcmp(res->value, "4"))
4004 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4005 else if (!strcmp(res->value, "8"))
4006 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4007 else if (!strcmp(res->value, "16"))
4008 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4009 else if (!strcmp(res->value, "32"))
4010 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4012 bypass_timeout = RTE_BYPASS_TMT_OFF;
4015 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4018 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4021 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4023 timeout, "timeout");
4024 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4026 value, "0#1.5#2#3#4#8#16#32");
4028 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4029 .f = cmd_set_bypass_timeout_parsed,
4030 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4031 "Set the NIC bypass watchdog timeout in seconds",
4034 (void *)&cmd_setbypass_timeout_set,
4035 (void *)&cmd_setbypass_timeout_bypass,
4036 (void *)&cmd_setbypass_timeout_timeout,
4037 (void *)&cmd_setbypass_timeout_value,
4042 /* *** SHOW NIC BYPASS MODE *** */
4043 struct cmd_show_bypass_config_result {
4044 cmdline_fixed_string_t show;
4045 cmdline_fixed_string_t bypass;
4046 cmdline_fixed_string_t config;
4051 cmd_show_bypass_config_parsed(void *parsed_result,
4052 __attribute__((unused)) struct cmdline *cl,
4053 __attribute__((unused)) void *data)
4055 struct cmd_show_bypass_config_result *res = parsed_result;
4056 uint32_t event_mode;
4057 uint32_t bypass_mode;
4058 portid_t port_id = res->port_id;
4059 uint32_t timeout = bypass_timeout;
4062 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4063 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4064 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4065 {"UNKNOWN", "normal", "bypass", "isolate"};
4066 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4073 int num_events = (sizeof events) / (sizeof events[0]);
4075 /* Display the bypass mode.*/
4076 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4077 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4081 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4082 bypass_mode = RTE_BYPASS_MODE_NONE;
4084 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4087 /* Display the bypass timeout.*/
4088 if (!RTE_BYPASS_TMT_VALID(timeout))
4089 timeout = RTE_BYPASS_TMT_OFF;
4091 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4093 /* Display the bypass events and associated modes. */
4094 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4096 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4097 printf("\tFailed to get bypass mode for event = %s\n",
4100 if (!RTE_BYPASS_MODE_VALID(event_mode))
4101 event_mode = RTE_BYPASS_MODE_NONE;
4103 printf("\tbypass event: %-16s = %s\n", events[i],
4109 cmdline_parse_token_string_t cmd_showbypass_config_show =
4110 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4112 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4113 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4115 cmdline_parse_token_string_t cmd_showbypass_config_config =
4116 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4118 cmdline_parse_token_num_t cmd_showbypass_config_port =
4119 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4122 cmdline_parse_inst_t cmd_show_bypass_config = {
4123 .f = cmd_show_bypass_config_parsed,
4124 .help_str = "show bypass config <port_id>: "
4125 "Show the NIC bypass config for port_id",
4128 (void *)&cmd_showbypass_config_show,
4129 (void *)&cmd_showbypass_config_bypass,
4130 (void *)&cmd_showbypass_config_config,
4131 (void *)&cmd_showbypass_config_port,
4137 #ifdef RTE_LIBRTE_PMD_BOND
4138 /* *** SET BONDING MODE *** */
4139 struct cmd_set_bonding_mode_result {
4140 cmdline_fixed_string_t set;
4141 cmdline_fixed_string_t bonding;
4142 cmdline_fixed_string_t mode;
4147 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4148 __attribute__((unused)) struct cmdline *cl,
4149 __attribute__((unused)) void *data)
4151 struct cmd_set_bonding_mode_result *res = parsed_result;
4152 portid_t port_id = res->port_id;
4154 /* Set the bonding mode for the relevant port. */
4155 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4156 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4159 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4160 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4162 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4163 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4164 bonding, "bonding");
4165 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4168 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4169 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4171 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4172 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4175 cmdline_parse_inst_t cmd_set_bonding_mode = {
4176 .f = cmd_set_bonding_mode_parsed,
4177 .help_str = "set bonding mode <mode_value> <port_id>: "
4178 "Set the bonding mode for port_id",
4181 (void *) &cmd_setbonding_mode_set,
4182 (void *) &cmd_setbonding_mode_bonding,
4183 (void *) &cmd_setbonding_mode_mode,
4184 (void *) &cmd_setbonding_mode_value,
4185 (void *) &cmd_setbonding_mode_port,
4190 /* *** SET BALANCE XMIT POLICY *** */
4191 struct cmd_set_bonding_balance_xmit_policy_result {
4192 cmdline_fixed_string_t set;
4193 cmdline_fixed_string_t bonding;
4194 cmdline_fixed_string_t balance_xmit_policy;
4196 cmdline_fixed_string_t policy;
4199 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4200 __attribute__((unused)) struct cmdline *cl,
4201 __attribute__((unused)) void *data)
4203 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4204 portid_t port_id = res->port_id;
4207 if (!strcmp(res->policy, "l2")) {
4208 policy = BALANCE_XMIT_POLICY_LAYER2;
4209 } else if (!strcmp(res->policy, "l23")) {
4210 policy = BALANCE_XMIT_POLICY_LAYER23;
4211 } else if (!strcmp(res->policy, "l34")) {
4212 policy = BALANCE_XMIT_POLICY_LAYER34;
4214 printf("\t Invalid xmit policy selection");
4218 /* Set the bonding mode for the relevant port. */
4219 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4220 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4225 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4226 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4228 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4230 bonding, "bonding");
4231 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4233 balance_xmit_policy, "balance_xmit_policy");
4234 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4235 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4237 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4238 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4239 policy, "l2#l23#l34");
4241 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4242 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4243 .help_str = "set bonding balance_xmit_policy <port_id> "
4245 "Set the bonding balance_xmit_policy for port_id",
4248 (void *)&cmd_setbonding_balance_xmit_policy_set,
4249 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4250 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4251 (void *)&cmd_setbonding_balance_xmit_policy_port,
4252 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4257 /* *** SHOW NIC BONDING CONFIGURATION *** */
4258 struct cmd_show_bonding_config_result {
4259 cmdline_fixed_string_t show;
4260 cmdline_fixed_string_t bonding;
4261 cmdline_fixed_string_t config;
4265 static void cmd_show_bonding_config_parsed(void *parsed_result,
4266 __attribute__((unused)) struct cmdline *cl,
4267 __attribute__((unused)) void *data)
4269 struct cmd_show_bonding_config_result *res = parsed_result;
4271 uint8_t slaves[RTE_MAX_ETHPORTS];
4272 int num_slaves, num_active_slaves;
4275 portid_t port_id = res->port_id;
4277 /* Display the bonding mode.*/
4278 bonding_mode = rte_eth_bond_mode_get(port_id);
4279 if (bonding_mode < 0) {
4280 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4283 printf("\tBonding mode: %d\n", bonding_mode);
4285 if (bonding_mode == BONDING_MODE_BALANCE) {
4286 int balance_xmit_policy;
4288 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4289 if (balance_xmit_policy < 0) {
4290 printf("\tFailed to get balance xmit policy for port = %d\n",
4294 printf("\tBalance Xmit Policy: ");
4296 switch (balance_xmit_policy) {
4297 case BALANCE_XMIT_POLICY_LAYER2:
4298 printf("BALANCE_XMIT_POLICY_LAYER2");
4300 case BALANCE_XMIT_POLICY_LAYER23:
4301 printf("BALANCE_XMIT_POLICY_LAYER23");
4303 case BALANCE_XMIT_POLICY_LAYER34:
4304 printf("BALANCE_XMIT_POLICY_LAYER34");
4311 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4313 if (num_slaves < 0) {
4314 printf("\tFailed to get slave list for port = %d\n", port_id);
4317 if (num_slaves > 0) {
4318 printf("\tSlaves (%d): [", num_slaves);
4319 for (i = 0; i < num_slaves - 1; i++)
4320 printf("%d ", slaves[i]);
4322 printf("%d]\n", slaves[num_slaves - 1]);
4324 printf("\tSlaves: []\n");
4328 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4331 if (num_active_slaves < 0) {
4332 printf("\tFailed to get active slave list for port = %d\n", port_id);
4335 if (num_active_slaves > 0) {
4336 printf("\tActive Slaves (%d): [", num_active_slaves);
4337 for (i = 0; i < num_active_slaves - 1; i++)
4338 printf("%d ", slaves[i]);
4340 printf("%d]\n", slaves[num_active_slaves - 1]);
4343 printf("\tActive Slaves: []\n");
4347 primary_id = rte_eth_bond_primary_get(port_id);
4348 if (primary_id < 0) {
4349 printf("\tFailed to get primary slave for port = %d\n", port_id);
4352 printf("\tPrimary: [%d]\n", primary_id);
4356 cmdline_parse_token_string_t cmd_showbonding_config_show =
4357 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4359 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4360 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4361 bonding, "bonding");
4362 cmdline_parse_token_string_t cmd_showbonding_config_config =
4363 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4365 cmdline_parse_token_num_t cmd_showbonding_config_port =
4366 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4369 cmdline_parse_inst_t cmd_show_bonding_config = {
4370 .f = cmd_show_bonding_config_parsed,
4371 .help_str = "show bonding config <port_id>: "
4372 "Show the bonding config for port_id",
4375 (void *)&cmd_showbonding_config_show,
4376 (void *)&cmd_showbonding_config_bonding,
4377 (void *)&cmd_showbonding_config_config,
4378 (void *)&cmd_showbonding_config_port,
4383 /* *** SET BONDING PRIMARY *** */
4384 struct cmd_set_bonding_primary_result {
4385 cmdline_fixed_string_t set;
4386 cmdline_fixed_string_t bonding;
4387 cmdline_fixed_string_t primary;
4392 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4393 __attribute__((unused)) struct cmdline *cl,
4394 __attribute__((unused)) void *data)
4396 struct cmd_set_bonding_primary_result *res = parsed_result;
4397 portid_t master_port_id = res->port_id;
4398 portid_t slave_port_id = res->slave_id;
4400 /* Set the primary slave for a bonded device. */
4401 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4402 printf("\t Failed to set primary slave for port = %d.\n",
4409 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4412 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4414 bonding, "bonding");
4415 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4417 primary, "primary");
4418 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4419 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4421 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4422 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4425 cmdline_parse_inst_t cmd_set_bonding_primary = {
4426 .f = cmd_set_bonding_primary_parsed,
4427 .help_str = "set bonding primary <slave_id> <port_id>: "
4428 "Set the primary slave for port_id",
4431 (void *)&cmd_setbonding_primary_set,
4432 (void *)&cmd_setbonding_primary_bonding,
4433 (void *)&cmd_setbonding_primary_primary,
4434 (void *)&cmd_setbonding_primary_slave,
4435 (void *)&cmd_setbonding_primary_port,
4440 /* *** ADD SLAVE *** */
4441 struct cmd_add_bonding_slave_result {
4442 cmdline_fixed_string_t add;
4443 cmdline_fixed_string_t bonding;
4444 cmdline_fixed_string_t slave;
4449 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4450 __attribute__((unused)) struct cmdline *cl,
4451 __attribute__((unused)) void *data)
4453 struct cmd_add_bonding_slave_result *res = parsed_result;
4454 portid_t master_port_id = res->port_id;
4455 portid_t slave_port_id = res->slave_id;
4457 /* Set the primary slave for a bonded device. */
4458 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4459 printf("\t Failed to add slave %d to master port = %d.\n",
4460 slave_port_id, master_port_id);
4464 set_port_slave_flag(slave_port_id);
4467 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4468 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4470 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4471 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4472 bonding, "bonding");
4473 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4474 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4476 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4477 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4479 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4480 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4483 cmdline_parse_inst_t cmd_add_bonding_slave = {
4484 .f = cmd_add_bonding_slave_parsed,
4485 .help_str = "add bonding slave <slave_id> <port_id>: "
4486 "Add a slave device to a bonded device",
4489 (void *)&cmd_addbonding_slave_add,
4490 (void *)&cmd_addbonding_slave_bonding,
4491 (void *)&cmd_addbonding_slave_slave,
4492 (void *)&cmd_addbonding_slave_slaveid,
4493 (void *)&cmd_addbonding_slave_port,
4498 /* *** REMOVE SLAVE *** */
4499 struct cmd_remove_bonding_slave_result {
4500 cmdline_fixed_string_t remove;
4501 cmdline_fixed_string_t bonding;
4502 cmdline_fixed_string_t slave;
4507 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4508 __attribute__((unused)) struct cmdline *cl,
4509 __attribute__((unused)) void *data)
4511 struct cmd_remove_bonding_slave_result *res = parsed_result;
4512 portid_t master_port_id = res->port_id;
4513 portid_t slave_port_id = res->slave_id;
4515 /* Set the primary slave for a bonded device. */
4516 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4517 printf("\t Failed to remove slave %d from master port = %d.\n",
4518 slave_port_id, master_port_id);
4522 clear_port_slave_flag(slave_port_id);
4525 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4526 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4528 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4529 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4530 bonding, "bonding");
4531 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4532 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4534 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4535 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4537 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4538 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4541 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4542 .f = cmd_remove_bonding_slave_parsed,
4543 .help_str = "remove bonding slave <slave_id> <port_id>: "
4544 "Remove a slave device from a bonded device",
4547 (void *)&cmd_removebonding_slave_remove,
4548 (void *)&cmd_removebonding_slave_bonding,
4549 (void *)&cmd_removebonding_slave_slave,
4550 (void *)&cmd_removebonding_slave_slaveid,
4551 (void *)&cmd_removebonding_slave_port,
4556 /* *** CREATE BONDED DEVICE *** */
4557 struct cmd_create_bonded_device_result {
4558 cmdline_fixed_string_t create;
4559 cmdline_fixed_string_t bonded;
4560 cmdline_fixed_string_t device;
4565 static int bond_dev_num = 0;
4567 static void cmd_create_bonded_device_parsed(void *parsed_result,
4568 __attribute__((unused)) struct cmdline *cl,
4569 __attribute__((unused)) void *data)
4571 struct cmd_create_bonded_device_result *res = parsed_result;
4572 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4575 if (test_done == 0) {
4576 printf("Please stop forwarding first\n");
4580 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4583 /* Create a new bonded device. */
4584 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4586 printf("\t Failed to create bonded device.\n");
4589 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4592 /* Update number of ports */
4593 nb_ports = rte_eth_dev_count();
4594 reconfig(port_id, res->socket);
4595 rte_eth_promiscuous_enable(port_id);
4596 ports[port_id].enabled = 1;
4601 cmdline_parse_token_string_t cmd_createbonded_device_create =
4602 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4604 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4605 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4607 cmdline_parse_token_string_t cmd_createbonded_device_device =
4608 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4610 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4611 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4613 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4614 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4617 cmdline_parse_inst_t cmd_create_bonded_device = {
4618 .f = cmd_create_bonded_device_parsed,
4619 .help_str = "create bonded device <mode> <socket>: "
4620 "Create a new bonded device with specific bonding mode and socket",
4623 (void *)&cmd_createbonded_device_create,
4624 (void *)&cmd_createbonded_device_bonded,
4625 (void *)&cmd_createbonded_device_device,
4626 (void *)&cmd_createbonded_device_mode,
4627 (void *)&cmd_createbonded_device_socket,
4632 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4633 struct cmd_set_bond_mac_addr_result {
4634 cmdline_fixed_string_t set;
4635 cmdline_fixed_string_t bonding;
4636 cmdline_fixed_string_t mac_addr;
4638 struct ether_addr address;
4641 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4642 __attribute__((unused)) struct cmdline *cl,
4643 __attribute__((unused)) void *data)
4645 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4648 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4651 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4653 /* check the return value and print it if is < 0 */
4655 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4658 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4659 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4660 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4661 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4663 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4664 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4666 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4667 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4668 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4669 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4671 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4672 .f = cmd_set_bond_mac_addr_parsed,
4674 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4676 (void *)&cmd_set_bond_mac_addr_set,
4677 (void *)&cmd_set_bond_mac_addr_bonding,
4678 (void *)&cmd_set_bond_mac_addr_mac,
4679 (void *)&cmd_set_bond_mac_addr_portnum,
4680 (void *)&cmd_set_bond_mac_addr_addr,
4686 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4687 struct cmd_set_bond_mon_period_result {
4688 cmdline_fixed_string_t set;
4689 cmdline_fixed_string_t bonding;
4690 cmdline_fixed_string_t mon_period;
4695 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4696 __attribute__((unused)) struct cmdline *cl,
4697 __attribute__((unused)) void *data)
4699 struct cmd_set_bond_mon_period_result *res = parsed_result;
4702 if (res->port_num >= nb_ports) {
4703 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4707 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4709 /* check the return value and print it if is < 0 */
4711 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4714 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4717 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4719 bonding, "bonding");
4720 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4722 mon_period, "mon_period");
4723 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4724 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4726 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4727 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4730 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4731 .f = cmd_set_bond_mon_period_parsed,
4733 .help_str = "set bonding mon_period <port_id> <period_ms>",
4735 (void *)&cmd_set_bond_mon_period_set,
4736 (void *)&cmd_set_bond_mon_period_bonding,
4737 (void *)&cmd_set_bond_mon_period_mon_period,
4738 (void *)&cmd_set_bond_mon_period_portnum,
4739 (void *)&cmd_set_bond_mon_period_period_ms,
4744 #endif /* RTE_LIBRTE_PMD_BOND */
4746 /* *** SET FORWARDING MODE *** */
4747 struct cmd_set_fwd_mode_result {
4748 cmdline_fixed_string_t set;
4749 cmdline_fixed_string_t fwd;
4750 cmdline_fixed_string_t mode;
4753 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4754 __attribute__((unused)) struct cmdline *cl,
4755 __attribute__((unused)) void *data)
4757 struct cmd_set_fwd_mode_result *res = parsed_result;
4760 set_pkt_forwarding_mode(res->mode);
4763 cmdline_parse_token_string_t cmd_setfwd_set =
4764 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4765 cmdline_parse_token_string_t cmd_setfwd_fwd =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4767 cmdline_parse_token_string_t cmd_setfwd_mode =
4768 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4769 "" /* defined at init */);
4771 cmdline_parse_inst_t cmd_set_fwd_mode = {
4772 .f = cmd_set_fwd_mode_parsed,
4774 .help_str = NULL, /* defined at init */
4776 (void *)&cmd_setfwd_set,
4777 (void *)&cmd_setfwd_fwd,
4778 (void *)&cmd_setfwd_mode,
4783 static void cmd_set_fwd_mode_init(void)
4786 static char token[128];
4787 static char help[256];
4788 cmdline_parse_token_string_t *token_struct;
4790 modes = list_pkt_forwarding_modes();
4791 snprintf(help, sizeof(help), "set fwd %s: "
4792 "Set packet forwarding mode", modes);
4793 cmd_set_fwd_mode.help_str = help;
4795 /* string token separator is # */
4796 for (c = token; *modes != '\0'; modes++)
4801 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4802 token_struct->string_data.str = token;
4805 /* *** SET RETRY FORWARDING MODE *** */
4806 struct cmd_set_fwd_retry_mode_result {
4807 cmdline_fixed_string_t set;
4808 cmdline_fixed_string_t fwd;
4809 cmdline_fixed_string_t mode;
4810 cmdline_fixed_string_t retry;
4813 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4814 __attribute__((unused)) struct cmdline *cl,
4815 __attribute__((unused)) void *data)
4817 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4820 set_pkt_forwarding_mode(res->mode);
4823 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4826 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4829 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4832 "" /* defined at init */);
4833 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4834 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4837 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4838 .f = cmd_set_fwd_retry_mode_parsed,
4840 .help_str = NULL, /* defined at init */
4842 (void *)&cmd_setfwd_retry_set,
4843 (void *)&cmd_setfwd_retry_fwd,
4844 (void *)&cmd_setfwd_retry_mode,
4845 (void *)&cmd_setfwd_retry_retry,
4850 static void cmd_set_fwd_retry_mode_init(void)
4853 static char token[128];
4854 static char help[256];
4855 cmdline_parse_token_string_t *token_struct;
4857 modes = list_pkt_forwarding_retry_modes();
4858 snprintf(help, sizeof(help), "set fwd %s retry: "
4859 "Set packet forwarding mode with retry", modes);
4860 cmd_set_fwd_retry_mode.help_str = help;
4862 /* string token separator is # */
4863 for (c = token; *modes != '\0'; modes++)
4868 token_struct = (cmdline_parse_token_string_t *)
4869 cmd_set_fwd_retry_mode.tokens[2];
4870 token_struct->string_data.str = token;
4873 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4874 struct cmd_set_burst_tx_retry_result {
4875 cmdline_fixed_string_t set;
4876 cmdline_fixed_string_t burst;
4877 cmdline_fixed_string_t tx;
4878 cmdline_fixed_string_t delay;
4880 cmdline_fixed_string_t retry;
4884 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4885 __attribute__((unused)) struct cmdline *cl,
4886 __attribute__((unused)) void *data)
4888 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4890 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4891 && !strcmp(res->tx, "tx")) {
4892 if (!strcmp(res->delay, "delay"))
4893 burst_tx_delay_time = res->time;
4894 if (!strcmp(res->retry, "retry"))
4895 burst_tx_retry_num = res->retry_num;
4900 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4901 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4902 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4903 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4905 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4906 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4907 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4908 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4909 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4910 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4911 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4912 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4913 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4914 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4916 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4917 .f = cmd_set_burst_tx_retry_parsed,
4918 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4920 (void *)&cmd_set_burst_tx_retry_set,
4921 (void *)&cmd_set_burst_tx_retry_burst,
4922 (void *)&cmd_set_burst_tx_retry_tx,
4923 (void *)&cmd_set_burst_tx_retry_delay,
4924 (void *)&cmd_set_burst_tx_retry_time,
4925 (void *)&cmd_set_burst_tx_retry_retry,
4926 (void *)&cmd_set_burst_tx_retry_retry_num,
4931 /* *** SET PROMISC MODE *** */
4932 struct cmd_set_promisc_mode_result {
4933 cmdline_fixed_string_t set;
4934 cmdline_fixed_string_t promisc;
4935 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4936 uint8_t port_num; /* valid if "allports" argument == 0 */
4937 cmdline_fixed_string_t mode;
4940 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4941 __attribute__((unused)) struct cmdline *cl,
4944 struct cmd_set_promisc_mode_result *res = parsed_result;
4948 if (!strcmp(res->mode, "on"))
4955 FOREACH_PORT(i, ports) {
4957 rte_eth_promiscuous_enable(i);
4959 rte_eth_promiscuous_disable(i);
4964 rte_eth_promiscuous_enable(res->port_num);
4966 rte_eth_promiscuous_disable(res->port_num);
4970 cmdline_parse_token_string_t cmd_setpromisc_set =
4971 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4972 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4973 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4975 cmdline_parse_token_string_t cmd_setpromisc_portall =
4976 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4978 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4979 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4981 cmdline_parse_token_string_t cmd_setpromisc_mode =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4985 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4986 .f = cmd_set_promisc_mode_parsed,
4988 .help_str = "set promisc all on|off: Set promisc mode for all ports",
4990 (void *)&cmd_setpromisc_set,
4991 (void *)&cmd_setpromisc_promisc,
4992 (void *)&cmd_setpromisc_portall,
4993 (void *)&cmd_setpromisc_mode,
4998 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4999 .f = cmd_set_promisc_mode_parsed,
5001 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5003 (void *)&cmd_setpromisc_set,
5004 (void *)&cmd_setpromisc_promisc,
5005 (void *)&cmd_setpromisc_portnum,
5006 (void *)&cmd_setpromisc_mode,
5011 /* *** SET ALLMULTI MODE *** */
5012 struct cmd_set_allmulti_mode_result {
5013 cmdline_fixed_string_t set;
5014 cmdline_fixed_string_t allmulti;
5015 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5016 uint8_t port_num; /* valid if "allports" argument == 0 */
5017 cmdline_fixed_string_t mode;
5020 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5024 struct cmd_set_allmulti_mode_result *res = parsed_result;
5028 if (!strcmp(res->mode, "on"))
5035 FOREACH_PORT(i, ports) {
5037 rte_eth_allmulticast_enable(i);
5039 rte_eth_allmulticast_disable(i);
5044 rte_eth_allmulticast_enable(res->port_num);
5046 rte_eth_allmulticast_disable(res->port_num);
5050 cmdline_parse_token_string_t cmd_setallmulti_set =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5052 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5053 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5055 cmdline_parse_token_string_t cmd_setallmulti_portall =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5058 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5059 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5061 cmdline_parse_token_string_t cmd_setallmulti_mode =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5065 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5066 .f = cmd_set_allmulti_mode_parsed,
5068 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5070 (void *)&cmd_setallmulti_set,
5071 (void *)&cmd_setallmulti_allmulti,
5072 (void *)&cmd_setallmulti_portall,
5073 (void *)&cmd_setallmulti_mode,
5078 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5079 .f = cmd_set_allmulti_mode_parsed,
5081 .help_str = "set allmulti <port_id> on|off: "
5082 "Set allmulti mode on port_id",
5084 (void *)&cmd_setallmulti_set,
5085 (void *)&cmd_setallmulti_allmulti,
5086 (void *)&cmd_setallmulti_portnum,
5087 (void *)&cmd_setallmulti_mode,
5092 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5093 struct cmd_link_flow_ctrl_set_result {
5094 cmdline_fixed_string_t set;
5095 cmdline_fixed_string_t flow_ctrl;
5096 cmdline_fixed_string_t rx;
5097 cmdline_fixed_string_t rx_lfc_mode;
5098 cmdline_fixed_string_t tx;
5099 cmdline_fixed_string_t tx_lfc_mode;
5100 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5101 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5102 cmdline_fixed_string_t autoneg_str;
5103 cmdline_fixed_string_t autoneg;
5104 cmdline_fixed_string_t hw_str;
5105 uint32_t high_water;
5106 cmdline_fixed_string_t lw_str;
5108 cmdline_fixed_string_t pt_str;
5109 uint16_t pause_time;
5110 cmdline_fixed_string_t xon_str;
5115 cmdline_parse_token_string_t cmd_lfc_set_set =
5116 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5118 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5119 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5120 flow_ctrl, "flow_ctrl");
5121 cmdline_parse_token_string_t cmd_lfc_set_rx =
5122 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5124 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5125 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5126 rx_lfc_mode, "on#off");
5127 cmdline_parse_token_string_t cmd_lfc_set_tx =
5128 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5130 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5131 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5132 tx_lfc_mode, "on#off");
5133 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5134 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5135 hw_str, "high_water");
5136 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5137 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5138 high_water, UINT32);
5139 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5140 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5141 lw_str, "low_water");
5142 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5143 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5145 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5146 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5147 pt_str, "pause_time");
5148 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5149 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5150 pause_time, UINT16);
5151 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5152 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5153 xon_str, "send_xon");
5154 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5155 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5157 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5158 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5159 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5160 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5161 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5162 mac_ctrl_frame_fwd_mode, "on#off");
5163 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5164 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 autoneg_str, "autoneg");
5166 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5169 cmdline_parse_token_num_t cmd_lfc_set_portid =
5170 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5173 /* forward declaration */
5175 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5178 cmdline_parse_inst_t cmd_link_flow_control_set = {
5179 .f = cmd_link_flow_ctrl_set_parsed,
5181 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5182 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5183 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5185 (void *)&cmd_lfc_set_set,
5186 (void *)&cmd_lfc_set_flow_ctrl,
5187 (void *)&cmd_lfc_set_rx,
5188 (void *)&cmd_lfc_set_rx_mode,
5189 (void *)&cmd_lfc_set_tx,
5190 (void *)&cmd_lfc_set_tx_mode,
5191 (void *)&cmd_lfc_set_high_water,
5192 (void *)&cmd_lfc_set_low_water,
5193 (void *)&cmd_lfc_set_pause_time,
5194 (void *)&cmd_lfc_set_send_xon,
5195 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5196 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5197 (void *)&cmd_lfc_set_autoneg_str,
5198 (void *)&cmd_lfc_set_autoneg,
5199 (void *)&cmd_lfc_set_portid,
5204 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5205 .f = cmd_link_flow_ctrl_set_parsed,
5206 .data = (void *)&cmd_link_flow_control_set_rx,
5207 .help_str = "set flow_ctrl rx on|off <port_id>: "
5208 "Change rx flow control parameter",
5210 (void *)&cmd_lfc_set_set,
5211 (void *)&cmd_lfc_set_flow_ctrl,
5212 (void *)&cmd_lfc_set_rx,
5213 (void *)&cmd_lfc_set_rx_mode,
5214 (void *)&cmd_lfc_set_portid,
5219 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5220 .f = cmd_link_flow_ctrl_set_parsed,
5221 .data = (void *)&cmd_link_flow_control_set_tx,
5222 .help_str = "set flow_ctrl tx on|off <port_id>: "
5223 "Change tx flow control parameter",
5225 (void *)&cmd_lfc_set_set,
5226 (void *)&cmd_lfc_set_flow_ctrl,
5227 (void *)&cmd_lfc_set_tx,
5228 (void *)&cmd_lfc_set_tx_mode,
5229 (void *)&cmd_lfc_set_portid,
5234 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5235 .f = cmd_link_flow_ctrl_set_parsed,
5236 .data = (void *)&cmd_link_flow_control_set_hw,
5237 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5238 "Change high water flow control parameter",
5240 (void *)&cmd_lfc_set_set,
5241 (void *)&cmd_lfc_set_flow_ctrl,
5242 (void *)&cmd_lfc_set_high_water_str,
5243 (void *)&cmd_lfc_set_high_water,
5244 (void *)&cmd_lfc_set_portid,
5249 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5250 .f = cmd_link_flow_ctrl_set_parsed,
5251 .data = (void *)&cmd_link_flow_control_set_lw,
5252 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5253 "Change low water flow control parameter",
5255 (void *)&cmd_lfc_set_set,
5256 (void *)&cmd_lfc_set_flow_ctrl,
5257 (void *)&cmd_lfc_set_low_water_str,
5258 (void *)&cmd_lfc_set_low_water,
5259 (void *)&cmd_lfc_set_portid,
5264 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5265 .f = cmd_link_flow_ctrl_set_parsed,
5266 .data = (void *)&cmd_link_flow_control_set_pt,
5267 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5268 "Change pause time flow control parameter",
5270 (void *)&cmd_lfc_set_set,
5271 (void *)&cmd_lfc_set_flow_ctrl,
5272 (void *)&cmd_lfc_set_pause_time_str,
5273 (void *)&cmd_lfc_set_pause_time,
5274 (void *)&cmd_lfc_set_portid,
5279 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5280 .f = cmd_link_flow_ctrl_set_parsed,
5281 .data = (void *)&cmd_link_flow_control_set_xon,
5282 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5283 "Change send_xon flow control parameter",
5285 (void *)&cmd_lfc_set_set,
5286 (void *)&cmd_lfc_set_flow_ctrl,
5287 (void *)&cmd_lfc_set_send_xon_str,
5288 (void *)&cmd_lfc_set_send_xon,
5289 (void *)&cmd_lfc_set_portid,
5294 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5295 .f = cmd_link_flow_ctrl_set_parsed,
5296 .data = (void *)&cmd_link_flow_control_set_macfwd,
5297 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5298 "Change mac ctrl fwd flow control parameter",
5300 (void *)&cmd_lfc_set_set,
5301 (void *)&cmd_lfc_set_flow_ctrl,
5302 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5303 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5304 (void *)&cmd_lfc_set_portid,
5309 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5310 .f = cmd_link_flow_ctrl_set_parsed,
5311 .data = (void *)&cmd_link_flow_control_set_autoneg,
5312 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5313 "Change autoneg flow control parameter",
5315 (void *)&cmd_lfc_set_set,
5316 (void *)&cmd_lfc_set_flow_ctrl,
5317 (void *)&cmd_lfc_set_autoneg_str,
5318 (void *)&cmd_lfc_set_autoneg,
5319 (void *)&cmd_lfc_set_portid,
5325 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5326 __attribute__((unused)) struct cmdline *cl,
5329 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5330 cmdline_parse_inst_t *cmd = data;
5331 struct rte_eth_fc_conf fc_conf;
5337 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5338 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5339 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5340 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5342 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5343 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5346 /* Partial command line, retrieve current configuration */
5348 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5350 printf("cannot get current flow ctrl parameters, return"
5351 "code = %d\n", ret);
5355 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5356 (fc_conf.mode == RTE_FC_FULL))
5358 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5359 (fc_conf.mode == RTE_FC_FULL))
5363 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5364 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5366 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5367 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5369 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5371 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5372 fc_conf.high_water = res->high_water;
5374 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5375 fc_conf.low_water = res->low_water;
5377 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5378 fc_conf.pause_time = res->pause_time;
5380 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5381 fc_conf.send_xon = res->send_xon;
5383 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5384 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5385 fc_conf.mac_ctrl_frame_fwd = 1;
5387 fc_conf.mac_ctrl_frame_fwd = 0;
5390 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5391 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5393 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5395 printf("bad flow contrl parameter, return code = %d \n", ret);
5398 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5399 struct cmd_priority_flow_ctrl_set_result {
5400 cmdline_fixed_string_t set;
5401 cmdline_fixed_string_t pfc_ctrl;
5402 cmdline_fixed_string_t rx;
5403 cmdline_fixed_string_t rx_pfc_mode;
5404 cmdline_fixed_string_t tx;
5405 cmdline_fixed_string_t tx_pfc_mode;
5406 uint32_t high_water;
5408 uint16_t pause_time;
5414 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5415 __attribute__((unused)) struct cmdline *cl,
5416 __attribute__((unused)) void *data)
5418 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5419 struct rte_eth_pfc_conf pfc_conf;
5420 int rx_fc_enable, tx_fc_enable;
5424 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5425 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5426 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5427 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5429 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5430 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5433 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5434 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5435 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5436 pfc_conf.fc.high_water = res->high_water;
5437 pfc_conf.fc.low_water = res->low_water;
5438 pfc_conf.fc.pause_time = res->pause_time;
5439 pfc_conf.priority = res->priority;
5441 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5443 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5446 cmdline_parse_token_string_t cmd_pfc_set_set =
5447 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5449 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5450 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5451 pfc_ctrl, "pfc_ctrl");
5452 cmdline_parse_token_string_t cmd_pfc_set_rx =
5453 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5455 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5456 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5457 rx_pfc_mode, "on#off");
5458 cmdline_parse_token_string_t cmd_pfc_set_tx =
5459 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5461 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5462 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5463 tx_pfc_mode, "on#off");
5464 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5465 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5466 high_water, UINT32);
5467 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5468 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5470 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5471 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5472 pause_time, UINT16);
5473 cmdline_parse_token_num_t cmd_pfc_set_priority =
5474 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5476 cmdline_parse_token_num_t cmd_pfc_set_portid =
5477 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5480 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5481 .f = cmd_priority_flow_ctrl_set_parsed,
5483 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5484 "<pause_time> <priority> <port_id>: "
5485 "Configure the Ethernet priority flow control",
5487 (void *)&cmd_pfc_set_set,
5488 (void *)&cmd_pfc_set_flow_ctrl,
5489 (void *)&cmd_pfc_set_rx,
5490 (void *)&cmd_pfc_set_rx_mode,
5491 (void *)&cmd_pfc_set_tx,
5492 (void *)&cmd_pfc_set_tx_mode,
5493 (void *)&cmd_pfc_set_high_water,
5494 (void *)&cmd_pfc_set_low_water,
5495 (void *)&cmd_pfc_set_pause_time,
5496 (void *)&cmd_pfc_set_priority,
5497 (void *)&cmd_pfc_set_portid,
5502 /* *** RESET CONFIGURATION *** */
5503 struct cmd_reset_result {
5504 cmdline_fixed_string_t reset;
5505 cmdline_fixed_string_t def;
5508 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5510 __attribute__((unused)) void *data)
5512 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5513 set_def_fwd_config();
5516 cmdline_parse_token_string_t cmd_reset_set =
5517 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5518 cmdline_parse_token_string_t cmd_reset_def =
5519 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5522 cmdline_parse_inst_t cmd_reset = {
5523 .f = cmd_reset_parsed,
5525 .help_str = "set default: Reset default forwarding configuration",
5527 (void *)&cmd_reset_set,
5528 (void *)&cmd_reset_def,
5533 /* *** START FORWARDING *** */
5534 struct cmd_start_result {
5535 cmdline_fixed_string_t start;
5538 cmdline_parse_token_string_t cmd_start_start =
5539 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5541 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5542 __attribute__((unused)) struct cmdline *cl,
5543 __attribute__((unused)) void *data)
5545 start_packet_forwarding(0);
5548 cmdline_parse_inst_t cmd_start = {
5549 .f = cmd_start_parsed,
5551 .help_str = "start: Start packet forwarding",
5553 (void *)&cmd_start_start,
5558 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5559 struct cmd_start_tx_first_result {
5560 cmdline_fixed_string_t start;
5561 cmdline_fixed_string_t tx_first;
5565 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5566 __attribute__((unused)) struct cmdline *cl,
5567 __attribute__((unused)) void *data)
5569 start_packet_forwarding(1);
5572 cmdline_parse_token_string_t cmd_start_tx_first_start =
5573 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5575 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5576 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5577 tx_first, "tx_first");
5579 cmdline_parse_inst_t cmd_start_tx_first = {
5580 .f = cmd_start_tx_first_parsed,
5582 .help_str = "start tx_first: Start packet forwarding, "
5583 "after sending 1 burst of packets",
5585 (void *)&cmd_start_tx_first_start,
5586 (void *)&cmd_start_tx_first_tx_first,
5591 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5592 struct cmd_start_tx_first_n_result {
5593 cmdline_fixed_string_t start;
5594 cmdline_fixed_string_t tx_first;
5599 cmd_start_tx_first_n_parsed(void *parsed_result,
5600 __attribute__((unused)) struct cmdline *cl,
5601 __attribute__((unused)) void *data)
5603 struct cmd_start_tx_first_n_result *res = parsed_result;
5605 start_packet_forwarding(res->tx_num);
5608 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5609 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5611 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5612 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5613 tx_first, "tx_first");
5614 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5615 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5618 cmdline_parse_inst_t cmd_start_tx_first_n = {
5619 .f = cmd_start_tx_first_n_parsed,
5621 .help_str = "start tx_first <num>: "
5622 "packet forwarding, after sending <num> bursts of packets",
5624 (void *)&cmd_start_tx_first_n_start,
5625 (void *)&cmd_start_tx_first_n_tx_first,
5626 (void *)&cmd_start_tx_first_n_tx_num,
5631 /* *** SET LINK UP *** */
5632 struct cmd_set_link_up_result {
5633 cmdline_fixed_string_t set;
5634 cmdline_fixed_string_t link_up;
5635 cmdline_fixed_string_t port;
5639 cmdline_parse_token_string_t cmd_set_link_up_set =
5640 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5641 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5642 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5644 cmdline_parse_token_string_t cmd_set_link_up_port =
5645 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5646 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5647 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5649 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5650 __attribute__((unused)) struct cmdline *cl,
5651 __attribute__((unused)) void *data)
5653 struct cmd_set_link_up_result *res = parsed_result;
5654 dev_set_link_up(res->port_id);
5657 cmdline_parse_inst_t cmd_set_link_up = {
5658 .f = cmd_set_link_up_parsed,
5660 .help_str = "set link-up port <port id>",
5662 (void *)&cmd_set_link_up_set,
5663 (void *)&cmd_set_link_up_link_up,
5664 (void *)&cmd_set_link_up_port,
5665 (void *)&cmd_set_link_up_port_id,
5670 /* *** SET LINK DOWN *** */
5671 struct cmd_set_link_down_result {
5672 cmdline_fixed_string_t set;
5673 cmdline_fixed_string_t link_down;
5674 cmdline_fixed_string_t port;
5678 cmdline_parse_token_string_t cmd_set_link_down_set =
5679 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5680 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5683 cmdline_parse_token_string_t cmd_set_link_down_port =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5685 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5686 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5688 static void cmd_set_link_down_parsed(
5689 __attribute__((unused)) void *parsed_result,
5690 __attribute__((unused)) struct cmdline *cl,
5691 __attribute__((unused)) void *data)
5693 struct cmd_set_link_down_result *res = parsed_result;
5694 dev_set_link_down(res->port_id);
5697 cmdline_parse_inst_t cmd_set_link_down = {
5698 .f = cmd_set_link_down_parsed,
5700 .help_str = "set link-down port <port id>",
5702 (void *)&cmd_set_link_down_set,
5703 (void *)&cmd_set_link_down_link_down,
5704 (void *)&cmd_set_link_down_port,
5705 (void *)&cmd_set_link_down_port_id,
5710 /* *** SHOW CFG *** */
5711 struct cmd_showcfg_result {
5712 cmdline_fixed_string_t show;
5713 cmdline_fixed_string_t cfg;
5714 cmdline_fixed_string_t what;
5717 static void cmd_showcfg_parsed(void *parsed_result,
5718 __attribute__((unused)) struct cmdline *cl,
5719 __attribute__((unused)) void *data)
5721 struct cmd_showcfg_result *res = parsed_result;
5722 if (!strcmp(res->what, "rxtx"))
5723 rxtx_config_display();
5724 else if (!strcmp(res->what, "cores"))
5725 fwd_lcores_config_display();
5726 else if (!strcmp(res->what, "fwd"))
5727 pkt_fwd_config_display(&cur_fwd_config);
5728 else if (!strcmp(res->what, "txpkts"))
5729 show_tx_pkt_segments();
5732 cmdline_parse_token_string_t cmd_showcfg_show =
5733 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5734 cmdline_parse_token_string_t cmd_showcfg_port =
5735 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5736 cmdline_parse_token_string_t cmd_showcfg_what =
5737 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5738 "rxtx#cores#fwd#txpkts");
5740 cmdline_parse_inst_t cmd_showcfg = {
5741 .f = cmd_showcfg_parsed,
5743 .help_str = "show config rxtx|cores|fwd|txpkts",
5745 (void *)&cmd_showcfg_show,
5746 (void *)&cmd_showcfg_port,
5747 (void *)&cmd_showcfg_what,
5752 /* *** SHOW ALL PORT INFO *** */
5753 struct cmd_showportall_result {
5754 cmdline_fixed_string_t show;
5755 cmdline_fixed_string_t port;
5756 cmdline_fixed_string_t what;
5757 cmdline_fixed_string_t all;
5760 static void cmd_showportall_parsed(void *parsed_result,
5761 __attribute__((unused)) struct cmdline *cl,
5762 __attribute__((unused)) void *data)
5766 struct cmd_showportall_result *res = parsed_result;
5767 if (!strcmp(res->show, "clear")) {
5768 if (!strcmp(res->what, "stats"))
5769 FOREACH_PORT(i, ports)
5771 else if (!strcmp(res->what, "xstats"))
5772 FOREACH_PORT(i, ports)
5773 nic_xstats_clear(i);
5774 } else if (!strcmp(res->what, "info"))
5775 FOREACH_PORT(i, ports)
5776 port_infos_display(i);
5777 else if (!strcmp(res->what, "stats"))
5778 FOREACH_PORT(i, ports)
5779 nic_stats_display(i);
5780 else if (!strcmp(res->what, "xstats"))
5781 FOREACH_PORT(i, ports)
5782 nic_xstats_display(i);
5783 else if (!strcmp(res->what, "fdir"))
5784 FOREACH_PORT(i, ports)
5786 else if (!strcmp(res->what, "stat_qmap"))
5787 FOREACH_PORT(i, ports)
5788 nic_stats_mapping_display(i);
5789 else if (!strcmp(res->what, "dcb_tc"))
5790 FOREACH_PORT(i, ports)
5791 port_dcb_info_display(i);
5794 cmdline_parse_token_string_t cmd_showportall_show =
5795 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5797 cmdline_parse_token_string_t cmd_showportall_port =
5798 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5799 cmdline_parse_token_string_t cmd_showportall_what =
5800 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5801 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5802 cmdline_parse_token_string_t cmd_showportall_all =
5803 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5804 cmdline_parse_inst_t cmd_showportall = {
5805 .f = cmd_showportall_parsed,
5807 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5809 (void *)&cmd_showportall_show,
5810 (void *)&cmd_showportall_port,
5811 (void *)&cmd_showportall_what,
5812 (void *)&cmd_showportall_all,
5817 /* *** SHOW PORT INFO *** */
5818 struct cmd_showport_result {
5819 cmdline_fixed_string_t show;
5820 cmdline_fixed_string_t port;
5821 cmdline_fixed_string_t what;
5825 static void cmd_showport_parsed(void *parsed_result,
5826 __attribute__((unused)) struct cmdline *cl,
5827 __attribute__((unused)) void *data)
5829 struct cmd_showport_result *res = parsed_result;
5830 if (!strcmp(res->show, "clear")) {
5831 if (!strcmp(res->what, "stats"))
5832 nic_stats_clear(res->portnum);
5833 else if (!strcmp(res->what, "xstats"))
5834 nic_xstats_clear(res->portnum);
5835 } else if (!strcmp(res->what, "info"))
5836 port_infos_display(res->portnum);
5837 else if (!strcmp(res->what, "stats"))
5838 nic_stats_display(res->portnum);
5839 else if (!strcmp(res->what, "xstats"))
5840 nic_xstats_display(res->portnum);
5841 else if (!strcmp(res->what, "fdir"))
5842 fdir_get_infos(res->portnum);
5843 else if (!strcmp(res->what, "stat_qmap"))
5844 nic_stats_mapping_display(res->portnum);
5845 else if (!strcmp(res->what, "dcb_tc"))
5846 port_dcb_info_display(res->portnum);
5849 cmdline_parse_token_string_t cmd_showport_show =
5850 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5852 cmdline_parse_token_string_t cmd_showport_port =
5853 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5854 cmdline_parse_token_string_t cmd_showport_what =
5855 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5856 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5857 cmdline_parse_token_num_t cmd_showport_portnum =
5858 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5860 cmdline_parse_inst_t cmd_showport = {
5861 .f = cmd_showport_parsed,
5863 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5866 (void *)&cmd_showport_show,
5867 (void *)&cmd_showport_port,
5868 (void *)&cmd_showport_what,
5869 (void *)&cmd_showport_portnum,
5874 /* *** SHOW QUEUE INFO *** */
5875 struct cmd_showqueue_result {
5876 cmdline_fixed_string_t show;
5877 cmdline_fixed_string_t type;
5878 cmdline_fixed_string_t what;
5884 cmd_showqueue_parsed(void *parsed_result,
5885 __attribute__((unused)) struct cmdline *cl,
5886 __attribute__((unused)) void *data)
5888 struct cmd_showqueue_result *res = parsed_result;
5890 if (!strcmp(res->type, "rxq"))
5891 rx_queue_infos_display(res->portnum, res->queuenum);
5892 else if (!strcmp(res->type, "txq"))
5893 tx_queue_infos_display(res->portnum, res->queuenum);
5896 cmdline_parse_token_string_t cmd_showqueue_show =
5897 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5898 cmdline_parse_token_string_t cmd_showqueue_type =
5899 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5900 cmdline_parse_token_string_t cmd_showqueue_what =
5901 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5902 cmdline_parse_token_num_t cmd_showqueue_portnum =
5903 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5904 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5905 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5907 cmdline_parse_inst_t cmd_showqueue = {
5908 .f = cmd_showqueue_parsed,
5910 .help_str = "show rxq|txq info <port_id> <queue_id>",
5912 (void *)&cmd_showqueue_show,
5913 (void *)&cmd_showqueue_type,
5914 (void *)&cmd_showqueue_what,
5915 (void *)&cmd_showqueue_portnum,
5916 (void *)&cmd_showqueue_queuenum,
5921 /* *** READ PORT REGISTER *** */
5922 struct cmd_read_reg_result {
5923 cmdline_fixed_string_t read;
5924 cmdline_fixed_string_t reg;
5930 cmd_read_reg_parsed(void *parsed_result,
5931 __attribute__((unused)) struct cmdline *cl,
5932 __attribute__((unused)) void *data)
5934 struct cmd_read_reg_result *res = parsed_result;
5935 port_reg_display(res->port_id, res->reg_off);
5938 cmdline_parse_token_string_t cmd_read_reg_read =
5939 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5940 cmdline_parse_token_string_t cmd_read_reg_reg =
5941 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5942 cmdline_parse_token_num_t cmd_read_reg_port_id =
5943 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5944 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5945 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5947 cmdline_parse_inst_t cmd_read_reg = {
5948 .f = cmd_read_reg_parsed,
5950 .help_str = "read reg <port_id> <reg_off>",
5952 (void *)&cmd_read_reg_read,
5953 (void *)&cmd_read_reg_reg,
5954 (void *)&cmd_read_reg_port_id,
5955 (void *)&cmd_read_reg_reg_off,
5960 /* *** READ PORT REGISTER BIT FIELD *** */
5961 struct cmd_read_reg_bit_field_result {
5962 cmdline_fixed_string_t read;
5963 cmdline_fixed_string_t regfield;
5971 cmd_read_reg_bit_field_parsed(void *parsed_result,
5972 __attribute__((unused)) struct cmdline *cl,
5973 __attribute__((unused)) void *data)
5975 struct cmd_read_reg_bit_field_result *res = parsed_result;
5976 port_reg_bit_field_display(res->port_id, res->reg_off,
5977 res->bit1_pos, res->bit2_pos);
5980 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5981 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5983 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5984 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5985 regfield, "regfield");
5986 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5987 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5989 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5990 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5992 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5993 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5995 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5996 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5999 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6000 .f = cmd_read_reg_bit_field_parsed,
6002 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6003 "Read register bit field between bit_x and bit_y included",
6005 (void *)&cmd_read_reg_bit_field_read,
6006 (void *)&cmd_read_reg_bit_field_regfield,
6007 (void *)&cmd_read_reg_bit_field_port_id,
6008 (void *)&cmd_read_reg_bit_field_reg_off,
6009 (void *)&cmd_read_reg_bit_field_bit1_pos,
6010 (void *)&cmd_read_reg_bit_field_bit2_pos,
6015 /* *** READ PORT REGISTER BIT *** */
6016 struct cmd_read_reg_bit_result {
6017 cmdline_fixed_string_t read;
6018 cmdline_fixed_string_t regbit;
6025 cmd_read_reg_bit_parsed(void *parsed_result,
6026 __attribute__((unused)) struct cmdline *cl,
6027 __attribute__((unused)) void *data)
6029 struct cmd_read_reg_bit_result *res = parsed_result;
6030 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6033 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6034 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6035 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6036 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6038 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6039 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6040 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6041 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6042 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6043 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6045 cmdline_parse_inst_t cmd_read_reg_bit = {
6046 .f = cmd_read_reg_bit_parsed,
6048 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6050 (void *)&cmd_read_reg_bit_read,
6051 (void *)&cmd_read_reg_bit_regbit,
6052 (void *)&cmd_read_reg_bit_port_id,
6053 (void *)&cmd_read_reg_bit_reg_off,
6054 (void *)&cmd_read_reg_bit_bit_pos,
6059 /* *** WRITE PORT REGISTER *** */
6060 struct cmd_write_reg_result {
6061 cmdline_fixed_string_t write;
6062 cmdline_fixed_string_t reg;
6069 cmd_write_reg_parsed(void *parsed_result,
6070 __attribute__((unused)) struct cmdline *cl,
6071 __attribute__((unused)) void *data)
6073 struct cmd_write_reg_result *res = parsed_result;
6074 port_reg_set(res->port_id, res->reg_off, res->value);
6077 cmdline_parse_token_string_t cmd_write_reg_write =
6078 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6079 cmdline_parse_token_string_t cmd_write_reg_reg =
6080 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6081 cmdline_parse_token_num_t cmd_write_reg_port_id =
6082 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6083 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6084 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6085 cmdline_parse_token_num_t cmd_write_reg_value =
6086 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6088 cmdline_parse_inst_t cmd_write_reg = {
6089 .f = cmd_write_reg_parsed,
6091 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6093 (void *)&cmd_write_reg_write,
6094 (void *)&cmd_write_reg_reg,
6095 (void *)&cmd_write_reg_port_id,
6096 (void *)&cmd_write_reg_reg_off,
6097 (void *)&cmd_write_reg_value,
6102 /* *** WRITE PORT REGISTER BIT FIELD *** */
6103 struct cmd_write_reg_bit_field_result {
6104 cmdline_fixed_string_t write;
6105 cmdline_fixed_string_t regfield;
6114 cmd_write_reg_bit_field_parsed(void *parsed_result,
6115 __attribute__((unused)) struct cmdline *cl,
6116 __attribute__((unused)) void *data)
6118 struct cmd_write_reg_bit_field_result *res = parsed_result;
6119 port_reg_bit_field_set(res->port_id, res->reg_off,
6120 res->bit1_pos, res->bit2_pos, res->value);
6123 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6124 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6126 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6127 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6128 regfield, "regfield");
6129 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6130 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6132 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6133 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6135 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6138 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6139 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6141 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6142 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6145 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6146 .f = cmd_write_reg_bit_field_parsed,
6148 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6150 "Set register bit field between bit_x and bit_y included",
6152 (void *)&cmd_write_reg_bit_field_write,
6153 (void *)&cmd_write_reg_bit_field_regfield,
6154 (void *)&cmd_write_reg_bit_field_port_id,
6155 (void *)&cmd_write_reg_bit_field_reg_off,
6156 (void *)&cmd_write_reg_bit_field_bit1_pos,
6157 (void *)&cmd_write_reg_bit_field_bit2_pos,
6158 (void *)&cmd_write_reg_bit_field_value,
6163 /* *** WRITE PORT REGISTER BIT *** */
6164 struct cmd_write_reg_bit_result {
6165 cmdline_fixed_string_t write;
6166 cmdline_fixed_string_t regbit;
6174 cmd_write_reg_bit_parsed(void *parsed_result,
6175 __attribute__((unused)) struct cmdline *cl,
6176 __attribute__((unused)) void *data)
6178 struct cmd_write_reg_bit_result *res = parsed_result;
6179 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6182 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6183 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6185 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6186 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6188 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6189 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6190 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6191 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6192 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6193 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6194 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6195 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6197 cmdline_parse_inst_t cmd_write_reg_bit = {
6198 .f = cmd_write_reg_bit_parsed,
6200 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6203 (void *)&cmd_write_reg_bit_write,
6204 (void *)&cmd_write_reg_bit_regbit,
6205 (void *)&cmd_write_reg_bit_port_id,
6206 (void *)&cmd_write_reg_bit_reg_off,
6207 (void *)&cmd_write_reg_bit_bit_pos,
6208 (void *)&cmd_write_reg_bit_value,
6213 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6214 struct cmd_read_rxd_txd_result {
6215 cmdline_fixed_string_t read;
6216 cmdline_fixed_string_t rxd_txd;
6223 cmd_read_rxd_txd_parsed(void *parsed_result,
6224 __attribute__((unused)) struct cmdline *cl,
6225 __attribute__((unused)) void *data)
6227 struct cmd_read_rxd_txd_result *res = parsed_result;
6229 if (!strcmp(res->rxd_txd, "rxd"))
6230 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6231 else if (!strcmp(res->rxd_txd, "txd"))
6232 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6235 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6236 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6237 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6238 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6240 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6241 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6242 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6243 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6244 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6245 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6247 cmdline_parse_inst_t cmd_read_rxd_txd = {
6248 .f = cmd_read_rxd_txd_parsed,
6250 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6252 (void *)&cmd_read_rxd_txd_read,
6253 (void *)&cmd_read_rxd_txd_rxd_txd,
6254 (void *)&cmd_read_rxd_txd_port_id,
6255 (void *)&cmd_read_rxd_txd_queue_id,
6256 (void *)&cmd_read_rxd_txd_desc_id,
6262 struct cmd_quit_result {
6263 cmdline_fixed_string_t quit;
6266 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6268 __attribute__((unused)) void *data)
6274 cmdline_parse_token_string_t cmd_quit_quit =
6275 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6277 cmdline_parse_inst_t cmd_quit = {
6278 .f = cmd_quit_parsed,
6280 .help_str = "quit: Exit application",
6282 (void *)&cmd_quit_quit,
6287 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6288 struct cmd_mac_addr_result {
6289 cmdline_fixed_string_t mac_addr_cmd;
6290 cmdline_fixed_string_t what;
6292 struct ether_addr address;
6295 static void cmd_mac_addr_parsed(void *parsed_result,
6296 __attribute__((unused)) struct cmdline *cl,
6297 __attribute__((unused)) void *data)
6299 struct cmd_mac_addr_result *res = parsed_result;
6302 if (strcmp(res->what, "add") == 0)
6303 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6305 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6307 /* check the return value and print it if is < 0 */
6309 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6313 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6314 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6316 cmdline_parse_token_string_t cmd_mac_addr_what =
6317 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6319 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6320 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6321 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6322 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6324 cmdline_parse_inst_t cmd_mac_addr = {
6325 .f = cmd_mac_addr_parsed,
6327 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6328 "Add/Remove MAC address on port_id",
6330 (void *)&cmd_mac_addr_cmd,
6331 (void *)&cmd_mac_addr_what,
6332 (void *)&cmd_mac_addr_portnum,
6333 (void *)&cmd_mac_addr_addr,
6339 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6340 struct cmd_set_qmap_result {
6341 cmdline_fixed_string_t set;
6342 cmdline_fixed_string_t qmap;
6343 cmdline_fixed_string_t what;
6350 cmd_set_qmap_parsed(void *parsed_result,
6351 __attribute__((unused)) struct cmdline *cl,
6352 __attribute__((unused)) void *data)
6354 struct cmd_set_qmap_result *res = parsed_result;
6355 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6357 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6360 cmdline_parse_token_string_t cmd_setqmap_set =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6363 cmdline_parse_token_string_t cmd_setqmap_qmap =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6366 cmdline_parse_token_string_t cmd_setqmap_what =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6369 cmdline_parse_token_num_t cmd_setqmap_portid =
6370 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6372 cmdline_parse_token_num_t cmd_setqmap_queueid =
6373 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6375 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6376 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6379 cmdline_parse_inst_t cmd_set_qmap = {
6380 .f = cmd_set_qmap_parsed,
6382 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6383 "Set statistics mapping value on tx|rx queue_id of port_id",
6385 (void *)&cmd_setqmap_set,
6386 (void *)&cmd_setqmap_qmap,
6387 (void *)&cmd_setqmap_what,
6388 (void *)&cmd_setqmap_portid,
6389 (void *)&cmd_setqmap_queueid,
6390 (void *)&cmd_setqmap_mapvalue,
6395 /* *** CONFIGURE UNICAST HASH TABLE *** */
6396 struct cmd_set_uc_hash_table {
6397 cmdline_fixed_string_t set;
6398 cmdline_fixed_string_t port;
6400 cmdline_fixed_string_t what;
6401 struct ether_addr address;
6402 cmdline_fixed_string_t mode;
6406 cmd_set_uc_hash_parsed(void *parsed_result,
6407 __attribute__((unused)) struct cmdline *cl,
6408 __attribute__((unused)) void *data)
6411 struct cmd_set_uc_hash_table *res = parsed_result;
6413 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6415 if (strcmp(res->what, "uta") == 0)
6416 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6417 &res->address,(uint8_t)is_on);
6419 printf("bad unicast hash table parameter, return code = %d \n", ret);
6423 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6424 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6426 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6429 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6430 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6432 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6435 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6438 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6442 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6443 .f = cmd_set_uc_hash_parsed,
6445 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6447 (void *)&cmd_set_uc_hash_set,
6448 (void *)&cmd_set_uc_hash_port,
6449 (void *)&cmd_set_uc_hash_portid,
6450 (void *)&cmd_set_uc_hash_what,
6451 (void *)&cmd_set_uc_hash_mac,
6452 (void *)&cmd_set_uc_hash_mode,
6457 struct cmd_set_uc_all_hash_table {
6458 cmdline_fixed_string_t set;
6459 cmdline_fixed_string_t port;
6461 cmdline_fixed_string_t what;
6462 cmdline_fixed_string_t value;
6463 cmdline_fixed_string_t mode;
6467 cmd_set_uc_all_hash_parsed(void *parsed_result,
6468 __attribute__((unused)) struct cmdline *cl,
6469 __attribute__((unused)) void *data)
6472 struct cmd_set_uc_all_hash_table *res = parsed_result;
6474 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6476 if ((strcmp(res->what, "uta") == 0) &&
6477 (strcmp(res->value, "all") == 0))
6478 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6480 printf("bad unicast hash table parameter,"
6481 "return code = %d \n", ret);
6484 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6487 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6490 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6491 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6493 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6496 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6499 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6503 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6504 .f = cmd_set_uc_all_hash_parsed,
6506 .help_str = "set port <port_id> uta all on|off",
6508 (void *)&cmd_set_uc_all_hash_set,
6509 (void *)&cmd_set_uc_all_hash_port,
6510 (void *)&cmd_set_uc_all_hash_portid,
6511 (void *)&cmd_set_uc_all_hash_what,
6512 (void *)&cmd_set_uc_all_hash_value,
6513 (void *)&cmd_set_uc_all_hash_mode,
6518 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6519 struct cmd_set_vf_macvlan_filter {
6520 cmdline_fixed_string_t set;
6521 cmdline_fixed_string_t port;
6523 cmdline_fixed_string_t vf;
6525 struct ether_addr address;
6526 cmdline_fixed_string_t filter_type;
6527 cmdline_fixed_string_t mode;
6531 cmd_set_vf_macvlan_parsed(void *parsed_result,
6532 __attribute__((unused)) struct cmdline *cl,
6533 __attribute__((unused)) void *data)
6536 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6537 struct rte_eth_mac_filter filter;
6539 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6541 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6543 /* set VF MAC filter */
6547 filter.dst_id = res->vf_id;
6549 if (!strcmp(res->filter_type, "exact-mac"))
6550 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6551 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6552 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6553 else if (!strcmp(res->filter_type, "hashmac"))
6554 filter.filter_type = RTE_MAC_HASH_MATCH;
6555 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6556 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6558 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6561 ret = rte_eth_dev_filter_ctrl(res->port_id,
6562 RTE_ETH_FILTER_MACVLAN,
6566 ret = rte_eth_dev_filter_ctrl(res->port_id,
6567 RTE_ETH_FILTER_MACVLAN,
6568 RTE_ETH_FILTER_DELETE,
6572 printf("bad set MAC hash parameter, return code = %d\n", ret);
6576 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6577 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6579 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6582 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6583 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6585 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6588 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6589 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6591 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6592 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6594 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6596 filter_type, "exact-mac#exact-mac-vlan"
6597 "#hashmac#hashmac-vlan");
6598 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6602 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6603 .f = cmd_set_vf_macvlan_parsed,
6605 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6606 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6607 "Exact match rule: exact match of MAC or MAC and VLAN; "
6608 "hash match rule: hash match of MAC and exact match of VLAN",
6610 (void *)&cmd_set_vf_macvlan_set,
6611 (void *)&cmd_set_vf_macvlan_port,
6612 (void *)&cmd_set_vf_macvlan_portid,
6613 (void *)&cmd_set_vf_macvlan_vf,
6614 (void *)&cmd_set_vf_macvlan_vf_id,
6615 (void *)&cmd_set_vf_macvlan_mac,
6616 (void *)&cmd_set_vf_macvlan_filter_type,
6617 (void *)&cmd_set_vf_macvlan_mode,
6622 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6623 struct cmd_set_vf_traffic {
6624 cmdline_fixed_string_t set;
6625 cmdline_fixed_string_t port;
6627 cmdline_fixed_string_t vf;
6629 cmdline_fixed_string_t what;
6630 cmdline_fixed_string_t mode;
6634 cmd_set_vf_traffic_parsed(void *parsed_result,
6635 __attribute__((unused)) struct cmdline *cl,
6636 __attribute__((unused)) void *data)
6638 struct cmd_set_vf_traffic *res = parsed_result;
6639 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6640 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6642 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6645 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6646 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6648 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6651 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6652 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6654 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6657 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6658 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6660 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6663 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6667 cmdline_parse_inst_t cmd_set_vf_traffic = {
6668 .f = cmd_set_vf_traffic_parsed,
6670 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6672 (void *)&cmd_setvf_traffic_set,
6673 (void *)&cmd_setvf_traffic_port,
6674 (void *)&cmd_setvf_traffic_portid,
6675 (void *)&cmd_setvf_traffic_vf,
6676 (void *)&cmd_setvf_traffic_vfid,
6677 (void *)&cmd_setvf_traffic_what,
6678 (void *)&cmd_setvf_traffic_mode,
6683 /* *** CONFIGURE VF RECEIVE MODE *** */
6684 struct cmd_set_vf_rxmode {
6685 cmdline_fixed_string_t set;
6686 cmdline_fixed_string_t port;
6688 cmdline_fixed_string_t vf;
6690 cmdline_fixed_string_t what;
6691 cmdline_fixed_string_t mode;
6692 cmdline_fixed_string_t on;
6696 cmd_set_vf_rxmode_parsed(void *parsed_result,
6697 __attribute__((unused)) struct cmdline *cl,
6698 __attribute__((unused)) void *data)
6701 uint16_t rx_mode = 0;
6702 struct cmd_set_vf_rxmode *res = parsed_result;
6704 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6705 if (!strcmp(res->what,"rxmode")) {
6706 if (!strcmp(res->mode, "AUPE"))
6707 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6708 else if (!strcmp(res->mode, "ROPE"))
6709 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6710 else if (!strcmp(res->mode, "BAM"))
6711 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6712 else if (!strncmp(res->mode, "MPE",3))
6713 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6716 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6718 printf("bad VF receive mode parameter, return code = %d \n",
6722 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6725 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6728 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6729 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6731 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6734 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6735 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6737 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6740 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6742 mode, "AUPE#ROPE#BAM#MPE");
6743 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6747 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6748 .f = cmd_set_vf_rxmode_parsed,
6750 .help_str = "set port <port_id> vf <vf_id> rxmode "
6751 "AUPE|ROPE|BAM|MPE on|off",
6753 (void *)&cmd_set_vf_rxmode_set,
6754 (void *)&cmd_set_vf_rxmode_port,
6755 (void *)&cmd_set_vf_rxmode_portid,
6756 (void *)&cmd_set_vf_rxmode_vf,
6757 (void *)&cmd_set_vf_rxmode_vfid,
6758 (void *)&cmd_set_vf_rxmode_what,
6759 (void *)&cmd_set_vf_rxmode_mode,
6760 (void *)&cmd_set_vf_rxmode_on,
6765 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6766 struct cmd_vf_mac_addr_result {
6767 cmdline_fixed_string_t mac_addr_cmd;
6768 cmdline_fixed_string_t what;
6769 cmdline_fixed_string_t port;
6771 cmdline_fixed_string_t vf;
6773 struct ether_addr address;
6776 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6780 struct cmd_vf_mac_addr_result *res = parsed_result;
6783 if (strcmp(res->what, "add") == 0)
6784 ret = rte_eth_dev_mac_addr_add(res->port_num,
6785 &res->address, res->vf_num);
6787 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6791 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6792 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6793 mac_addr_cmd,"mac_addr");
6794 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6795 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6797 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6798 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6800 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6801 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6803 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6804 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6806 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6807 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6809 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6810 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6813 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6814 .f = cmd_vf_mac_addr_parsed,
6816 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6817 "Add MAC address filtering for a VF on port_id",
6819 (void *)&cmd_vf_mac_addr_cmd,
6820 (void *)&cmd_vf_mac_addr_what,
6821 (void *)&cmd_vf_mac_addr_port,
6822 (void *)&cmd_vf_mac_addr_portnum,
6823 (void *)&cmd_vf_mac_addr_vf,
6824 (void *)&cmd_vf_mac_addr_vfnum,
6825 (void *)&cmd_vf_mac_addr_addr,
6830 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6831 struct cmd_vf_rx_vlan_filter {
6832 cmdline_fixed_string_t rx_vlan;
6833 cmdline_fixed_string_t what;
6835 cmdline_fixed_string_t port;
6837 cmdline_fixed_string_t vf;
6842 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6843 __attribute__((unused)) struct cmdline *cl,
6844 __attribute__((unused)) void *data)
6846 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6848 if (!strcmp(res->what, "add"))
6849 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6851 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6854 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6855 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6856 rx_vlan, "rx_vlan");
6857 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6858 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6860 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6861 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6863 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6864 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6866 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6867 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6869 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6870 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6872 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6873 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6876 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6877 .f = cmd_vf_rx_vlan_filter_parsed,
6879 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6880 "(vf_mask = hexadecimal VF mask)",
6882 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6883 (void *)&cmd_vf_rx_vlan_filter_what,
6884 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6885 (void *)&cmd_vf_rx_vlan_filter_port,
6886 (void *)&cmd_vf_rx_vlan_filter_portid,
6887 (void *)&cmd_vf_rx_vlan_filter_vf,
6888 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6893 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6894 struct cmd_queue_rate_limit_result {
6895 cmdline_fixed_string_t set;
6896 cmdline_fixed_string_t port;
6898 cmdline_fixed_string_t queue;
6900 cmdline_fixed_string_t rate;
6904 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6905 __attribute__((unused)) struct cmdline *cl,
6906 __attribute__((unused)) void *data)
6908 struct cmd_queue_rate_limit_result *res = parsed_result;
6911 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6912 && (strcmp(res->queue, "queue") == 0)
6913 && (strcmp(res->rate, "rate") == 0))
6914 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6917 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6921 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6922 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6924 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6925 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6927 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6928 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6930 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6931 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6933 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6934 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6936 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6937 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6939 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6940 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6943 cmdline_parse_inst_t cmd_queue_rate_limit = {
6944 .f = cmd_queue_rate_limit_parsed,
6946 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6947 "Set rate limit for a queue on port_id",
6949 (void *)&cmd_queue_rate_limit_set,
6950 (void *)&cmd_queue_rate_limit_port,
6951 (void *)&cmd_queue_rate_limit_portnum,
6952 (void *)&cmd_queue_rate_limit_queue,
6953 (void *)&cmd_queue_rate_limit_queuenum,
6954 (void *)&cmd_queue_rate_limit_rate,
6955 (void *)&cmd_queue_rate_limit_ratenum,
6960 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6961 struct cmd_vf_rate_limit_result {
6962 cmdline_fixed_string_t set;
6963 cmdline_fixed_string_t port;
6965 cmdline_fixed_string_t vf;
6967 cmdline_fixed_string_t rate;
6969 cmdline_fixed_string_t q_msk;
6973 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6974 __attribute__((unused)) struct cmdline *cl,
6975 __attribute__((unused)) void *data)
6977 struct cmd_vf_rate_limit_result *res = parsed_result;
6980 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6981 && (strcmp(res->vf, "vf") == 0)
6982 && (strcmp(res->rate, "rate") == 0)
6983 && (strcmp(res->q_msk, "queue_mask") == 0))
6984 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6985 res->rate_num, res->q_msk_val);
6987 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6991 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6992 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6994 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6995 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6997 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6998 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7000 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7001 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7003 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7004 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7006 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7009 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7010 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7012 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7013 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7014 q_msk, "queue_mask");
7015 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7016 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7019 cmdline_parse_inst_t cmd_vf_rate_limit = {
7020 .f = cmd_vf_rate_limit_parsed,
7022 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7023 "queue_mask <queue_mask_value>: "
7024 "Set rate limit for queues of VF on port_id",
7026 (void *)&cmd_vf_rate_limit_set,
7027 (void *)&cmd_vf_rate_limit_port,
7028 (void *)&cmd_vf_rate_limit_portnum,
7029 (void *)&cmd_vf_rate_limit_vf,
7030 (void *)&cmd_vf_rate_limit_vfnum,
7031 (void *)&cmd_vf_rate_limit_rate,
7032 (void *)&cmd_vf_rate_limit_ratenum,
7033 (void *)&cmd_vf_rate_limit_q_msk,
7034 (void *)&cmd_vf_rate_limit_q_msk_val,
7039 /* *** ADD TUNNEL FILTER OF A PORT *** */
7040 struct cmd_tunnel_filter_result {
7041 cmdline_fixed_string_t cmd;
7042 cmdline_fixed_string_t what;
7044 struct ether_addr outer_mac;
7045 struct ether_addr inner_mac;
7046 cmdline_ipaddr_t ip_value;
7047 uint16_t inner_vlan;
7048 cmdline_fixed_string_t tunnel_type;
7049 cmdline_fixed_string_t filter_type;
7055 cmd_tunnel_filter_parsed(void *parsed_result,
7056 __attribute__((unused)) struct cmdline *cl,
7057 __attribute__((unused)) void *data)
7059 struct cmd_tunnel_filter_result *res = parsed_result;
7060 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7063 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7065 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7066 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7067 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7069 if (res->ip_value.family == AF_INET) {
7070 tunnel_filter_conf.ip_addr.ipv4_addr =
7071 res->ip_value.addr.ipv4.s_addr;
7072 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7074 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7075 &(res->ip_value.addr.ipv6),
7076 sizeof(struct in6_addr));
7077 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7080 if (!strcmp(res->filter_type, "imac-ivlan"))
7081 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7082 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7083 tunnel_filter_conf.filter_type =
7084 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7085 else if (!strcmp(res->filter_type, "imac-tenid"))
7086 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7087 else if (!strcmp(res->filter_type, "imac"))
7088 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7089 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7090 tunnel_filter_conf.filter_type =
7091 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7092 else if (!strcmp(res->filter_type, "oip"))
7093 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7094 else if (!strcmp(res->filter_type, "iip"))
7095 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7097 printf("The filter type is not supported");
7101 if (!strcmp(res->tunnel_type, "vxlan"))
7102 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7103 else if (!strcmp(res->tunnel_type, "nvgre"))
7104 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7105 else if (!strcmp(res->tunnel_type, "ipingre"))
7106 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7108 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7112 tunnel_filter_conf.tenant_id = res->tenant_id;
7113 tunnel_filter_conf.queue_id = res->queue_num;
7114 if (!strcmp(res->what, "add"))
7115 ret = rte_eth_dev_filter_ctrl(res->port_id,
7116 RTE_ETH_FILTER_TUNNEL,
7118 &tunnel_filter_conf);
7120 ret = rte_eth_dev_filter_ctrl(res->port_id,
7121 RTE_ETH_FILTER_TUNNEL,
7122 RTE_ETH_FILTER_DELETE,
7123 &tunnel_filter_conf);
7125 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7129 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7130 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7131 cmd, "tunnel_filter");
7132 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7133 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7135 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7136 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7138 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7139 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7141 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7142 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7144 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7145 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7146 inner_vlan, UINT16);
7147 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7148 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7150 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7151 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7152 tunnel_type, "vxlan#nvgre#ipingre");
7154 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7155 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7156 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7157 "imac#omac-imac-tenid");
7158 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7159 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7161 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7162 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7165 cmdline_parse_inst_t cmd_tunnel_filter = {
7166 .f = cmd_tunnel_filter_parsed,
7168 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7169 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7170 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7171 "<queue_id>: Add/Rm tunnel filter of a port",
7173 (void *)&cmd_tunnel_filter_cmd,
7174 (void *)&cmd_tunnel_filter_what,
7175 (void *)&cmd_tunnel_filter_port_id,
7176 (void *)&cmd_tunnel_filter_outer_mac,
7177 (void *)&cmd_tunnel_filter_inner_mac,
7178 (void *)&cmd_tunnel_filter_ip_value,
7179 (void *)&cmd_tunnel_filter_innner_vlan,
7180 (void *)&cmd_tunnel_filter_tunnel_type,
7181 (void *)&cmd_tunnel_filter_filter_type,
7182 (void *)&cmd_tunnel_filter_tenant_id,
7183 (void *)&cmd_tunnel_filter_queue_num,
7188 /* *** CONFIGURE TUNNEL UDP PORT *** */
7189 struct cmd_tunnel_udp_config {
7190 cmdline_fixed_string_t cmd;
7191 cmdline_fixed_string_t what;
7197 cmd_tunnel_udp_config_parsed(void *parsed_result,
7198 __attribute__((unused)) struct cmdline *cl,
7199 __attribute__((unused)) void *data)
7201 struct cmd_tunnel_udp_config *res = parsed_result;
7202 struct rte_eth_udp_tunnel tunnel_udp;
7205 tunnel_udp.udp_port = res->udp_port;
7207 if (!strcmp(res->cmd, "rx_vxlan_port"))
7208 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7210 if (!strcmp(res->what, "add"))
7211 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7214 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7218 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7221 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7222 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7223 cmd, "rx_vxlan_port");
7224 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7227 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7228 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7230 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7234 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7235 .f = cmd_tunnel_udp_config_parsed,
7237 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7238 "Add/Remove a tunneling UDP port filter",
7240 (void *)&cmd_tunnel_udp_config_cmd,
7241 (void *)&cmd_tunnel_udp_config_what,
7242 (void *)&cmd_tunnel_udp_config_udp_port,
7243 (void *)&cmd_tunnel_udp_config_port_id,
7248 /* *** GLOBAL CONFIG *** */
7249 struct cmd_global_config_result {
7250 cmdline_fixed_string_t cmd;
7252 cmdline_fixed_string_t cfg_type;
7257 cmd_global_config_parsed(void *parsed_result,
7258 __attribute__((unused)) struct cmdline *cl,
7259 __attribute__((unused)) void *data)
7261 struct cmd_global_config_result *res = parsed_result;
7262 struct rte_eth_global_cfg conf;
7265 memset(&conf, 0, sizeof(conf));
7266 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7267 conf.cfg.gre_key_len = res->len;
7268 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7269 RTE_ETH_FILTER_SET, &conf);
7271 printf("Global config error\n");
7274 cmdline_parse_token_string_t cmd_global_config_cmd =
7275 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7277 cmdline_parse_token_num_t cmd_global_config_port_id =
7278 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7279 cmdline_parse_token_string_t cmd_global_config_type =
7280 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7281 cfg_type, "gre-key-len");
7282 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7283 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7286 cmdline_parse_inst_t cmd_global_config = {
7287 .f = cmd_global_config_parsed,
7288 .data = (void *)NULL,
7289 .help_str = "global_config <port_id> gre-key-len <key_len>",
7291 (void *)&cmd_global_config_cmd,
7292 (void *)&cmd_global_config_port_id,
7293 (void *)&cmd_global_config_type,
7294 (void *)&cmd_global_config_gre_key_len,
7299 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7300 struct cmd_set_mirror_mask_result {
7301 cmdline_fixed_string_t set;
7302 cmdline_fixed_string_t port;
7304 cmdline_fixed_string_t mirror;
7306 cmdline_fixed_string_t what;
7307 cmdline_fixed_string_t value;
7308 cmdline_fixed_string_t dstpool;
7310 cmdline_fixed_string_t on;
7313 cmdline_parse_token_string_t cmd_mirror_mask_set =
7314 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7316 cmdline_parse_token_string_t cmd_mirror_mask_port =
7317 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7319 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7320 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7322 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7324 mirror, "mirror-rule");
7325 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7326 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7328 cmdline_parse_token_string_t cmd_mirror_mask_what =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7330 what, "pool-mirror-up#pool-mirror-down"
7332 cmdline_parse_token_string_t cmd_mirror_mask_value =
7333 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7335 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7337 dstpool, "dst-pool");
7338 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7339 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7341 cmdline_parse_token_string_t cmd_mirror_mask_on =
7342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7346 cmd_set_mirror_mask_parsed(void *parsed_result,
7347 __attribute__((unused)) struct cmdline *cl,
7348 __attribute__((unused)) void *data)
7351 struct cmd_set_mirror_mask_result *res = parsed_result;
7352 struct rte_eth_mirror_conf mr_conf;
7354 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7356 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7358 mr_conf.dst_pool = res->dstpool_id;
7360 if (!strcmp(res->what, "pool-mirror-up")) {
7361 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7362 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7363 } else if (!strcmp(res->what, "pool-mirror-down")) {
7364 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7365 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7366 } else if (!strcmp(res->what, "vlan-mirror")) {
7367 mr_conf.rule_type = ETH_MIRROR_VLAN;
7368 nb_item = parse_item_list(res->value, "vlan",
7369 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7373 for (i = 0; i < nb_item; i++) {
7374 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7375 printf("Invalid vlan_id: must be < 4096\n");
7379 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7380 mr_conf.vlan.vlan_mask |= 1ULL << i;
7384 if (!strcmp(res->on, "on"))
7385 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7388 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7391 printf("mirror rule add error: (%s)\n", strerror(-ret));
7394 cmdline_parse_inst_t cmd_set_mirror_mask = {
7395 .f = cmd_set_mirror_mask_parsed,
7397 .help_str = "set port <port_id> mirror-rule <rule_id> "
7398 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7399 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7401 (void *)&cmd_mirror_mask_set,
7402 (void *)&cmd_mirror_mask_port,
7403 (void *)&cmd_mirror_mask_portid,
7404 (void *)&cmd_mirror_mask_mirror,
7405 (void *)&cmd_mirror_mask_ruleid,
7406 (void *)&cmd_mirror_mask_what,
7407 (void *)&cmd_mirror_mask_value,
7408 (void *)&cmd_mirror_mask_dstpool,
7409 (void *)&cmd_mirror_mask_poolid,
7410 (void *)&cmd_mirror_mask_on,
7415 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7416 struct cmd_set_mirror_link_result {
7417 cmdline_fixed_string_t set;
7418 cmdline_fixed_string_t port;
7420 cmdline_fixed_string_t mirror;
7422 cmdline_fixed_string_t what;
7423 cmdline_fixed_string_t dstpool;
7425 cmdline_fixed_string_t on;
7428 cmdline_parse_token_string_t cmd_mirror_link_set =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7431 cmdline_parse_token_string_t cmd_mirror_link_port =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7434 cmdline_parse_token_num_t cmd_mirror_link_portid =
7435 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7437 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7439 mirror, "mirror-rule");
7440 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7441 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7443 cmdline_parse_token_string_t cmd_mirror_link_what =
7444 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7445 what, "uplink-mirror#downlink-mirror");
7446 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7448 dstpool, "dst-pool");
7449 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7450 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7452 cmdline_parse_token_string_t cmd_mirror_link_on =
7453 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7457 cmd_set_mirror_link_parsed(void *parsed_result,
7458 __attribute__((unused)) struct cmdline *cl,
7459 __attribute__((unused)) void *data)
7462 struct cmd_set_mirror_link_result *res = parsed_result;
7463 struct rte_eth_mirror_conf mr_conf;
7465 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7466 if (!strcmp(res->what, "uplink-mirror"))
7467 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7469 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7471 mr_conf.dst_pool = res->dstpool_id;
7473 if (!strcmp(res->on, "on"))
7474 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7477 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7480 /* check the return value and print it if is < 0 */
7482 printf("mirror rule add error: (%s)\n", strerror(-ret));
7486 cmdline_parse_inst_t cmd_set_mirror_link = {
7487 .f = cmd_set_mirror_link_parsed,
7489 .help_str = "set port <port_id> mirror-rule <rule_id> "
7490 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7492 (void *)&cmd_mirror_link_set,
7493 (void *)&cmd_mirror_link_port,
7494 (void *)&cmd_mirror_link_portid,
7495 (void *)&cmd_mirror_link_mirror,
7496 (void *)&cmd_mirror_link_ruleid,
7497 (void *)&cmd_mirror_link_what,
7498 (void *)&cmd_mirror_link_dstpool,
7499 (void *)&cmd_mirror_link_poolid,
7500 (void *)&cmd_mirror_link_on,
7505 /* *** RESET VM MIRROR RULE *** */
7506 struct cmd_rm_mirror_rule_result {
7507 cmdline_fixed_string_t reset;
7508 cmdline_fixed_string_t port;
7510 cmdline_fixed_string_t mirror;
7514 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7515 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7517 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7518 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7520 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7521 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7523 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7524 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7525 mirror, "mirror-rule");
7526 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7527 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7531 cmd_reset_mirror_rule_parsed(void *parsed_result,
7532 __attribute__((unused)) struct cmdline *cl,
7533 __attribute__((unused)) void *data)
7536 struct cmd_set_mirror_link_result *res = parsed_result;
7538 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7540 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7543 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7544 .f = cmd_reset_mirror_rule_parsed,
7546 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7548 (void *)&cmd_rm_mirror_rule_reset,
7549 (void *)&cmd_rm_mirror_rule_port,
7550 (void *)&cmd_rm_mirror_rule_portid,
7551 (void *)&cmd_rm_mirror_rule_mirror,
7552 (void *)&cmd_rm_mirror_rule_ruleid,
7557 /* ******************************************************************************** */
7559 struct cmd_dump_result {
7560 cmdline_fixed_string_t dump;
7564 dump_struct_sizes(void)
7566 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7567 DUMP_SIZE(struct rte_mbuf);
7568 DUMP_SIZE(struct rte_mempool);
7569 DUMP_SIZE(struct rte_ring);
7573 static void cmd_dump_parsed(void *parsed_result,
7574 __attribute__((unused)) struct cmdline *cl,
7575 __attribute__((unused)) void *data)
7577 struct cmd_dump_result *res = parsed_result;
7579 if (!strcmp(res->dump, "dump_physmem"))
7580 rte_dump_physmem_layout(stdout);
7581 else if (!strcmp(res->dump, "dump_memzone"))
7582 rte_memzone_dump(stdout);
7583 else if (!strcmp(res->dump, "dump_struct_sizes"))
7584 dump_struct_sizes();
7585 else if (!strcmp(res->dump, "dump_ring"))
7586 rte_ring_list_dump(stdout);
7587 else if (!strcmp(res->dump, "dump_mempool"))
7588 rte_mempool_list_dump(stdout);
7589 else if (!strcmp(res->dump, "dump_devargs"))
7590 rte_eal_devargs_dump(stdout);
7593 cmdline_parse_token_string_t cmd_dump_dump =
7594 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7597 "dump_struct_sizes#"
7602 cmdline_parse_inst_t cmd_dump = {
7603 .f = cmd_dump_parsed, /* function to call */
7604 .data = NULL, /* 2nd arg of func */
7605 .help_str = "Dump status",
7606 .tokens = { /* token list, NULL terminated */
7607 (void *)&cmd_dump_dump,
7612 /* ******************************************************************************** */
7614 struct cmd_dump_one_result {
7615 cmdline_fixed_string_t dump;
7616 cmdline_fixed_string_t name;
7619 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7620 __attribute__((unused)) void *data)
7622 struct cmd_dump_one_result *res = parsed_result;
7624 if (!strcmp(res->dump, "dump_ring")) {
7626 r = rte_ring_lookup(res->name);
7628 cmdline_printf(cl, "Cannot find ring\n");
7631 rte_ring_dump(stdout, r);
7632 } else if (!strcmp(res->dump, "dump_mempool")) {
7633 struct rte_mempool *mp;
7634 mp = rte_mempool_lookup(res->name);
7636 cmdline_printf(cl, "Cannot find mempool\n");
7639 rte_mempool_dump(stdout, mp);
7643 cmdline_parse_token_string_t cmd_dump_one_dump =
7644 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7645 "dump_ring#dump_mempool");
7647 cmdline_parse_token_string_t cmd_dump_one_name =
7648 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7650 cmdline_parse_inst_t cmd_dump_one = {
7651 .f = cmd_dump_one_parsed, /* function to call */
7652 .data = NULL, /* 2nd arg of func */
7653 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7654 .tokens = { /* token list, NULL terminated */
7655 (void *)&cmd_dump_one_dump,
7656 (void *)&cmd_dump_one_name,
7661 /* *** Add/Del syn filter *** */
7662 struct cmd_syn_filter_result {
7663 cmdline_fixed_string_t filter;
7665 cmdline_fixed_string_t ops;
7666 cmdline_fixed_string_t priority;
7667 cmdline_fixed_string_t high;
7668 cmdline_fixed_string_t queue;
7673 cmd_syn_filter_parsed(void *parsed_result,
7674 __attribute__((unused)) struct cmdline *cl,
7675 __attribute__((unused)) void *data)
7677 struct cmd_syn_filter_result *res = parsed_result;
7678 struct rte_eth_syn_filter syn_filter;
7681 ret = rte_eth_dev_filter_supported(res->port_id,
7682 RTE_ETH_FILTER_SYN);
7684 printf("syn filter is not supported on port %u.\n",
7689 memset(&syn_filter, 0, sizeof(syn_filter));
7691 if (!strcmp(res->ops, "add")) {
7692 if (!strcmp(res->high, "high"))
7693 syn_filter.hig_pri = 1;
7695 syn_filter.hig_pri = 0;
7697 syn_filter.queue = res->queue_id;
7698 ret = rte_eth_dev_filter_ctrl(res->port_id,
7703 ret = rte_eth_dev_filter_ctrl(res->port_id,
7705 RTE_ETH_FILTER_DELETE,
7709 printf("syn filter programming error: (%s)\n",
7713 cmdline_parse_token_string_t cmd_syn_filter_filter =
7714 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7715 filter, "syn_filter");
7716 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7717 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7719 cmdline_parse_token_string_t cmd_syn_filter_ops =
7720 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7722 cmdline_parse_token_string_t cmd_syn_filter_priority =
7723 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7724 priority, "priority");
7725 cmdline_parse_token_string_t cmd_syn_filter_high =
7726 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7728 cmdline_parse_token_string_t cmd_syn_filter_queue =
7729 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7731 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7732 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7735 cmdline_parse_inst_t cmd_syn_filter = {
7736 .f = cmd_syn_filter_parsed,
7738 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7739 "<queue_id>: Add/Delete syn filter",
7741 (void *)&cmd_syn_filter_filter,
7742 (void *)&cmd_syn_filter_port_id,
7743 (void *)&cmd_syn_filter_ops,
7744 (void *)&cmd_syn_filter_priority,
7745 (void *)&cmd_syn_filter_high,
7746 (void *)&cmd_syn_filter_queue,
7747 (void *)&cmd_syn_filter_queue_id,
7752 /* *** ADD/REMOVE A 2tuple FILTER *** */
7753 struct cmd_2tuple_filter_result {
7754 cmdline_fixed_string_t filter;
7756 cmdline_fixed_string_t ops;
7757 cmdline_fixed_string_t dst_port;
7758 uint16_t dst_port_value;
7759 cmdline_fixed_string_t protocol;
7760 uint8_t protocol_value;
7761 cmdline_fixed_string_t mask;
7763 cmdline_fixed_string_t tcp_flags;
7764 uint8_t tcp_flags_value;
7765 cmdline_fixed_string_t priority;
7766 uint8_t priority_value;
7767 cmdline_fixed_string_t queue;
7772 cmd_2tuple_filter_parsed(void *parsed_result,
7773 __attribute__((unused)) struct cmdline *cl,
7774 __attribute__((unused)) void *data)
7776 struct rte_eth_ntuple_filter filter;
7777 struct cmd_2tuple_filter_result *res = parsed_result;
7780 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7782 printf("ntuple filter is not supported on port %u.\n",
7787 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7789 filter.flags = RTE_2TUPLE_FLAGS;
7790 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7791 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7792 filter.proto = res->protocol_value;
7793 filter.priority = res->priority_value;
7794 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7795 printf("nonzero tcp_flags is only meaningful"
7796 " when protocol is TCP.\n");
7799 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7800 printf("invalid TCP flags.\n");
7804 if (res->tcp_flags_value != 0) {
7805 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7806 filter.tcp_flags = res->tcp_flags_value;
7809 /* need convert to big endian. */
7810 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7811 filter.queue = res->queue_id;
7813 if (!strcmp(res->ops, "add"))
7814 ret = rte_eth_dev_filter_ctrl(res->port_id,
7815 RTE_ETH_FILTER_NTUPLE,
7819 ret = rte_eth_dev_filter_ctrl(res->port_id,
7820 RTE_ETH_FILTER_NTUPLE,
7821 RTE_ETH_FILTER_DELETE,
7824 printf("2tuple filter programming error: (%s)\n",
7829 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7830 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7831 filter, "2tuple_filter");
7832 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7833 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7835 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7836 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7838 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7839 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7840 dst_port, "dst_port");
7841 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7842 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7843 dst_port_value, UINT16);
7844 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7845 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7846 protocol, "protocol");
7847 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7848 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7849 protocol_value, UINT8);
7850 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7851 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7853 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7854 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7856 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7857 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7858 tcp_flags, "tcp_flags");
7859 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7860 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7861 tcp_flags_value, UINT8);
7862 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7863 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7864 priority, "priority");
7865 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7866 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7867 priority_value, UINT8);
7868 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7869 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7871 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7872 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7875 cmdline_parse_inst_t cmd_2tuple_filter = {
7876 .f = cmd_2tuple_filter_parsed,
7878 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7879 "<value> mask <value> tcp_flags <value> priority <value> queue "
7880 "<queue_id>: Add a 2tuple filter",
7882 (void *)&cmd_2tuple_filter_filter,
7883 (void *)&cmd_2tuple_filter_port_id,
7884 (void *)&cmd_2tuple_filter_ops,
7885 (void *)&cmd_2tuple_filter_dst_port,
7886 (void *)&cmd_2tuple_filter_dst_port_value,
7887 (void *)&cmd_2tuple_filter_protocol,
7888 (void *)&cmd_2tuple_filter_protocol_value,
7889 (void *)&cmd_2tuple_filter_mask,
7890 (void *)&cmd_2tuple_filter_mask_value,
7891 (void *)&cmd_2tuple_filter_tcp_flags,
7892 (void *)&cmd_2tuple_filter_tcp_flags_value,
7893 (void *)&cmd_2tuple_filter_priority,
7894 (void *)&cmd_2tuple_filter_priority_value,
7895 (void *)&cmd_2tuple_filter_queue,
7896 (void *)&cmd_2tuple_filter_queue_id,
7901 /* *** ADD/REMOVE A 5tuple FILTER *** */
7902 struct cmd_5tuple_filter_result {
7903 cmdline_fixed_string_t filter;
7905 cmdline_fixed_string_t ops;
7906 cmdline_fixed_string_t dst_ip;
7907 cmdline_ipaddr_t dst_ip_value;
7908 cmdline_fixed_string_t src_ip;
7909 cmdline_ipaddr_t src_ip_value;
7910 cmdline_fixed_string_t dst_port;
7911 uint16_t dst_port_value;
7912 cmdline_fixed_string_t src_port;
7913 uint16_t src_port_value;
7914 cmdline_fixed_string_t protocol;
7915 uint8_t protocol_value;
7916 cmdline_fixed_string_t mask;
7918 cmdline_fixed_string_t tcp_flags;
7919 uint8_t tcp_flags_value;
7920 cmdline_fixed_string_t priority;
7921 uint8_t priority_value;
7922 cmdline_fixed_string_t queue;
7927 cmd_5tuple_filter_parsed(void *parsed_result,
7928 __attribute__((unused)) struct cmdline *cl,
7929 __attribute__((unused)) void *data)
7931 struct rte_eth_ntuple_filter filter;
7932 struct cmd_5tuple_filter_result *res = parsed_result;
7935 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7937 printf("ntuple filter is not supported on port %u.\n",
7942 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7944 filter.flags = RTE_5TUPLE_FLAGS;
7945 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7946 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7947 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7948 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7949 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7950 filter.proto = res->protocol_value;
7951 filter.priority = res->priority_value;
7952 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7953 printf("nonzero tcp_flags is only meaningful"
7954 " when protocol is TCP.\n");
7957 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7958 printf("invalid TCP flags.\n");
7962 if (res->tcp_flags_value != 0) {
7963 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7964 filter.tcp_flags = res->tcp_flags_value;
7967 if (res->dst_ip_value.family == AF_INET)
7968 /* no need to convert, already big endian. */
7969 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7971 if (filter.dst_ip_mask == 0) {
7972 printf("can not support ipv6 involved compare.\n");
7978 if (res->src_ip_value.family == AF_INET)
7979 /* no need to convert, already big endian. */
7980 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7982 if (filter.src_ip_mask == 0) {
7983 printf("can not support ipv6 involved compare.\n");
7988 /* need convert to big endian. */
7989 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7990 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7991 filter.queue = res->queue_id;
7993 if (!strcmp(res->ops, "add"))
7994 ret = rte_eth_dev_filter_ctrl(res->port_id,
7995 RTE_ETH_FILTER_NTUPLE,
7999 ret = rte_eth_dev_filter_ctrl(res->port_id,
8000 RTE_ETH_FILTER_NTUPLE,
8001 RTE_ETH_FILTER_DELETE,
8004 printf("5tuple filter programming error: (%s)\n",
8008 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8009 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8010 filter, "5tuple_filter");
8011 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8012 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8014 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8015 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8017 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8018 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8020 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8021 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8023 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8024 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8026 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8027 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8029 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8030 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8031 dst_port, "dst_port");
8032 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8033 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8034 dst_port_value, UINT16);
8035 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8036 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8037 src_port, "src_port");
8038 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8039 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8040 src_port_value, UINT16);
8041 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8042 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8043 protocol, "protocol");
8044 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8045 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8046 protocol_value, UINT8);
8047 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8048 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8050 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8051 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8053 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8054 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8055 tcp_flags, "tcp_flags");
8056 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8057 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8058 tcp_flags_value, UINT8);
8059 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8060 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8061 priority, "priority");
8062 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8063 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8064 priority_value, UINT8);
8065 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8068 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8069 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8072 cmdline_parse_inst_t cmd_5tuple_filter = {
8073 .f = cmd_5tuple_filter_parsed,
8075 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8076 "src_ip <value> dst_port <value> src_port <value> "
8077 "protocol <value> mask <value> tcp_flags <value> "
8078 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8080 (void *)&cmd_5tuple_filter_filter,
8081 (void *)&cmd_5tuple_filter_port_id,
8082 (void *)&cmd_5tuple_filter_ops,
8083 (void *)&cmd_5tuple_filter_dst_ip,
8084 (void *)&cmd_5tuple_filter_dst_ip_value,
8085 (void *)&cmd_5tuple_filter_src_ip,
8086 (void *)&cmd_5tuple_filter_src_ip_value,
8087 (void *)&cmd_5tuple_filter_dst_port,
8088 (void *)&cmd_5tuple_filter_dst_port_value,
8089 (void *)&cmd_5tuple_filter_src_port,
8090 (void *)&cmd_5tuple_filter_src_port_value,
8091 (void *)&cmd_5tuple_filter_protocol,
8092 (void *)&cmd_5tuple_filter_protocol_value,
8093 (void *)&cmd_5tuple_filter_mask,
8094 (void *)&cmd_5tuple_filter_mask_value,
8095 (void *)&cmd_5tuple_filter_tcp_flags,
8096 (void *)&cmd_5tuple_filter_tcp_flags_value,
8097 (void *)&cmd_5tuple_filter_priority,
8098 (void *)&cmd_5tuple_filter_priority_value,
8099 (void *)&cmd_5tuple_filter_queue,
8100 (void *)&cmd_5tuple_filter_queue_id,
8105 /* *** ADD/REMOVE A flex FILTER *** */
8106 struct cmd_flex_filter_result {
8107 cmdline_fixed_string_t filter;
8108 cmdline_fixed_string_t ops;
8110 cmdline_fixed_string_t len;
8112 cmdline_fixed_string_t bytes;
8113 cmdline_fixed_string_t bytes_value;
8114 cmdline_fixed_string_t mask;
8115 cmdline_fixed_string_t mask_value;
8116 cmdline_fixed_string_t priority;
8117 uint8_t priority_value;
8118 cmdline_fixed_string_t queue;
8122 static int xdigit2val(unsigned char c)
8127 else if (isupper(c))
8135 cmd_flex_filter_parsed(void *parsed_result,
8136 __attribute__((unused)) struct cmdline *cl,
8137 __attribute__((unused)) void *data)
8140 struct rte_eth_flex_filter filter;
8141 struct cmd_flex_filter_result *res = parsed_result;
8142 char *bytes_ptr, *mask_ptr;
8143 uint16_t len, i, j = 0;
8148 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8149 printf("the len exceed the max length 128\n");
8152 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8153 filter.len = res->len_value;
8154 filter.priority = res->priority_value;
8155 filter.queue = res->queue_id;
8156 bytes_ptr = res->bytes_value;
8157 mask_ptr = res->mask_value;
8159 /* translate bytes string to array. */
8160 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8161 (bytes_ptr[1] == 'X')))
8163 len = strnlen(bytes_ptr, res->len_value * 2);
8164 if (len == 0 || (len % 8 != 0)) {
8165 printf("please check len and bytes input\n");
8168 for (i = 0; i < len; i++) {
8170 if (isxdigit(c) == 0) {
8171 /* invalid characters. */
8172 printf("invalid input\n");
8175 val = xdigit2val(c);
8178 filter.bytes[j] = byte;
8179 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8186 /* translate mask string to uint8_t array. */
8187 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8188 (mask_ptr[1] == 'X')))
8190 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8192 printf("invalid input\n");
8197 for (i = 0; i < len; i++) {
8199 if (isxdigit(c) == 0) {
8200 /* invalid characters. */
8201 printf("invalid input\n");
8204 val = xdigit2val(c);
8207 filter.mask[j] = byte;
8208 printf("mask[%d]:%02x ", j, filter.mask[j]);
8216 if (!strcmp(res->ops, "add"))
8217 ret = rte_eth_dev_filter_ctrl(res->port_id,
8218 RTE_ETH_FILTER_FLEXIBLE,
8222 ret = rte_eth_dev_filter_ctrl(res->port_id,
8223 RTE_ETH_FILTER_FLEXIBLE,
8224 RTE_ETH_FILTER_DELETE,
8228 printf("flex filter setting error: (%s)\n", strerror(-ret));
8231 cmdline_parse_token_string_t cmd_flex_filter_filter =
8232 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8233 filter, "flex_filter");
8234 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8235 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8237 cmdline_parse_token_string_t cmd_flex_filter_ops =
8238 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8240 cmdline_parse_token_string_t cmd_flex_filter_len =
8241 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8243 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8244 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8246 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8247 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8249 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8250 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8252 cmdline_parse_token_string_t cmd_flex_filter_mask =
8253 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8255 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8256 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8258 cmdline_parse_token_string_t cmd_flex_filter_priority =
8259 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8260 priority, "priority");
8261 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8262 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8263 priority_value, UINT8);
8264 cmdline_parse_token_string_t cmd_flex_filter_queue =
8265 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8267 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8268 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8270 cmdline_parse_inst_t cmd_flex_filter = {
8271 .f = cmd_flex_filter_parsed,
8273 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8274 "<value> mask <value> priority <value> queue <queue_id>: "
8275 "Add/Del a flex filter",
8277 (void *)&cmd_flex_filter_filter,
8278 (void *)&cmd_flex_filter_port_id,
8279 (void *)&cmd_flex_filter_ops,
8280 (void *)&cmd_flex_filter_len,
8281 (void *)&cmd_flex_filter_len_value,
8282 (void *)&cmd_flex_filter_bytes,
8283 (void *)&cmd_flex_filter_bytes_value,
8284 (void *)&cmd_flex_filter_mask,
8285 (void *)&cmd_flex_filter_mask_value,
8286 (void *)&cmd_flex_filter_priority,
8287 (void *)&cmd_flex_filter_priority_value,
8288 (void *)&cmd_flex_filter_queue,
8289 (void *)&cmd_flex_filter_queue_id,
8294 /* *** Filters Control *** */
8296 /* *** deal with ethertype filter *** */
8297 struct cmd_ethertype_filter_result {
8298 cmdline_fixed_string_t filter;
8300 cmdline_fixed_string_t ops;
8301 cmdline_fixed_string_t mac;
8302 struct ether_addr mac_addr;
8303 cmdline_fixed_string_t ethertype;
8304 uint16_t ethertype_value;
8305 cmdline_fixed_string_t drop;
8306 cmdline_fixed_string_t queue;
8310 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8311 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8312 filter, "ethertype_filter");
8313 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8314 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8316 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8317 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8319 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8320 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8321 mac, "mac_addr#mac_ignr");
8322 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8323 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8325 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8326 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8327 ethertype, "ethertype");
8328 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8329 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8330 ethertype_value, UINT16);
8331 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8332 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8334 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8335 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8337 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8338 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8342 cmd_ethertype_filter_parsed(void *parsed_result,
8343 __attribute__((unused)) struct cmdline *cl,
8344 __attribute__((unused)) void *data)
8346 struct cmd_ethertype_filter_result *res = parsed_result;
8347 struct rte_eth_ethertype_filter filter;
8350 ret = rte_eth_dev_filter_supported(res->port_id,
8351 RTE_ETH_FILTER_ETHERTYPE);
8353 printf("ethertype filter is not supported on port %u.\n",
8358 memset(&filter, 0, sizeof(filter));
8359 if (!strcmp(res->mac, "mac_addr")) {
8360 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8361 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8362 sizeof(struct ether_addr));
8364 if (!strcmp(res->drop, "drop"))
8365 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8366 filter.ether_type = res->ethertype_value;
8367 filter.queue = res->queue_id;
8369 if (!strcmp(res->ops, "add"))
8370 ret = rte_eth_dev_filter_ctrl(res->port_id,
8371 RTE_ETH_FILTER_ETHERTYPE,
8375 ret = rte_eth_dev_filter_ctrl(res->port_id,
8376 RTE_ETH_FILTER_ETHERTYPE,
8377 RTE_ETH_FILTER_DELETE,
8380 printf("ethertype filter programming error: (%s)\n",
8384 cmdline_parse_inst_t cmd_ethertype_filter = {
8385 .f = cmd_ethertype_filter_parsed,
8387 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8388 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8389 "Add or delete an ethertype filter entry",
8391 (void *)&cmd_ethertype_filter_filter,
8392 (void *)&cmd_ethertype_filter_port_id,
8393 (void *)&cmd_ethertype_filter_ops,
8394 (void *)&cmd_ethertype_filter_mac,
8395 (void *)&cmd_ethertype_filter_mac_addr,
8396 (void *)&cmd_ethertype_filter_ethertype,
8397 (void *)&cmd_ethertype_filter_ethertype_value,
8398 (void *)&cmd_ethertype_filter_drop,
8399 (void *)&cmd_ethertype_filter_queue,
8400 (void *)&cmd_ethertype_filter_queue_id,
8405 /* *** deal with flow director filter *** */
8406 struct cmd_flow_director_result {
8407 cmdline_fixed_string_t flow_director_filter;
8409 cmdline_fixed_string_t mode;
8410 cmdline_fixed_string_t mode_value;
8411 cmdline_fixed_string_t ops;
8412 cmdline_fixed_string_t flow;
8413 cmdline_fixed_string_t flow_type;
8414 cmdline_fixed_string_t ether;
8415 uint16_t ether_type;
8416 cmdline_fixed_string_t src;
8417 cmdline_ipaddr_t ip_src;
8419 cmdline_fixed_string_t dst;
8420 cmdline_ipaddr_t ip_dst;
8422 cmdline_fixed_string_t verify_tag;
8423 uint32_t verify_tag_value;
8424 cmdline_ipaddr_t tos;
8426 cmdline_ipaddr_t proto;
8427 uint8_t proto_value;
8428 cmdline_ipaddr_t ttl;
8430 cmdline_fixed_string_t vlan;
8431 uint16_t vlan_value;
8432 cmdline_fixed_string_t flexbytes;
8433 cmdline_fixed_string_t flexbytes_value;
8434 cmdline_fixed_string_t pf_vf;
8435 cmdline_fixed_string_t drop;
8436 cmdline_fixed_string_t queue;
8438 cmdline_fixed_string_t fd_id;
8439 uint32_t fd_id_value;
8440 cmdline_fixed_string_t mac;
8441 struct ether_addr mac_addr;
8442 cmdline_fixed_string_t tunnel;
8443 cmdline_fixed_string_t tunnel_type;
8444 cmdline_fixed_string_t tunnel_id;
8445 uint32_t tunnel_id_value;
8449 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8452 const char *p, *p0 = q_arg;
8454 unsigned long int_fld;
8455 char *str_fld[max_num];
8460 p = strchr(p0, '(');
8464 p0 = strchr(p, ')');
8469 if (size >= sizeof(s))
8472 snprintf(s, sizeof(s), "%.*s", size, p);
8473 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8474 if (ret < 0 || ret > max_num)
8476 for (i = 0; i < ret; i++) {
8478 int_fld = strtoul(str_fld[i], &end, 0);
8479 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8481 flexbytes[i] = (uint8_t)int_fld;
8487 str2flowtype(char *string)
8490 static const struct {
8493 } flowtype_str[] = {
8494 {"raw", RTE_ETH_FLOW_RAW},
8495 {"ipv4", RTE_ETH_FLOW_IPV4},
8496 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8497 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8498 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8499 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8500 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8501 {"ipv6", RTE_ETH_FLOW_IPV6},
8502 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8503 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8504 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8505 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8506 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8507 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8510 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8511 if (!strcmp(flowtype_str[i].str, string))
8512 return flowtype_str[i].type;
8514 return RTE_ETH_FLOW_UNKNOWN;
8517 static enum rte_eth_fdir_tunnel_type
8518 str2fdir_tunneltype(char *string)
8522 static const struct {
8524 enum rte_eth_fdir_tunnel_type type;
8525 } tunneltype_str[] = {
8526 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8527 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8530 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8531 if (!strcmp(tunneltype_str[i].str, string))
8532 return tunneltype_str[i].type;
8534 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8537 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8539 if ((ip_addr).family == AF_INET) \
8540 (ip) = (ip_addr).addr.ipv4.s_addr; \
8542 printf("invalid parameter.\n"); \
8547 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8549 if ((ip_addr).family == AF_INET6) \
8550 (void)rte_memcpy(&(ip), \
8551 &((ip_addr).addr.ipv6), \
8552 sizeof(struct in6_addr)); \
8554 printf("invalid parameter.\n"); \
8560 cmd_flow_director_filter_parsed(void *parsed_result,
8561 __attribute__((unused)) struct cmdline *cl,
8562 __attribute__((unused)) void *data)
8564 struct cmd_flow_director_result *res = parsed_result;
8565 struct rte_eth_fdir_filter entry;
8566 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8568 unsigned long vf_id;
8571 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8573 printf("flow director is not supported on port %u.\n",
8577 memset(flexbytes, 0, sizeof(flexbytes));
8578 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8580 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8581 if (strcmp(res->mode_value, "MAC-VLAN")) {
8582 printf("Please set mode to MAC-VLAN.\n");
8585 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8586 if (strcmp(res->mode_value, "Tunnel")) {
8587 printf("Please set mode to Tunnel.\n");
8591 if (strcmp(res->mode_value, "IP")) {
8592 printf("Please set mode to IP.\n");
8595 entry.input.flow_type = str2flowtype(res->flow_type);
8598 ret = parse_flexbytes(res->flexbytes_value,
8600 RTE_ETH_FDIR_MAX_FLEXLEN);
8602 printf("error: Cannot parse flexbytes input.\n");
8606 switch (entry.input.flow_type) {
8607 case RTE_ETH_FLOW_FRAG_IPV4:
8608 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8609 entry.input.flow.ip4_flow.proto = res->proto_value;
8610 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8611 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8612 IPV4_ADDR_TO_UINT(res->ip_dst,
8613 entry.input.flow.ip4_flow.dst_ip);
8614 IPV4_ADDR_TO_UINT(res->ip_src,
8615 entry.input.flow.ip4_flow.src_ip);
8616 entry.input.flow.ip4_flow.tos = res->tos_value;
8617 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8618 /* need convert to big endian. */
8619 entry.input.flow.udp4_flow.dst_port =
8620 rte_cpu_to_be_16(res->port_dst);
8621 entry.input.flow.udp4_flow.src_port =
8622 rte_cpu_to_be_16(res->port_src);
8624 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8625 IPV4_ADDR_TO_UINT(res->ip_dst,
8626 entry.input.flow.sctp4_flow.ip.dst_ip);
8627 IPV4_ADDR_TO_UINT(res->ip_src,
8628 entry.input.flow.sctp4_flow.ip.src_ip);
8629 entry.input.flow.ip4_flow.tos = res->tos_value;
8630 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8631 /* need convert to big endian. */
8632 entry.input.flow.sctp4_flow.dst_port =
8633 rte_cpu_to_be_16(res->port_dst);
8634 entry.input.flow.sctp4_flow.src_port =
8635 rte_cpu_to_be_16(res->port_src);
8636 entry.input.flow.sctp4_flow.verify_tag =
8637 rte_cpu_to_be_32(res->verify_tag_value);
8639 case RTE_ETH_FLOW_FRAG_IPV6:
8640 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8641 entry.input.flow.ipv6_flow.proto = res->proto_value;
8642 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8643 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8644 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8645 entry.input.flow.ipv6_flow.dst_ip);
8646 IPV6_ADDR_TO_ARRAY(res->ip_src,
8647 entry.input.flow.ipv6_flow.src_ip);
8648 entry.input.flow.ipv6_flow.tc = res->tos_value;
8649 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8650 /* need convert to big endian. */
8651 entry.input.flow.udp6_flow.dst_port =
8652 rte_cpu_to_be_16(res->port_dst);
8653 entry.input.flow.udp6_flow.src_port =
8654 rte_cpu_to_be_16(res->port_src);
8656 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8657 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8658 entry.input.flow.sctp6_flow.ip.dst_ip);
8659 IPV6_ADDR_TO_ARRAY(res->ip_src,
8660 entry.input.flow.sctp6_flow.ip.src_ip);
8661 entry.input.flow.ipv6_flow.tc = res->tos_value;
8662 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8663 /* need convert to big endian. */
8664 entry.input.flow.sctp6_flow.dst_port =
8665 rte_cpu_to_be_16(res->port_dst);
8666 entry.input.flow.sctp6_flow.src_port =
8667 rte_cpu_to_be_16(res->port_src);
8668 entry.input.flow.sctp6_flow.verify_tag =
8669 rte_cpu_to_be_32(res->verify_tag_value);
8671 case RTE_ETH_FLOW_L2_PAYLOAD:
8672 entry.input.flow.l2_flow.ether_type =
8673 rte_cpu_to_be_16(res->ether_type);
8679 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8680 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8682 sizeof(struct ether_addr));
8684 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8685 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8687 sizeof(struct ether_addr));
8688 entry.input.flow.tunnel_flow.tunnel_type =
8689 str2fdir_tunneltype(res->tunnel_type);
8690 entry.input.flow.tunnel_flow.tunnel_id =
8691 rte_cpu_to_be_32(res->tunnel_id_value);
8694 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8696 RTE_ETH_FDIR_MAX_FLEXLEN);
8698 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8700 entry.action.flex_off = 0; /*use 0 by default */
8701 if (!strcmp(res->drop, "drop"))
8702 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8704 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8706 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8707 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8708 if (!strcmp(res->pf_vf, "pf"))
8709 entry.input.flow_ext.is_vf = 0;
8710 else if (!strncmp(res->pf_vf, "vf", 2)) {
8711 struct rte_eth_dev_info dev_info;
8713 memset(&dev_info, 0, sizeof(dev_info));
8714 rte_eth_dev_info_get(res->port_id, &dev_info);
8716 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8717 if (errno != 0 || *end != '\0' ||
8718 vf_id >= dev_info.max_vfs) {
8719 printf("invalid parameter %s.\n", res->pf_vf);
8722 entry.input.flow_ext.is_vf = 1;
8723 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8725 printf("invalid parameter %s.\n", res->pf_vf);
8730 /* set to report FD ID by default */
8731 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8732 entry.action.rx_queue = res->queue_id;
8733 entry.soft_id = res->fd_id_value;
8734 if (!strcmp(res->ops, "add"))
8735 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8736 RTE_ETH_FILTER_ADD, &entry);
8737 else if (!strcmp(res->ops, "del"))
8738 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8739 RTE_ETH_FILTER_DELETE, &entry);
8741 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8742 RTE_ETH_FILTER_UPDATE, &entry);
8744 printf("flow director programming error: (%s)\n",
8748 cmdline_parse_token_string_t cmd_flow_director_filter =
8749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8750 flow_director_filter, "flow_director_filter");
8751 cmdline_parse_token_num_t cmd_flow_director_port_id =
8752 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8754 cmdline_parse_token_string_t cmd_flow_director_ops =
8755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8756 ops, "add#del#update");
8757 cmdline_parse_token_string_t cmd_flow_director_flow =
8758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8760 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8762 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8763 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8764 cmdline_parse_token_string_t cmd_flow_director_ether =
8765 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8767 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8768 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8769 ether_type, UINT16);
8770 cmdline_parse_token_string_t cmd_flow_director_src =
8771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8773 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8774 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8776 cmdline_parse_token_num_t cmd_flow_director_port_src =
8777 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8779 cmdline_parse_token_string_t cmd_flow_director_dst =
8780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8782 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8783 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8785 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8788 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8790 verify_tag, "verify_tag");
8791 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8792 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8793 verify_tag_value, UINT32);
8794 cmdline_parse_token_string_t cmd_flow_director_tos =
8795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8797 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8798 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8800 cmdline_parse_token_string_t cmd_flow_director_proto =
8801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8803 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8804 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8805 proto_value, UINT8);
8806 cmdline_parse_token_string_t cmd_flow_director_ttl =
8807 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8809 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8810 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8812 cmdline_parse_token_string_t cmd_flow_director_vlan =
8813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8815 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8817 vlan_value, UINT16);
8818 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8820 flexbytes, "flexbytes");
8821 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8823 flexbytes_value, NULL);
8824 cmdline_parse_token_string_t cmd_flow_director_drop =
8825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8827 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8830 cmdline_parse_token_string_t cmd_flow_director_queue =
8831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8833 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8834 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8836 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8839 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8841 fd_id_value, UINT32);
8843 cmdline_parse_token_string_t cmd_flow_director_mode =
8844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8846 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8849 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8851 mode_value, "MAC-VLAN");
8852 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8854 mode_value, "Tunnel");
8855 cmdline_parse_token_string_t cmd_flow_director_mac =
8856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8858 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8859 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8861 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8864 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8866 tunnel_type, "NVGRE#VxLAN");
8867 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 tunnel_id, "tunnel-id");
8870 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8872 tunnel_id_value, UINT32);
8874 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8875 .f = cmd_flow_director_filter_parsed,
8877 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8878 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8879 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8880 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8881 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8882 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8883 "fd_id <fd_id_value>: "
8884 "Add or delete an ip flow director entry on NIC",
8886 (void *)&cmd_flow_director_filter,
8887 (void *)&cmd_flow_director_port_id,
8888 (void *)&cmd_flow_director_mode,
8889 (void *)&cmd_flow_director_mode_ip,
8890 (void *)&cmd_flow_director_ops,
8891 (void *)&cmd_flow_director_flow,
8892 (void *)&cmd_flow_director_flow_type,
8893 (void *)&cmd_flow_director_src,
8894 (void *)&cmd_flow_director_ip_src,
8895 (void *)&cmd_flow_director_dst,
8896 (void *)&cmd_flow_director_ip_dst,
8897 (void *)&cmd_flow_director_tos,
8898 (void *)&cmd_flow_director_tos_value,
8899 (void *)&cmd_flow_director_proto,
8900 (void *)&cmd_flow_director_proto_value,
8901 (void *)&cmd_flow_director_ttl,
8902 (void *)&cmd_flow_director_ttl_value,
8903 (void *)&cmd_flow_director_vlan,
8904 (void *)&cmd_flow_director_vlan_value,
8905 (void *)&cmd_flow_director_flexbytes,
8906 (void *)&cmd_flow_director_flexbytes_value,
8907 (void *)&cmd_flow_director_drop,
8908 (void *)&cmd_flow_director_pf_vf,
8909 (void *)&cmd_flow_director_queue,
8910 (void *)&cmd_flow_director_queue_id,
8911 (void *)&cmd_flow_director_fd_id,
8912 (void *)&cmd_flow_director_fd_id_value,
8917 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8918 .f = cmd_flow_director_filter_parsed,
8920 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8921 "director entry on NIC",
8923 (void *)&cmd_flow_director_filter,
8924 (void *)&cmd_flow_director_port_id,
8925 (void *)&cmd_flow_director_mode,
8926 (void *)&cmd_flow_director_mode_ip,
8927 (void *)&cmd_flow_director_ops,
8928 (void *)&cmd_flow_director_flow,
8929 (void *)&cmd_flow_director_flow_type,
8930 (void *)&cmd_flow_director_src,
8931 (void *)&cmd_flow_director_ip_src,
8932 (void *)&cmd_flow_director_port_src,
8933 (void *)&cmd_flow_director_dst,
8934 (void *)&cmd_flow_director_ip_dst,
8935 (void *)&cmd_flow_director_port_dst,
8936 (void *)&cmd_flow_director_tos,
8937 (void *)&cmd_flow_director_tos_value,
8938 (void *)&cmd_flow_director_ttl,
8939 (void *)&cmd_flow_director_ttl_value,
8940 (void *)&cmd_flow_director_vlan,
8941 (void *)&cmd_flow_director_vlan_value,
8942 (void *)&cmd_flow_director_flexbytes,
8943 (void *)&cmd_flow_director_flexbytes_value,
8944 (void *)&cmd_flow_director_drop,
8945 (void *)&cmd_flow_director_pf_vf,
8946 (void *)&cmd_flow_director_queue,
8947 (void *)&cmd_flow_director_queue_id,
8948 (void *)&cmd_flow_director_fd_id,
8949 (void *)&cmd_flow_director_fd_id_value,
8954 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8955 .f = cmd_flow_director_filter_parsed,
8957 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
8958 "director entry on NIC",
8960 (void *)&cmd_flow_director_filter,
8961 (void *)&cmd_flow_director_port_id,
8962 (void *)&cmd_flow_director_mode,
8963 (void *)&cmd_flow_director_mode_ip,
8964 (void *)&cmd_flow_director_ops,
8965 (void *)&cmd_flow_director_flow,
8966 (void *)&cmd_flow_director_flow_type,
8967 (void *)&cmd_flow_director_src,
8968 (void *)&cmd_flow_director_ip_src,
8969 (void *)&cmd_flow_director_port_dst,
8970 (void *)&cmd_flow_director_dst,
8971 (void *)&cmd_flow_director_ip_dst,
8972 (void *)&cmd_flow_director_port_dst,
8973 (void *)&cmd_flow_director_verify_tag,
8974 (void *)&cmd_flow_director_verify_tag_value,
8975 (void *)&cmd_flow_director_tos,
8976 (void *)&cmd_flow_director_tos_value,
8977 (void *)&cmd_flow_director_ttl,
8978 (void *)&cmd_flow_director_ttl_value,
8979 (void *)&cmd_flow_director_vlan,
8980 (void *)&cmd_flow_director_vlan_value,
8981 (void *)&cmd_flow_director_flexbytes,
8982 (void *)&cmd_flow_director_flexbytes_value,
8983 (void *)&cmd_flow_director_drop,
8984 (void *)&cmd_flow_director_pf_vf,
8985 (void *)&cmd_flow_director_queue,
8986 (void *)&cmd_flow_director_queue_id,
8987 (void *)&cmd_flow_director_fd_id,
8988 (void *)&cmd_flow_director_fd_id_value,
8993 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8994 .f = cmd_flow_director_filter_parsed,
8996 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
8997 "director entry on NIC",
8999 (void *)&cmd_flow_director_filter,
9000 (void *)&cmd_flow_director_port_id,
9001 (void *)&cmd_flow_director_mode,
9002 (void *)&cmd_flow_director_mode_ip,
9003 (void *)&cmd_flow_director_ops,
9004 (void *)&cmd_flow_director_flow,
9005 (void *)&cmd_flow_director_flow_type,
9006 (void *)&cmd_flow_director_ether,
9007 (void *)&cmd_flow_director_ether_type,
9008 (void *)&cmd_flow_director_flexbytes,
9009 (void *)&cmd_flow_director_flexbytes_value,
9010 (void *)&cmd_flow_director_drop,
9011 (void *)&cmd_flow_director_pf_vf,
9012 (void *)&cmd_flow_director_queue,
9013 (void *)&cmd_flow_director_queue_id,
9014 (void *)&cmd_flow_director_fd_id,
9015 (void *)&cmd_flow_director_fd_id_value,
9020 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9021 .f = cmd_flow_director_filter_parsed,
9023 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9024 "director entry on NIC",
9026 (void *)&cmd_flow_director_filter,
9027 (void *)&cmd_flow_director_port_id,
9028 (void *)&cmd_flow_director_mode,
9029 (void *)&cmd_flow_director_mode_mac_vlan,
9030 (void *)&cmd_flow_director_ops,
9031 (void *)&cmd_flow_director_mac,
9032 (void *)&cmd_flow_director_mac_addr,
9033 (void *)&cmd_flow_director_vlan,
9034 (void *)&cmd_flow_director_vlan_value,
9035 (void *)&cmd_flow_director_flexbytes,
9036 (void *)&cmd_flow_director_flexbytes_value,
9037 (void *)&cmd_flow_director_drop,
9038 (void *)&cmd_flow_director_queue,
9039 (void *)&cmd_flow_director_queue_id,
9040 (void *)&cmd_flow_director_fd_id,
9041 (void *)&cmd_flow_director_fd_id_value,
9046 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9047 .f = cmd_flow_director_filter_parsed,
9049 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9050 "director entry on NIC",
9052 (void *)&cmd_flow_director_filter,
9053 (void *)&cmd_flow_director_port_id,
9054 (void *)&cmd_flow_director_mode,
9055 (void *)&cmd_flow_director_mode_tunnel,
9056 (void *)&cmd_flow_director_ops,
9057 (void *)&cmd_flow_director_mac,
9058 (void *)&cmd_flow_director_mac_addr,
9059 (void *)&cmd_flow_director_vlan,
9060 (void *)&cmd_flow_director_vlan_value,
9061 (void *)&cmd_flow_director_tunnel,
9062 (void *)&cmd_flow_director_tunnel_type,
9063 (void *)&cmd_flow_director_tunnel_id,
9064 (void *)&cmd_flow_director_tunnel_id_value,
9065 (void *)&cmd_flow_director_flexbytes,
9066 (void *)&cmd_flow_director_flexbytes_value,
9067 (void *)&cmd_flow_director_drop,
9068 (void *)&cmd_flow_director_queue,
9069 (void *)&cmd_flow_director_queue_id,
9070 (void *)&cmd_flow_director_fd_id,
9071 (void *)&cmd_flow_director_fd_id_value,
9076 struct cmd_flush_flow_director_result {
9077 cmdline_fixed_string_t flush_flow_director;
9081 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9082 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9083 flush_flow_director, "flush_flow_director");
9084 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9085 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9089 cmd_flush_flow_director_parsed(void *parsed_result,
9090 __attribute__((unused)) struct cmdline *cl,
9091 __attribute__((unused)) void *data)
9093 struct cmd_flow_director_result *res = parsed_result;
9096 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9098 printf("flow director is not supported on port %u.\n",
9103 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9104 RTE_ETH_FILTER_FLUSH, NULL);
9106 printf("flow director table flushing error: (%s)\n",
9110 cmdline_parse_inst_t cmd_flush_flow_director = {
9111 .f = cmd_flush_flow_director_parsed,
9113 .help_str = "flush_flow_director <port_id>: "
9114 "Flush all flow director entries of a device on NIC",
9116 (void *)&cmd_flush_flow_director_flush,
9117 (void *)&cmd_flush_flow_director_port_id,
9122 /* *** deal with flow director mask *** */
9123 struct cmd_flow_director_mask_result {
9124 cmdline_fixed_string_t flow_director_mask;
9126 cmdline_fixed_string_t mode;
9127 cmdline_fixed_string_t mode_value;
9128 cmdline_fixed_string_t vlan;
9130 cmdline_fixed_string_t src_mask;
9131 cmdline_ipaddr_t ipv4_src;
9132 cmdline_ipaddr_t ipv6_src;
9134 cmdline_fixed_string_t dst_mask;
9135 cmdline_ipaddr_t ipv4_dst;
9136 cmdline_ipaddr_t ipv6_dst;
9138 cmdline_fixed_string_t mac;
9139 uint8_t mac_addr_byte_mask;
9140 cmdline_fixed_string_t tunnel_id;
9141 uint32_t tunnel_id_mask;
9142 cmdline_fixed_string_t tunnel_type;
9143 uint8_t tunnel_type_mask;
9147 cmd_flow_director_mask_parsed(void *parsed_result,
9148 __attribute__((unused)) struct cmdline *cl,
9149 __attribute__((unused)) void *data)
9151 struct cmd_flow_director_mask_result *res = parsed_result;
9152 struct rte_eth_fdir_masks *mask;
9153 struct rte_port *port;
9155 if (res->port_id > nb_ports) {
9156 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9160 port = &ports[res->port_id];
9161 /** Check if the port is not started **/
9162 if (port->port_status != RTE_PORT_STOPPED) {
9163 printf("Please stop port %d first\n", res->port_id);
9167 mask = &port->dev_conf.fdir_conf.mask;
9169 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9170 if (strcmp(res->mode_value, "MAC-VLAN")) {
9171 printf("Please set mode to MAC-VLAN.\n");
9175 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9176 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9177 if (strcmp(res->mode_value, "Tunnel")) {
9178 printf("Please set mode to Tunnel.\n");
9182 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9183 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9184 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9185 mask->tunnel_type_mask = res->tunnel_type_mask;
9187 if (strcmp(res->mode_value, "IP")) {
9188 printf("Please set mode to IP.\n");
9192 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9193 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9194 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9195 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9196 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9197 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9198 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9201 cmd_reconfig_device_queue(res->port_id, 1, 1);
9204 cmdline_parse_token_string_t cmd_flow_director_mask =
9205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9206 flow_director_mask, "flow_director_mask");
9207 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9208 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9210 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9213 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9214 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9216 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9218 src_mask, "src_mask");
9219 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9220 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9222 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9223 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9225 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9226 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9228 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9230 dst_mask, "dst_mask");
9231 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9232 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9234 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9235 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9237 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9238 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9241 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9244 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9247 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9249 mode_value, "MAC-VLAN");
9250 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9252 mode_value, "Tunnel");
9253 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9256 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9258 mac_addr_byte_mask, UINT8);
9259 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9261 tunnel_type, "tunnel-type");
9262 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9263 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9264 tunnel_type_mask, UINT8);
9265 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9267 tunnel_id, "tunnel-id");
9268 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9270 tunnel_id_mask, UINT32);
9272 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9273 .f = cmd_flow_director_mask_parsed,
9275 .help_str = "flow_director_mask ... : "
9276 "Set IP mode flow director's mask on NIC",
9278 (void *)&cmd_flow_director_mask,
9279 (void *)&cmd_flow_director_mask_port_id,
9280 (void *)&cmd_flow_director_mask_mode,
9281 (void *)&cmd_flow_director_mask_mode_ip,
9282 (void *)&cmd_flow_director_mask_vlan,
9283 (void *)&cmd_flow_director_mask_vlan_value,
9284 (void *)&cmd_flow_director_mask_src,
9285 (void *)&cmd_flow_director_mask_ipv4_src,
9286 (void *)&cmd_flow_director_mask_ipv6_src,
9287 (void *)&cmd_flow_director_mask_port_src,
9288 (void *)&cmd_flow_director_mask_dst,
9289 (void *)&cmd_flow_director_mask_ipv4_dst,
9290 (void *)&cmd_flow_director_mask_ipv6_dst,
9291 (void *)&cmd_flow_director_mask_port_dst,
9296 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9297 .f = cmd_flow_director_mask_parsed,
9299 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9300 "flow director's mask on NIC",
9302 (void *)&cmd_flow_director_mask,
9303 (void *)&cmd_flow_director_mask_port_id,
9304 (void *)&cmd_flow_director_mask_mode,
9305 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9306 (void *)&cmd_flow_director_mask_vlan,
9307 (void *)&cmd_flow_director_mask_vlan_value,
9312 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9313 .f = cmd_flow_director_mask_parsed,
9315 .help_str = "flow_director_mask ... : Set tunnel mode "
9316 "flow director's mask on NIC",
9318 (void *)&cmd_flow_director_mask,
9319 (void *)&cmd_flow_director_mask_port_id,
9320 (void *)&cmd_flow_director_mask_mode,
9321 (void *)&cmd_flow_director_mask_mode_tunnel,
9322 (void *)&cmd_flow_director_mask_vlan,
9323 (void *)&cmd_flow_director_mask_vlan_value,
9324 (void *)&cmd_flow_director_mask_mac,
9325 (void *)&cmd_flow_director_mask_mac_value,
9326 (void *)&cmd_flow_director_mask_tunnel_type,
9327 (void *)&cmd_flow_director_mask_tunnel_type_value,
9328 (void *)&cmd_flow_director_mask_tunnel_id,
9329 (void *)&cmd_flow_director_mask_tunnel_id_value,
9334 /* *** deal with flow director mask on flexible payload *** */
9335 struct cmd_flow_director_flex_mask_result {
9336 cmdline_fixed_string_t flow_director_flexmask;
9338 cmdline_fixed_string_t flow;
9339 cmdline_fixed_string_t flow_type;
9340 cmdline_fixed_string_t mask;
9344 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9345 __attribute__((unused)) struct cmdline *cl,
9346 __attribute__((unused)) void *data)
9348 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9349 struct rte_eth_fdir_info fdir_info;
9350 struct rte_eth_fdir_flex_mask flex_mask;
9351 struct rte_port *port;
9352 uint32_t flow_type_mask;
9356 if (res->port_id > nb_ports) {
9357 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9361 port = &ports[res->port_id];
9362 /** Check if the port is not started **/
9363 if (port->port_status != RTE_PORT_STOPPED) {
9364 printf("Please stop port %d first\n", res->port_id);
9368 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9369 ret = parse_flexbytes(res->mask,
9371 RTE_ETH_FDIR_MAX_FLEXLEN);
9373 printf("error: Cannot parse mask input.\n");
9377 memset(&fdir_info, 0, sizeof(fdir_info));
9378 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9379 RTE_ETH_FILTER_INFO, &fdir_info);
9381 printf("Cannot get FDir filter info\n");
9385 if (!strcmp(res->flow_type, "none")) {
9386 /* means don't specify the flow type */
9387 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9388 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9389 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9390 0, sizeof(struct rte_eth_fdir_flex_mask));
9391 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9392 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9394 sizeof(struct rte_eth_fdir_flex_mask));
9395 cmd_reconfig_device_queue(res->port_id, 1, 1);
9398 flow_type_mask = fdir_info.flow_types_mask[0];
9399 if (!strcmp(res->flow_type, "all")) {
9400 if (!flow_type_mask) {
9401 printf("No flow type supported\n");
9404 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9405 if (flow_type_mask & (1 << i)) {
9406 flex_mask.flow_type = i;
9407 fdir_set_flex_mask(res->port_id, &flex_mask);
9410 cmd_reconfig_device_queue(res->port_id, 1, 1);
9413 flex_mask.flow_type = str2flowtype(res->flow_type);
9414 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9415 printf("Flow type %s not supported on port %d\n",
9416 res->flow_type, res->port_id);
9419 fdir_set_flex_mask(res->port_id, &flex_mask);
9420 cmd_reconfig_device_queue(res->port_id, 1, 1);
9423 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9425 flow_director_flexmask,
9426 "flow_director_flex_mask");
9427 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9428 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9430 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9433 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9435 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9436 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9437 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9441 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9442 .f = cmd_flow_director_flex_mask_parsed,
9444 .help_str = "flow_director_flex_mask ... : "
9445 "Set flow director's flex mask on NIC",
9447 (void *)&cmd_flow_director_flexmask,
9448 (void *)&cmd_flow_director_flexmask_port_id,
9449 (void *)&cmd_flow_director_flexmask_flow,
9450 (void *)&cmd_flow_director_flexmask_flow_type,
9451 (void *)&cmd_flow_director_flexmask_mask,
9456 /* *** deal with flow director flexible payload configuration *** */
9457 struct cmd_flow_director_flexpayload_result {
9458 cmdline_fixed_string_t flow_director_flexpayload;
9460 cmdline_fixed_string_t payload_layer;
9461 cmdline_fixed_string_t payload_cfg;
9465 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9468 const char *p, *p0 = q_arg;
9470 unsigned long int_fld;
9471 char *str_fld[max_num];
9476 p = strchr(p0, '(');
9480 p0 = strchr(p, ')');
9485 if (size >= sizeof(s))
9488 snprintf(s, sizeof(s), "%.*s", size, p);
9489 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9490 if (ret < 0 || ret > max_num)
9492 for (i = 0; i < ret; i++) {
9494 int_fld = strtoul(str_fld[i], &end, 0);
9495 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9497 offsets[i] = (uint16_t)int_fld;
9503 cmd_flow_director_flxpld_parsed(void *parsed_result,
9504 __attribute__((unused)) struct cmdline *cl,
9505 __attribute__((unused)) void *data)
9507 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9508 struct rte_eth_flex_payload_cfg flex_cfg;
9509 struct rte_port *port;
9512 if (res->port_id > nb_ports) {
9513 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9517 port = &ports[res->port_id];
9518 /** Check if the port is not started **/
9519 if (port->port_status != RTE_PORT_STOPPED) {
9520 printf("Please stop port %d first\n", res->port_id);
9524 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9526 if (!strcmp(res->payload_layer, "raw"))
9527 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9528 else if (!strcmp(res->payload_layer, "l2"))
9529 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9530 else if (!strcmp(res->payload_layer, "l3"))
9531 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9532 else if (!strcmp(res->payload_layer, "l4"))
9533 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9535 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9536 RTE_ETH_FDIR_MAX_FLEXLEN);
9538 printf("error: Cannot parse flex payload input.\n");
9542 fdir_set_flex_payload(res->port_id, &flex_cfg);
9543 cmd_reconfig_device_queue(res->port_id, 1, 1);
9546 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9548 flow_director_flexpayload,
9549 "flow_director_flex_payload");
9550 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9551 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9553 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9555 payload_layer, "raw#l2#l3#l4");
9556 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9560 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9561 .f = cmd_flow_director_flxpld_parsed,
9563 .help_str = "flow_director_flexpayload ... : "
9564 "Set flow director's flex payload on NIC",
9566 (void *)&cmd_flow_director_flexpayload,
9567 (void *)&cmd_flow_director_flexpayload_port_id,
9568 (void *)&cmd_flow_director_flexpayload_payload_layer,
9569 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9574 /* Generic flow interface command. */
9575 extern cmdline_parse_inst_t cmd_flow;
9577 /* *** Classification Filters Control *** */
9578 /* *** Get symmetric hash enable per port *** */
9579 struct cmd_get_sym_hash_ena_per_port_result {
9580 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9585 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9586 __rte_unused struct cmdline *cl,
9587 __rte_unused void *data)
9589 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9590 struct rte_eth_hash_filter_info info;
9593 if (rte_eth_dev_filter_supported(res->port_id,
9594 RTE_ETH_FILTER_HASH) < 0) {
9595 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9600 memset(&info, 0, sizeof(info));
9601 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9602 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9603 RTE_ETH_FILTER_GET, &info);
9606 printf("Cannot get symmetric hash enable per port "
9607 "on port %u\n", res->port_id);
9611 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9612 "enabled" : "disabled", res->port_id);
9615 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9616 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9617 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9618 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9619 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9622 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9623 .f = cmd_get_sym_hash_per_port_parsed,
9625 .help_str = "get_sym_hash_ena_per_port <port_id>",
9627 (void *)&cmd_get_sym_hash_ena_per_port_all,
9628 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9633 /* *** Set symmetric hash enable per port *** */
9634 struct cmd_set_sym_hash_ena_per_port_result {
9635 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9636 cmdline_fixed_string_t enable;
9641 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9642 __rte_unused struct cmdline *cl,
9643 __rte_unused void *data)
9645 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9646 struct rte_eth_hash_filter_info info;
9649 if (rte_eth_dev_filter_supported(res->port_id,
9650 RTE_ETH_FILTER_HASH) < 0) {
9651 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9656 memset(&info, 0, sizeof(info));
9657 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9658 if (!strcmp(res->enable, "enable"))
9659 info.info.enable = 1;
9660 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9661 RTE_ETH_FILTER_SET, &info);
9663 printf("Cannot set symmetric hash enable per port on "
9664 "port %u\n", res->port_id);
9667 printf("Symmetric hash has been set to %s on port %u\n",
9668 res->enable, res->port_id);
9671 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9672 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9673 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9674 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9675 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9677 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9678 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9679 enable, "enable#disable");
9681 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9682 .f = cmd_set_sym_hash_per_port_parsed,
9684 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9686 (void *)&cmd_set_sym_hash_ena_per_port_all,
9687 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9688 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9693 /* Get global config of hash function */
9694 struct cmd_get_hash_global_config_result {
9695 cmdline_fixed_string_t get_hash_global_config;
9700 flowtype_to_str(uint16_t ftype)
9707 {"ipv4", RTE_ETH_FLOW_IPV4},
9708 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9709 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9710 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9711 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9712 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9713 {"ipv6", RTE_ETH_FLOW_IPV6},
9714 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9715 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9716 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9717 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9718 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9719 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9720 {"port", RTE_ETH_FLOW_PORT},
9721 {"vxlan", RTE_ETH_FLOW_VXLAN},
9722 {"geneve", RTE_ETH_FLOW_GENEVE},
9723 {"nvgre", RTE_ETH_FLOW_NVGRE},
9726 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9727 if (ftype_table[i].ftype == ftype)
9728 return ftype_table[i].str;
9735 cmd_get_hash_global_config_parsed(void *parsed_result,
9736 __rte_unused struct cmdline *cl,
9737 __rte_unused void *data)
9739 struct cmd_get_hash_global_config_result *res = parsed_result;
9740 struct rte_eth_hash_filter_info info;
9741 uint32_t idx, offset;
9746 if (rte_eth_dev_filter_supported(res->port_id,
9747 RTE_ETH_FILTER_HASH) < 0) {
9748 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9753 memset(&info, 0, sizeof(info));
9754 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9755 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9756 RTE_ETH_FILTER_GET, &info);
9758 printf("Cannot get hash global configurations by port %d\n",
9763 switch (info.info.global_conf.hash_func) {
9764 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9765 printf("Hash function is Toeplitz\n");
9767 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9768 printf("Hash function is Simple XOR\n");
9771 printf("Unknown hash function\n");
9775 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9776 idx = i / UINT32_BIT;
9777 offset = i % UINT32_BIT;
9778 if (!(info.info.global_conf.valid_bit_mask[idx] &
9781 str = flowtype_to_str(i);
9784 printf("Symmetric hash is %s globally for flow type %s "
9786 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9787 (1UL << offset)) ? "enabled" : "disabled"), str,
9792 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9793 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9794 get_hash_global_config, "get_hash_global_config");
9795 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9796 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9799 cmdline_parse_inst_t cmd_get_hash_global_config = {
9800 .f = cmd_get_hash_global_config_parsed,
9802 .help_str = "get_hash_global_config <port_id>",
9804 (void *)&cmd_get_hash_global_config_all,
9805 (void *)&cmd_get_hash_global_config_port_id,
9810 /* Set global config of hash function */
9811 struct cmd_set_hash_global_config_result {
9812 cmdline_fixed_string_t set_hash_global_config;
9814 cmdline_fixed_string_t hash_func;
9815 cmdline_fixed_string_t flow_type;
9816 cmdline_fixed_string_t enable;
9820 cmd_set_hash_global_config_parsed(void *parsed_result,
9821 __rte_unused struct cmdline *cl,
9822 __rte_unused void *data)
9824 struct cmd_set_hash_global_config_result *res = parsed_result;
9825 struct rte_eth_hash_filter_info info;
9826 uint32_t ftype, idx, offset;
9829 if (rte_eth_dev_filter_supported(res->port_id,
9830 RTE_ETH_FILTER_HASH) < 0) {
9831 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9835 memset(&info, 0, sizeof(info));
9836 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9837 if (!strcmp(res->hash_func, "toeplitz"))
9838 info.info.global_conf.hash_func =
9839 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9840 else if (!strcmp(res->hash_func, "simple_xor"))
9841 info.info.global_conf.hash_func =
9842 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9843 else if (!strcmp(res->hash_func, "default"))
9844 info.info.global_conf.hash_func =
9845 RTE_ETH_HASH_FUNCTION_DEFAULT;
9847 ftype = str2flowtype(res->flow_type);
9848 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9849 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9850 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9851 if (!strcmp(res->enable, "enable"))
9852 info.info.global_conf.sym_hash_enable_mask[idx] |=
9854 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9855 RTE_ETH_FILTER_SET, &info);
9857 printf("Cannot set global hash configurations by port %d\n",
9860 printf("Global hash configurations have been set "
9861 "succcessfully by port %d\n", res->port_id);
9864 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9865 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9866 set_hash_global_config, "set_hash_global_config");
9867 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9868 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9870 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9871 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9872 hash_func, "toeplitz#simple_xor#default");
9873 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9874 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9876 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9877 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9878 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9879 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9880 enable, "enable#disable");
9882 cmdline_parse_inst_t cmd_set_hash_global_config = {
9883 .f = cmd_set_hash_global_config_parsed,
9885 .help_str = "set_hash_global_config <port_id> "
9886 "toeplitz|simple_xor|default "
9887 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9888 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9889 "l2_payload enable|disable",
9891 (void *)&cmd_set_hash_global_config_all,
9892 (void *)&cmd_set_hash_global_config_port_id,
9893 (void *)&cmd_set_hash_global_config_hash_func,
9894 (void *)&cmd_set_hash_global_config_flow_type,
9895 (void *)&cmd_set_hash_global_config_enable,
9900 /* Set hash input set */
9901 struct cmd_set_hash_input_set_result {
9902 cmdline_fixed_string_t set_hash_input_set;
9904 cmdline_fixed_string_t flow_type;
9905 cmdline_fixed_string_t inset_field;
9906 cmdline_fixed_string_t select;
9909 static enum rte_eth_input_set_field
9910 str2inset(char *string)
9914 static const struct {
9916 enum rte_eth_input_set_field inset;
9918 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9919 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9920 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9921 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9922 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9923 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9924 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9925 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9926 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9927 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9928 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9929 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9930 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9931 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9932 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9933 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9934 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9935 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9936 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9937 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9938 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9939 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9940 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9941 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9942 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9943 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9944 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9945 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9946 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9947 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9948 {"none", RTE_ETH_INPUT_SET_NONE},
9951 for (i = 0; i < RTE_DIM(inset_table); i++) {
9952 if (!strcmp(string, inset_table[i].str))
9953 return inset_table[i].inset;
9956 return RTE_ETH_INPUT_SET_UNKNOWN;
9960 cmd_set_hash_input_set_parsed(void *parsed_result,
9961 __rte_unused struct cmdline *cl,
9962 __rte_unused void *data)
9964 struct cmd_set_hash_input_set_result *res = parsed_result;
9965 struct rte_eth_hash_filter_info info;
9967 memset(&info, 0, sizeof(info));
9968 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9969 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9970 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9971 info.info.input_set_conf.inset_size = 1;
9972 if (!strcmp(res->select, "select"))
9973 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9974 else if (!strcmp(res->select, "add"))
9975 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9976 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9977 RTE_ETH_FILTER_SET, &info);
9980 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9981 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9982 set_hash_input_set, "set_hash_input_set");
9983 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9984 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9986 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9987 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9989 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9990 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9991 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9992 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9994 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9995 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9996 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9997 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9998 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10000 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10001 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10002 select, "select#add");
10004 cmdline_parse_inst_t cmd_set_hash_input_set = {
10005 .f = cmd_set_hash_input_set_parsed,
10007 .help_str = "set_hash_input_set <port_id> "
10008 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10009 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10010 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10011 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10012 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10013 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10014 "fld-7th|fld-8th|none select|add",
10016 (void *)&cmd_set_hash_input_set_cmd,
10017 (void *)&cmd_set_hash_input_set_port_id,
10018 (void *)&cmd_set_hash_input_set_flow_type,
10019 (void *)&cmd_set_hash_input_set_field,
10020 (void *)&cmd_set_hash_input_set_select,
10025 /* Set flow director input set */
10026 struct cmd_set_fdir_input_set_result {
10027 cmdline_fixed_string_t set_fdir_input_set;
10029 cmdline_fixed_string_t flow_type;
10030 cmdline_fixed_string_t inset_field;
10031 cmdline_fixed_string_t select;
10035 cmd_set_fdir_input_set_parsed(void *parsed_result,
10036 __rte_unused struct cmdline *cl,
10037 __rte_unused void *data)
10039 struct cmd_set_fdir_input_set_result *res = parsed_result;
10040 struct rte_eth_fdir_filter_info info;
10042 memset(&info, 0, sizeof(info));
10043 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10044 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10045 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10046 info.info.input_set_conf.inset_size = 1;
10047 if (!strcmp(res->select, "select"))
10048 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10049 else if (!strcmp(res->select, "add"))
10050 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10051 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10052 RTE_ETH_FILTER_SET, &info);
10055 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10056 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10057 set_fdir_input_set, "set_fdir_input_set");
10058 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10059 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10061 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10062 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10064 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10065 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10066 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10067 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10069 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10070 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10071 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10072 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10073 "sctp-veri-tag#none");
10074 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10075 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10076 select, "select#add");
10078 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10079 .f = cmd_set_fdir_input_set_parsed,
10081 .help_str = "set_fdir_input_set <port_id> "
10082 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10083 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10084 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10085 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10086 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10087 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10088 "sctp-veri-tag|none select|add",
10090 (void *)&cmd_set_fdir_input_set_cmd,
10091 (void *)&cmd_set_fdir_input_set_port_id,
10092 (void *)&cmd_set_fdir_input_set_flow_type,
10093 (void *)&cmd_set_fdir_input_set_field,
10094 (void *)&cmd_set_fdir_input_set_select,
10099 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10100 struct cmd_mcast_addr_result {
10101 cmdline_fixed_string_t mcast_addr_cmd;
10102 cmdline_fixed_string_t what;
10104 struct ether_addr mc_addr;
10107 static void cmd_mcast_addr_parsed(void *parsed_result,
10108 __attribute__((unused)) struct cmdline *cl,
10109 __attribute__((unused)) void *data)
10111 struct cmd_mcast_addr_result *res = parsed_result;
10113 if (!is_multicast_ether_addr(&res->mc_addr)) {
10114 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10115 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10116 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10117 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10120 if (strcmp(res->what, "add") == 0)
10121 mcast_addr_add(res->port_num, &res->mc_addr);
10123 mcast_addr_remove(res->port_num, &res->mc_addr);
10126 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10127 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10128 mcast_addr_cmd, "mcast_addr");
10129 cmdline_parse_token_string_t cmd_mcast_addr_what =
10130 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10132 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10133 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10134 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10135 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10137 cmdline_parse_inst_t cmd_mcast_addr = {
10138 .f = cmd_mcast_addr_parsed,
10140 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10141 "Add/Remove multicast MAC address on port_id",
10143 (void *)&cmd_mcast_addr_cmd,
10144 (void *)&cmd_mcast_addr_what,
10145 (void *)&cmd_mcast_addr_portnum,
10146 (void *)&cmd_mcast_addr_addr,
10151 /* l2 tunnel config
10152 * only support E-tag now.
10155 /* Ether type config */
10156 struct cmd_config_l2_tunnel_eth_type_result {
10157 cmdline_fixed_string_t port;
10158 cmdline_fixed_string_t config;
10159 cmdline_fixed_string_t all;
10161 cmdline_fixed_string_t l2_tunnel;
10162 cmdline_fixed_string_t l2_tunnel_type;
10163 cmdline_fixed_string_t eth_type;
10164 uint16_t eth_type_val;
10167 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10168 TOKEN_STRING_INITIALIZER
10169 (struct cmd_config_l2_tunnel_eth_type_result,
10171 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10172 TOKEN_STRING_INITIALIZER
10173 (struct cmd_config_l2_tunnel_eth_type_result,
10175 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10176 TOKEN_STRING_INITIALIZER
10177 (struct cmd_config_l2_tunnel_eth_type_result,
10179 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10180 TOKEN_NUM_INITIALIZER
10181 (struct cmd_config_l2_tunnel_eth_type_result,
10183 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10184 TOKEN_STRING_INITIALIZER
10185 (struct cmd_config_l2_tunnel_eth_type_result,
10186 l2_tunnel, "l2-tunnel");
10187 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10188 TOKEN_STRING_INITIALIZER
10189 (struct cmd_config_l2_tunnel_eth_type_result,
10190 l2_tunnel_type, "E-tag");
10191 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10192 TOKEN_STRING_INITIALIZER
10193 (struct cmd_config_l2_tunnel_eth_type_result,
10194 eth_type, "ether-type");
10195 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10196 TOKEN_NUM_INITIALIZER
10197 (struct cmd_config_l2_tunnel_eth_type_result,
10198 eth_type_val, UINT16);
10200 static enum rte_eth_tunnel_type
10201 str2fdir_l2_tunnel_type(char *string)
10205 static const struct {
10207 enum rte_eth_tunnel_type type;
10208 } l2_tunnel_type_str[] = {
10209 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10212 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10213 if (!strcmp(l2_tunnel_type_str[i].str, string))
10214 return l2_tunnel_type_str[i].type;
10216 return RTE_TUNNEL_TYPE_NONE;
10219 /* ether type config for all ports */
10221 cmd_config_l2_tunnel_eth_type_all_parsed
10222 (void *parsed_result,
10223 __attribute__((unused)) struct cmdline *cl,
10224 __attribute__((unused)) void *data)
10226 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10227 struct rte_eth_l2_tunnel_conf entry;
10230 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10231 entry.ether_type = res->eth_type_val;
10233 FOREACH_PORT(pid, ports) {
10234 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10238 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10239 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10241 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10243 (void *)&cmd_config_l2_tunnel_eth_type_port,
10244 (void *)&cmd_config_l2_tunnel_eth_type_config,
10245 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10246 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10247 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10248 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10249 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10254 /* ether type config for a specific port */
10256 cmd_config_l2_tunnel_eth_type_specific_parsed(
10257 void *parsed_result,
10258 __attribute__((unused)) struct cmdline *cl,
10259 __attribute__((unused)) void *data)
10261 struct cmd_config_l2_tunnel_eth_type_result *res =
10263 struct rte_eth_l2_tunnel_conf entry;
10265 if (port_id_is_invalid(res->id, ENABLED_WARN))
10268 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10269 entry.ether_type = res->eth_type_val;
10271 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10274 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10275 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10277 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10279 (void *)&cmd_config_l2_tunnel_eth_type_port,
10280 (void *)&cmd_config_l2_tunnel_eth_type_config,
10281 (void *)&cmd_config_l2_tunnel_eth_type_id,
10282 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10283 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10284 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10285 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10290 /* Enable/disable l2 tunnel */
10291 struct cmd_config_l2_tunnel_en_dis_result {
10292 cmdline_fixed_string_t port;
10293 cmdline_fixed_string_t config;
10294 cmdline_fixed_string_t all;
10296 cmdline_fixed_string_t l2_tunnel;
10297 cmdline_fixed_string_t l2_tunnel_type;
10298 cmdline_fixed_string_t en_dis;
10301 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10302 TOKEN_STRING_INITIALIZER
10303 (struct cmd_config_l2_tunnel_en_dis_result,
10305 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10306 TOKEN_STRING_INITIALIZER
10307 (struct cmd_config_l2_tunnel_en_dis_result,
10309 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10310 TOKEN_STRING_INITIALIZER
10311 (struct cmd_config_l2_tunnel_en_dis_result,
10313 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10314 TOKEN_NUM_INITIALIZER
10315 (struct cmd_config_l2_tunnel_en_dis_result,
10317 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10318 TOKEN_STRING_INITIALIZER
10319 (struct cmd_config_l2_tunnel_en_dis_result,
10320 l2_tunnel, "l2-tunnel");
10321 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10322 TOKEN_STRING_INITIALIZER
10323 (struct cmd_config_l2_tunnel_en_dis_result,
10324 l2_tunnel_type, "E-tag");
10325 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10326 TOKEN_STRING_INITIALIZER
10327 (struct cmd_config_l2_tunnel_en_dis_result,
10328 en_dis, "enable#disable");
10330 /* enable/disable l2 tunnel for all ports */
10332 cmd_config_l2_tunnel_en_dis_all_parsed(
10333 void *parsed_result,
10334 __attribute__((unused)) struct cmdline *cl,
10335 __attribute__((unused)) void *data)
10337 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10338 struct rte_eth_l2_tunnel_conf entry;
10342 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10344 if (!strcmp("enable", res->en_dis))
10349 FOREACH_PORT(pid, ports) {
10350 rte_eth_dev_l2_tunnel_offload_set(pid,
10352 ETH_L2_TUNNEL_ENABLE_MASK,
10357 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10358 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10360 .help_str = "port config all l2-tunnel E-tag enable|disable",
10362 (void *)&cmd_config_l2_tunnel_en_dis_port,
10363 (void *)&cmd_config_l2_tunnel_en_dis_config,
10364 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10365 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10366 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10367 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10372 /* enable/disable l2 tunnel for a port */
10374 cmd_config_l2_tunnel_en_dis_specific_parsed(
10375 void *parsed_result,
10376 __attribute__((unused)) struct cmdline *cl,
10377 __attribute__((unused)) void *data)
10379 struct cmd_config_l2_tunnel_en_dis_result *res =
10381 struct rte_eth_l2_tunnel_conf entry;
10383 if (port_id_is_invalid(res->id, ENABLED_WARN))
10386 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10388 if (!strcmp("enable", res->en_dis))
10389 rte_eth_dev_l2_tunnel_offload_set(res->id,
10391 ETH_L2_TUNNEL_ENABLE_MASK,
10394 rte_eth_dev_l2_tunnel_offload_set(res->id,
10396 ETH_L2_TUNNEL_ENABLE_MASK,
10400 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10401 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10403 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10405 (void *)&cmd_config_l2_tunnel_en_dis_port,
10406 (void *)&cmd_config_l2_tunnel_en_dis_config,
10407 (void *)&cmd_config_l2_tunnel_en_dis_id,
10408 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10409 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10410 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10415 /* E-tag configuration */
10417 /* Common result structure for all E-tag configuration */
10418 struct cmd_config_e_tag_result {
10419 cmdline_fixed_string_t e_tag;
10420 cmdline_fixed_string_t set;
10421 cmdline_fixed_string_t insertion;
10422 cmdline_fixed_string_t stripping;
10423 cmdline_fixed_string_t forwarding;
10424 cmdline_fixed_string_t filter;
10425 cmdline_fixed_string_t add;
10426 cmdline_fixed_string_t del;
10427 cmdline_fixed_string_t on;
10428 cmdline_fixed_string_t off;
10429 cmdline_fixed_string_t on_off;
10430 cmdline_fixed_string_t port_tag_id;
10431 uint32_t port_tag_id_val;
10432 cmdline_fixed_string_t e_tag_id;
10433 uint16_t e_tag_id_val;
10434 cmdline_fixed_string_t dst_pool;
10435 uint8_t dst_pool_val;
10436 cmdline_fixed_string_t port;
10438 cmdline_fixed_string_t vf;
10442 /* Common CLI fields for all E-tag configuration */
10443 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10444 TOKEN_STRING_INITIALIZER
10445 (struct cmd_config_e_tag_result,
10447 cmdline_parse_token_string_t cmd_config_e_tag_set =
10448 TOKEN_STRING_INITIALIZER
10449 (struct cmd_config_e_tag_result,
10451 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10452 TOKEN_STRING_INITIALIZER
10453 (struct cmd_config_e_tag_result,
10454 insertion, "insertion");
10455 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10456 TOKEN_STRING_INITIALIZER
10457 (struct cmd_config_e_tag_result,
10458 stripping, "stripping");
10459 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10460 TOKEN_STRING_INITIALIZER
10461 (struct cmd_config_e_tag_result,
10462 forwarding, "forwarding");
10463 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10464 TOKEN_STRING_INITIALIZER
10465 (struct cmd_config_e_tag_result,
10467 cmdline_parse_token_string_t cmd_config_e_tag_add =
10468 TOKEN_STRING_INITIALIZER
10469 (struct cmd_config_e_tag_result,
10471 cmdline_parse_token_string_t cmd_config_e_tag_del =
10472 TOKEN_STRING_INITIALIZER
10473 (struct cmd_config_e_tag_result,
10475 cmdline_parse_token_string_t cmd_config_e_tag_on =
10476 TOKEN_STRING_INITIALIZER
10477 (struct cmd_config_e_tag_result,
10479 cmdline_parse_token_string_t cmd_config_e_tag_off =
10480 TOKEN_STRING_INITIALIZER
10481 (struct cmd_config_e_tag_result,
10483 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10484 TOKEN_STRING_INITIALIZER
10485 (struct cmd_config_e_tag_result,
10487 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10488 TOKEN_STRING_INITIALIZER
10489 (struct cmd_config_e_tag_result,
10490 port_tag_id, "port-tag-id");
10491 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10492 TOKEN_NUM_INITIALIZER
10493 (struct cmd_config_e_tag_result,
10494 port_tag_id_val, UINT32);
10495 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10496 TOKEN_STRING_INITIALIZER
10497 (struct cmd_config_e_tag_result,
10498 e_tag_id, "e-tag-id");
10499 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10500 TOKEN_NUM_INITIALIZER
10501 (struct cmd_config_e_tag_result,
10502 e_tag_id_val, UINT16);
10503 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10504 TOKEN_STRING_INITIALIZER
10505 (struct cmd_config_e_tag_result,
10506 dst_pool, "dst-pool");
10507 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10508 TOKEN_NUM_INITIALIZER
10509 (struct cmd_config_e_tag_result,
10510 dst_pool_val, UINT8);
10511 cmdline_parse_token_string_t cmd_config_e_tag_port =
10512 TOKEN_STRING_INITIALIZER
10513 (struct cmd_config_e_tag_result,
10515 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10516 TOKEN_NUM_INITIALIZER
10517 (struct cmd_config_e_tag_result,
10519 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10520 TOKEN_STRING_INITIALIZER
10521 (struct cmd_config_e_tag_result,
10523 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10524 TOKEN_NUM_INITIALIZER
10525 (struct cmd_config_e_tag_result,
10528 /* E-tag insertion configuration */
10530 cmd_config_e_tag_insertion_en_parsed(
10531 void *parsed_result,
10532 __attribute__((unused)) struct cmdline *cl,
10533 __attribute__((unused)) void *data)
10535 struct cmd_config_e_tag_result *res =
10537 struct rte_eth_l2_tunnel_conf entry;
10539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10542 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10543 entry.tunnel_id = res->port_tag_id_val;
10544 entry.vf_id = res->vf_id;
10545 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10547 ETH_L2_TUNNEL_INSERTION_MASK,
10552 cmd_config_e_tag_insertion_dis_parsed(
10553 void *parsed_result,
10554 __attribute__((unused)) struct cmdline *cl,
10555 __attribute__((unused)) void *data)
10557 struct cmd_config_e_tag_result *res =
10559 struct rte_eth_l2_tunnel_conf entry;
10561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10564 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10565 entry.vf_id = res->vf_id;
10567 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10569 ETH_L2_TUNNEL_INSERTION_MASK,
10573 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10574 .f = cmd_config_e_tag_insertion_en_parsed,
10576 .help_str = "E-tag ... : E-tag insertion enable",
10578 (void *)&cmd_config_e_tag_e_tag,
10579 (void *)&cmd_config_e_tag_set,
10580 (void *)&cmd_config_e_tag_insertion,
10581 (void *)&cmd_config_e_tag_on,
10582 (void *)&cmd_config_e_tag_port_tag_id,
10583 (void *)&cmd_config_e_tag_port_tag_id_val,
10584 (void *)&cmd_config_e_tag_port,
10585 (void *)&cmd_config_e_tag_port_id,
10586 (void *)&cmd_config_e_tag_vf,
10587 (void *)&cmd_config_e_tag_vf_id,
10592 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10593 .f = cmd_config_e_tag_insertion_dis_parsed,
10595 .help_str = "E-tag ... : E-tag insertion disable",
10597 (void *)&cmd_config_e_tag_e_tag,
10598 (void *)&cmd_config_e_tag_set,
10599 (void *)&cmd_config_e_tag_insertion,
10600 (void *)&cmd_config_e_tag_off,
10601 (void *)&cmd_config_e_tag_port,
10602 (void *)&cmd_config_e_tag_port_id,
10603 (void *)&cmd_config_e_tag_vf,
10604 (void *)&cmd_config_e_tag_vf_id,
10609 /* E-tag stripping configuration */
10611 cmd_config_e_tag_stripping_parsed(
10612 void *parsed_result,
10613 __attribute__((unused)) struct cmdline *cl,
10614 __attribute__((unused)) void *data)
10616 struct cmd_config_e_tag_result *res =
10618 struct rte_eth_l2_tunnel_conf entry;
10620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10623 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10625 if (!strcmp(res->on_off, "on"))
10626 rte_eth_dev_l2_tunnel_offload_set
10629 ETH_L2_TUNNEL_STRIPPING_MASK,
10632 rte_eth_dev_l2_tunnel_offload_set
10635 ETH_L2_TUNNEL_STRIPPING_MASK,
10639 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10640 .f = cmd_config_e_tag_stripping_parsed,
10642 .help_str = "E-tag ... : E-tag stripping enable/disable",
10644 (void *)&cmd_config_e_tag_e_tag,
10645 (void *)&cmd_config_e_tag_set,
10646 (void *)&cmd_config_e_tag_stripping,
10647 (void *)&cmd_config_e_tag_on_off,
10648 (void *)&cmd_config_e_tag_port,
10649 (void *)&cmd_config_e_tag_port_id,
10654 /* E-tag forwarding configuration */
10656 cmd_config_e_tag_forwarding_parsed(
10657 void *parsed_result,
10658 __attribute__((unused)) struct cmdline *cl,
10659 __attribute__((unused)) void *data)
10661 struct cmd_config_e_tag_result *res = parsed_result;
10662 struct rte_eth_l2_tunnel_conf entry;
10664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10667 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10669 if (!strcmp(res->on_off, "on"))
10670 rte_eth_dev_l2_tunnel_offload_set
10673 ETH_L2_TUNNEL_FORWARDING_MASK,
10676 rte_eth_dev_l2_tunnel_offload_set
10679 ETH_L2_TUNNEL_FORWARDING_MASK,
10683 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10684 .f = cmd_config_e_tag_forwarding_parsed,
10686 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10688 (void *)&cmd_config_e_tag_e_tag,
10689 (void *)&cmd_config_e_tag_set,
10690 (void *)&cmd_config_e_tag_forwarding,
10691 (void *)&cmd_config_e_tag_on_off,
10692 (void *)&cmd_config_e_tag_port,
10693 (void *)&cmd_config_e_tag_port_id,
10698 /* E-tag filter configuration */
10700 cmd_config_e_tag_filter_add_parsed(
10701 void *parsed_result,
10702 __attribute__((unused)) struct cmdline *cl,
10703 __attribute__((unused)) void *data)
10705 struct cmd_config_e_tag_result *res = parsed_result;
10706 struct rte_eth_l2_tunnel_conf entry;
10709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10712 if (res->e_tag_id_val > 0x3fff) {
10713 printf("e-tag-id must be equal or less than 0x3fff.\n");
10717 ret = rte_eth_dev_filter_supported(res->port_id,
10718 RTE_ETH_FILTER_L2_TUNNEL);
10720 printf("E-tag filter is not supported on port %u.\n",
10725 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10726 entry.tunnel_id = res->e_tag_id_val;
10727 entry.pool = res->dst_pool_val;
10729 ret = rte_eth_dev_filter_ctrl(res->port_id,
10730 RTE_ETH_FILTER_L2_TUNNEL,
10731 RTE_ETH_FILTER_ADD,
10734 printf("E-tag filter programming error: (%s)\n",
10738 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10739 .f = cmd_config_e_tag_filter_add_parsed,
10741 .help_str = "E-tag ... : E-tag filter add",
10743 (void *)&cmd_config_e_tag_e_tag,
10744 (void *)&cmd_config_e_tag_set,
10745 (void *)&cmd_config_e_tag_filter,
10746 (void *)&cmd_config_e_tag_add,
10747 (void *)&cmd_config_e_tag_e_tag_id,
10748 (void *)&cmd_config_e_tag_e_tag_id_val,
10749 (void *)&cmd_config_e_tag_dst_pool,
10750 (void *)&cmd_config_e_tag_dst_pool_val,
10751 (void *)&cmd_config_e_tag_port,
10752 (void *)&cmd_config_e_tag_port_id,
10758 cmd_config_e_tag_filter_del_parsed(
10759 void *parsed_result,
10760 __attribute__((unused)) struct cmdline *cl,
10761 __attribute__((unused)) void *data)
10763 struct cmd_config_e_tag_result *res = parsed_result;
10764 struct rte_eth_l2_tunnel_conf entry;
10767 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10770 if (res->e_tag_id_val > 0x3fff) {
10771 printf("e-tag-id must be less than 0x3fff.\n");
10775 ret = rte_eth_dev_filter_supported(res->port_id,
10776 RTE_ETH_FILTER_L2_TUNNEL);
10778 printf("E-tag filter is not supported on port %u.\n",
10783 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10784 entry.tunnel_id = res->e_tag_id_val;
10786 ret = rte_eth_dev_filter_ctrl(res->port_id,
10787 RTE_ETH_FILTER_L2_TUNNEL,
10788 RTE_ETH_FILTER_DELETE,
10791 printf("E-tag filter programming error: (%s)\n",
10795 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10796 .f = cmd_config_e_tag_filter_del_parsed,
10798 .help_str = "E-tag ... : E-tag filter delete",
10800 (void *)&cmd_config_e_tag_e_tag,
10801 (void *)&cmd_config_e_tag_set,
10802 (void *)&cmd_config_e_tag_filter,
10803 (void *)&cmd_config_e_tag_del,
10804 (void *)&cmd_config_e_tag_e_tag_id,
10805 (void *)&cmd_config_e_tag_e_tag_id_val,
10806 (void *)&cmd_config_e_tag_port,
10807 (void *)&cmd_config_e_tag_port_id,
10811 #ifdef RTE_LIBRTE_IXGBE_PMD
10813 /* vf vlan anti spoof configuration */
10815 /* Common result structure for vf vlan anti spoof */
10816 struct cmd_vf_vlan_anti_spoof_result {
10817 cmdline_fixed_string_t set;
10818 cmdline_fixed_string_t vf;
10819 cmdline_fixed_string_t vlan;
10820 cmdline_fixed_string_t antispoof;
10823 cmdline_fixed_string_t on_off;
10826 /* Common CLI fields for vf vlan anti spoof enable disable */
10827 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10828 TOKEN_STRING_INITIALIZER
10829 (struct cmd_vf_vlan_anti_spoof_result,
10831 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10832 TOKEN_STRING_INITIALIZER
10833 (struct cmd_vf_vlan_anti_spoof_result,
10835 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10836 TOKEN_STRING_INITIALIZER
10837 (struct cmd_vf_vlan_anti_spoof_result,
10839 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10840 TOKEN_STRING_INITIALIZER
10841 (struct cmd_vf_vlan_anti_spoof_result,
10842 antispoof, "antispoof");
10843 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10844 TOKEN_NUM_INITIALIZER
10845 (struct cmd_vf_vlan_anti_spoof_result,
10847 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10848 TOKEN_NUM_INITIALIZER
10849 (struct cmd_vf_vlan_anti_spoof_result,
10851 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10852 TOKEN_STRING_INITIALIZER
10853 (struct cmd_vf_vlan_anti_spoof_result,
10857 cmd_set_vf_vlan_anti_spoof_parsed(
10858 void *parsed_result,
10859 __attribute__((unused)) struct cmdline *cl,
10860 __attribute__((unused)) void *data)
10862 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10864 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10866 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10872 printf("invalid vf_id %d\n", res->vf_id);
10875 printf("invalid port_id %d\n", res->port_id);
10878 printf("programming error: (%s)\n", strerror(-ret));
10882 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10883 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10885 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10887 (void *)&cmd_vf_vlan_anti_spoof_set,
10888 (void *)&cmd_vf_vlan_anti_spoof_vf,
10889 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10890 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10891 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10892 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10893 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10898 /* vf mac anti spoof configuration */
10900 /* Common result structure for vf mac anti spoof */
10901 struct cmd_vf_mac_anti_spoof_result {
10902 cmdline_fixed_string_t set;
10903 cmdline_fixed_string_t vf;
10904 cmdline_fixed_string_t mac;
10905 cmdline_fixed_string_t antispoof;
10908 cmdline_fixed_string_t on_off;
10911 /* Common CLI fields for vf mac anti spoof enable disable */
10912 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10913 TOKEN_STRING_INITIALIZER
10914 (struct cmd_vf_mac_anti_spoof_result,
10916 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10917 TOKEN_STRING_INITIALIZER
10918 (struct cmd_vf_mac_anti_spoof_result,
10920 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10921 TOKEN_STRING_INITIALIZER
10922 (struct cmd_vf_mac_anti_spoof_result,
10924 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10925 TOKEN_STRING_INITIALIZER
10926 (struct cmd_vf_mac_anti_spoof_result,
10927 antispoof, "antispoof");
10928 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10929 TOKEN_NUM_INITIALIZER
10930 (struct cmd_vf_mac_anti_spoof_result,
10932 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10933 TOKEN_NUM_INITIALIZER
10934 (struct cmd_vf_mac_anti_spoof_result,
10936 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10937 TOKEN_STRING_INITIALIZER
10938 (struct cmd_vf_mac_anti_spoof_result,
10942 cmd_set_vf_mac_anti_spoof_parsed(
10943 void *parsed_result,
10944 __attribute__((unused)) struct cmdline *cl,
10945 __attribute__((unused)) void *data)
10947 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10949 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10951 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10957 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10960 printf("invalid port_id %d\n", res->port_id);
10963 printf("programming error: (%s)\n", strerror(-ret));
10967 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10968 .f = cmd_set_vf_mac_anti_spoof_parsed,
10970 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10972 (void *)&cmd_vf_mac_anti_spoof_set,
10973 (void *)&cmd_vf_mac_anti_spoof_vf,
10974 (void *)&cmd_vf_mac_anti_spoof_mac,
10975 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10976 (void *)&cmd_vf_mac_anti_spoof_port_id,
10977 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10978 (void *)&cmd_vf_mac_anti_spoof_on_off,
10983 /* vf vlan strip queue configuration */
10985 /* Common result structure for vf mac anti spoof */
10986 struct cmd_vf_vlan_stripq_result {
10987 cmdline_fixed_string_t set;
10988 cmdline_fixed_string_t vf;
10989 cmdline_fixed_string_t vlan;
10990 cmdline_fixed_string_t stripq;
10993 cmdline_fixed_string_t on_off;
10996 /* Common CLI fields for vf vlan strip enable disable */
10997 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10998 TOKEN_STRING_INITIALIZER
10999 (struct cmd_vf_vlan_stripq_result,
11001 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_vf_vlan_stripq_result,
11005 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11006 TOKEN_STRING_INITIALIZER
11007 (struct cmd_vf_vlan_stripq_result,
11009 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11010 TOKEN_STRING_INITIALIZER
11011 (struct cmd_vf_vlan_stripq_result,
11013 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11014 TOKEN_NUM_INITIALIZER
11015 (struct cmd_vf_vlan_stripq_result,
11017 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11018 TOKEN_NUM_INITIALIZER
11019 (struct cmd_vf_vlan_stripq_result,
11021 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11022 TOKEN_STRING_INITIALIZER
11023 (struct cmd_vf_vlan_stripq_result,
11027 cmd_set_vf_vlan_stripq_parsed(
11028 void *parsed_result,
11029 __attribute__((unused)) struct cmdline *cl,
11030 __attribute__((unused)) void *data)
11032 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11034 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11036 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11041 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11044 printf("invalid port_id %d\n", res->port_id);
11047 printf("programming error: (%s)\n", strerror(-ret));
11051 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11052 .f = cmd_set_vf_vlan_stripq_parsed,
11054 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11056 (void *)&cmd_vf_vlan_stripq_set,
11057 (void *)&cmd_vf_vlan_stripq_vf,
11058 (void *)&cmd_vf_vlan_stripq_vlan,
11059 (void *)&cmd_vf_vlan_stripq_stripq,
11060 (void *)&cmd_vf_vlan_stripq_port_id,
11061 (void *)&cmd_vf_vlan_stripq_vf_id,
11062 (void *)&cmd_vf_vlan_stripq_on_off,
11067 /* vf vlan insert configuration */
11069 /* Common result structure for vf vlan insert */
11070 struct cmd_vf_vlan_insert_result {
11071 cmdline_fixed_string_t set;
11072 cmdline_fixed_string_t vf;
11073 cmdline_fixed_string_t vlan;
11074 cmdline_fixed_string_t insert;
11080 /* Common CLI fields for vf vlan insert enable disable */
11081 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11082 TOKEN_STRING_INITIALIZER
11083 (struct cmd_vf_vlan_insert_result,
11085 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11086 TOKEN_STRING_INITIALIZER
11087 (struct cmd_vf_vlan_insert_result,
11089 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11090 TOKEN_STRING_INITIALIZER
11091 (struct cmd_vf_vlan_insert_result,
11093 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11094 TOKEN_STRING_INITIALIZER
11095 (struct cmd_vf_vlan_insert_result,
11097 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11098 TOKEN_NUM_INITIALIZER
11099 (struct cmd_vf_vlan_insert_result,
11101 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11102 TOKEN_NUM_INITIALIZER
11103 (struct cmd_vf_vlan_insert_result,
11105 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11106 TOKEN_NUM_INITIALIZER
11107 (struct cmd_vf_vlan_insert_result,
11111 cmd_set_vf_vlan_insert_parsed(
11112 void *parsed_result,
11113 __attribute__((unused)) struct cmdline *cl,
11114 __attribute__((unused)) void *data)
11116 struct cmd_vf_vlan_insert_result *res = parsed_result;
11119 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11124 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11127 printf("invalid port_id %d\n", res->port_id);
11130 printf("programming error: (%s)\n", strerror(-ret));
11134 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11135 .f = cmd_set_vf_vlan_insert_parsed,
11137 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11139 (void *)&cmd_vf_vlan_insert_set,
11140 (void *)&cmd_vf_vlan_insert_vf,
11141 (void *)&cmd_vf_vlan_insert_vlan,
11142 (void *)&cmd_vf_vlan_insert_insert,
11143 (void *)&cmd_vf_vlan_insert_port_id,
11144 (void *)&cmd_vf_vlan_insert_vf_id,
11145 (void *)&cmd_vf_vlan_insert_vlan_id,
11150 /* tx loopback configuration */
11152 /* Common result structure for tx loopback */
11153 struct cmd_tx_loopback_result {
11154 cmdline_fixed_string_t set;
11155 cmdline_fixed_string_t tx;
11156 cmdline_fixed_string_t loopback;
11158 cmdline_fixed_string_t on_off;
11161 /* Common CLI fields for tx loopback enable disable */
11162 cmdline_parse_token_string_t cmd_tx_loopback_set =
11163 TOKEN_STRING_INITIALIZER
11164 (struct cmd_tx_loopback_result,
11166 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11167 TOKEN_STRING_INITIALIZER
11168 (struct cmd_tx_loopback_result,
11170 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11171 TOKEN_STRING_INITIALIZER
11172 (struct cmd_tx_loopback_result,
11173 loopback, "loopback");
11174 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11175 TOKEN_NUM_INITIALIZER
11176 (struct cmd_tx_loopback_result,
11178 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11179 TOKEN_STRING_INITIALIZER
11180 (struct cmd_tx_loopback_result,
11184 cmd_set_tx_loopback_parsed(
11185 void *parsed_result,
11186 __attribute__((unused)) struct cmdline *cl,
11187 __attribute__((unused)) void *data)
11189 struct cmd_tx_loopback_result *res = parsed_result;
11191 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11193 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11198 printf("invalid is_on %d\n", is_on);
11201 printf("invalid port_id %d\n", res->port_id);
11204 printf("programming error: (%s)\n", strerror(-ret));
11208 cmdline_parse_inst_t cmd_set_tx_loopback = {
11209 .f = cmd_set_tx_loopback_parsed,
11211 .help_str = "set tx loopback <port_id> on|off",
11213 (void *)&cmd_tx_loopback_set,
11214 (void *)&cmd_tx_loopback_tx,
11215 (void *)&cmd_tx_loopback_loopback,
11216 (void *)&cmd_tx_loopback_port_id,
11217 (void *)&cmd_tx_loopback_on_off,
11222 /* all queues drop enable configuration */
11224 /* Common result structure for all queues drop enable */
11225 struct cmd_all_queues_drop_en_result {
11226 cmdline_fixed_string_t set;
11227 cmdline_fixed_string_t all;
11228 cmdline_fixed_string_t queues;
11229 cmdline_fixed_string_t drop;
11231 cmdline_fixed_string_t on_off;
11234 /* Common CLI fields for tx loopback enable disable */
11235 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11236 TOKEN_STRING_INITIALIZER
11237 (struct cmd_all_queues_drop_en_result,
11239 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11240 TOKEN_STRING_INITIALIZER
11241 (struct cmd_all_queues_drop_en_result,
11243 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11244 TOKEN_STRING_INITIALIZER
11245 (struct cmd_all_queues_drop_en_result,
11247 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_all_queues_drop_en_result,
11251 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11252 TOKEN_NUM_INITIALIZER
11253 (struct cmd_all_queues_drop_en_result,
11255 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11256 TOKEN_STRING_INITIALIZER
11257 (struct cmd_all_queues_drop_en_result,
11261 cmd_set_all_queues_drop_en_parsed(
11262 void *parsed_result,
11263 __attribute__((unused)) struct cmdline *cl,
11264 __attribute__((unused)) void *data)
11266 struct cmd_all_queues_drop_en_result *res = parsed_result;
11268 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11270 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11275 printf("invalid is_on %d\n", is_on);
11278 printf("invalid port_id %d\n", res->port_id);
11281 printf("programming error: (%s)\n", strerror(-ret));
11285 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11286 .f = cmd_set_all_queues_drop_en_parsed,
11288 .help_str = "set all queues drop <port_id> on|off",
11290 (void *)&cmd_all_queues_drop_en_set,
11291 (void *)&cmd_all_queues_drop_en_all,
11292 (void *)&cmd_all_queues_drop_en_queues,
11293 (void *)&cmd_all_queues_drop_en_drop,
11294 (void *)&cmd_all_queues_drop_en_port_id,
11295 (void *)&cmd_all_queues_drop_en_on_off,
11300 /* vf split drop enable configuration */
11302 /* Common result structure for vf split drop enable */
11303 struct cmd_vf_split_drop_en_result {
11304 cmdline_fixed_string_t set;
11305 cmdline_fixed_string_t vf;
11306 cmdline_fixed_string_t split;
11307 cmdline_fixed_string_t drop;
11310 cmdline_fixed_string_t on_off;
11313 /* Common CLI fields for vf split drop enable disable */
11314 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11315 TOKEN_STRING_INITIALIZER
11316 (struct cmd_vf_split_drop_en_result,
11318 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11319 TOKEN_STRING_INITIALIZER
11320 (struct cmd_vf_split_drop_en_result,
11322 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11323 TOKEN_STRING_INITIALIZER
11324 (struct cmd_vf_split_drop_en_result,
11326 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11327 TOKEN_STRING_INITIALIZER
11328 (struct cmd_vf_split_drop_en_result,
11330 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11331 TOKEN_NUM_INITIALIZER
11332 (struct cmd_vf_split_drop_en_result,
11334 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11335 TOKEN_NUM_INITIALIZER
11336 (struct cmd_vf_split_drop_en_result,
11338 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11339 TOKEN_STRING_INITIALIZER
11340 (struct cmd_vf_split_drop_en_result,
11344 cmd_set_vf_split_drop_en_parsed(
11345 void *parsed_result,
11346 __attribute__((unused)) struct cmdline *cl,
11347 __attribute__((unused)) void *data)
11349 struct cmd_vf_split_drop_en_result *res = parsed_result;
11351 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11353 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11359 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11362 printf("invalid port_id %d\n", res->port_id);
11365 printf("programming error: (%s)\n", strerror(-ret));
11369 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11370 .f = cmd_set_vf_split_drop_en_parsed,
11372 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11374 (void *)&cmd_vf_split_drop_en_set,
11375 (void *)&cmd_vf_split_drop_en_vf,
11376 (void *)&cmd_vf_split_drop_en_split,
11377 (void *)&cmd_vf_split_drop_en_drop,
11378 (void *)&cmd_vf_split_drop_en_port_id,
11379 (void *)&cmd_vf_split_drop_en_vf_id,
11380 (void *)&cmd_vf_split_drop_en_on_off,
11385 /* vf mac address configuration */
11387 /* Common result structure for vf mac address */
11388 struct cmd_set_vf_mac_addr_result {
11389 cmdline_fixed_string_t set;
11390 cmdline_fixed_string_t vf;
11391 cmdline_fixed_string_t mac;
11392 cmdline_fixed_string_t addr;
11395 struct ether_addr mac_addr;
11399 /* Common CLI fields for vf split drop enable disable */
11400 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_set_vf_mac_addr_result,
11404 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_set_vf_mac_addr_result,
11408 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11409 TOKEN_STRING_INITIALIZER
11410 (struct cmd_set_vf_mac_addr_result,
11412 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11413 TOKEN_STRING_INITIALIZER
11414 (struct cmd_set_vf_mac_addr_result,
11416 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11417 TOKEN_NUM_INITIALIZER
11418 (struct cmd_set_vf_mac_addr_result,
11420 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11421 TOKEN_NUM_INITIALIZER
11422 (struct cmd_set_vf_mac_addr_result,
11424 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11425 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11429 cmd_set_vf_mac_addr_parsed(
11430 void *parsed_result,
11431 __attribute__((unused)) struct cmdline *cl,
11432 __attribute__((unused)) void *data)
11434 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11437 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11443 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11446 printf("invalid port_id %d\n", res->port_id);
11449 printf("programming error: (%s)\n", strerror(-ret));
11453 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11454 .f = cmd_set_vf_mac_addr_parsed,
11456 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11458 (void *)&cmd_set_vf_mac_addr_set,
11459 (void *)&cmd_set_vf_mac_addr_vf,
11460 (void *)&cmd_set_vf_mac_addr_mac,
11461 (void *)&cmd_set_vf_mac_addr_addr,
11462 (void *)&cmd_set_vf_mac_addr_port_id,
11463 (void *)&cmd_set_vf_mac_addr_vf_id,
11464 (void *)&cmd_set_vf_mac_addr_mac_addr,
11470 /* ******************************************************************************** */
11472 /* list of instructions */
11473 cmdline_parse_ctx_t main_ctx[] = {
11474 (cmdline_parse_inst_t *)&cmd_help_brief,
11475 (cmdline_parse_inst_t *)&cmd_help_long,
11476 (cmdline_parse_inst_t *)&cmd_quit,
11477 (cmdline_parse_inst_t *)&cmd_showport,
11478 (cmdline_parse_inst_t *)&cmd_showqueue,
11479 (cmdline_parse_inst_t *)&cmd_showportall,
11480 (cmdline_parse_inst_t *)&cmd_showcfg,
11481 (cmdline_parse_inst_t *)&cmd_start,
11482 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11483 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11484 (cmdline_parse_inst_t *)&cmd_set_link_up,
11485 (cmdline_parse_inst_t *)&cmd_set_link_down,
11486 (cmdline_parse_inst_t *)&cmd_reset,
11487 (cmdline_parse_inst_t *)&cmd_set_numbers,
11488 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11489 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11490 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11491 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11492 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11493 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11494 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11495 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11496 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11497 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11498 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11499 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11500 (cmdline_parse_inst_t *)&cmd_set_link_check,
11501 #ifdef RTE_NIC_BYPASS
11502 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11503 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11504 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11505 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11507 #ifdef RTE_LIBRTE_PMD_BOND
11508 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11509 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11510 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11511 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11512 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11513 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11514 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11515 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11516 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11518 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11519 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11520 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11521 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11522 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11523 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11524 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11525 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11526 (cmdline_parse_inst_t *)&cmd_csum_set,
11527 (cmdline_parse_inst_t *)&cmd_csum_show,
11528 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11529 (cmdline_parse_inst_t *)&cmd_tso_set,
11530 (cmdline_parse_inst_t *)&cmd_tso_show,
11531 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11532 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11536 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11537 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11538 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11539 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11540 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11541 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11542 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11543 (cmdline_parse_inst_t *)&cmd_config_dcb,
11544 (cmdline_parse_inst_t *)&cmd_read_reg,
11545 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11546 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11547 (cmdline_parse_inst_t *)&cmd_write_reg,
11548 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11549 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11550 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11551 (cmdline_parse_inst_t *)&cmd_stop,
11552 (cmdline_parse_inst_t *)&cmd_mac_addr,
11553 (cmdline_parse_inst_t *)&cmd_set_qmap,
11554 (cmdline_parse_inst_t *)&cmd_operate_port,
11555 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11556 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11557 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11558 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11559 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11560 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11561 (cmdline_parse_inst_t *)&cmd_config_mtu,
11562 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11563 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11564 (cmdline_parse_inst_t *)&cmd_config_rss,
11565 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11566 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11567 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11568 (cmdline_parse_inst_t *)&cmd_showport_reta,
11569 (cmdline_parse_inst_t *)&cmd_config_burst,
11570 (cmdline_parse_inst_t *)&cmd_config_thresh,
11571 (cmdline_parse_inst_t *)&cmd_config_threshold,
11572 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11573 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11574 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11575 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11576 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11577 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11578 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11579 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11580 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11581 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11582 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11583 (cmdline_parse_inst_t *)&cmd_global_config,
11584 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11585 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11586 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11587 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11588 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11589 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11590 (cmdline_parse_inst_t *)&cmd_dump,
11591 (cmdline_parse_inst_t *)&cmd_dump_one,
11592 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11593 (cmdline_parse_inst_t *)&cmd_syn_filter,
11594 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11595 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11596 (cmdline_parse_inst_t *)&cmd_flex_filter,
11597 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11598 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11599 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11600 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11601 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11602 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11603 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11604 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11605 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11606 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11607 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11608 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11609 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11610 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11611 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11612 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11613 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11614 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11615 (cmdline_parse_inst_t *)&cmd_flow,
11616 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11617 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11618 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11619 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11620 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11621 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11622 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11623 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11624 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11625 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11626 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11627 #ifdef RTE_LIBRTE_IXGBE_PMD
11628 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11629 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11630 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11631 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11632 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11633 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11634 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11635 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11640 /* prompt function, called from main on MASTER lcore */
11644 /* initialize non-constant commands */
11645 cmd_set_fwd_mode_init();
11646 cmd_set_fwd_retry_mode_init();
11648 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11649 if (testpmd_cl == NULL)
11651 cmdline_interact(testpmd_cl);
11652 cmdline_stdin_exit(testpmd_cl);
11658 if (testpmd_cl != NULL)
11659 cmdline_quit(testpmd_cl);
11663 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11665 if (id == (portid_t)RTE_PORT_ALL) {
11668 FOREACH_PORT(pid, ports) {
11669 /* check if need_reconfig has been set to 1 */
11670 if (ports[pid].need_reconfig == 0)
11671 ports[pid].need_reconfig = dev;
11672 /* check if need_reconfig_queues has been set to 1 */
11673 if (ports[pid].need_reconfig_queues == 0)
11674 ports[pid].need_reconfig_queues = queue;
11676 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11677 /* check if need_reconfig has been set to 1 */
11678 if (ports[id].need_reconfig == 0)
11679 ports[id].need_reconfig = dev;
11680 /* check if need_reconfig_queues has been set to 1 */
11681 if (ports[id].need_reconfig_queues == 0)
11682 ports[id].need_reconfig_queues = queue;