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 validate {port_id}"
815 " [group {group_id}] [priority {level}]"
816 " [ingress] [egress]"
817 " pattern {item} [/ {item} [...]] / end"
818 " actions {action} [/ {action} [...]] / end\n"
819 " Check whether a flow rule can be created.\n\n"
821 "flow create {port_id}"
822 " [group {group_id}] [priority {level}]"
823 " [ingress] [egress]"
824 " pattern {item} [/ {item} [...]] / end"
825 " actions {action} [/ {action} [...]] / end\n"
826 " Create a flow rule.\n\n"
828 "flow destroy {port_id} rule {rule_id} [...]\n"
829 " Destroy specific flow rules.\n\n"
831 "flow flush {port_id}\n"
832 " Destroy all flow rules.\n\n"
834 "flow query {port_id} {rule_id} {action}\n"
835 " Query an existing flow rule.\n\n"
837 "flow list {port_id} [group {group_id}] [...]\n"
838 " List existing flow rules sorted by priority,"
839 " filtered by group identifiers.\n\n"
844 cmdline_parse_token_string_t cmd_help_long_help =
845 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
847 cmdline_parse_token_string_t cmd_help_long_section =
848 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
849 "all#control#display#config#"
850 "ports#registers#filters");
852 cmdline_parse_inst_t cmd_help_long = {
853 .f = cmd_help_long_parsed,
855 .help_str = "help all|control|display|config|ports|register|filters: "
858 (void *)&cmd_help_long_help,
859 (void *)&cmd_help_long_section,
865 /* *** start/stop/close all ports *** */
866 struct cmd_operate_port_result {
867 cmdline_fixed_string_t keyword;
868 cmdline_fixed_string_t name;
869 cmdline_fixed_string_t value;
872 static void cmd_operate_port_parsed(void *parsed_result,
873 __attribute__((unused)) struct cmdline *cl,
874 __attribute__((unused)) void *data)
876 struct cmd_operate_port_result *res = parsed_result;
878 if (!strcmp(res->name, "start"))
879 start_port(RTE_PORT_ALL);
880 else if (!strcmp(res->name, "stop"))
881 stop_port(RTE_PORT_ALL);
882 else if (!strcmp(res->name, "close"))
883 close_port(RTE_PORT_ALL);
885 printf("Unknown parameter\n");
888 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
889 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
891 cmdline_parse_token_string_t cmd_operate_port_all_port =
892 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
894 cmdline_parse_token_string_t cmd_operate_port_all_all =
895 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
897 cmdline_parse_inst_t cmd_operate_port = {
898 .f = cmd_operate_port_parsed,
900 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
902 (void *)&cmd_operate_port_all_cmd,
903 (void *)&cmd_operate_port_all_port,
904 (void *)&cmd_operate_port_all_all,
909 /* *** start/stop/close specific port *** */
910 struct cmd_operate_specific_port_result {
911 cmdline_fixed_string_t keyword;
912 cmdline_fixed_string_t name;
916 static void cmd_operate_specific_port_parsed(void *parsed_result,
917 __attribute__((unused)) struct cmdline *cl,
918 __attribute__((unused)) void *data)
920 struct cmd_operate_specific_port_result *res = parsed_result;
922 if (!strcmp(res->name, "start"))
923 start_port(res->value);
924 else if (!strcmp(res->name, "stop"))
925 stop_port(res->value);
926 else if (!strcmp(res->name, "close"))
927 close_port(res->value);
929 printf("Unknown parameter\n");
932 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
933 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
935 cmdline_parse_token_string_t cmd_operate_specific_port_port =
936 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
937 name, "start#stop#close");
938 cmdline_parse_token_num_t cmd_operate_specific_port_id =
939 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
942 cmdline_parse_inst_t cmd_operate_specific_port = {
943 .f = cmd_operate_specific_port_parsed,
945 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
947 (void *)&cmd_operate_specific_port_cmd,
948 (void *)&cmd_operate_specific_port_port,
949 (void *)&cmd_operate_specific_port_id,
954 /* *** attach a specified port *** */
955 struct cmd_operate_attach_port_result {
956 cmdline_fixed_string_t port;
957 cmdline_fixed_string_t keyword;
958 cmdline_fixed_string_t identifier;
961 static void cmd_operate_attach_port_parsed(void *parsed_result,
962 __attribute__((unused)) struct cmdline *cl,
963 __attribute__((unused)) void *data)
965 struct cmd_operate_attach_port_result *res = parsed_result;
967 if (!strcmp(res->keyword, "attach"))
968 attach_port(res->identifier);
970 printf("Unknown parameter\n");
973 cmdline_parse_token_string_t cmd_operate_attach_port_port =
974 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
976 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
977 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
979 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
980 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
983 cmdline_parse_inst_t cmd_operate_attach_port = {
984 .f = cmd_operate_attach_port_parsed,
986 .help_str = "port attach <identifier>: "
987 "(identifier: pci address or virtual dev name)",
989 (void *)&cmd_operate_attach_port_port,
990 (void *)&cmd_operate_attach_port_keyword,
991 (void *)&cmd_operate_attach_port_identifier,
996 /* *** detach a specified port *** */
997 struct cmd_operate_detach_port_result {
998 cmdline_fixed_string_t port;
999 cmdline_fixed_string_t keyword;
1003 static void cmd_operate_detach_port_parsed(void *parsed_result,
1004 __attribute__((unused)) struct cmdline *cl,
1005 __attribute__((unused)) void *data)
1007 struct cmd_operate_detach_port_result *res = parsed_result;
1009 if (!strcmp(res->keyword, "detach"))
1010 detach_port(res->port_id);
1012 printf("Unknown parameter\n");
1015 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1016 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1018 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1019 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1021 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1022 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1025 cmdline_parse_inst_t cmd_operate_detach_port = {
1026 .f = cmd_operate_detach_port_parsed,
1028 .help_str = "port detach <port_id>",
1030 (void *)&cmd_operate_detach_port_port,
1031 (void *)&cmd_operate_detach_port_keyword,
1032 (void *)&cmd_operate_detach_port_port_id,
1037 /* *** configure speed for all ports *** */
1038 struct cmd_config_speed_all {
1039 cmdline_fixed_string_t port;
1040 cmdline_fixed_string_t keyword;
1041 cmdline_fixed_string_t all;
1042 cmdline_fixed_string_t item1;
1043 cmdline_fixed_string_t item2;
1044 cmdline_fixed_string_t value1;
1045 cmdline_fixed_string_t value2;
1049 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1054 if (!strcmp(duplexstr, "half")) {
1055 duplex = ETH_LINK_HALF_DUPLEX;
1056 } else if (!strcmp(duplexstr, "full")) {
1057 duplex = ETH_LINK_FULL_DUPLEX;
1058 } else if (!strcmp(duplexstr, "auto")) {
1059 duplex = ETH_LINK_FULL_DUPLEX;
1061 printf("Unknown duplex parameter\n");
1065 if (!strcmp(speedstr, "10")) {
1066 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1067 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1068 } else if (!strcmp(speedstr, "100")) {
1069 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1070 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1072 if (duplex != ETH_LINK_FULL_DUPLEX) {
1073 printf("Invalid speed/duplex parameters\n");
1076 if (!strcmp(speedstr, "1000")) {
1077 *speed = ETH_LINK_SPEED_1G;
1078 } else if (!strcmp(speedstr, "10000")) {
1079 *speed = ETH_LINK_SPEED_10G;
1080 } else if (!strcmp(speedstr, "25000")) {
1081 *speed = ETH_LINK_SPEED_25G;
1082 } else if (!strcmp(speedstr, "40000")) {
1083 *speed = ETH_LINK_SPEED_40G;
1084 } else if (!strcmp(speedstr, "50000")) {
1085 *speed = ETH_LINK_SPEED_50G;
1086 } else if (!strcmp(speedstr, "100000")) {
1087 *speed = ETH_LINK_SPEED_100G;
1088 } else if (!strcmp(speedstr, "auto")) {
1089 *speed = ETH_LINK_SPEED_AUTONEG;
1091 printf("Unknown speed parameter\n");
1100 cmd_config_speed_all_parsed(void *parsed_result,
1101 __attribute__((unused)) struct cmdline *cl,
1102 __attribute__((unused)) void *data)
1104 struct cmd_config_speed_all *res = parsed_result;
1105 uint32_t link_speed;
1108 if (!all_ports_stopped()) {
1109 printf("Please stop all ports first\n");
1113 if (parse_and_check_speed_duplex(res->value1, res->value2,
1117 FOREACH_PORT(pid, ports) {
1118 ports[pid].dev_conf.link_speeds = link_speed;
1121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1124 cmdline_parse_token_string_t cmd_config_speed_all_port =
1125 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1126 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1129 cmdline_parse_token_string_t cmd_config_speed_all_all =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1131 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1132 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1133 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1134 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1135 "10#100#1000#10000#25000#40000#50000#100000#auto");
1136 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1137 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1138 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1142 cmdline_parse_inst_t cmd_config_speed_all = {
1143 .f = cmd_config_speed_all_parsed,
1145 .help_str = "port config all speed "
1146 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1149 (void *)&cmd_config_speed_all_port,
1150 (void *)&cmd_config_speed_all_keyword,
1151 (void *)&cmd_config_speed_all_all,
1152 (void *)&cmd_config_speed_all_item1,
1153 (void *)&cmd_config_speed_all_value1,
1154 (void *)&cmd_config_speed_all_item2,
1155 (void *)&cmd_config_speed_all_value2,
1160 /* *** configure speed for specific port *** */
1161 struct cmd_config_speed_specific {
1162 cmdline_fixed_string_t port;
1163 cmdline_fixed_string_t keyword;
1165 cmdline_fixed_string_t item1;
1166 cmdline_fixed_string_t item2;
1167 cmdline_fixed_string_t value1;
1168 cmdline_fixed_string_t value2;
1172 cmd_config_speed_specific_parsed(void *parsed_result,
1173 __attribute__((unused)) struct cmdline *cl,
1174 __attribute__((unused)) void *data)
1176 struct cmd_config_speed_specific *res = parsed_result;
1177 uint32_t link_speed;
1179 if (!all_ports_stopped()) {
1180 printf("Please stop all ports first\n");
1184 if (port_id_is_invalid(res->id, ENABLED_WARN))
1187 if (parse_and_check_speed_duplex(res->value1, res->value2,
1191 ports[res->id].dev_conf.link_speeds = link_speed;
1193 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1197 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1200 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1201 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1203 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1204 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1205 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1206 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1208 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1209 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1210 "10#100#1000#10000#25000#40000#50000#100000#auto");
1211 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1214 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1215 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1218 cmdline_parse_inst_t cmd_config_speed_specific = {
1219 .f = cmd_config_speed_specific_parsed,
1221 .help_str = "port config <port_id> speed "
1222 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1225 (void *)&cmd_config_speed_specific_port,
1226 (void *)&cmd_config_speed_specific_keyword,
1227 (void *)&cmd_config_speed_specific_id,
1228 (void *)&cmd_config_speed_specific_item1,
1229 (void *)&cmd_config_speed_specific_value1,
1230 (void *)&cmd_config_speed_specific_item2,
1231 (void *)&cmd_config_speed_specific_value2,
1236 /* *** configure txq/rxq, txd/rxd *** */
1237 struct cmd_config_rx_tx {
1238 cmdline_fixed_string_t port;
1239 cmdline_fixed_string_t keyword;
1240 cmdline_fixed_string_t all;
1241 cmdline_fixed_string_t name;
1246 cmd_config_rx_tx_parsed(void *parsed_result,
1247 __attribute__((unused)) struct cmdline *cl,
1248 __attribute__((unused)) void *data)
1250 struct cmd_config_rx_tx *res = parsed_result;
1252 if (!all_ports_stopped()) {
1253 printf("Please stop all ports first\n");
1256 if (!strcmp(res->name, "rxq")) {
1257 if (!res->value && !nb_txq) {
1258 printf("Warning: Either rx or tx queues should be non zero\n");
1261 nb_rxq = res->value;
1263 else if (!strcmp(res->name, "txq")) {
1264 if (!res->value && !nb_rxq) {
1265 printf("Warning: Either rx or tx queues should be non zero\n");
1268 nb_txq = res->value;
1270 else if (!strcmp(res->name, "rxd")) {
1271 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1272 printf("rxd %d invalid - must be > 0 && <= %d\n",
1273 res->value, RTE_TEST_RX_DESC_MAX);
1276 nb_rxd = res->value;
1277 } else if (!strcmp(res->name, "txd")) {
1278 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1279 printf("txd %d invalid - must be > 0 && <= %d\n",
1280 res->value, RTE_TEST_TX_DESC_MAX);
1283 nb_txd = res->value;
1285 printf("Unknown parameter\n");
1293 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1296 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1297 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1298 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1299 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1300 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1302 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1303 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1305 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1306 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1308 cmdline_parse_inst_t cmd_config_rx_tx = {
1309 .f = cmd_config_rx_tx_parsed,
1311 .help_str = "port config all rxq|txq|rxd|txd <value>",
1313 (void *)&cmd_config_rx_tx_port,
1314 (void *)&cmd_config_rx_tx_keyword,
1315 (void *)&cmd_config_rx_tx_all,
1316 (void *)&cmd_config_rx_tx_name,
1317 (void *)&cmd_config_rx_tx_value,
1322 /* *** config max packet length *** */
1323 struct cmd_config_max_pkt_len_result {
1324 cmdline_fixed_string_t port;
1325 cmdline_fixed_string_t keyword;
1326 cmdline_fixed_string_t all;
1327 cmdline_fixed_string_t name;
1332 cmd_config_max_pkt_len_parsed(void *parsed_result,
1333 __attribute__((unused)) struct cmdline *cl,
1334 __attribute__((unused)) void *data)
1336 struct cmd_config_max_pkt_len_result *res = parsed_result;
1338 if (!all_ports_stopped()) {
1339 printf("Please stop all ports first\n");
1343 if (!strcmp(res->name, "max-pkt-len")) {
1344 if (res->value < ETHER_MIN_LEN) {
1345 printf("max-pkt-len can not be less than %d\n",
1349 if (res->value == rx_mode.max_rx_pkt_len)
1352 rx_mode.max_rx_pkt_len = res->value;
1353 if (res->value > ETHER_MAX_LEN)
1354 rx_mode.jumbo_frame = 1;
1356 rx_mode.jumbo_frame = 0;
1358 printf("Unknown parameter\n");
1364 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1367 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1370 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1371 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1373 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1374 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1376 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1377 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1379 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1380 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1383 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1384 .f = cmd_config_max_pkt_len_parsed,
1386 .help_str = "port config all max-pkt-len <value>",
1388 (void *)&cmd_config_max_pkt_len_port,
1389 (void *)&cmd_config_max_pkt_len_keyword,
1390 (void *)&cmd_config_max_pkt_len_all,
1391 (void *)&cmd_config_max_pkt_len_name,
1392 (void *)&cmd_config_max_pkt_len_value,
1397 /* *** configure port MTU *** */
1398 struct cmd_config_mtu_result {
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t keyword;
1401 cmdline_fixed_string_t mtu;
1407 cmd_config_mtu_parsed(void *parsed_result,
1408 __attribute__((unused)) struct cmdline *cl,
1409 __attribute__((unused)) void *data)
1411 struct cmd_config_mtu_result *res = parsed_result;
1413 if (res->value < ETHER_MIN_LEN) {
1414 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1417 port_mtu_set(res->port_id, res->value);
1420 cmdline_parse_token_string_t cmd_config_mtu_port =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1423 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1426 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1427 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1429 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1430 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1431 cmdline_parse_token_num_t cmd_config_mtu_value =
1432 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1434 cmdline_parse_inst_t cmd_config_mtu = {
1435 .f = cmd_config_mtu_parsed,
1437 .help_str = "port config mtu <port_id> <value>",
1439 (void *)&cmd_config_mtu_port,
1440 (void *)&cmd_config_mtu_keyword,
1441 (void *)&cmd_config_mtu_mtu,
1442 (void *)&cmd_config_mtu_port_id,
1443 (void *)&cmd_config_mtu_value,
1448 /* *** configure rx mode *** */
1449 struct cmd_config_rx_mode_flag {
1450 cmdline_fixed_string_t port;
1451 cmdline_fixed_string_t keyword;
1452 cmdline_fixed_string_t all;
1453 cmdline_fixed_string_t name;
1454 cmdline_fixed_string_t value;
1458 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1459 __attribute__((unused)) struct cmdline *cl,
1460 __attribute__((unused)) void *data)
1462 struct cmd_config_rx_mode_flag *res = parsed_result;
1464 if (!all_ports_stopped()) {
1465 printf("Please stop all ports first\n");
1469 if (!strcmp(res->name, "crc-strip")) {
1470 if (!strcmp(res->value, "on"))
1471 rx_mode.hw_strip_crc = 1;
1472 else if (!strcmp(res->value, "off"))
1473 rx_mode.hw_strip_crc = 0;
1475 printf("Unknown parameter\n");
1478 } else if (!strcmp(res->name, "scatter")) {
1479 if (!strcmp(res->value, "on"))
1480 rx_mode.enable_scatter = 1;
1481 else if (!strcmp(res->value, "off"))
1482 rx_mode.enable_scatter = 0;
1484 printf("Unknown parameter\n");
1487 } else if (!strcmp(res->name, "rx-cksum")) {
1488 if (!strcmp(res->value, "on"))
1489 rx_mode.hw_ip_checksum = 1;
1490 else if (!strcmp(res->value, "off"))
1491 rx_mode.hw_ip_checksum = 0;
1493 printf("Unknown parameter\n");
1496 } else if (!strcmp(res->name, "hw-vlan")) {
1497 if (!strcmp(res->value, "on")) {
1498 rx_mode.hw_vlan_filter = 1;
1499 rx_mode.hw_vlan_strip = 1;
1501 else if (!strcmp(res->value, "off")) {
1502 rx_mode.hw_vlan_filter = 0;
1503 rx_mode.hw_vlan_strip = 0;
1506 printf("Unknown parameter\n");
1509 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1510 if (!strcmp(res->value, "on"))
1511 rx_mode.hw_vlan_filter = 1;
1512 else if (!strcmp(res->value, "off"))
1513 rx_mode.hw_vlan_filter = 0;
1515 printf("Unknown parameter\n");
1518 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1519 if (!strcmp(res->value, "on"))
1520 rx_mode.hw_vlan_strip = 1;
1521 else if (!strcmp(res->value, "off"))
1522 rx_mode.hw_vlan_strip = 0;
1524 printf("Unknown parameter\n");
1527 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1528 if (!strcmp(res->value, "on"))
1529 rx_mode.hw_vlan_extend = 1;
1530 else if (!strcmp(res->value, "off"))
1531 rx_mode.hw_vlan_extend = 0;
1533 printf("Unknown parameter\n");
1536 } else if (!strcmp(res->name, "drop-en")) {
1537 if (!strcmp(res->value, "on"))
1539 else if (!strcmp(res->value, "off"))
1542 printf("Unknown parameter\n");
1546 printf("Unknown parameter\n");
1552 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1555 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1557 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1560 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1562 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1564 "crc-strip#scatter#rx-cksum#hw-vlan#"
1565 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1566 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1570 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1571 .f = cmd_config_rx_mode_flag_parsed,
1573 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1574 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1576 (void *)&cmd_config_rx_mode_flag_port,
1577 (void *)&cmd_config_rx_mode_flag_keyword,
1578 (void *)&cmd_config_rx_mode_flag_all,
1579 (void *)&cmd_config_rx_mode_flag_name,
1580 (void *)&cmd_config_rx_mode_flag_value,
1585 /* *** configure rss *** */
1586 struct cmd_config_rss {
1587 cmdline_fixed_string_t port;
1588 cmdline_fixed_string_t keyword;
1589 cmdline_fixed_string_t all;
1590 cmdline_fixed_string_t name;
1591 cmdline_fixed_string_t value;
1595 cmd_config_rss_parsed(void *parsed_result,
1596 __attribute__((unused)) struct cmdline *cl,
1597 __attribute__((unused)) void *data)
1599 struct cmd_config_rss *res = parsed_result;
1600 struct rte_eth_rss_conf rss_conf;
1604 if (!strcmp(res->value, "all"))
1605 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1606 ETH_RSS_UDP | ETH_RSS_SCTP |
1608 else if (!strcmp(res->value, "ip"))
1609 rss_conf.rss_hf = ETH_RSS_IP;
1610 else if (!strcmp(res->value, "udp"))
1611 rss_conf.rss_hf = ETH_RSS_UDP;
1612 else if (!strcmp(res->value, "tcp"))
1613 rss_conf.rss_hf = ETH_RSS_TCP;
1614 else if (!strcmp(res->value, "sctp"))
1615 rss_conf.rss_hf = ETH_RSS_SCTP;
1616 else if (!strcmp(res->value, "ether"))
1617 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1618 else if (!strcmp(res->value, "port"))
1619 rss_conf.rss_hf = ETH_RSS_PORT;
1620 else if (!strcmp(res->value, "vxlan"))
1621 rss_conf.rss_hf = ETH_RSS_VXLAN;
1622 else if (!strcmp(res->value, "geneve"))
1623 rss_conf.rss_hf = ETH_RSS_GENEVE;
1624 else if (!strcmp(res->value, "nvgre"))
1625 rss_conf.rss_hf = ETH_RSS_NVGRE;
1626 else if (!strcmp(res->value, "none"))
1627 rss_conf.rss_hf = 0;
1629 printf("Unknown parameter\n");
1632 rss_conf.rss_key = NULL;
1633 for (i = 0; i < rte_eth_dev_count(); i++) {
1634 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1636 printf("Configuration of RSS hash at ethernet port %d "
1637 "failed with error (%d): %s.\n",
1638 i, -diag, strerror(-diag));
1642 cmdline_parse_token_string_t cmd_config_rss_port =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1644 cmdline_parse_token_string_t cmd_config_rss_keyword =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1646 cmdline_parse_token_string_t cmd_config_rss_all =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1648 cmdline_parse_token_string_t cmd_config_rss_name =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1650 cmdline_parse_token_string_t cmd_config_rss_value =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1652 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1654 cmdline_parse_inst_t cmd_config_rss = {
1655 .f = cmd_config_rss_parsed,
1657 .help_str = "port config all rss "
1658 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1660 (void *)&cmd_config_rss_port,
1661 (void *)&cmd_config_rss_keyword,
1662 (void *)&cmd_config_rss_all,
1663 (void *)&cmd_config_rss_name,
1664 (void *)&cmd_config_rss_value,
1669 /* *** configure rss hash key *** */
1670 struct cmd_config_rss_hash_key {
1671 cmdline_fixed_string_t port;
1672 cmdline_fixed_string_t config;
1674 cmdline_fixed_string_t rss_hash_key;
1675 cmdline_fixed_string_t rss_type;
1676 cmdline_fixed_string_t key;
1680 hexa_digit_to_value(char hexa_digit)
1682 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1683 return (uint8_t) (hexa_digit - '0');
1684 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1685 return (uint8_t) ((hexa_digit - 'a') + 10);
1686 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1687 return (uint8_t) ((hexa_digit - 'A') + 10);
1688 /* Invalid hexa digit */
1693 parse_and_check_key_hexa_digit(char *key, int idx)
1697 hexa_v = hexa_digit_to_value(key[idx]);
1699 printf("invalid key: character %c at position %d is not a "
1700 "valid hexa digit\n", key[idx], idx);
1705 cmd_config_rss_hash_key_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_config_rss_hash_key *res = parsed_result;
1710 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1714 struct rte_eth_dev_info dev_info;
1715 uint8_t hash_key_size;
1718 memset(&dev_info, 0, sizeof(dev_info));
1719 rte_eth_dev_info_get(res->port_id, &dev_info);
1720 if (dev_info.hash_key_size > 0 &&
1721 dev_info.hash_key_size <= sizeof(hash_key))
1722 hash_key_size = dev_info.hash_key_size;
1724 printf("dev_info did not provide a valid hash key size\n");
1727 /* Check the length of the RSS hash key */
1728 key_len = strlen(res->key);
1729 if (key_len != (hash_key_size * 2)) {
1730 printf("key length: %d invalid - key must be a string of %d"
1731 " hexa-decimal numbers\n",
1732 (int) key_len, hash_key_size * 2);
1735 /* Translate RSS hash key into binary representation */
1736 for (i = 0; i < hash_key_size; i++) {
1737 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1740 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1743 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1745 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1749 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1750 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1751 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1752 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1754 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1755 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1756 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1758 rss_hash_key, "rss-hash-key");
1759 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1761 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1762 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1763 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1764 "ipv6-tcp-ex#ipv6-udp-ex");
1765 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1768 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1769 .f = cmd_config_rss_hash_key_parsed,
1771 .help_str = "port config <port_id> rss-hash-key "
1772 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1773 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1774 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1775 "<string of hex digits (variable length, NIC dependent)>",
1777 (void *)&cmd_config_rss_hash_key_port,
1778 (void *)&cmd_config_rss_hash_key_config,
1779 (void *)&cmd_config_rss_hash_key_port_id,
1780 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1781 (void *)&cmd_config_rss_hash_key_rss_type,
1782 (void *)&cmd_config_rss_hash_key_value,
1787 /* *** configure port rxq/txq start/stop *** */
1788 struct cmd_config_rxtx_queue {
1789 cmdline_fixed_string_t port;
1791 cmdline_fixed_string_t rxtxq;
1793 cmdline_fixed_string_t opname;
1797 cmd_config_rxtx_queue_parsed(void *parsed_result,
1798 __attribute__((unused)) struct cmdline *cl,
1799 __attribute__((unused)) void *data)
1801 struct cmd_config_rxtx_queue *res = parsed_result;
1806 if (test_done == 0) {
1807 printf("Please stop forwarding first\n");
1811 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1814 if (port_is_started(res->portid) != 1) {
1815 printf("Please start port %u first\n", res->portid);
1819 if (!strcmp(res->rxtxq, "rxq"))
1821 else if (!strcmp(res->rxtxq, "txq"))
1824 printf("Unknown parameter\n");
1828 if (isrx && rx_queue_id_is_invalid(res->qid))
1830 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1833 if (!strcmp(res->opname, "start"))
1835 else if (!strcmp(res->opname, "stop"))
1838 printf("Unknown parameter\n");
1842 if (isstart && isrx)
1843 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1844 else if (!isstart && isrx)
1845 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1846 else if (isstart && !isrx)
1847 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1849 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1851 if (ret == -ENOTSUP)
1852 printf("Function not supported in PMD driver\n");
1855 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1857 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1858 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1859 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1861 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1862 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1863 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1867 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1868 .f = cmd_config_rxtx_queue_parsed,
1870 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1872 (void *)&cmd_config_speed_all_port,
1873 (void *)&cmd_config_rxtx_queue_portid,
1874 (void *)&cmd_config_rxtx_queue_rxtxq,
1875 (void *)&cmd_config_rxtx_queue_qid,
1876 (void *)&cmd_config_rxtx_queue_opname,
1881 /* *** Configure RSS RETA *** */
1882 struct cmd_config_rss_reta {
1883 cmdline_fixed_string_t port;
1884 cmdline_fixed_string_t keyword;
1886 cmdline_fixed_string_t name;
1887 cmdline_fixed_string_t list_name;
1888 cmdline_fixed_string_t list_of_items;
1892 parse_reta_config(const char *str,
1893 struct rte_eth_rss_reta_entry64 *reta_conf,
1894 uint16_t nb_entries)
1898 uint16_t hash_index, idx, shift;
1901 const char *p, *p0 = str;
1908 unsigned long int_fld[_NUM_FLD];
1909 char *str_fld[_NUM_FLD];
1911 while ((p = strchr(p0,'(')) != NULL) {
1913 if((p0 = strchr(p,')')) == NULL)
1917 if(size >= sizeof(s))
1920 snprintf(s, sizeof(s), "%.*s", size, p);
1921 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1923 for (i = 0; i < _NUM_FLD; i++) {
1925 int_fld[i] = strtoul(str_fld[i], &end, 0);
1926 if (errno != 0 || end == str_fld[i] ||
1931 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1932 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1934 if (hash_index >= nb_entries) {
1935 printf("Invalid RETA hash index=%d\n", hash_index);
1939 idx = hash_index / RTE_RETA_GROUP_SIZE;
1940 shift = hash_index % RTE_RETA_GROUP_SIZE;
1941 reta_conf[idx].mask |= (1ULL << shift);
1942 reta_conf[idx].reta[shift] = nb_queue;
1949 cmd_set_rss_reta_parsed(void *parsed_result,
1950 __attribute__((unused)) struct cmdline *cl,
1951 __attribute__((unused)) void *data)
1954 struct rte_eth_dev_info dev_info;
1955 struct rte_eth_rss_reta_entry64 reta_conf[8];
1956 struct cmd_config_rss_reta *res = parsed_result;
1958 memset(&dev_info, 0, sizeof(dev_info));
1959 rte_eth_dev_info_get(res->port_id, &dev_info);
1960 if (dev_info.reta_size == 0) {
1961 printf("Redirection table size is 0 which is "
1962 "invalid for RSS\n");
1965 printf("The reta size of port %d is %u\n",
1966 res->port_id, dev_info.reta_size);
1967 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1968 printf("Currently do not support more than %u entries of "
1969 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1973 memset(reta_conf, 0, sizeof(reta_conf));
1974 if (!strcmp(res->list_name, "reta")) {
1975 if (parse_reta_config(res->list_of_items, reta_conf,
1976 dev_info.reta_size)) {
1977 printf("Invalid RSS Redirection Table "
1978 "config entered\n");
1981 ret = rte_eth_dev_rss_reta_update(res->port_id,
1982 reta_conf, dev_info.reta_size);
1984 printf("Bad redirection table parameter, "
1985 "return code = %d \n", ret);
1989 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1991 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1992 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1993 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1994 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1995 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1997 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1999 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2002 cmdline_parse_inst_t cmd_config_rss_reta = {
2003 .f = cmd_set_rss_reta_parsed,
2005 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2007 (void *)&cmd_config_rss_reta_port,
2008 (void *)&cmd_config_rss_reta_keyword,
2009 (void *)&cmd_config_rss_reta_port_id,
2010 (void *)&cmd_config_rss_reta_name,
2011 (void *)&cmd_config_rss_reta_list_name,
2012 (void *)&cmd_config_rss_reta_list_of_items,
2017 /* *** SHOW PORT RETA INFO *** */
2018 struct cmd_showport_reta {
2019 cmdline_fixed_string_t show;
2020 cmdline_fixed_string_t port;
2022 cmdline_fixed_string_t rss;
2023 cmdline_fixed_string_t reta;
2025 cmdline_fixed_string_t list_of_items;
2029 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2030 uint16_t nb_entries,
2034 const char *p, *p0 = str;
2038 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2041 p = strchr(p0, '(');
2045 p0 = strchr(p, ')');
2049 if (size >= sizeof(s)) {
2050 printf("The string size exceeds the internal buffer size\n");
2053 snprintf(s, sizeof(s), "%.*s", size, p);
2054 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2055 if (ret <= 0 || ret != num) {
2056 printf("The bits of masks do not match the number of "
2057 "reta entries: %u\n", num);
2060 for (i = 0; i < ret; i++)
2061 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2067 cmd_showport_reta_parsed(void *parsed_result,
2068 __attribute__((unused)) struct cmdline *cl,
2069 __attribute__((unused)) void *data)
2071 struct cmd_showport_reta *res = parsed_result;
2072 struct rte_eth_rss_reta_entry64 reta_conf[8];
2073 struct rte_eth_dev_info dev_info;
2075 memset(&dev_info, 0, sizeof(dev_info));
2076 rte_eth_dev_info_get(res->port_id, &dev_info);
2077 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2078 res->size > ETH_RSS_RETA_SIZE_512) {
2079 printf("Invalid redirection table size: %u\n", res->size);
2083 memset(reta_conf, 0, sizeof(reta_conf));
2084 if (showport_parse_reta_config(reta_conf, res->size,
2085 res->list_of_items) < 0) {
2086 printf("Invalid string: %s for reta masks\n",
2087 res->list_of_items);
2090 port_rss_reta_info(res->port_id, reta_conf, res->size);
2093 cmdline_parse_token_string_t cmd_showport_reta_show =
2094 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2095 cmdline_parse_token_string_t cmd_showport_reta_port =
2096 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2097 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2098 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2099 cmdline_parse_token_string_t cmd_showport_reta_rss =
2100 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2101 cmdline_parse_token_string_t cmd_showport_reta_reta =
2102 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2103 cmdline_parse_token_num_t cmd_showport_reta_size =
2104 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2105 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2106 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2107 list_of_items, NULL);
2109 cmdline_parse_inst_t cmd_showport_reta = {
2110 .f = cmd_showport_reta_parsed,
2112 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2114 (void *)&cmd_showport_reta_show,
2115 (void *)&cmd_showport_reta_port,
2116 (void *)&cmd_showport_reta_port_id,
2117 (void *)&cmd_showport_reta_rss,
2118 (void *)&cmd_showport_reta_reta,
2119 (void *)&cmd_showport_reta_size,
2120 (void *)&cmd_showport_reta_list_of_items,
2125 /* *** Show RSS hash configuration *** */
2126 struct cmd_showport_rss_hash {
2127 cmdline_fixed_string_t show;
2128 cmdline_fixed_string_t port;
2130 cmdline_fixed_string_t rss_hash;
2131 cmdline_fixed_string_t rss_type;
2132 cmdline_fixed_string_t key; /* optional argument */
2135 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2136 __attribute__((unused)) struct cmdline *cl,
2139 struct cmd_showport_rss_hash *res = parsed_result;
2141 port_rss_hash_conf_show(res->port_id, res->rss_type,
2142 show_rss_key != NULL);
2145 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2146 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2147 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2148 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2149 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2150 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2151 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2152 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2154 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2155 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2156 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2157 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2158 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2159 "ipv6-tcp-ex#ipv6-udp-ex");
2160 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2161 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2163 cmdline_parse_inst_t cmd_showport_rss_hash = {
2164 .f = cmd_showport_rss_hash_parsed,
2166 .help_str = "show port <port_id> rss-hash "
2167 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2168 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2169 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2171 (void *)&cmd_showport_rss_hash_show,
2172 (void *)&cmd_showport_rss_hash_port,
2173 (void *)&cmd_showport_rss_hash_port_id,
2174 (void *)&cmd_showport_rss_hash_rss_hash,
2175 (void *)&cmd_showport_rss_hash_rss_hash_info,
2180 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2181 .f = cmd_showport_rss_hash_parsed,
2183 .help_str = "show port <port_id> rss-hash "
2184 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2185 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2186 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2188 (void *)&cmd_showport_rss_hash_show,
2189 (void *)&cmd_showport_rss_hash_port,
2190 (void *)&cmd_showport_rss_hash_port_id,
2191 (void *)&cmd_showport_rss_hash_rss_hash,
2192 (void *)&cmd_showport_rss_hash_rss_hash_info,
2193 (void *)&cmd_showport_rss_hash_rss_key,
2198 /* *** Configure DCB *** */
2199 struct cmd_config_dcb {
2200 cmdline_fixed_string_t port;
2201 cmdline_fixed_string_t config;
2203 cmdline_fixed_string_t dcb;
2204 cmdline_fixed_string_t vt;
2205 cmdline_fixed_string_t vt_en;
2207 cmdline_fixed_string_t pfc;
2208 cmdline_fixed_string_t pfc_en;
2212 cmd_config_dcb_parsed(void *parsed_result,
2213 __attribute__((unused)) struct cmdline *cl,
2214 __attribute__((unused)) void *data)
2216 struct cmd_config_dcb *res = parsed_result;
2217 portid_t port_id = res->port_id;
2218 struct rte_port *port;
2222 port = &ports[port_id];
2223 /** Check if the port is not started **/
2224 if (port->port_status != RTE_PORT_STOPPED) {
2225 printf("Please stop port %d first\n", port_id);
2229 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2230 printf("The invalid number of traffic class,"
2231 " only 4 or 8 allowed.\n");
2235 if (nb_fwd_lcores < res->num_tcs) {
2236 printf("nb_cores shouldn't be less than number of TCs.\n");
2239 if (!strncmp(res->pfc_en, "on", 2))
2244 /* DCB in VT mode */
2245 if (!strncmp(res->vt_en, "on", 2))
2246 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2247 (enum rte_eth_nb_tcs)res->num_tcs,
2250 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2251 (enum rte_eth_nb_tcs)res->num_tcs,
2256 printf("Cannot initialize network ports.\n");
2260 cmd_reconfig_device_queue(port_id, 1, 1);
2263 cmdline_parse_token_string_t cmd_config_dcb_port =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2265 cmdline_parse_token_string_t cmd_config_dcb_config =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2267 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2268 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2269 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2270 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2271 cmdline_parse_token_string_t cmd_config_dcb_vt =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2273 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2275 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2276 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2277 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2279 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2282 cmdline_parse_inst_t cmd_config_dcb = {
2283 .f = cmd_config_dcb_parsed,
2285 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2287 (void *)&cmd_config_dcb_port,
2288 (void *)&cmd_config_dcb_config,
2289 (void *)&cmd_config_dcb_port_id,
2290 (void *)&cmd_config_dcb_dcb,
2291 (void *)&cmd_config_dcb_vt,
2292 (void *)&cmd_config_dcb_vt_en,
2293 (void *)&cmd_config_dcb_num_tcs,
2294 (void *)&cmd_config_dcb_pfc,
2295 (void *)&cmd_config_dcb_pfc_en,
2300 /* *** configure number of packets per burst *** */
2301 struct cmd_config_burst {
2302 cmdline_fixed_string_t port;
2303 cmdline_fixed_string_t keyword;
2304 cmdline_fixed_string_t all;
2305 cmdline_fixed_string_t name;
2310 cmd_config_burst_parsed(void *parsed_result,
2311 __attribute__((unused)) struct cmdline *cl,
2312 __attribute__((unused)) void *data)
2314 struct cmd_config_burst *res = parsed_result;
2316 if (!all_ports_stopped()) {
2317 printf("Please stop all ports first\n");
2321 if (!strcmp(res->name, "burst")) {
2322 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2323 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2326 nb_pkt_per_burst = res->value;
2328 printf("Unknown parameter\n");
2334 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2337 cmdline_parse_token_string_t cmd_config_burst_port =
2338 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2339 cmdline_parse_token_string_t cmd_config_burst_keyword =
2340 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2341 cmdline_parse_token_string_t cmd_config_burst_all =
2342 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2343 cmdline_parse_token_string_t cmd_config_burst_name =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2345 cmdline_parse_token_num_t cmd_config_burst_value =
2346 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2348 cmdline_parse_inst_t cmd_config_burst = {
2349 .f = cmd_config_burst_parsed,
2351 .help_str = "port config all burst <value>",
2353 (void *)&cmd_config_burst_port,
2354 (void *)&cmd_config_burst_keyword,
2355 (void *)&cmd_config_burst_all,
2356 (void *)&cmd_config_burst_name,
2357 (void *)&cmd_config_burst_value,
2362 /* *** configure rx/tx queues *** */
2363 struct cmd_config_thresh {
2364 cmdline_fixed_string_t port;
2365 cmdline_fixed_string_t keyword;
2366 cmdline_fixed_string_t all;
2367 cmdline_fixed_string_t name;
2372 cmd_config_thresh_parsed(void *parsed_result,
2373 __attribute__((unused)) struct cmdline *cl,
2374 __attribute__((unused)) void *data)
2376 struct cmd_config_thresh *res = parsed_result;
2378 if (!all_ports_stopped()) {
2379 printf("Please stop all ports first\n");
2383 if (!strcmp(res->name, "txpt"))
2384 tx_pthresh = res->value;
2385 else if(!strcmp(res->name, "txht"))
2386 tx_hthresh = res->value;
2387 else if(!strcmp(res->name, "txwt"))
2388 tx_wthresh = res->value;
2389 else if(!strcmp(res->name, "rxpt"))
2390 rx_pthresh = res->value;
2391 else if(!strcmp(res->name, "rxht"))
2392 rx_hthresh = res->value;
2393 else if(!strcmp(res->name, "rxwt"))
2394 rx_wthresh = res->value;
2396 printf("Unknown parameter\n");
2402 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2405 cmdline_parse_token_string_t cmd_config_thresh_port =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2407 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2408 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2409 cmdline_parse_token_string_t cmd_config_thresh_all =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2411 cmdline_parse_token_string_t cmd_config_thresh_name =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2413 "txpt#txht#txwt#rxpt#rxht#rxwt");
2414 cmdline_parse_token_num_t cmd_config_thresh_value =
2415 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2417 cmdline_parse_inst_t cmd_config_thresh = {
2418 .f = cmd_config_thresh_parsed,
2420 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2422 (void *)&cmd_config_thresh_port,
2423 (void *)&cmd_config_thresh_keyword,
2424 (void *)&cmd_config_thresh_all,
2425 (void *)&cmd_config_thresh_name,
2426 (void *)&cmd_config_thresh_value,
2431 /* *** configure free/rs threshold *** */
2432 struct cmd_config_threshold {
2433 cmdline_fixed_string_t port;
2434 cmdline_fixed_string_t keyword;
2435 cmdline_fixed_string_t all;
2436 cmdline_fixed_string_t name;
2441 cmd_config_threshold_parsed(void *parsed_result,
2442 __attribute__((unused)) struct cmdline *cl,
2443 __attribute__((unused)) void *data)
2445 struct cmd_config_threshold *res = parsed_result;
2447 if (!all_ports_stopped()) {
2448 printf("Please stop all ports first\n");
2452 if (!strcmp(res->name, "txfreet"))
2453 tx_free_thresh = res->value;
2454 else if (!strcmp(res->name, "txrst"))
2455 tx_rs_thresh = res->value;
2456 else if (!strcmp(res->name, "rxfreet"))
2457 rx_free_thresh = res->value;
2459 printf("Unknown parameter\n");
2465 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2468 cmdline_parse_token_string_t cmd_config_threshold_port =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2470 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2471 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2473 cmdline_parse_token_string_t cmd_config_threshold_all =
2474 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2475 cmdline_parse_token_string_t cmd_config_threshold_name =
2476 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2477 "txfreet#txrst#rxfreet");
2478 cmdline_parse_token_num_t cmd_config_threshold_value =
2479 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2481 cmdline_parse_inst_t cmd_config_threshold = {
2482 .f = cmd_config_threshold_parsed,
2484 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2486 (void *)&cmd_config_threshold_port,
2487 (void *)&cmd_config_threshold_keyword,
2488 (void *)&cmd_config_threshold_all,
2489 (void *)&cmd_config_threshold_name,
2490 (void *)&cmd_config_threshold_value,
2496 struct cmd_stop_result {
2497 cmdline_fixed_string_t stop;
2500 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2501 __attribute__((unused)) struct cmdline *cl,
2502 __attribute__((unused)) void *data)
2504 stop_packet_forwarding();
2507 cmdline_parse_token_string_t cmd_stop_stop =
2508 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2510 cmdline_parse_inst_t cmd_stop = {
2511 .f = cmd_stop_parsed,
2513 .help_str = "stop: Stop packet forwarding",
2515 (void *)&cmd_stop_stop,
2520 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2523 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2524 unsigned int *parsed_items, int check_unique_values)
2526 unsigned int nb_item;
2534 * First parse all items in the list and store their value.
2539 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2541 if ((c >= '0') && (c <= '9')) {
2542 value = (unsigned int) (value * 10 + (c - '0'));
2547 printf("character %c is not a decimal digit\n", c);
2551 printf("No valid value before comma\n");
2554 if (nb_item < max_items) {
2555 parsed_items[nb_item] = value;
2561 if (nb_item >= max_items) {
2562 printf("Number of %s = %u > %u (maximum items)\n",
2563 item_name, nb_item + 1, max_items);
2566 parsed_items[nb_item++] = value;
2567 if (! check_unique_values)
2571 * Then, check that all values in the list are differents.
2572 * No optimization here...
2574 for (i = 0; i < nb_item; i++) {
2575 for (j = i + 1; j < nb_item; j++) {
2576 if (parsed_items[j] == parsed_items[i]) {
2577 printf("duplicated %s %u at index %u and %u\n",
2578 item_name, parsed_items[i], i, j);
2586 struct cmd_set_list_result {
2587 cmdline_fixed_string_t cmd_keyword;
2588 cmdline_fixed_string_t list_name;
2589 cmdline_fixed_string_t list_of_items;
2592 static void cmd_set_list_parsed(void *parsed_result,
2593 __attribute__((unused)) struct cmdline *cl,
2594 __attribute__((unused)) void *data)
2596 struct cmd_set_list_result *res;
2598 unsigned int lcorelist[RTE_MAX_LCORE];
2599 unsigned int portlist[RTE_MAX_ETHPORTS];
2601 unsigned int nb_item;
2603 if (test_done == 0) {
2604 printf("Please stop forwarding first\n");
2608 res = parsed_result;
2609 if (!strcmp(res->list_name, "corelist")) {
2610 nb_item = parse_item_list(res->list_of_items, "core",
2612 parsed_items.lcorelist, 1);
2614 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2619 if (!strcmp(res->list_name, "portlist")) {
2620 nb_item = parse_item_list(res->list_of_items, "port",
2622 parsed_items.portlist, 1);
2624 set_fwd_ports_list(parsed_items.portlist, nb_item);
2630 cmdline_parse_token_string_t cmd_set_list_keyword =
2631 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2633 cmdline_parse_token_string_t cmd_set_list_name =
2634 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2635 "corelist#portlist");
2636 cmdline_parse_token_string_t cmd_set_list_of_items =
2637 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2640 cmdline_parse_inst_t cmd_set_fwd_list = {
2641 .f = cmd_set_list_parsed,
2643 .help_str = "set corelist|portlist <list0[,list1]*>",
2645 (void *)&cmd_set_list_keyword,
2646 (void *)&cmd_set_list_name,
2647 (void *)&cmd_set_list_of_items,
2652 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2654 struct cmd_setmask_result {
2655 cmdline_fixed_string_t set;
2656 cmdline_fixed_string_t mask;
2660 static void cmd_set_mask_parsed(void *parsed_result,
2661 __attribute__((unused)) struct cmdline *cl,
2662 __attribute__((unused)) void *data)
2664 struct cmd_setmask_result *res = parsed_result;
2666 if (test_done == 0) {
2667 printf("Please stop forwarding first\n");
2670 if (!strcmp(res->mask, "coremask")) {
2671 set_fwd_lcores_mask(res->hexavalue);
2673 } else if (!strcmp(res->mask, "portmask")) {
2674 set_fwd_ports_mask(res->hexavalue);
2679 cmdline_parse_token_string_t cmd_setmask_set =
2680 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2681 cmdline_parse_token_string_t cmd_setmask_mask =
2682 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2683 "coremask#portmask");
2684 cmdline_parse_token_num_t cmd_setmask_value =
2685 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2687 cmdline_parse_inst_t cmd_set_fwd_mask = {
2688 .f = cmd_set_mask_parsed,
2690 .help_str = "set coremask|portmask <hexadecimal value>",
2692 (void *)&cmd_setmask_set,
2693 (void *)&cmd_setmask_mask,
2694 (void *)&cmd_setmask_value,
2700 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2702 struct cmd_set_result {
2703 cmdline_fixed_string_t set;
2704 cmdline_fixed_string_t what;
2708 static void cmd_set_parsed(void *parsed_result,
2709 __attribute__((unused)) struct cmdline *cl,
2710 __attribute__((unused)) void *data)
2712 struct cmd_set_result *res = parsed_result;
2713 if (!strcmp(res->what, "nbport")) {
2714 set_fwd_ports_number(res->value);
2716 } else if (!strcmp(res->what, "nbcore")) {
2717 set_fwd_lcores_number(res->value);
2719 } else if (!strcmp(res->what, "burst"))
2720 set_nb_pkt_per_burst(res->value);
2721 else if (!strcmp(res->what, "verbose"))
2722 set_verbose_level(res->value);
2725 cmdline_parse_token_string_t cmd_set_set =
2726 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2727 cmdline_parse_token_string_t cmd_set_what =
2728 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2729 "nbport#nbcore#burst#verbose");
2730 cmdline_parse_token_num_t cmd_set_value =
2731 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2733 cmdline_parse_inst_t cmd_set_numbers = {
2734 .f = cmd_set_parsed,
2736 .help_str = "set nbport|nbcore|burst|verbose <value>",
2738 (void *)&cmd_set_set,
2739 (void *)&cmd_set_what,
2740 (void *)&cmd_set_value,
2745 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2747 struct cmd_set_txpkts_result {
2748 cmdline_fixed_string_t cmd_keyword;
2749 cmdline_fixed_string_t txpkts;
2750 cmdline_fixed_string_t seg_lengths;
2754 cmd_set_txpkts_parsed(void *parsed_result,
2755 __attribute__((unused)) struct cmdline *cl,
2756 __attribute__((unused)) void *data)
2758 struct cmd_set_txpkts_result *res;
2759 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2760 unsigned int nb_segs;
2762 res = parsed_result;
2763 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2764 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2766 set_tx_pkt_segments(seg_lengths, nb_segs);
2769 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2770 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2771 cmd_keyword, "set");
2772 cmdline_parse_token_string_t cmd_set_txpkts_name =
2773 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2775 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2776 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2779 cmdline_parse_inst_t cmd_set_txpkts = {
2780 .f = cmd_set_txpkts_parsed,
2782 .help_str = "set txpkts <len0[,len1]*>",
2784 (void *)&cmd_set_txpkts_keyword,
2785 (void *)&cmd_set_txpkts_name,
2786 (void *)&cmd_set_txpkts_lengths,
2791 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2793 struct cmd_set_txsplit_result {
2794 cmdline_fixed_string_t cmd_keyword;
2795 cmdline_fixed_string_t txsplit;
2796 cmdline_fixed_string_t mode;
2800 cmd_set_txsplit_parsed(void *parsed_result,
2801 __attribute__((unused)) struct cmdline *cl,
2802 __attribute__((unused)) void *data)
2804 struct cmd_set_txsplit_result *res;
2806 res = parsed_result;
2807 set_tx_pkt_split(res->mode);
2810 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2811 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2812 cmd_keyword, "set");
2813 cmdline_parse_token_string_t cmd_set_txsplit_name =
2814 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2815 txsplit, "txsplit");
2816 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2817 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2820 cmdline_parse_inst_t cmd_set_txsplit = {
2821 .f = cmd_set_txsplit_parsed,
2823 .help_str = "set txsplit on|off|rand",
2825 (void *)&cmd_set_txsplit_keyword,
2826 (void *)&cmd_set_txsplit_name,
2827 (void *)&cmd_set_txsplit_mode,
2832 /* *** CONFIG TX QUEUE FLAGS *** */
2834 struct cmd_config_txqflags_result {
2835 cmdline_fixed_string_t port;
2836 cmdline_fixed_string_t config;
2837 cmdline_fixed_string_t all;
2838 cmdline_fixed_string_t what;
2842 static void cmd_config_txqflags_parsed(void *parsed_result,
2843 __attribute__((unused)) struct cmdline *cl,
2844 __attribute__((unused)) void *data)
2846 struct cmd_config_txqflags_result *res = parsed_result;
2848 if (!all_ports_stopped()) {
2849 printf("Please stop all ports first\n");
2853 if (strcmp(res->what, "txqflags")) {
2854 printf("Unknown parameter\n");
2858 if (res->hexvalue >= 0) {
2859 txq_flags = res->hexvalue;
2861 printf("txqflags must be >= 0\n");
2867 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2870 cmdline_parse_token_string_t cmd_config_txqflags_port =
2871 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2873 cmdline_parse_token_string_t cmd_config_txqflags_config =
2874 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2876 cmdline_parse_token_string_t cmd_config_txqflags_all =
2877 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2879 cmdline_parse_token_string_t cmd_config_txqflags_what =
2880 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2882 cmdline_parse_token_num_t cmd_config_txqflags_value =
2883 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2886 cmdline_parse_inst_t cmd_config_txqflags = {
2887 .f = cmd_config_txqflags_parsed,
2889 .help_str = "port config all txqflags <value>",
2891 (void *)&cmd_config_txqflags_port,
2892 (void *)&cmd_config_txqflags_config,
2893 (void *)&cmd_config_txqflags_all,
2894 (void *)&cmd_config_txqflags_what,
2895 (void *)&cmd_config_txqflags_value,
2900 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2901 struct cmd_rx_vlan_filter_all_result {
2902 cmdline_fixed_string_t rx_vlan;
2903 cmdline_fixed_string_t what;
2904 cmdline_fixed_string_t all;
2909 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2910 __attribute__((unused)) struct cmdline *cl,
2911 __attribute__((unused)) void *data)
2913 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2915 if (!strcmp(res->what, "add"))
2916 rx_vlan_all_filter_set(res->port_id, 1);
2918 rx_vlan_all_filter_set(res->port_id, 0);
2921 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2922 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2923 rx_vlan, "rx_vlan");
2924 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2925 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2927 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2928 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2930 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2931 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2934 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2935 .f = cmd_rx_vlan_filter_all_parsed,
2937 .help_str = "rx_vlan add|rm all <port_id>: "
2938 "Add/Remove all identifiers to/from the set of VLAN "
2939 "identifiers filtered by a port",
2941 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2942 (void *)&cmd_rx_vlan_filter_all_what,
2943 (void *)&cmd_rx_vlan_filter_all_all,
2944 (void *)&cmd_rx_vlan_filter_all_portid,
2949 /* *** VLAN OFFLOAD SET ON A PORT *** */
2950 struct cmd_vlan_offload_result {
2951 cmdline_fixed_string_t vlan;
2952 cmdline_fixed_string_t set;
2953 cmdline_fixed_string_t vlan_type;
2954 cmdline_fixed_string_t what;
2955 cmdline_fixed_string_t on;
2956 cmdline_fixed_string_t port_id;
2960 cmd_vlan_offload_parsed(void *parsed_result,
2961 __attribute__((unused)) struct cmdline *cl,
2962 __attribute__((unused)) void *data)
2965 struct cmd_vlan_offload_result *res = parsed_result;
2968 portid_t port_id = 0;
2972 len = strnlen(str, STR_TOKEN_SIZE);
2974 /* Get port_id first */
2982 tmp = strtoul(str, NULL, 0);
2983 /* If port_id greater that what portid_t can represent, return */
2984 if(tmp >= RTE_MAX_ETHPORTS)
2986 port_id = (portid_t)tmp;
2988 if (!strcmp(res->on, "on"))
2993 if (!strcmp(res->what, "strip"))
2994 rx_vlan_strip_set(port_id, on);
2995 else if(!strcmp(res->what, "stripq")){
2996 uint16_t queue_id = 0;
2998 /* No queue_id, return */
3000 printf("must specify (port,queue_id)\n");
3003 tmp = strtoul(str + i + 1, NULL, 0);
3004 /* If queue_id greater that what 16-bits can represent, return */
3008 queue_id = (uint16_t)tmp;
3009 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3011 else if (!strcmp(res->what, "filter"))
3012 rx_vlan_filter_set(port_id, on);
3014 vlan_extend_set(port_id, on);
3019 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3020 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3022 cmdline_parse_token_string_t cmd_vlan_offload_set =
3023 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3025 cmdline_parse_token_string_t cmd_vlan_offload_what =
3026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3027 what, "strip#filter#qinq#stripq");
3028 cmdline_parse_token_string_t cmd_vlan_offload_on =
3029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3031 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3032 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3035 cmdline_parse_inst_t cmd_vlan_offload = {
3036 .f = cmd_vlan_offload_parsed,
3038 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3039 "<port_id[,queue_id]>: "
3040 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3042 (void *)&cmd_vlan_offload_vlan,
3043 (void *)&cmd_vlan_offload_set,
3044 (void *)&cmd_vlan_offload_what,
3045 (void *)&cmd_vlan_offload_on,
3046 (void *)&cmd_vlan_offload_portid,
3051 /* *** VLAN TPID SET ON A PORT *** */
3052 struct cmd_vlan_tpid_result {
3053 cmdline_fixed_string_t vlan;
3054 cmdline_fixed_string_t set;
3055 cmdline_fixed_string_t vlan_type;
3056 cmdline_fixed_string_t what;
3062 cmd_vlan_tpid_parsed(void *parsed_result,
3063 __attribute__((unused)) struct cmdline *cl,
3064 __attribute__((unused)) void *data)
3066 struct cmd_vlan_tpid_result *res = parsed_result;
3067 enum rte_vlan_type vlan_type;
3069 if (!strcmp(res->vlan_type, "inner"))
3070 vlan_type = ETH_VLAN_TYPE_INNER;
3071 else if (!strcmp(res->vlan_type, "outer"))
3072 vlan_type = ETH_VLAN_TYPE_OUTER;
3074 printf("Unknown vlan type\n");
3077 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3080 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3081 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3083 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3084 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3086 cmdline_parse_token_string_t cmd_vlan_type =
3087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3088 vlan_type, "inner#outer");
3089 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3090 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3092 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3093 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3095 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3096 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3099 cmdline_parse_inst_t cmd_vlan_tpid = {
3100 .f = cmd_vlan_tpid_parsed,
3102 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3103 "Set the VLAN Ether type",
3105 (void *)&cmd_vlan_tpid_vlan,
3106 (void *)&cmd_vlan_tpid_set,
3107 (void *)&cmd_vlan_type,
3108 (void *)&cmd_vlan_tpid_what,
3109 (void *)&cmd_vlan_tpid_tpid,
3110 (void *)&cmd_vlan_tpid_portid,
3115 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3116 struct cmd_rx_vlan_filter_result {
3117 cmdline_fixed_string_t rx_vlan;
3118 cmdline_fixed_string_t what;
3124 cmd_rx_vlan_filter_parsed(void *parsed_result,
3125 __attribute__((unused)) struct cmdline *cl,
3126 __attribute__((unused)) void *data)
3128 struct cmd_rx_vlan_filter_result *res = parsed_result;
3130 if (!strcmp(res->what, "add"))
3131 rx_vft_set(res->port_id, res->vlan_id, 1);
3133 rx_vft_set(res->port_id, res->vlan_id, 0);
3136 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3138 rx_vlan, "rx_vlan");
3139 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3142 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3145 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3146 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3149 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3150 .f = cmd_rx_vlan_filter_parsed,
3152 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3153 "Add/Remove a VLAN identifier to/from the set of VLAN "
3154 "identifiers filtered by a port",
3156 (void *)&cmd_rx_vlan_filter_rx_vlan,
3157 (void *)&cmd_rx_vlan_filter_what,
3158 (void *)&cmd_rx_vlan_filter_vlanid,
3159 (void *)&cmd_rx_vlan_filter_portid,
3164 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3165 struct cmd_tx_vlan_set_result {
3166 cmdline_fixed_string_t tx_vlan;
3167 cmdline_fixed_string_t set;
3173 cmd_tx_vlan_set_parsed(void *parsed_result,
3174 __attribute__((unused)) struct cmdline *cl,
3175 __attribute__((unused)) void *data)
3177 struct cmd_tx_vlan_set_result *res = parsed_result;
3179 tx_vlan_set(res->port_id, res->vlan_id);
3182 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3183 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3184 tx_vlan, "tx_vlan");
3185 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3186 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3188 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3189 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3191 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3192 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3195 cmdline_parse_inst_t cmd_tx_vlan_set = {
3196 .f = cmd_tx_vlan_set_parsed,
3198 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3199 "Enable hardware insertion of a single VLAN header "
3200 "with a given TAG Identifier in packets sent on a port",
3202 (void *)&cmd_tx_vlan_set_tx_vlan,
3203 (void *)&cmd_tx_vlan_set_set,
3204 (void *)&cmd_tx_vlan_set_portid,
3205 (void *)&cmd_tx_vlan_set_vlanid,
3210 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3211 struct cmd_tx_vlan_set_qinq_result {
3212 cmdline_fixed_string_t tx_vlan;
3213 cmdline_fixed_string_t set;
3216 uint16_t vlan_id_outer;
3220 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3221 __attribute__((unused)) struct cmdline *cl,
3222 __attribute__((unused)) void *data)
3224 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3226 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3229 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3231 tx_vlan, "tx_vlan");
3232 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3233 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3235 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3236 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3238 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3239 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3241 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3242 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3243 vlan_id_outer, UINT16);
3245 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3246 .f = cmd_tx_vlan_set_qinq_parsed,
3248 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3249 "Enable hardware insertion of double VLAN header "
3250 "with given TAG Identifiers in packets sent on a port",
3252 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3253 (void *)&cmd_tx_vlan_set_qinq_set,
3254 (void *)&cmd_tx_vlan_set_qinq_portid,
3255 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3256 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3261 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3262 struct cmd_tx_vlan_set_pvid_result {
3263 cmdline_fixed_string_t tx_vlan;
3264 cmdline_fixed_string_t set;
3265 cmdline_fixed_string_t pvid;
3268 cmdline_fixed_string_t mode;
3272 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3273 __attribute__((unused)) struct cmdline *cl,
3274 __attribute__((unused)) void *data)
3276 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3278 if (strcmp(res->mode, "on") == 0)
3279 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3281 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3284 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3285 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3286 tx_vlan, "tx_vlan");
3287 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3288 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3290 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3291 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3293 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3294 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3296 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3297 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3299 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3300 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3303 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3304 .f = cmd_tx_vlan_set_pvid_parsed,
3306 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3308 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3309 (void *)&cmd_tx_vlan_set_pvid_set,
3310 (void *)&cmd_tx_vlan_set_pvid_pvid,
3311 (void *)&cmd_tx_vlan_set_pvid_port_id,
3312 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3313 (void *)&cmd_tx_vlan_set_pvid_mode,
3318 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3319 struct cmd_tx_vlan_reset_result {
3320 cmdline_fixed_string_t tx_vlan;
3321 cmdline_fixed_string_t reset;
3326 cmd_tx_vlan_reset_parsed(void *parsed_result,
3327 __attribute__((unused)) struct cmdline *cl,
3328 __attribute__((unused)) void *data)
3330 struct cmd_tx_vlan_reset_result *res = parsed_result;
3332 tx_vlan_reset(res->port_id);
3335 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3337 tx_vlan, "tx_vlan");
3338 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3341 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3342 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3345 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3346 .f = cmd_tx_vlan_reset_parsed,
3348 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3349 "VLAN header in packets sent on a port",
3351 (void *)&cmd_tx_vlan_reset_tx_vlan,
3352 (void *)&cmd_tx_vlan_reset_reset,
3353 (void *)&cmd_tx_vlan_reset_portid,
3359 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3360 struct cmd_csum_result {
3361 cmdline_fixed_string_t csum;
3362 cmdline_fixed_string_t mode;
3363 cmdline_fixed_string_t proto;
3364 cmdline_fixed_string_t hwsw;
3369 csum_show(int port_id)
3371 struct rte_eth_dev_info dev_info;
3374 ol_flags = ports[port_id].tx_ol_flags;
3375 printf("Parse tunnel is %s\n",
3376 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3377 printf("IP checksum offload is %s\n",
3378 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3379 printf("UDP checksum offload is %s\n",
3380 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3381 printf("TCP checksum offload is %s\n",
3382 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3383 printf("SCTP checksum offload is %s\n",
3384 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3385 printf("Outer-Ip checksum offload is %s\n",
3386 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3388 /* display warnings if configuration is not supported by the NIC */
3389 rte_eth_dev_info_get(port_id, &dev_info);
3390 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3391 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3392 printf("Warning: hardware IP checksum enabled but not "
3393 "supported by port %d\n", port_id);
3395 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3396 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3397 printf("Warning: hardware UDP checksum enabled but not "
3398 "supported by port %d\n", port_id);
3400 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3401 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3402 printf("Warning: hardware TCP checksum enabled but not "
3403 "supported by port %d\n", port_id);
3405 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3406 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3407 printf("Warning: hardware SCTP checksum enabled but not "
3408 "supported by port %d\n", port_id);
3410 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3411 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3412 printf("Warning: hardware outer IP checksum enabled but not "
3413 "supported by port %d\n", port_id);
3418 cmd_csum_parsed(void *parsed_result,
3419 __attribute__((unused)) struct cmdline *cl,
3420 __attribute__((unused)) void *data)
3422 struct cmd_csum_result *res = parsed_result;
3426 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3427 printf("invalid port %d\n", res->port_id);
3431 if (!strcmp(res->mode, "set")) {
3433 if (!strcmp(res->hwsw, "hw"))
3436 if (!strcmp(res->proto, "ip")) {
3437 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3438 } else if (!strcmp(res->proto, "udp")) {
3439 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3440 } else if (!strcmp(res->proto, "tcp")) {
3441 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3442 } else if (!strcmp(res->proto, "sctp")) {
3443 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3444 } else if (!strcmp(res->proto, "outer-ip")) {
3445 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3449 ports[res->port_id].tx_ol_flags |= mask;
3451 ports[res->port_id].tx_ol_flags &= (~mask);
3453 csum_show(res->port_id);
3456 cmdline_parse_token_string_t cmd_csum_csum =
3457 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3459 cmdline_parse_token_string_t cmd_csum_mode =
3460 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3462 cmdline_parse_token_string_t cmd_csum_proto =
3463 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3464 proto, "ip#tcp#udp#sctp#outer-ip");
3465 cmdline_parse_token_string_t cmd_csum_hwsw =
3466 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3468 cmdline_parse_token_num_t cmd_csum_portid =
3469 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3472 cmdline_parse_inst_t cmd_csum_set = {
3473 .f = cmd_csum_parsed,
3475 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3476 "Enable/Disable hardware calculation of L3/L4 checksum when "
3477 "using csum forward engine",
3479 (void *)&cmd_csum_csum,
3480 (void *)&cmd_csum_mode,
3481 (void *)&cmd_csum_proto,
3482 (void *)&cmd_csum_hwsw,
3483 (void *)&cmd_csum_portid,
3488 cmdline_parse_token_string_t cmd_csum_mode_show =
3489 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3492 cmdline_parse_inst_t cmd_csum_show = {
3493 .f = cmd_csum_parsed,
3495 .help_str = "csum show <port_id>: Show checksum offload configuration",
3497 (void *)&cmd_csum_csum,
3498 (void *)&cmd_csum_mode_show,
3499 (void *)&cmd_csum_portid,
3504 /* Enable/disable tunnel parsing */
3505 struct cmd_csum_tunnel_result {
3506 cmdline_fixed_string_t csum;
3507 cmdline_fixed_string_t parse;
3508 cmdline_fixed_string_t onoff;
3513 cmd_csum_tunnel_parsed(void *parsed_result,
3514 __attribute__((unused)) struct cmdline *cl,
3515 __attribute__((unused)) void *data)
3517 struct cmd_csum_tunnel_result *res = parsed_result;
3519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3522 if (!strcmp(res->onoff, "on"))
3523 ports[res->port_id].tx_ol_flags |=
3524 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3526 ports[res->port_id].tx_ol_flags &=
3527 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3529 csum_show(res->port_id);
3532 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3533 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3535 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3536 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3537 parse, "parse_tunnel");
3538 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3539 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3541 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3542 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3545 cmdline_parse_inst_t cmd_csum_tunnel = {
3546 .f = cmd_csum_tunnel_parsed,
3548 .help_str = "csum parse_tunnel on|off <port_id>: "
3549 "Enable/Disable parsing of tunnels for csum engine",
3551 (void *)&cmd_csum_tunnel_csum,
3552 (void *)&cmd_csum_tunnel_parse,
3553 (void *)&cmd_csum_tunnel_onoff,
3554 (void *)&cmd_csum_tunnel_portid,
3559 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3560 struct cmd_tso_set_result {
3561 cmdline_fixed_string_t tso;
3562 cmdline_fixed_string_t mode;
3568 cmd_tso_set_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_tso_set_result *res = parsed_result;
3573 struct rte_eth_dev_info dev_info;
3575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3578 if (!strcmp(res->mode, "set"))
3579 ports[res->port_id].tso_segsz = res->tso_segsz;
3581 if (ports[res->port_id].tso_segsz == 0)
3582 printf("TSO for non-tunneled packets is disabled\n");
3584 printf("TSO segment size for non-tunneled packets is %d\n",
3585 ports[res->port_id].tso_segsz);
3587 /* display warnings if configuration is not supported by the NIC */
3588 rte_eth_dev_info_get(res->port_id, &dev_info);
3589 if ((ports[res->port_id].tso_segsz != 0) &&
3590 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3591 printf("Warning: TSO enabled but not "
3592 "supported by port %d\n", res->port_id);
3596 cmdline_parse_token_string_t cmd_tso_set_tso =
3597 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3599 cmdline_parse_token_string_t cmd_tso_set_mode =
3600 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3602 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3603 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3605 cmdline_parse_token_num_t cmd_tso_set_portid =
3606 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3609 cmdline_parse_inst_t cmd_tso_set = {
3610 .f = cmd_tso_set_parsed,
3612 .help_str = "tso set <tso_segsz> <port_id>: "
3613 "Set TSO segment size of non-tunneled packets for csum engine "
3616 (void *)&cmd_tso_set_tso,
3617 (void *)&cmd_tso_set_mode,
3618 (void *)&cmd_tso_set_tso_segsz,
3619 (void *)&cmd_tso_set_portid,
3624 cmdline_parse_token_string_t cmd_tso_show_mode =
3625 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3629 cmdline_parse_inst_t cmd_tso_show = {
3630 .f = cmd_tso_set_parsed,
3632 .help_str = "tso show <port_id>: "
3633 "Show TSO segment size of non-tunneled packets for csum engine",
3635 (void *)&cmd_tso_set_tso,
3636 (void *)&cmd_tso_show_mode,
3637 (void *)&cmd_tso_set_portid,
3642 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3643 struct cmd_tunnel_tso_set_result {
3644 cmdline_fixed_string_t tso;
3645 cmdline_fixed_string_t mode;
3651 check_tunnel_tso_nic_support(uint8_t port_id)
3653 struct rte_eth_dev_info dev_info;
3655 rte_eth_dev_info_get(port_id, &dev_info);
3656 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3657 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3658 "supported by port %d\n", port_id);
3659 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3660 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3661 "supported by port %d\n", port_id);
3662 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3663 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3664 "supported by port %d\n", port_id);
3665 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3666 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3667 "supported by port %d\n", port_id);
3671 cmd_tunnel_tso_set_parsed(void *parsed_result,
3672 __attribute__((unused)) struct cmdline *cl,
3673 __attribute__((unused)) void *data)
3675 struct cmd_tunnel_tso_set_result *res = parsed_result;
3677 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3680 if (!strcmp(res->mode, "set"))
3681 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3683 if (ports[res->port_id].tunnel_tso_segsz == 0)
3684 printf("TSO for tunneled packets is disabled\n");
3686 printf("TSO segment size for tunneled packets is %d\n",
3687 ports[res->port_id].tunnel_tso_segsz);
3689 /* Below conditions are needed to make it work:
3690 * (1) tunnel TSO is supported by the NIC;
3691 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3693 * (3) for tunneled pkts with outer L3 of IPv4,
3694 * "csum set outer-ip" must be set to hw, because after tso,
3695 * total_len of outer IP header is changed, and the checksum
3696 * of outer IP header calculated by sw should be wrong; that
3697 * is not necessary for IPv6 tunneled pkts because there's no
3698 * checksum in IP header anymore.
3700 check_tunnel_tso_nic_support(res->port_id);
3702 if (!(ports[res->port_id].tx_ol_flags &
3703 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3704 printf("Warning: csum parse_tunnel must be set "
3705 "so that tunneled packets are recognized\n");
3706 if (!(ports[res->port_id].tx_ol_flags &
3707 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3708 printf("Warning: csum set outer-ip must be set to hw "
3709 "if outer L3 is IPv4; not necessary for IPv6\n");
3713 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3714 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3716 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3717 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3719 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3720 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3722 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3723 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3726 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3727 .f = cmd_tunnel_tso_set_parsed,
3729 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3730 "Set TSO segment size of tunneled packets for csum engine "
3733 (void *)&cmd_tunnel_tso_set_tso,
3734 (void *)&cmd_tunnel_tso_set_mode,
3735 (void *)&cmd_tunnel_tso_set_tso_segsz,
3736 (void *)&cmd_tunnel_tso_set_portid,
3741 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3742 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3746 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3747 .f = cmd_tunnel_tso_set_parsed,
3749 .help_str = "tunnel_tso show <port_id> "
3750 "Show TSO segment size of tunneled packets for csum engine",
3752 (void *)&cmd_tunnel_tso_set_tso,
3753 (void *)&cmd_tunnel_tso_show_mode,
3754 (void *)&cmd_tunnel_tso_set_portid,
3759 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3760 struct cmd_set_flush_rx {
3761 cmdline_fixed_string_t set;
3762 cmdline_fixed_string_t flush_rx;
3763 cmdline_fixed_string_t mode;
3767 cmd_set_flush_rx_parsed(void *parsed_result,
3768 __attribute__((unused)) struct cmdline *cl,
3769 __attribute__((unused)) void *data)
3771 struct cmd_set_flush_rx *res = parsed_result;
3772 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3775 cmdline_parse_token_string_t cmd_setflushrx_set =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3778 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3780 flush_rx, "flush_rx");
3781 cmdline_parse_token_string_t cmd_setflushrx_mode =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3786 cmdline_parse_inst_t cmd_set_flush_rx = {
3787 .f = cmd_set_flush_rx_parsed,
3788 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3791 (void *)&cmd_setflushrx_set,
3792 (void *)&cmd_setflushrx_flush_rx,
3793 (void *)&cmd_setflushrx_mode,
3798 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3799 struct cmd_set_link_check {
3800 cmdline_fixed_string_t set;
3801 cmdline_fixed_string_t link_check;
3802 cmdline_fixed_string_t mode;
3806 cmd_set_link_check_parsed(void *parsed_result,
3807 __attribute__((unused)) struct cmdline *cl,
3808 __attribute__((unused)) void *data)
3810 struct cmd_set_link_check *res = parsed_result;
3811 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3814 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3815 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3817 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3818 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3819 link_check, "link_check");
3820 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3821 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3825 cmdline_parse_inst_t cmd_set_link_check = {
3826 .f = cmd_set_link_check_parsed,
3827 .help_str = "set link_check on|off: Enable/Disable link status check "
3828 "when starting/stopping a port",
3831 (void *)&cmd_setlinkcheck_set,
3832 (void *)&cmd_setlinkcheck_link_check,
3833 (void *)&cmd_setlinkcheck_mode,
3838 #ifdef RTE_NIC_BYPASS
3839 /* *** SET NIC BYPASS MODE *** */
3840 struct cmd_set_bypass_mode_result {
3841 cmdline_fixed_string_t set;
3842 cmdline_fixed_string_t bypass;
3843 cmdline_fixed_string_t mode;
3844 cmdline_fixed_string_t value;
3849 cmd_set_bypass_mode_parsed(void *parsed_result,
3850 __attribute__((unused)) struct cmdline *cl,
3851 __attribute__((unused)) void *data)
3853 struct cmd_set_bypass_mode_result *res = parsed_result;
3854 portid_t port_id = res->port_id;
3855 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3857 if (!strcmp(res->value, "bypass"))
3858 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3859 else if (!strcmp(res->value, "isolate"))
3860 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3862 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3864 /* Set the bypass mode for the relevant port. */
3865 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3866 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3870 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3873 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3876 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3879 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3881 value, "normal#bypass#isolate");
3882 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3883 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3886 cmdline_parse_inst_t cmd_set_bypass_mode = {
3887 .f = cmd_set_bypass_mode_parsed,
3888 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3889 "Set the NIC bypass mode for port_id",
3892 (void *)&cmd_setbypass_mode_set,
3893 (void *)&cmd_setbypass_mode_bypass,
3894 (void *)&cmd_setbypass_mode_mode,
3895 (void *)&cmd_setbypass_mode_value,
3896 (void *)&cmd_setbypass_mode_port,
3901 /* *** SET NIC BYPASS EVENT *** */
3902 struct cmd_set_bypass_event_result {
3903 cmdline_fixed_string_t set;
3904 cmdline_fixed_string_t bypass;
3905 cmdline_fixed_string_t event;
3906 cmdline_fixed_string_t event_value;
3907 cmdline_fixed_string_t mode;
3908 cmdline_fixed_string_t mode_value;
3913 cmd_set_bypass_event_parsed(void *parsed_result,
3914 __attribute__((unused)) struct cmdline *cl,
3915 __attribute__((unused)) void *data)
3918 struct cmd_set_bypass_event_result *res = parsed_result;
3919 portid_t port_id = res->port_id;
3920 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3921 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3923 if (!strcmp(res->event_value, "timeout"))
3924 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3925 else if (!strcmp(res->event_value, "os_on"))
3926 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3927 else if (!strcmp(res->event_value, "os_off"))
3928 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3929 else if (!strcmp(res->event_value, "power_on"))
3930 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3931 else if (!strcmp(res->event_value, "power_off"))
3932 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3934 bypass_event = RTE_BYPASS_EVENT_NONE;
3936 if (!strcmp(res->mode_value, "bypass"))
3937 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3938 else if (!strcmp(res->mode_value, "isolate"))
3939 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3941 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3943 /* Set the watchdog timeout. */
3944 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3947 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3948 (rc = rte_eth_dev_wd_timeout_store(port_id,
3949 bypass_timeout)) != 0) {
3950 printf("Failed to set timeout value %u "
3951 "for port %d, errto code: %d.\n",
3952 bypass_timeout, port_id, rc);
3956 /* Set the bypass event to transition to bypass mode. */
3957 if (0 != rte_eth_dev_bypass_event_store(port_id,
3958 bypass_event, bypass_mode)) {
3959 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3964 cmdline_parse_token_string_t cmd_setbypass_event_set =
3965 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3967 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3970 cmdline_parse_token_string_t cmd_setbypass_event_event =
3971 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3973 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3975 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3976 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3977 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3979 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3980 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3981 mode_value, "normal#bypass#isolate");
3982 cmdline_parse_token_num_t cmd_setbypass_event_port =
3983 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3986 cmdline_parse_inst_t cmd_set_bypass_event = {
3987 .f = cmd_set_bypass_event_parsed,
3988 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
3989 "power_off mode normal|bypass|isolate <port_id>: "
3990 "Set the NIC bypass event mode for port_id",
3993 (void *)&cmd_setbypass_event_set,
3994 (void *)&cmd_setbypass_event_bypass,
3995 (void *)&cmd_setbypass_event_event,
3996 (void *)&cmd_setbypass_event_event_value,
3997 (void *)&cmd_setbypass_event_mode,
3998 (void *)&cmd_setbypass_event_mode_value,
3999 (void *)&cmd_setbypass_event_port,
4005 /* *** SET NIC BYPASS TIMEOUT *** */
4006 struct cmd_set_bypass_timeout_result {
4007 cmdline_fixed_string_t set;
4008 cmdline_fixed_string_t bypass;
4009 cmdline_fixed_string_t timeout;
4010 cmdline_fixed_string_t value;
4014 cmd_set_bypass_timeout_parsed(void *parsed_result,
4015 __attribute__((unused)) struct cmdline *cl,
4016 __attribute__((unused)) void *data)
4018 struct cmd_set_bypass_timeout_result *res = parsed_result;
4020 if (!strcmp(res->value, "1.5"))
4021 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4022 else if (!strcmp(res->value, "2"))
4023 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4024 else if (!strcmp(res->value, "3"))
4025 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4026 else if (!strcmp(res->value, "4"))
4027 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4028 else if (!strcmp(res->value, "8"))
4029 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4030 else if (!strcmp(res->value, "16"))
4031 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4032 else if (!strcmp(res->value, "32"))
4033 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4035 bypass_timeout = RTE_BYPASS_TMT_OFF;
4038 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4039 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4041 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4042 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4044 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4046 timeout, "timeout");
4047 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4049 value, "0#1.5#2#3#4#8#16#32");
4051 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4052 .f = cmd_set_bypass_timeout_parsed,
4053 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4054 "Set the NIC bypass watchdog timeout in seconds",
4057 (void *)&cmd_setbypass_timeout_set,
4058 (void *)&cmd_setbypass_timeout_bypass,
4059 (void *)&cmd_setbypass_timeout_timeout,
4060 (void *)&cmd_setbypass_timeout_value,
4065 /* *** SHOW NIC BYPASS MODE *** */
4066 struct cmd_show_bypass_config_result {
4067 cmdline_fixed_string_t show;
4068 cmdline_fixed_string_t bypass;
4069 cmdline_fixed_string_t config;
4074 cmd_show_bypass_config_parsed(void *parsed_result,
4075 __attribute__((unused)) struct cmdline *cl,
4076 __attribute__((unused)) void *data)
4078 struct cmd_show_bypass_config_result *res = parsed_result;
4079 uint32_t event_mode;
4080 uint32_t bypass_mode;
4081 portid_t port_id = res->port_id;
4082 uint32_t timeout = bypass_timeout;
4085 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4086 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4087 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4088 {"UNKNOWN", "normal", "bypass", "isolate"};
4089 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4096 int num_events = (sizeof events) / (sizeof events[0]);
4098 /* Display the bypass mode.*/
4099 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4100 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4104 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4105 bypass_mode = RTE_BYPASS_MODE_NONE;
4107 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4110 /* Display the bypass timeout.*/
4111 if (!RTE_BYPASS_TMT_VALID(timeout))
4112 timeout = RTE_BYPASS_TMT_OFF;
4114 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4116 /* Display the bypass events and associated modes. */
4117 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4119 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4120 printf("\tFailed to get bypass mode for event = %s\n",
4123 if (!RTE_BYPASS_MODE_VALID(event_mode))
4124 event_mode = RTE_BYPASS_MODE_NONE;
4126 printf("\tbypass event: %-16s = %s\n", events[i],
4132 cmdline_parse_token_string_t cmd_showbypass_config_show =
4133 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4135 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4136 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4138 cmdline_parse_token_string_t cmd_showbypass_config_config =
4139 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4141 cmdline_parse_token_num_t cmd_showbypass_config_port =
4142 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4145 cmdline_parse_inst_t cmd_show_bypass_config = {
4146 .f = cmd_show_bypass_config_parsed,
4147 .help_str = "show bypass config <port_id>: "
4148 "Show the NIC bypass config for port_id",
4151 (void *)&cmd_showbypass_config_show,
4152 (void *)&cmd_showbypass_config_bypass,
4153 (void *)&cmd_showbypass_config_config,
4154 (void *)&cmd_showbypass_config_port,
4160 #ifdef RTE_LIBRTE_PMD_BOND
4161 /* *** SET BONDING MODE *** */
4162 struct cmd_set_bonding_mode_result {
4163 cmdline_fixed_string_t set;
4164 cmdline_fixed_string_t bonding;
4165 cmdline_fixed_string_t mode;
4170 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4171 __attribute__((unused)) struct cmdline *cl,
4172 __attribute__((unused)) void *data)
4174 struct cmd_set_bonding_mode_result *res = parsed_result;
4175 portid_t port_id = res->port_id;
4177 /* Set the bonding mode for the relevant port. */
4178 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4179 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4182 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4183 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4185 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4186 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4187 bonding, "bonding");
4188 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4189 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4191 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4192 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4194 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4195 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4198 cmdline_parse_inst_t cmd_set_bonding_mode = {
4199 .f = cmd_set_bonding_mode_parsed,
4200 .help_str = "set bonding mode <mode_value> <port_id>: "
4201 "Set the bonding mode for port_id",
4204 (void *) &cmd_setbonding_mode_set,
4205 (void *) &cmd_setbonding_mode_bonding,
4206 (void *) &cmd_setbonding_mode_mode,
4207 (void *) &cmd_setbonding_mode_value,
4208 (void *) &cmd_setbonding_mode_port,
4213 /* *** SET BALANCE XMIT POLICY *** */
4214 struct cmd_set_bonding_balance_xmit_policy_result {
4215 cmdline_fixed_string_t set;
4216 cmdline_fixed_string_t bonding;
4217 cmdline_fixed_string_t balance_xmit_policy;
4219 cmdline_fixed_string_t policy;
4222 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4223 __attribute__((unused)) struct cmdline *cl,
4224 __attribute__((unused)) void *data)
4226 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4227 portid_t port_id = res->port_id;
4230 if (!strcmp(res->policy, "l2")) {
4231 policy = BALANCE_XMIT_POLICY_LAYER2;
4232 } else if (!strcmp(res->policy, "l23")) {
4233 policy = BALANCE_XMIT_POLICY_LAYER23;
4234 } else if (!strcmp(res->policy, "l34")) {
4235 policy = BALANCE_XMIT_POLICY_LAYER34;
4237 printf("\t Invalid xmit policy selection");
4241 /* Set the bonding mode for the relevant port. */
4242 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4243 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4248 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4249 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4251 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4252 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4253 bonding, "bonding");
4254 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4256 balance_xmit_policy, "balance_xmit_policy");
4257 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4258 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4260 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4261 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4262 policy, "l2#l23#l34");
4264 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4265 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4266 .help_str = "set bonding balance_xmit_policy <port_id> "
4268 "Set the bonding balance_xmit_policy for port_id",
4271 (void *)&cmd_setbonding_balance_xmit_policy_set,
4272 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4273 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4274 (void *)&cmd_setbonding_balance_xmit_policy_port,
4275 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4280 /* *** SHOW NIC BONDING CONFIGURATION *** */
4281 struct cmd_show_bonding_config_result {
4282 cmdline_fixed_string_t show;
4283 cmdline_fixed_string_t bonding;
4284 cmdline_fixed_string_t config;
4288 static void cmd_show_bonding_config_parsed(void *parsed_result,
4289 __attribute__((unused)) struct cmdline *cl,
4290 __attribute__((unused)) void *data)
4292 struct cmd_show_bonding_config_result *res = parsed_result;
4294 uint8_t slaves[RTE_MAX_ETHPORTS];
4295 int num_slaves, num_active_slaves;
4298 portid_t port_id = res->port_id;
4300 /* Display the bonding mode.*/
4301 bonding_mode = rte_eth_bond_mode_get(port_id);
4302 if (bonding_mode < 0) {
4303 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4306 printf("\tBonding mode: %d\n", bonding_mode);
4308 if (bonding_mode == BONDING_MODE_BALANCE) {
4309 int balance_xmit_policy;
4311 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4312 if (balance_xmit_policy < 0) {
4313 printf("\tFailed to get balance xmit policy for port = %d\n",
4317 printf("\tBalance Xmit Policy: ");
4319 switch (balance_xmit_policy) {
4320 case BALANCE_XMIT_POLICY_LAYER2:
4321 printf("BALANCE_XMIT_POLICY_LAYER2");
4323 case BALANCE_XMIT_POLICY_LAYER23:
4324 printf("BALANCE_XMIT_POLICY_LAYER23");
4326 case BALANCE_XMIT_POLICY_LAYER34:
4327 printf("BALANCE_XMIT_POLICY_LAYER34");
4334 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4336 if (num_slaves < 0) {
4337 printf("\tFailed to get slave list for port = %d\n", port_id);
4340 if (num_slaves > 0) {
4341 printf("\tSlaves (%d): [", num_slaves);
4342 for (i = 0; i < num_slaves - 1; i++)
4343 printf("%d ", slaves[i]);
4345 printf("%d]\n", slaves[num_slaves - 1]);
4347 printf("\tSlaves: []\n");
4351 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4354 if (num_active_slaves < 0) {
4355 printf("\tFailed to get active slave list for port = %d\n", port_id);
4358 if (num_active_slaves > 0) {
4359 printf("\tActive Slaves (%d): [", num_active_slaves);
4360 for (i = 0; i < num_active_slaves - 1; i++)
4361 printf("%d ", slaves[i]);
4363 printf("%d]\n", slaves[num_active_slaves - 1]);
4366 printf("\tActive Slaves: []\n");
4370 primary_id = rte_eth_bond_primary_get(port_id);
4371 if (primary_id < 0) {
4372 printf("\tFailed to get primary slave for port = %d\n", port_id);
4375 printf("\tPrimary: [%d]\n", primary_id);
4379 cmdline_parse_token_string_t cmd_showbonding_config_show =
4380 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4382 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4383 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4384 bonding, "bonding");
4385 cmdline_parse_token_string_t cmd_showbonding_config_config =
4386 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4388 cmdline_parse_token_num_t cmd_showbonding_config_port =
4389 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4392 cmdline_parse_inst_t cmd_show_bonding_config = {
4393 .f = cmd_show_bonding_config_parsed,
4394 .help_str = "show bonding config <port_id>: "
4395 "Show the bonding config for port_id",
4398 (void *)&cmd_showbonding_config_show,
4399 (void *)&cmd_showbonding_config_bonding,
4400 (void *)&cmd_showbonding_config_config,
4401 (void *)&cmd_showbonding_config_port,
4406 /* *** SET BONDING PRIMARY *** */
4407 struct cmd_set_bonding_primary_result {
4408 cmdline_fixed_string_t set;
4409 cmdline_fixed_string_t bonding;
4410 cmdline_fixed_string_t primary;
4415 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4416 __attribute__((unused)) struct cmdline *cl,
4417 __attribute__((unused)) void *data)
4419 struct cmd_set_bonding_primary_result *res = parsed_result;
4420 portid_t master_port_id = res->port_id;
4421 portid_t slave_port_id = res->slave_id;
4423 /* Set the primary slave for a bonded device. */
4424 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4425 printf("\t Failed to set primary slave for port = %d.\n",
4432 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4433 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4435 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4436 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4437 bonding, "bonding");
4438 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4439 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4440 primary, "primary");
4441 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4442 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4444 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4445 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4448 cmdline_parse_inst_t cmd_set_bonding_primary = {
4449 .f = cmd_set_bonding_primary_parsed,
4450 .help_str = "set bonding primary <slave_id> <port_id>: "
4451 "Set the primary slave for port_id",
4454 (void *)&cmd_setbonding_primary_set,
4455 (void *)&cmd_setbonding_primary_bonding,
4456 (void *)&cmd_setbonding_primary_primary,
4457 (void *)&cmd_setbonding_primary_slave,
4458 (void *)&cmd_setbonding_primary_port,
4463 /* *** ADD SLAVE *** */
4464 struct cmd_add_bonding_slave_result {
4465 cmdline_fixed_string_t add;
4466 cmdline_fixed_string_t bonding;
4467 cmdline_fixed_string_t slave;
4472 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4473 __attribute__((unused)) struct cmdline *cl,
4474 __attribute__((unused)) void *data)
4476 struct cmd_add_bonding_slave_result *res = parsed_result;
4477 portid_t master_port_id = res->port_id;
4478 portid_t slave_port_id = res->slave_id;
4480 /* Set the primary slave for a bonded device. */
4481 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4482 printf("\t Failed to add slave %d to master port = %d.\n",
4483 slave_port_id, master_port_id);
4487 set_port_slave_flag(slave_port_id);
4490 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4491 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4493 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4494 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4495 bonding, "bonding");
4496 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4497 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4499 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4500 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4502 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4503 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4506 cmdline_parse_inst_t cmd_add_bonding_slave = {
4507 .f = cmd_add_bonding_slave_parsed,
4508 .help_str = "add bonding slave <slave_id> <port_id>: "
4509 "Add a slave device to a bonded device",
4512 (void *)&cmd_addbonding_slave_add,
4513 (void *)&cmd_addbonding_slave_bonding,
4514 (void *)&cmd_addbonding_slave_slave,
4515 (void *)&cmd_addbonding_slave_slaveid,
4516 (void *)&cmd_addbonding_slave_port,
4521 /* *** REMOVE SLAVE *** */
4522 struct cmd_remove_bonding_slave_result {
4523 cmdline_fixed_string_t remove;
4524 cmdline_fixed_string_t bonding;
4525 cmdline_fixed_string_t slave;
4530 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4531 __attribute__((unused)) struct cmdline *cl,
4532 __attribute__((unused)) void *data)
4534 struct cmd_remove_bonding_slave_result *res = parsed_result;
4535 portid_t master_port_id = res->port_id;
4536 portid_t slave_port_id = res->slave_id;
4538 /* Set the primary slave for a bonded device. */
4539 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4540 printf("\t Failed to remove slave %d from master port = %d.\n",
4541 slave_port_id, master_port_id);
4545 clear_port_slave_flag(slave_port_id);
4548 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4549 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4551 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4552 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4553 bonding, "bonding");
4554 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4555 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4557 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4558 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4560 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4561 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4564 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4565 .f = cmd_remove_bonding_slave_parsed,
4566 .help_str = "remove bonding slave <slave_id> <port_id>: "
4567 "Remove a slave device from a bonded device",
4570 (void *)&cmd_removebonding_slave_remove,
4571 (void *)&cmd_removebonding_slave_bonding,
4572 (void *)&cmd_removebonding_slave_slave,
4573 (void *)&cmd_removebonding_slave_slaveid,
4574 (void *)&cmd_removebonding_slave_port,
4579 /* *** CREATE BONDED DEVICE *** */
4580 struct cmd_create_bonded_device_result {
4581 cmdline_fixed_string_t create;
4582 cmdline_fixed_string_t bonded;
4583 cmdline_fixed_string_t device;
4588 static int bond_dev_num = 0;
4590 static void cmd_create_bonded_device_parsed(void *parsed_result,
4591 __attribute__((unused)) struct cmdline *cl,
4592 __attribute__((unused)) void *data)
4594 struct cmd_create_bonded_device_result *res = parsed_result;
4595 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4598 if (test_done == 0) {
4599 printf("Please stop forwarding first\n");
4603 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4606 /* Create a new bonded device. */
4607 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4609 printf("\t Failed to create bonded device.\n");
4612 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4615 /* Update number of ports */
4616 nb_ports = rte_eth_dev_count();
4617 reconfig(port_id, res->socket);
4618 rte_eth_promiscuous_enable(port_id);
4619 ports[port_id].enabled = 1;
4624 cmdline_parse_token_string_t cmd_createbonded_device_create =
4625 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4627 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4628 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4630 cmdline_parse_token_string_t cmd_createbonded_device_device =
4631 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4633 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4634 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4636 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4637 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4640 cmdline_parse_inst_t cmd_create_bonded_device = {
4641 .f = cmd_create_bonded_device_parsed,
4642 .help_str = "create bonded device <mode> <socket>: "
4643 "Create a new bonded device with specific bonding mode and socket",
4646 (void *)&cmd_createbonded_device_create,
4647 (void *)&cmd_createbonded_device_bonded,
4648 (void *)&cmd_createbonded_device_device,
4649 (void *)&cmd_createbonded_device_mode,
4650 (void *)&cmd_createbonded_device_socket,
4655 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4656 struct cmd_set_bond_mac_addr_result {
4657 cmdline_fixed_string_t set;
4658 cmdline_fixed_string_t bonding;
4659 cmdline_fixed_string_t mac_addr;
4661 struct ether_addr address;
4664 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4665 __attribute__((unused)) struct cmdline *cl,
4666 __attribute__((unused)) void *data)
4668 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4671 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4674 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4676 /* check the return value and print it if is < 0 */
4678 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4681 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4682 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4683 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4684 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4686 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4687 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4689 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4690 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4691 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4692 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4694 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4695 .f = cmd_set_bond_mac_addr_parsed,
4697 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4699 (void *)&cmd_set_bond_mac_addr_set,
4700 (void *)&cmd_set_bond_mac_addr_bonding,
4701 (void *)&cmd_set_bond_mac_addr_mac,
4702 (void *)&cmd_set_bond_mac_addr_portnum,
4703 (void *)&cmd_set_bond_mac_addr_addr,
4709 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4710 struct cmd_set_bond_mon_period_result {
4711 cmdline_fixed_string_t set;
4712 cmdline_fixed_string_t bonding;
4713 cmdline_fixed_string_t mon_period;
4718 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4719 __attribute__((unused)) struct cmdline *cl,
4720 __attribute__((unused)) void *data)
4722 struct cmd_set_bond_mon_period_result *res = parsed_result;
4725 if (res->port_num >= nb_ports) {
4726 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4730 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4732 /* check the return value and print it if is < 0 */
4734 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4737 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4738 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4740 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4741 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4742 bonding, "bonding");
4743 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4744 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4745 mon_period, "mon_period");
4746 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4747 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4749 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4750 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4753 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4754 .f = cmd_set_bond_mon_period_parsed,
4756 .help_str = "set bonding mon_period <port_id> <period_ms>",
4758 (void *)&cmd_set_bond_mon_period_set,
4759 (void *)&cmd_set_bond_mon_period_bonding,
4760 (void *)&cmd_set_bond_mon_period_mon_period,
4761 (void *)&cmd_set_bond_mon_period_portnum,
4762 (void *)&cmd_set_bond_mon_period_period_ms,
4767 #endif /* RTE_LIBRTE_PMD_BOND */
4769 /* *** SET FORWARDING MODE *** */
4770 struct cmd_set_fwd_mode_result {
4771 cmdline_fixed_string_t set;
4772 cmdline_fixed_string_t fwd;
4773 cmdline_fixed_string_t mode;
4776 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4777 __attribute__((unused)) struct cmdline *cl,
4778 __attribute__((unused)) void *data)
4780 struct cmd_set_fwd_mode_result *res = parsed_result;
4783 set_pkt_forwarding_mode(res->mode);
4786 cmdline_parse_token_string_t cmd_setfwd_set =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4788 cmdline_parse_token_string_t cmd_setfwd_fwd =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4790 cmdline_parse_token_string_t cmd_setfwd_mode =
4791 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4792 "" /* defined at init */);
4794 cmdline_parse_inst_t cmd_set_fwd_mode = {
4795 .f = cmd_set_fwd_mode_parsed,
4797 .help_str = NULL, /* defined at init */
4799 (void *)&cmd_setfwd_set,
4800 (void *)&cmd_setfwd_fwd,
4801 (void *)&cmd_setfwd_mode,
4806 static void cmd_set_fwd_mode_init(void)
4809 static char token[128];
4810 static char help[256];
4811 cmdline_parse_token_string_t *token_struct;
4813 modes = list_pkt_forwarding_modes();
4814 snprintf(help, sizeof(help), "set fwd %s: "
4815 "Set packet forwarding mode", modes);
4816 cmd_set_fwd_mode.help_str = help;
4818 /* string token separator is # */
4819 for (c = token; *modes != '\0'; modes++)
4824 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4825 token_struct->string_data.str = token;
4828 /* *** SET RETRY FORWARDING MODE *** */
4829 struct cmd_set_fwd_retry_mode_result {
4830 cmdline_fixed_string_t set;
4831 cmdline_fixed_string_t fwd;
4832 cmdline_fixed_string_t mode;
4833 cmdline_fixed_string_t retry;
4836 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4837 __attribute__((unused)) struct cmdline *cl,
4838 __attribute__((unused)) void *data)
4840 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4843 set_pkt_forwarding_mode(res->mode);
4846 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4847 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4849 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4850 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4852 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4853 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4855 "" /* defined at init */);
4856 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4857 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4860 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4861 .f = cmd_set_fwd_retry_mode_parsed,
4863 .help_str = NULL, /* defined at init */
4865 (void *)&cmd_setfwd_retry_set,
4866 (void *)&cmd_setfwd_retry_fwd,
4867 (void *)&cmd_setfwd_retry_mode,
4868 (void *)&cmd_setfwd_retry_retry,
4873 static void cmd_set_fwd_retry_mode_init(void)
4876 static char token[128];
4877 static char help[256];
4878 cmdline_parse_token_string_t *token_struct;
4880 modes = list_pkt_forwarding_retry_modes();
4881 snprintf(help, sizeof(help), "set fwd %s retry: "
4882 "Set packet forwarding mode with retry", modes);
4883 cmd_set_fwd_retry_mode.help_str = help;
4885 /* string token separator is # */
4886 for (c = token; *modes != '\0'; modes++)
4891 token_struct = (cmdline_parse_token_string_t *)
4892 cmd_set_fwd_retry_mode.tokens[2];
4893 token_struct->string_data.str = token;
4896 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4897 struct cmd_set_burst_tx_retry_result {
4898 cmdline_fixed_string_t set;
4899 cmdline_fixed_string_t burst;
4900 cmdline_fixed_string_t tx;
4901 cmdline_fixed_string_t delay;
4903 cmdline_fixed_string_t retry;
4907 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4908 __attribute__((unused)) struct cmdline *cl,
4909 __attribute__((unused)) void *data)
4911 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4913 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4914 && !strcmp(res->tx, "tx")) {
4915 if (!strcmp(res->delay, "delay"))
4916 burst_tx_delay_time = res->time;
4917 if (!strcmp(res->retry, "retry"))
4918 burst_tx_retry_num = res->retry_num;
4923 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4924 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4925 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4928 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4930 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4931 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4932 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4933 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4934 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4935 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4936 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4937 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4939 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4940 .f = cmd_set_burst_tx_retry_parsed,
4941 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4943 (void *)&cmd_set_burst_tx_retry_set,
4944 (void *)&cmd_set_burst_tx_retry_burst,
4945 (void *)&cmd_set_burst_tx_retry_tx,
4946 (void *)&cmd_set_burst_tx_retry_delay,
4947 (void *)&cmd_set_burst_tx_retry_time,
4948 (void *)&cmd_set_burst_tx_retry_retry,
4949 (void *)&cmd_set_burst_tx_retry_retry_num,
4954 /* *** SET PROMISC MODE *** */
4955 struct cmd_set_promisc_mode_result {
4956 cmdline_fixed_string_t set;
4957 cmdline_fixed_string_t promisc;
4958 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4959 uint8_t port_num; /* valid if "allports" argument == 0 */
4960 cmdline_fixed_string_t mode;
4963 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4964 __attribute__((unused)) struct cmdline *cl,
4967 struct cmd_set_promisc_mode_result *res = parsed_result;
4971 if (!strcmp(res->mode, "on"))
4978 FOREACH_PORT(i, ports) {
4980 rte_eth_promiscuous_enable(i);
4982 rte_eth_promiscuous_disable(i);
4987 rte_eth_promiscuous_enable(res->port_num);
4989 rte_eth_promiscuous_disable(res->port_num);
4993 cmdline_parse_token_string_t cmd_setpromisc_set =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4995 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4996 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4998 cmdline_parse_token_string_t cmd_setpromisc_portall =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5001 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5002 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5004 cmdline_parse_token_string_t cmd_setpromisc_mode =
5005 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5008 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5009 .f = cmd_set_promisc_mode_parsed,
5011 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5013 (void *)&cmd_setpromisc_set,
5014 (void *)&cmd_setpromisc_promisc,
5015 (void *)&cmd_setpromisc_portall,
5016 (void *)&cmd_setpromisc_mode,
5021 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5022 .f = cmd_set_promisc_mode_parsed,
5024 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5026 (void *)&cmd_setpromisc_set,
5027 (void *)&cmd_setpromisc_promisc,
5028 (void *)&cmd_setpromisc_portnum,
5029 (void *)&cmd_setpromisc_mode,
5034 /* *** SET ALLMULTI MODE *** */
5035 struct cmd_set_allmulti_mode_result {
5036 cmdline_fixed_string_t set;
5037 cmdline_fixed_string_t allmulti;
5038 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5039 uint8_t port_num; /* valid if "allports" argument == 0 */
5040 cmdline_fixed_string_t mode;
5043 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5044 __attribute__((unused)) struct cmdline *cl,
5047 struct cmd_set_allmulti_mode_result *res = parsed_result;
5051 if (!strcmp(res->mode, "on"))
5058 FOREACH_PORT(i, ports) {
5060 rte_eth_allmulticast_enable(i);
5062 rte_eth_allmulticast_disable(i);
5067 rte_eth_allmulticast_enable(res->port_num);
5069 rte_eth_allmulticast_disable(res->port_num);
5073 cmdline_parse_token_string_t cmd_setallmulti_set =
5074 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5075 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5076 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5078 cmdline_parse_token_string_t cmd_setallmulti_portall =
5079 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5081 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5082 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5084 cmdline_parse_token_string_t cmd_setallmulti_mode =
5085 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5088 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5089 .f = cmd_set_allmulti_mode_parsed,
5091 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5093 (void *)&cmd_setallmulti_set,
5094 (void *)&cmd_setallmulti_allmulti,
5095 (void *)&cmd_setallmulti_portall,
5096 (void *)&cmd_setallmulti_mode,
5101 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5102 .f = cmd_set_allmulti_mode_parsed,
5104 .help_str = "set allmulti <port_id> on|off: "
5105 "Set allmulti mode on port_id",
5107 (void *)&cmd_setallmulti_set,
5108 (void *)&cmd_setallmulti_allmulti,
5109 (void *)&cmd_setallmulti_portnum,
5110 (void *)&cmd_setallmulti_mode,
5115 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5116 struct cmd_link_flow_ctrl_set_result {
5117 cmdline_fixed_string_t set;
5118 cmdline_fixed_string_t flow_ctrl;
5119 cmdline_fixed_string_t rx;
5120 cmdline_fixed_string_t rx_lfc_mode;
5121 cmdline_fixed_string_t tx;
5122 cmdline_fixed_string_t tx_lfc_mode;
5123 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5124 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5125 cmdline_fixed_string_t autoneg_str;
5126 cmdline_fixed_string_t autoneg;
5127 cmdline_fixed_string_t hw_str;
5128 uint32_t high_water;
5129 cmdline_fixed_string_t lw_str;
5131 cmdline_fixed_string_t pt_str;
5132 uint16_t pause_time;
5133 cmdline_fixed_string_t xon_str;
5138 cmdline_parse_token_string_t cmd_lfc_set_set =
5139 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5141 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5142 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5143 flow_ctrl, "flow_ctrl");
5144 cmdline_parse_token_string_t cmd_lfc_set_rx =
5145 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5147 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5148 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5149 rx_lfc_mode, "on#off");
5150 cmdline_parse_token_string_t cmd_lfc_set_tx =
5151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5153 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5155 tx_lfc_mode, "on#off");
5156 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5157 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5158 hw_str, "high_water");
5159 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5160 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5161 high_water, UINT32);
5162 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5163 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5164 lw_str, "low_water");
5165 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5166 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5168 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5169 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5170 pt_str, "pause_time");
5171 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5172 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5173 pause_time, UINT16);
5174 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5175 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5176 xon_str, "send_xon");
5177 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5178 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5181 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5182 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5183 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5184 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5185 mac_ctrl_frame_fwd_mode, "on#off");
5186 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5187 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5188 autoneg_str, "autoneg");
5189 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5190 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 cmdline_parse_token_num_t cmd_lfc_set_portid =
5193 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5196 /* forward declaration */
5198 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5201 cmdline_parse_inst_t cmd_link_flow_control_set = {
5202 .f = cmd_link_flow_ctrl_set_parsed,
5204 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5205 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5206 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5208 (void *)&cmd_lfc_set_set,
5209 (void *)&cmd_lfc_set_flow_ctrl,
5210 (void *)&cmd_lfc_set_rx,
5211 (void *)&cmd_lfc_set_rx_mode,
5212 (void *)&cmd_lfc_set_tx,
5213 (void *)&cmd_lfc_set_tx_mode,
5214 (void *)&cmd_lfc_set_high_water,
5215 (void *)&cmd_lfc_set_low_water,
5216 (void *)&cmd_lfc_set_pause_time,
5217 (void *)&cmd_lfc_set_send_xon,
5218 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5219 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5220 (void *)&cmd_lfc_set_autoneg_str,
5221 (void *)&cmd_lfc_set_autoneg,
5222 (void *)&cmd_lfc_set_portid,
5227 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5228 .f = cmd_link_flow_ctrl_set_parsed,
5229 .data = (void *)&cmd_link_flow_control_set_rx,
5230 .help_str = "set flow_ctrl rx on|off <port_id>: "
5231 "Change rx flow control parameter",
5233 (void *)&cmd_lfc_set_set,
5234 (void *)&cmd_lfc_set_flow_ctrl,
5235 (void *)&cmd_lfc_set_rx,
5236 (void *)&cmd_lfc_set_rx_mode,
5237 (void *)&cmd_lfc_set_portid,
5242 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5243 .f = cmd_link_flow_ctrl_set_parsed,
5244 .data = (void *)&cmd_link_flow_control_set_tx,
5245 .help_str = "set flow_ctrl tx on|off <port_id>: "
5246 "Change tx flow control parameter",
5248 (void *)&cmd_lfc_set_set,
5249 (void *)&cmd_lfc_set_flow_ctrl,
5250 (void *)&cmd_lfc_set_tx,
5251 (void *)&cmd_lfc_set_tx_mode,
5252 (void *)&cmd_lfc_set_portid,
5257 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5258 .f = cmd_link_flow_ctrl_set_parsed,
5259 .data = (void *)&cmd_link_flow_control_set_hw,
5260 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5261 "Change high water flow control parameter",
5263 (void *)&cmd_lfc_set_set,
5264 (void *)&cmd_lfc_set_flow_ctrl,
5265 (void *)&cmd_lfc_set_high_water_str,
5266 (void *)&cmd_lfc_set_high_water,
5267 (void *)&cmd_lfc_set_portid,
5272 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5273 .f = cmd_link_flow_ctrl_set_parsed,
5274 .data = (void *)&cmd_link_flow_control_set_lw,
5275 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5276 "Change low water flow control parameter",
5278 (void *)&cmd_lfc_set_set,
5279 (void *)&cmd_lfc_set_flow_ctrl,
5280 (void *)&cmd_lfc_set_low_water_str,
5281 (void *)&cmd_lfc_set_low_water,
5282 (void *)&cmd_lfc_set_portid,
5287 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5288 .f = cmd_link_flow_ctrl_set_parsed,
5289 .data = (void *)&cmd_link_flow_control_set_pt,
5290 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5291 "Change pause time flow control parameter",
5293 (void *)&cmd_lfc_set_set,
5294 (void *)&cmd_lfc_set_flow_ctrl,
5295 (void *)&cmd_lfc_set_pause_time_str,
5296 (void *)&cmd_lfc_set_pause_time,
5297 (void *)&cmd_lfc_set_portid,
5302 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5303 .f = cmd_link_flow_ctrl_set_parsed,
5304 .data = (void *)&cmd_link_flow_control_set_xon,
5305 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5306 "Change send_xon flow control parameter",
5308 (void *)&cmd_lfc_set_set,
5309 (void *)&cmd_lfc_set_flow_ctrl,
5310 (void *)&cmd_lfc_set_send_xon_str,
5311 (void *)&cmd_lfc_set_send_xon,
5312 (void *)&cmd_lfc_set_portid,
5317 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5318 .f = cmd_link_flow_ctrl_set_parsed,
5319 .data = (void *)&cmd_link_flow_control_set_macfwd,
5320 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5321 "Change mac ctrl fwd flow control parameter",
5323 (void *)&cmd_lfc_set_set,
5324 (void *)&cmd_lfc_set_flow_ctrl,
5325 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5326 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5327 (void *)&cmd_lfc_set_portid,
5332 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5333 .f = cmd_link_flow_ctrl_set_parsed,
5334 .data = (void *)&cmd_link_flow_control_set_autoneg,
5335 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5336 "Change autoneg flow control parameter",
5338 (void *)&cmd_lfc_set_set,
5339 (void *)&cmd_lfc_set_flow_ctrl,
5340 (void *)&cmd_lfc_set_autoneg_str,
5341 (void *)&cmd_lfc_set_autoneg,
5342 (void *)&cmd_lfc_set_portid,
5348 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5349 __attribute__((unused)) struct cmdline *cl,
5352 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5353 cmdline_parse_inst_t *cmd = data;
5354 struct rte_eth_fc_conf fc_conf;
5360 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5361 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5362 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5363 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5365 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5366 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5369 /* Partial command line, retrieve current configuration */
5371 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5373 printf("cannot get current flow ctrl parameters, return"
5374 "code = %d\n", ret);
5378 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5379 (fc_conf.mode == RTE_FC_FULL))
5381 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5382 (fc_conf.mode == RTE_FC_FULL))
5386 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5387 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5389 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5390 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5392 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5394 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5395 fc_conf.high_water = res->high_water;
5397 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5398 fc_conf.low_water = res->low_water;
5400 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5401 fc_conf.pause_time = res->pause_time;
5403 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5404 fc_conf.send_xon = res->send_xon;
5406 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5407 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5408 fc_conf.mac_ctrl_frame_fwd = 1;
5410 fc_conf.mac_ctrl_frame_fwd = 0;
5413 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5414 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5416 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5418 printf("bad flow contrl parameter, return code = %d \n", ret);
5421 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5422 struct cmd_priority_flow_ctrl_set_result {
5423 cmdline_fixed_string_t set;
5424 cmdline_fixed_string_t pfc_ctrl;
5425 cmdline_fixed_string_t rx;
5426 cmdline_fixed_string_t rx_pfc_mode;
5427 cmdline_fixed_string_t tx;
5428 cmdline_fixed_string_t tx_pfc_mode;
5429 uint32_t high_water;
5431 uint16_t pause_time;
5437 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5438 __attribute__((unused)) struct cmdline *cl,
5439 __attribute__((unused)) void *data)
5441 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5442 struct rte_eth_pfc_conf pfc_conf;
5443 int rx_fc_enable, tx_fc_enable;
5447 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5448 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5449 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5450 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5452 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5453 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5456 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5457 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5458 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5459 pfc_conf.fc.high_water = res->high_water;
5460 pfc_conf.fc.low_water = res->low_water;
5461 pfc_conf.fc.pause_time = res->pause_time;
5462 pfc_conf.priority = res->priority;
5464 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5466 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5469 cmdline_parse_token_string_t cmd_pfc_set_set =
5470 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5472 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5473 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5474 pfc_ctrl, "pfc_ctrl");
5475 cmdline_parse_token_string_t cmd_pfc_set_rx =
5476 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5478 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5479 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5480 rx_pfc_mode, "on#off");
5481 cmdline_parse_token_string_t cmd_pfc_set_tx =
5482 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5484 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5485 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5486 tx_pfc_mode, "on#off");
5487 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5488 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5489 high_water, UINT32);
5490 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5491 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5493 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5494 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5495 pause_time, UINT16);
5496 cmdline_parse_token_num_t cmd_pfc_set_priority =
5497 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5499 cmdline_parse_token_num_t cmd_pfc_set_portid =
5500 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5503 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5504 .f = cmd_priority_flow_ctrl_set_parsed,
5506 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5507 "<pause_time> <priority> <port_id>: "
5508 "Configure the Ethernet priority flow control",
5510 (void *)&cmd_pfc_set_set,
5511 (void *)&cmd_pfc_set_flow_ctrl,
5512 (void *)&cmd_pfc_set_rx,
5513 (void *)&cmd_pfc_set_rx_mode,
5514 (void *)&cmd_pfc_set_tx,
5515 (void *)&cmd_pfc_set_tx_mode,
5516 (void *)&cmd_pfc_set_high_water,
5517 (void *)&cmd_pfc_set_low_water,
5518 (void *)&cmd_pfc_set_pause_time,
5519 (void *)&cmd_pfc_set_priority,
5520 (void *)&cmd_pfc_set_portid,
5525 /* *** RESET CONFIGURATION *** */
5526 struct cmd_reset_result {
5527 cmdline_fixed_string_t reset;
5528 cmdline_fixed_string_t def;
5531 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5533 __attribute__((unused)) void *data)
5535 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5536 set_def_fwd_config();
5539 cmdline_parse_token_string_t cmd_reset_set =
5540 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5541 cmdline_parse_token_string_t cmd_reset_def =
5542 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5545 cmdline_parse_inst_t cmd_reset = {
5546 .f = cmd_reset_parsed,
5548 .help_str = "set default: Reset default forwarding configuration",
5550 (void *)&cmd_reset_set,
5551 (void *)&cmd_reset_def,
5556 /* *** START FORWARDING *** */
5557 struct cmd_start_result {
5558 cmdline_fixed_string_t start;
5561 cmdline_parse_token_string_t cmd_start_start =
5562 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5564 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5565 __attribute__((unused)) struct cmdline *cl,
5566 __attribute__((unused)) void *data)
5568 start_packet_forwarding(0);
5571 cmdline_parse_inst_t cmd_start = {
5572 .f = cmd_start_parsed,
5574 .help_str = "start: Start packet forwarding",
5576 (void *)&cmd_start_start,
5581 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5582 struct cmd_start_tx_first_result {
5583 cmdline_fixed_string_t start;
5584 cmdline_fixed_string_t tx_first;
5588 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5589 __attribute__((unused)) struct cmdline *cl,
5590 __attribute__((unused)) void *data)
5592 start_packet_forwarding(1);
5595 cmdline_parse_token_string_t cmd_start_tx_first_start =
5596 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5598 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5599 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5600 tx_first, "tx_first");
5602 cmdline_parse_inst_t cmd_start_tx_first = {
5603 .f = cmd_start_tx_first_parsed,
5605 .help_str = "start tx_first: Start packet forwarding, "
5606 "after sending 1 burst of packets",
5608 (void *)&cmd_start_tx_first_start,
5609 (void *)&cmd_start_tx_first_tx_first,
5614 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5615 struct cmd_start_tx_first_n_result {
5616 cmdline_fixed_string_t start;
5617 cmdline_fixed_string_t tx_first;
5622 cmd_start_tx_first_n_parsed(void *parsed_result,
5623 __attribute__((unused)) struct cmdline *cl,
5624 __attribute__((unused)) void *data)
5626 struct cmd_start_tx_first_n_result *res = parsed_result;
5628 start_packet_forwarding(res->tx_num);
5631 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5632 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5634 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5635 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5636 tx_first, "tx_first");
5637 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5638 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5641 cmdline_parse_inst_t cmd_start_tx_first_n = {
5642 .f = cmd_start_tx_first_n_parsed,
5644 .help_str = "start tx_first <num>: "
5645 "packet forwarding, after sending <num> bursts of packets",
5647 (void *)&cmd_start_tx_first_n_start,
5648 (void *)&cmd_start_tx_first_n_tx_first,
5649 (void *)&cmd_start_tx_first_n_tx_num,
5654 /* *** SET LINK UP *** */
5655 struct cmd_set_link_up_result {
5656 cmdline_fixed_string_t set;
5657 cmdline_fixed_string_t link_up;
5658 cmdline_fixed_string_t port;
5662 cmdline_parse_token_string_t cmd_set_link_up_set =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5664 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5667 cmdline_parse_token_string_t cmd_set_link_up_port =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5669 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5670 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5672 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5673 __attribute__((unused)) struct cmdline *cl,
5674 __attribute__((unused)) void *data)
5676 struct cmd_set_link_up_result *res = parsed_result;
5677 dev_set_link_up(res->port_id);
5680 cmdline_parse_inst_t cmd_set_link_up = {
5681 .f = cmd_set_link_up_parsed,
5683 .help_str = "set link-up port <port id>",
5685 (void *)&cmd_set_link_up_set,
5686 (void *)&cmd_set_link_up_link_up,
5687 (void *)&cmd_set_link_up_port,
5688 (void *)&cmd_set_link_up_port_id,
5693 /* *** SET LINK DOWN *** */
5694 struct cmd_set_link_down_result {
5695 cmdline_fixed_string_t set;
5696 cmdline_fixed_string_t link_down;
5697 cmdline_fixed_string_t port;
5701 cmdline_parse_token_string_t cmd_set_link_down_set =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5703 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5706 cmdline_parse_token_string_t cmd_set_link_down_port =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5708 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5709 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5711 static void cmd_set_link_down_parsed(
5712 __attribute__((unused)) void *parsed_result,
5713 __attribute__((unused)) struct cmdline *cl,
5714 __attribute__((unused)) void *data)
5716 struct cmd_set_link_down_result *res = parsed_result;
5717 dev_set_link_down(res->port_id);
5720 cmdline_parse_inst_t cmd_set_link_down = {
5721 .f = cmd_set_link_down_parsed,
5723 .help_str = "set link-down port <port id>",
5725 (void *)&cmd_set_link_down_set,
5726 (void *)&cmd_set_link_down_link_down,
5727 (void *)&cmd_set_link_down_port,
5728 (void *)&cmd_set_link_down_port_id,
5733 /* *** SHOW CFG *** */
5734 struct cmd_showcfg_result {
5735 cmdline_fixed_string_t show;
5736 cmdline_fixed_string_t cfg;
5737 cmdline_fixed_string_t what;
5740 static void cmd_showcfg_parsed(void *parsed_result,
5741 __attribute__((unused)) struct cmdline *cl,
5742 __attribute__((unused)) void *data)
5744 struct cmd_showcfg_result *res = parsed_result;
5745 if (!strcmp(res->what, "rxtx"))
5746 rxtx_config_display();
5747 else if (!strcmp(res->what, "cores"))
5748 fwd_lcores_config_display();
5749 else if (!strcmp(res->what, "fwd"))
5750 pkt_fwd_config_display(&cur_fwd_config);
5751 else if (!strcmp(res->what, "txpkts"))
5752 show_tx_pkt_segments();
5755 cmdline_parse_token_string_t cmd_showcfg_show =
5756 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5757 cmdline_parse_token_string_t cmd_showcfg_port =
5758 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5759 cmdline_parse_token_string_t cmd_showcfg_what =
5760 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5761 "rxtx#cores#fwd#txpkts");
5763 cmdline_parse_inst_t cmd_showcfg = {
5764 .f = cmd_showcfg_parsed,
5766 .help_str = "show config rxtx|cores|fwd|txpkts",
5768 (void *)&cmd_showcfg_show,
5769 (void *)&cmd_showcfg_port,
5770 (void *)&cmd_showcfg_what,
5775 /* *** SHOW ALL PORT INFO *** */
5776 struct cmd_showportall_result {
5777 cmdline_fixed_string_t show;
5778 cmdline_fixed_string_t port;
5779 cmdline_fixed_string_t what;
5780 cmdline_fixed_string_t all;
5783 static void cmd_showportall_parsed(void *parsed_result,
5784 __attribute__((unused)) struct cmdline *cl,
5785 __attribute__((unused)) void *data)
5789 struct cmd_showportall_result *res = parsed_result;
5790 if (!strcmp(res->show, "clear")) {
5791 if (!strcmp(res->what, "stats"))
5792 FOREACH_PORT(i, ports)
5794 else if (!strcmp(res->what, "xstats"))
5795 FOREACH_PORT(i, ports)
5796 nic_xstats_clear(i);
5797 } else if (!strcmp(res->what, "info"))
5798 FOREACH_PORT(i, ports)
5799 port_infos_display(i);
5800 else if (!strcmp(res->what, "stats"))
5801 FOREACH_PORT(i, ports)
5802 nic_stats_display(i);
5803 else if (!strcmp(res->what, "xstats"))
5804 FOREACH_PORT(i, ports)
5805 nic_xstats_display(i);
5806 else if (!strcmp(res->what, "fdir"))
5807 FOREACH_PORT(i, ports)
5809 else if (!strcmp(res->what, "stat_qmap"))
5810 FOREACH_PORT(i, ports)
5811 nic_stats_mapping_display(i);
5812 else if (!strcmp(res->what, "dcb_tc"))
5813 FOREACH_PORT(i, ports)
5814 port_dcb_info_display(i);
5817 cmdline_parse_token_string_t cmd_showportall_show =
5818 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5820 cmdline_parse_token_string_t cmd_showportall_port =
5821 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5822 cmdline_parse_token_string_t cmd_showportall_what =
5823 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5824 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5825 cmdline_parse_token_string_t cmd_showportall_all =
5826 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5827 cmdline_parse_inst_t cmd_showportall = {
5828 .f = cmd_showportall_parsed,
5830 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5832 (void *)&cmd_showportall_show,
5833 (void *)&cmd_showportall_port,
5834 (void *)&cmd_showportall_what,
5835 (void *)&cmd_showportall_all,
5840 /* *** SHOW PORT INFO *** */
5841 struct cmd_showport_result {
5842 cmdline_fixed_string_t show;
5843 cmdline_fixed_string_t port;
5844 cmdline_fixed_string_t what;
5848 static void cmd_showport_parsed(void *parsed_result,
5849 __attribute__((unused)) struct cmdline *cl,
5850 __attribute__((unused)) void *data)
5852 struct cmd_showport_result *res = parsed_result;
5853 if (!strcmp(res->show, "clear")) {
5854 if (!strcmp(res->what, "stats"))
5855 nic_stats_clear(res->portnum);
5856 else if (!strcmp(res->what, "xstats"))
5857 nic_xstats_clear(res->portnum);
5858 } else if (!strcmp(res->what, "info"))
5859 port_infos_display(res->portnum);
5860 else if (!strcmp(res->what, "stats"))
5861 nic_stats_display(res->portnum);
5862 else if (!strcmp(res->what, "xstats"))
5863 nic_xstats_display(res->portnum);
5864 else if (!strcmp(res->what, "fdir"))
5865 fdir_get_infos(res->portnum);
5866 else if (!strcmp(res->what, "stat_qmap"))
5867 nic_stats_mapping_display(res->portnum);
5868 else if (!strcmp(res->what, "dcb_tc"))
5869 port_dcb_info_display(res->portnum);
5872 cmdline_parse_token_string_t cmd_showport_show =
5873 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5875 cmdline_parse_token_string_t cmd_showport_port =
5876 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5877 cmdline_parse_token_string_t cmd_showport_what =
5878 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5879 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5880 cmdline_parse_token_num_t cmd_showport_portnum =
5881 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5883 cmdline_parse_inst_t cmd_showport = {
5884 .f = cmd_showport_parsed,
5886 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5889 (void *)&cmd_showport_show,
5890 (void *)&cmd_showport_port,
5891 (void *)&cmd_showport_what,
5892 (void *)&cmd_showport_portnum,
5897 /* *** SHOW QUEUE INFO *** */
5898 struct cmd_showqueue_result {
5899 cmdline_fixed_string_t show;
5900 cmdline_fixed_string_t type;
5901 cmdline_fixed_string_t what;
5907 cmd_showqueue_parsed(void *parsed_result,
5908 __attribute__((unused)) struct cmdline *cl,
5909 __attribute__((unused)) void *data)
5911 struct cmd_showqueue_result *res = parsed_result;
5913 if (!strcmp(res->type, "rxq"))
5914 rx_queue_infos_display(res->portnum, res->queuenum);
5915 else if (!strcmp(res->type, "txq"))
5916 tx_queue_infos_display(res->portnum, res->queuenum);
5919 cmdline_parse_token_string_t cmd_showqueue_show =
5920 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5921 cmdline_parse_token_string_t cmd_showqueue_type =
5922 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5923 cmdline_parse_token_string_t cmd_showqueue_what =
5924 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5925 cmdline_parse_token_num_t cmd_showqueue_portnum =
5926 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5927 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5928 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5930 cmdline_parse_inst_t cmd_showqueue = {
5931 .f = cmd_showqueue_parsed,
5933 .help_str = "show rxq|txq info <port_id> <queue_id>",
5935 (void *)&cmd_showqueue_show,
5936 (void *)&cmd_showqueue_type,
5937 (void *)&cmd_showqueue_what,
5938 (void *)&cmd_showqueue_portnum,
5939 (void *)&cmd_showqueue_queuenum,
5944 /* *** READ PORT REGISTER *** */
5945 struct cmd_read_reg_result {
5946 cmdline_fixed_string_t read;
5947 cmdline_fixed_string_t reg;
5953 cmd_read_reg_parsed(void *parsed_result,
5954 __attribute__((unused)) struct cmdline *cl,
5955 __attribute__((unused)) void *data)
5957 struct cmd_read_reg_result *res = parsed_result;
5958 port_reg_display(res->port_id, res->reg_off);
5961 cmdline_parse_token_string_t cmd_read_reg_read =
5962 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5963 cmdline_parse_token_string_t cmd_read_reg_reg =
5964 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5965 cmdline_parse_token_num_t cmd_read_reg_port_id =
5966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5967 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5970 cmdline_parse_inst_t cmd_read_reg = {
5971 .f = cmd_read_reg_parsed,
5973 .help_str = "read reg <port_id> <reg_off>",
5975 (void *)&cmd_read_reg_read,
5976 (void *)&cmd_read_reg_reg,
5977 (void *)&cmd_read_reg_port_id,
5978 (void *)&cmd_read_reg_reg_off,
5983 /* *** READ PORT REGISTER BIT FIELD *** */
5984 struct cmd_read_reg_bit_field_result {
5985 cmdline_fixed_string_t read;
5986 cmdline_fixed_string_t regfield;
5994 cmd_read_reg_bit_field_parsed(void *parsed_result,
5995 __attribute__((unused)) struct cmdline *cl,
5996 __attribute__((unused)) void *data)
5998 struct cmd_read_reg_bit_field_result *res = parsed_result;
5999 port_reg_bit_field_display(res->port_id, res->reg_off,
6000 res->bit1_pos, res->bit2_pos);
6003 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6004 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6006 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6007 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6008 regfield, "regfield");
6009 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6010 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6012 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6013 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6015 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6016 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6018 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6019 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6022 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6023 .f = cmd_read_reg_bit_field_parsed,
6025 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6026 "Read register bit field between bit_x and bit_y included",
6028 (void *)&cmd_read_reg_bit_field_read,
6029 (void *)&cmd_read_reg_bit_field_regfield,
6030 (void *)&cmd_read_reg_bit_field_port_id,
6031 (void *)&cmd_read_reg_bit_field_reg_off,
6032 (void *)&cmd_read_reg_bit_field_bit1_pos,
6033 (void *)&cmd_read_reg_bit_field_bit2_pos,
6038 /* *** READ PORT REGISTER BIT *** */
6039 struct cmd_read_reg_bit_result {
6040 cmdline_fixed_string_t read;
6041 cmdline_fixed_string_t regbit;
6048 cmd_read_reg_bit_parsed(void *parsed_result,
6049 __attribute__((unused)) struct cmdline *cl,
6050 __attribute__((unused)) void *data)
6052 struct cmd_read_reg_bit_result *res = parsed_result;
6053 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6056 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6057 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6058 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6059 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6061 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6062 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6063 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6064 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6065 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6068 cmdline_parse_inst_t cmd_read_reg_bit = {
6069 .f = cmd_read_reg_bit_parsed,
6071 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6073 (void *)&cmd_read_reg_bit_read,
6074 (void *)&cmd_read_reg_bit_regbit,
6075 (void *)&cmd_read_reg_bit_port_id,
6076 (void *)&cmd_read_reg_bit_reg_off,
6077 (void *)&cmd_read_reg_bit_bit_pos,
6082 /* *** WRITE PORT REGISTER *** */
6083 struct cmd_write_reg_result {
6084 cmdline_fixed_string_t write;
6085 cmdline_fixed_string_t reg;
6092 cmd_write_reg_parsed(void *parsed_result,
6093 __attribute__((unused)) struct cmdline *cl,
6094 __attribute__((unused)) void *data)
6096 struct cmd_write_reg_result *res = parsed_result;
6097 port_reg_set(res->port_id, res->reg_off, res->value);
6100 cmdline_parse_token_string_t cmd_write_reg_write =
6101 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6102 cmdline_parse_token_string_t cmd_write_reg_reg =
6103 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6104 cmdline_parse_token_num_t cmd_write_reg_port_id =
6105 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6106 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6108 cmdline_parse_token_num_t cmd_write_reg_value =
6109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6111 cmdline_parse_inst_t cmd_write_reg = {
6112 .f = cmd_write_reg_parsed,
6114 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6116 (void *)&cmd_write_reg_write,
6117 (void *)&cmd_write_reg_reg,
6118 (void *)&cmd_write_reg_port_id,
6119 (void *)&cmd_write_reg_reg_off,
6120 (void *)&cmd_write_reg_value,
6125 /* *** WRITE PORT REGISTER BIT FIELD *** */
6126 struct cmd_write_reg_bit_field_result {
6127 cmdline_fixed_string_t write;
6128 cmdline_fixed_string_t regfield;
6137 cmd_write_reg_bit_field_parsed(void *parsed_result,
6138 __attribute__((unused)) struct cmdline *cl,
6139 __attribute__((unused)) void *data)
6141 struct cmd_write_reg_bit_field_result *res = parsed_result;
6142 port_reg_bit_field_set(res->port_id, res->reg_off,
6143 res->bit1_pos, res->bit2_pos, res->value);
6146 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6149 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6150 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6151 regfield, "regfield");
6152 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6155 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6156 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6158 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6159 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6161 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6162 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6164 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6165 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6168 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6169 .f = cmd_write_reg_bit_field_parsed,
6171 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6173 "Set register bit field between bit_x and bit_y included",
6175 (void *)&cmd_write_reg_bit_field_write,
6176 (void *)&cmd_write_reg_bit_field_regfield,
6177 (void *)&cmd_write_reg_bit_field_port_id,
6178 (void *)&cmd_write_reg_bit_field_reg_off,
6179 (void *)&cmd_write_reg_bit_field_bit1_pos,
6180 (void *)&cmd_write_reg_bit_field_bit2_pos,
6181 (void *)&cmd_write_reg_bit_field_value,
6186 /* *** WRITE PORT REGISTER BIT *** */
6187 struct cmd_write_reg_bit_result {
6188 cmdline_fixed_string_t write;
6189 cmdline_fixed_string_t regbit;
6197 cmd_write_reg_bit_parsed(void *parsed_result,
6198 __attribute__((unused)) struct cmdline *cl,
6199 __attribute__((unused)) void *data)
6201 struct cmd_write_reg_bit_result *res = parsed_result;
6202 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6205 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6206 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6208 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6209 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6211 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6212 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6213 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6214 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6215 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6217 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6220 cmdline_parse_inst_t cmd_write_reg_bit = {
6221 .f = cmd_write_reg_bit_parsed,
6223 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6226 (void *)&cmd_write_reg_bit_write,
6227 (void *)&cmd_write_reg_bit_regbit,
6228 (void *)&cmd_write_reg_bit_port_id,
6229 (void *)&cmd_write_reg_bit_reg_off,
6230 (void *)&cmd_write_reg_bit_bit_pos,
6231 (void *)&cmd_write_reg_bit_value,
6236 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6237 struct cmd_read_rxd_txd_result {
6238 cmdline_fixed_string_t read;
6239 cmdline_fixed_string_t rxd_txd;
6246 cmd_read_rxd_txd_parsed(void *parsed_result,
6247 __attribute__((unused)) struct cmdline *cl,
6248 __attribute__((unused)) void *data)
6250 struct cmd_read_rxd_txd_result *res = parsed_result;
6252 if (!strcmp(res->rxd_txd, "rxd"))
6253 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6254 else if (!strcmp(res->rxd_txd, "txd"))
6255 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6258 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6259 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6260 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6261 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6263 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6264 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6265 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6266 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6267 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6268 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6270 cmdline_parse_inst_t cmd_read_rxd_txd = {
6271 .f = cmd_read_rxd_txd_parsed,
6273 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6275 (void *)&cmd_read_rxd_txd_read,
6276 (void *)&cmd_read_rxd_txd_rxd_txd,
6277 (void *)&cmd_read_rxd_txd_port_id,
6278 (void *)&cmd_read_rxd_txd_queue_id,
6279 (void *)&cmd_read_rxd_txd_desc_id,
6285 struct cmd_quit_result {
6286 cmdline_fixed_string_t quit;
6289 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6291 __attribute__((unused)) void *data)
6297 cmdline_parse_token_string_t cmd_quit_quit =
6298 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6300 cmdline_parse_inst_t cmd_quit = {
6301 .f = cmd_quit_parsed,
6303 .help_str = "quit: Exit application",
6305 (void *)&cmd_quit_quit,
6310 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6311 struct cmd_mac_addr_result {
6312 cmdline_fixed_string_t mac_addr_cmd;
6313 cmdline_fixed_string_t what;
6315 struct ether_addr address;
6318 static void cmd_mac_addr_parsed(void *parsed_result,
6319 __attribute__((unused)) struct cmdline *cl,
6320 __attribute__((unused)) void *data)
6322 struct cmd_mac_addr_result *res = parsed_result;
6325 if (strcmp(res->what, "add") == 0)
6326 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6328 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6330 /* check the return value and print it if is < 0 */
6332 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6336 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6337 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6339 cmdline_parse_token_string_t cmd_mac_addr_what =
6340 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6342 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6343 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6344 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6345 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6347 cmdline_parse_inst_t cmd_mac_addr = {
6348 .f = cmd_mac_addr_parsed,
6350 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6351 "Add/Remove MAC address on port_id",
6353 (void *)&cmd_mac_addr_cmd,
6354 (void *)&cmd_mac_addr_what,
6355 (void *)&cmd_mac_addr_portnum,
6356 (void *)&cmd_mac_addr_addr,
6362 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6363 struct cmd_set_qmap_result {
6364 cmdline_fixed_string_t set;
6365 cmdline_fixed_string_t qmap;
6366 cmdline_fixed_string_t what;
6373 cmd_set_qmap_parsed(void *parsed_result,
6374 __attribute__((unused)) struct cmdline *cl,
6375 __attribute__((unused)) void *data)
6377 struct cmd_set_qmap_result *res = parsed_result;
6378 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6380 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6383 cmdline_parse_token_string_t cmd_setqmap_set =
6384 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6386 cmdline_parse_token_string_t cmd_setqmap_qmap =
6387 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6389 cmdline_parse_token_string_t cmd_setqmap_what =
6390 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6392 cmdline_parse_token_num_t cmd_setqmap_portid =
6393 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6395 cmdline_parse_token_num_t cmd_setqmap_queueid =
6396 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6398 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6399 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6402 cmdline_parse_inst_t cmd_set_qmap = {
6403 .f = cmd_set_qmap_parsed,
6405 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6406 "Set statistics mapping value on tx|rx queue_id of port_id",
6408 (void *)&cmd_setqmap_set,
6409 (void *)&cmd_setqmap_qmap,
6410 (void *)&cmd_setqmap_what,
6411 (void *)&cmd_setqmap_portid,
6412 (void *)&cmd_setqmap_queueid,
6413 (void *)&cmd_setqmap_mapvalue,
6418 /* *** CONFIGURE UNICAST HASH TABLE *** */
6419 struct cmd_set_uc_hash_table {
6420 cmdline_fixed_string_t set;
6421 cmdline_fixed_string_t port;
6423 cmdline_fixed_string_t what;
6424 struct ether_addr address;
6425 cmdline_fixed_string_t mode;
6429 cmd_set_uc_hash_parsed(void *parsed_result,
6430 __attribute__((unused)) struct cmdline *cl,
6431 __attribute__((unused)) void *data)
6434 struct cmd_set_uc_hash_table *res = parsed_result;
6436 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6438 if (strcmp(res->what, "uta") == 0)
6439 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6440 &res->address,(uint8_t)is_on);
6442 printf("bad unicast hash table parameter, return code = %d \n", ret);
6446 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6447 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6449 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6450 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6452 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6453 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6455 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6456 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6458 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6459 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6461 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6465 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6466 .f = cmd_set_uc_hash_parsed,
6468 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6470 (void *)&cmd_set_uc_hash_set,
6471 (void *)&cmd_set_uc_hash_port,
6472 (void *)&cmd_set_uc_hash_portid,
6473 (void *)&cmd_set_uc_hash_what,
6474 (void *)&cmd_set_uc_hash_mac,
6475 (void *)&cmd_set_uc_hash_mode,
6480 struct cmd_set_uc_all_hash_table {
6481 cmdline_fixed_string_t set;
6482 cmdline_fixed_string_t port;
6484 cmdline_fixed_string_t what;
6485 cmdline_fixed_string_t value;
6486 cmdline_fixed_string_t mode;
6490 cmd_set_uc_all_hash_parsed(void *parsed_result,
6491 __attribute__((unused)) struct cmdline *cl,
6492 __attribute__((unused)) void *data)
6495 struct cmd_set_uc_all_hash_table *res = parsed_result;
6497 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6499 if ((strcmp(res->what, "uta") == 0) &&
6500 (strcmp(res->value, "all") == 0))
6501 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6503 printf("bad unicast hash table parameter,"
6504 "return code = %d \n", ret);
6507 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6510 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6511 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6513 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6514 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6516 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6519 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6522 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6526 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6527 .f = cmd_set_uc_all_hash_parsed,
6529 .help_str = "set port <port_id> uta all on|off",
6531 (void *)&cmd_set_uc_all_hash_set,
6532 (void *)&cmd_set_uc_all_hash_port,
6533 (void *)&cmd_set_uc_all_hash_portid,
6534 (void *)&cmd_set_uc_all_hash_what,
6535 (void *)&cmd_set_uc_all_hash_value,
6536 (void *)&cmd_set_uc_all_hash_mode,
6541 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6542 struct cmd_set_vf_macvlan_filter {
6543 cmdline_fixed_string_t set;
6544 cmdline_fixed_string_t port;
6546 cmdline_fixed_string_t vf;
6548 struct ether_addr address;
6549 cmdline_fixed_string_t filter_type;
6550 cmdline_fixed_string_t mode;
6554 cmd_set_vf_macvlan_parsed(void *parsed_result,
6555 __attribute__((unused)) struct cmdline *cl,
6556 __attribute__((unused)) void *data)
6559 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6560 struct rte_eth_mac_filter filter;
6562 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6564 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6566 /* set VF MAC filter */
6570 filter.dst_id = res->vf_id;
6572 if (!strcmp(res->filter_type, "exact-mac"))
6573 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6574 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6575 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6576 else if (!strcmp(res->filter_type, "hashmac"))
6577 filter.filter_type = RTE_MAC_HASH_MATCH;
6578 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6579 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6581 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6584 ret = rte_eth_dev_filter_ctrl(res->port_id,
6585 RTE_ETH_FILTER_MACVLAN,
6589 ret = rte_eth_dev_filter_ctrl(res->port_id,
6590 RTE_ETH_FILTER_MACVLAN,
6591 RTE_ETH_FILTER_DELETE,
6595 printf("bad set MAC hash parameter, return code = %d\n", ret);
6599 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6602 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6605 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6606 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6608 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6609 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6611 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6612 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6614 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6615 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6617 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6618 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6619 filter_type, "exact-mac#exact-mac-vlan"
6620 "#hashmac#hashmac-vlan");
6621 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6625 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6626 .f = cmd_set_vf_macvlan_parsed,
6628 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6629 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6630 "Exact match rule: exact match of MAC or MAC and VLAN; "
6631 "hash match rule: hash match of MAC and exact match of VLAN",
6633 (void *)&cmd_set_vf_macvlan_set,
6634 (void *)&cmd_set_vf_macvlan_port,
6635 (void *)&cmd_set_vf_macvlan_portid,
6636 (void *)&cmd_set_vf_macvlan_vf,
6637 (void *)&cmd_set_vf_macvlan_vf_id,
6638 (void *)&cmd_set_vf_macvlan_mac,
6639 (void *)&cmd_set_vf_macvlan_filter_type,
6640 (void *)&cmd_set_vf_macvlan_mode,
6645 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6646 struct cmd_set_vf_traffic {
6647 cmdline_fixed_string_t set;
6648 cmdline_fixed_string_t port;
6650 cmdline_fixed_string_t vf;
6652 cmdline_fixed_string_t what;
6653 cmdline_fixed_string_t mode;
6657 cmd_set_vf_traffic_parsed(void *parsed_result,
6658 __attribute__((unused)) struct cmdline *cl,
6659 __attribute__((unused)) void *data)
6661 struct cmd_set_vf_traffic *res = parsed_result;
6662 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6663 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6665 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6668 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6671 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6672 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6674 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6675 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6677 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6680 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6681 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6683 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6686 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6690 cmdline_parse_inst_t cmd_set_vf_traffic = {
6691 .f = cmd_set_vf_traffic_parsed,
6693 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6695 (void *)&cmd_setvf_traffic_set,
6696 (void *)&cmd_setvf_traffic_port,
6697 (void *)&cmd_setvf_traffic_portid,
6698 (void *)&cmd_setvf_traffic_vf,
6699 (void *)&cmd_setvf_traffic_vfid,
6700 (void *)&cmd_setvf_traffic_what,
6701 (void *)&cmd_setvf_traffic_mode,
6706 /* *** CONFIGURE VF RECEIVE MODE *** */
6707 struct cmd_set_vf_rxmode {
6708 cmdline_fixed_string_t set;
6709 cmdline_fixed_string_t port;
6711 cmdline_fixed_string_t vf;
6713 cmdline_fixed_string_t what;
6714 cmdline_fixed_string_t mode;
6715 cmdline_fixed_string_t on;
6719 cmd_set_vf_rxmode_parsed(void *parsed_result,
6720 __attribute__((unused)) struct cmdline *cl,
6721 __attribute__((unused)) void *data)
6724 uint16_t rx_mode = 0;
6725 struct cmd_set_vf_rxmode *res = parsed_result;
6727 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6728 if (!strcmp(res->what,"rxmode")) {
6729 if (!strcmp(res->mode, "AUPE"))
6730 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6731 else if (!strcmp(res->mode, "ROPE"))
6732 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6733 else if (!strcmp(res->mode, "BAM"))
6734 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6735 else if (!strncmp(res->mode, "MPE",3))
6736 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6739 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6741 printf("bad VF receive mode parameter, return code = %d \n",
6745 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6748 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6749 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6751 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6752 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6754 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6757 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6758 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6760 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6763 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6765 mode, "AUPE#ROPE#BAM#MPE");
6766 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6767 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6770 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6771 .f = cmd_set_vf_rxmode_parsed,
6773 .help_str = "set port <port_id> vf <vf_id> rxmode "
6774 "AUPE|ROPE|BAM|MPE on|off",
6776 (void *)&cmd_set_vf_rxmode_set,
6777 (void *)&cmd_set_vf_rxmode_port,
6778 (void *)&cmd_set_vf_rxmode_portid,
6779 (void *)&cmd_set_vf_rxmode_vf,
6780 (void *)&cmd_set_vf_rxmode_vfid,
6781 (void *)&cmd_set_vf_rxmode_what,
6782 (void *)&cmd_set_vf_rxmode_mode,
6783 (void *)&cmd_set_vf_rxmode_on,
6788 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6789 struct cmd_vf_mac_addr_result {
6790 cmdline_fixed_string_t mac_addr_cmd;
6791 cmdline_fixed_string_t what;
6792 cmdline_fixed_string_t port;
6794 cmdline_fixed_string_t vf;
6796 struct ether_addr address;
6799 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6800 __attribute__((unused)) struct cmdline *cl,
6801 __attribute__((unused)) void *data)
6803 struct cmd_vf_mac_addr_result *res = parsed_result;
6806 if (strcmp(res->what, "add") == 0)
6807 ret = rte_eth_dev_mac_addr_add(res->port_num,
6808 &res->address, res->vf_num);
6810 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6814 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6815 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6816 mac_addr_cmd,"mac_addr");
6817 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6818 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6820 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6821 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6823 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6824 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6826 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6827 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6829 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6830 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6832 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6833 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6836 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6837 .f = cmd_vf_mac_addr_parsed,
6839 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6840 "Add MAC address filtering for a VF on port_id",
6842 (void *)&cmd_vf_mac_addr_cmd,
6843 (void *)&cmd_vf_mac_addr_what,
6844 (void *)&cmd_vf_mac_addr_port,
6845 (void *)&cmd_vf_mac_addr_portnum,
6846 (void *)&cmd_vf_mac_addr_vf,
6847 (void *)&cmd_vf_mac_addr_vfnum,
6848 (void *)&cmd_vf_mac_addr_addr,
6853 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6854 struct cmd_vf_rx_vlan_filter {
6855 cmdline_fixed_string_t rx_vlan;
6856 cmdline_fixed_string_t what;
6858 cmdline_fixed_string_t port;
6860 cmdline_fixed_string_t vf;
6865 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6866 __attribute__((unused)) struct cmdline *cl,
6867 __attribute__((unused)) void *data)
6869 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6871 if (!strcmp(res->what, "add"))
6872 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6874 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6877 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6878 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6879 rx_vlan, "rx_vlan");
6880 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6881 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6883 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6884 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6886 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6887 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6889 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6890 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6892 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6893 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6895 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6896 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6899 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6900 .f = cmd_vf_rx_vlan_filter_parsed,
6902 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6903 "(vf_mask = hexadecimal VF mask)",
6905 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6906 (void *)&cmd_vf_rx_vlan_filter_what,
6907 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6908 (void *)&cmd_vf_rx_vlan_filter_port,
6909 (void *)&cmd_vf_rx_vlan_filter_portid,
6910 (void *)&cmd_vf_rx_vlan_filter_vf,
6911 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6916 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6917 struct cmd_queue_rate_limit_result {
6918 cmdline_fixed_string_t set;
6919 cmdline_fixed_string_t port;
6921 cmdline_fixed_string_t queue;
6923 cmdline_fixed_string_t rate;
6927 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6928 __attribute__((unused)) struct cmdline *cl,
6929 __attribute__((unused)) void *data)
6931 struct cmd_queue_rate_limit_result *res = parsed_result;
6934 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6935 && (strcmp(res->queue, "queue") == 0)
6936 && (strcmp(res->rate, "rate") == 0))
6937 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6940 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6944 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6945 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6947 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6948 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6950 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6951 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6953 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6954 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6956 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6957 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6959 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6960 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6962 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6963 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6966 cmdline_parse_inst_t cmd_queue_rate_limit = {
6967 .f = cmd_queue_rate_limit_parsed,
6969 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6970 "Set rate limit for a queue on port_id",
6972 (void *)&cmd_queue_rate_limit_set,
6973 (void *)&cmd_queue_rate_limit_port,
6974 (void *)&cmd_queue_rate_limit_portnum,
6975 (void *)&cmd_queue_rate_limit_queue,
6976 (void *)&cmd_queue_rate_limit_queuenum,
6977 (void *)&cmd_queue_rate_limit_rate,
6978 (void *)&cmd_queue_rate_limit_ratenum,
6983 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6984 struct cmd_vf_rate_limit_result {
6985 cmdline_fixed_string_t set;
6986 cmdline_fixed_string_t port;
6988 cmdline_fixed_string_t vf;
6990 cmdline_fixed_string_t rate;
6992 cmdline_fixed_string_t q_msk;
6996 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6997 __attribute__((unused)) struct cmdline *cl,
6998 __attribute__((unused)) void *data)
7000 struct cmd_vf_rate_limit_result *res = parsed_result;
7003 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7004 && (strcmp(res->vf, "vf") == 0)
7005 && (strcmp(res->rate, "rate") == 0)
7006 && (strcmp(res->q_msk, "queue_mask") == 0))
7007 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7008 res->rate_num, res->q_msk_val);
7010 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7014 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7015 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7017 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7018 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7020 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7021 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7023 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7024 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7026 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7027 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7029 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7030 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7032 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7033 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7035 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7037 q_msk, "queue_mask");
7038 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7039 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7042 cmdline_parse_inst_t cmd_vf_rate_limit = {
7043 .f = cmd_vf_rate_limit_parsed,
7045 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7046 "queue_mask <queue_mask_value>: "
7047 "Set rate limit for queues of VF on port_id",
7049 (void *)&cmd_vf_rate_limit_set,
7050 (void *)&cmd_vf_rate_limit_port,
7051 (void *)&cmd_vf_rate_limit_portnum,
7052 (void *)&cmd_vf_rate_limit_vf,
7053 (void *)&cmd_vf_rate_limit_vfnum,
7054 (void *)&cmd_vf_rate_limit_rate,
7055 (void *)&cmd_vf_rate_limit_ratenum,
7056 (void *)&cmd_vf_rate_limit_q_msk,
7057 (void *)&cmd_vf_rate_limit_q_msk_val,
7062 /* *** ADD TUNNEL FILTER OF A PORT *** */
7063 struct cmd_tunnel_filter_result {
7064 cmdline_fixed_string_t cmd;
7065 cmdline_fixed_string_t what;
7067 struct ether_addr outer_mac;
7068 struct ether_addr inner_mac;
7069 cmdline_ipaddr_t ip_value;
7070 uint16_t inner_vlan;
7071 cmdline_fixed_string_t tunnel_type;
7072 cmdline_fixed_string_t filter_type;
7078 cmd_tunnel_filter_parsed(void *parsed_result,
7079 __attribute__((unused)) struct cmdline *cl,
7080 __attribute__((unused)) void *data)
7082 struct cmd_tunnel_filter_result *res = parsed_result;
7083 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7086 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7088 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7089 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7090 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7092 if (res->ip_value.family == AF_INET) {
7093 tunnel_filter_conf.ip_addr.ipv4_addr =
7094 res->ip_value.addr.ipv4.s_addr;
7095 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7097 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7098 &(res->ip_value.addr.ipv6),
7099 sizeof(struct in6_addr));
7100 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7103 if (!strcmp(res->filter_type, "imac-ivlan"))
7104 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7105 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7106 tunnel_filter_conf.filter_type =
7107 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7108 else if (!strcmp(res->filter_type, "imac-tenid"))
7109 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7110 else if (!strcmp(res->filter_type, "imac"))
7111 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7112 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7113 tunnel_filter_conf.filter_type =
7114 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7115 else if (!strcmp(res->filter_type, "oip"))
7116 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7117 else if (!strcmp(res->filter_type, "iip"))
7118 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7120 printf("The filter type is not supported");
7124 if (!strcmp(res->tunnel_type, "vxlan"))
7125 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7126 else if (!strcmp(res->tunnel_type, "nvgre"))
7127 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7128 else if (!strcmp(res->tunnel_type, "ipingre"))
7129 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7131 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7135 tunnel_filter_conf.tenant_id = res->tenant_id;
7136 tunnel_filter_conf.queue_id = res->queue_num;
7137 if (!strcmp(res->what, "add"))
7138 ret = rte_eth_dev_filter_ctrl(res->port_id,
7139 RTE_ETH_FILTER_TUNNEL,
7141 &tunnel_filter_conf);
7143 ret = rte_eth_dev_filter_ctrl(res->port_id,
7144 RTE_ETH_FILTER_TUNNEL,
7145 RTE_ETH_FILTER_DELETE,
7146 &tunnel_filter_conf);
7148 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7152 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7153 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7154 cmd, "tunnel_filter");
7155 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7156 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7158 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7159 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7161 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7164 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7165 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7167 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7168 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7169 inner_vlan, UINT16);
7170 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7171 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7173 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7174 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7175 tunnel_type, "vxlan#nvgre#ipingre");
7177 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7179 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7180 "imac#omac-imac-tenid");
7181 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7182 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7184 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7185 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7188 cmdline_parse_inst_t cmd_tunnel_filter = {
7189 .f = cmd_tunnel_filter_parsed,
7191 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7192 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7193 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7194 "<queue_id>: Add/Rm tunnel filter of a port",
7196 (void *)&cmd_tunnel_filter_cmd,
7197 (void *)&cmd_tunnel_filter_what,
7198 (void *)&cmd_tunnel_filter_port_id,
7199 (void *)&cmd_tunnel_filter_outer_mac,
7200 (void *)&cmd_tunnel_filter_inner_mac,
7201 (void *)&cmd_tunnel_filter_ip_value,
7202 (void *)&cmd_tunnel_filter_innner_vlan,
7203 (void *)&cmd_tunnel_filter_tunnel_type,
7204 (void *)&cmd_tunnel_filter_filter_type,
7205 (void *)&cmd_tunnel_filter_tenant_id,
7206 (void *)&cmd_tunnel_filter_queue_num,
7211 /* *** CONFIGURE TUNNEL UDP PORT *** */
7212 struct cmd_tunnel_udp_config {
7213 cmdline_fixed_string_t cmd;
7214 cmdline_fixed_string_t what;
7220 cmd_tunnel_udp_config_parsed(void *parsed_result,
7221 __attribute__((unused)) struct cmdline *cl,
7222 __attribute__((unused)) void *data)
7224 struct cmd_tunnel_udp_config *res = parsed_result;
7225 struct rte_eth_udp_tunnel tunnel_udp;
7228 tunnel_udp.udp_port = res->udp_port;
7230 if (!strcmp(res->cmd, "rx_vxlan_port"))
7231 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7233 if (!strcmp(res->what, "add"))
7234 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7237 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7241 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7244 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7245 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7246 cmd, "rx_vxlan_port");
7247 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7248 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7250 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7251 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7253 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7254 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7257 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7258 .f = cmd_tunnel_udp_config_parsed,
7260 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7261 "Add/Remove a tunneling UDP port filter",
7263 (void *)&cmd_tunnel_udp_config_cmd,
7264 (void *)&cmd_tunnel_udp_config_what,
7265 (void *)&cmd_tunnel_udp_config_udp_port,
7266 (void *)&cmd_tunnel_udp_config_port_id,
7271 /* *** GLOBAL CONFIG *** */
7272 struct cmd_global_config_result {
7273 cmdline_fixed_string_t cmd;
7275 cmdline_fixed_string_t cfg_type;
7280 cmd_global_config_parsed(void *parsed_result,
7281 __attribute__((unused)) struct cmdline *cl,
7282 __attribute__((unused)) void *data)
7284 struct cmd_global_config_result *res = parsed_result;
7285 struct rte_eth_global_cfg conf;
7288 memset(&conf, 0, sizeof(conf));
7289 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7290 conf.cfg.gre_key_len = res->len;
7291 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7292 RTE_ETH_FILTER_SET, &conf);
7294 printf("Global config error\n");
7297 cmdline_parse_token_string_t cmd_global_config_cmd =
7298 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7300 cmdline_parse_token_num_t cmd_global_config_port_id =
7301 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7302 cmdline_parse_token_string_t cmd_global_config_type =
7303 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7304 cfg_type, "gre-key-len");
7305 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7306 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7309 cmdline_parse_inst_t cmd_global_config = {
7310 .f = cmd_global_config_parsed,
7311 .data = (void *)NULL,
7312 .help_str = "global_config <port_id> gre-key-len <key_len>",
7314 (void *)&cmd_global_config_cmd,
7315 (void *)&cmd_global_config_port_id,
7316 (void *)&cmd_global_config_type,
7317 (void *)&cmd_global_config_gre_key_len,
7322 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7323 struct cmd_set_mirror_mask_result {
7324 cmdline_fixed_string_t set;
7325 cmdline_fixed_string_t port;
7327 cmdline_fixed_string_t mirror;
7329 cmdline_fixed_string_t what;
7330 cmdline_fixed_string_t value;
7331 cmdline_fixed_string_t dstpool;
7333 cmdline_fixed_string_t on;
7336 cmdline_parse_token_string_t cmd_mirror_mask_set =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7339 cmdline_parse_token_string_t cmd_mirror_mask_port =
7340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7342 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7343 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7345 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7346 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7347 mirror, "mirror-rule");
7348 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7349 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7351 cmdline_parse_token_string_t cmd_mirror_mask_what =
7352 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7353 what, "pool-mirror-up#pool-mirror-down"
7355 cmdline_parse_token_string_t cmd_mirror_mask_value =
7356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7358 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7360 dstpool, "dst-pool");
7361 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7362 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7364 cmdline_parse_token_string_t cmd_mirror_mask_on =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7369 cmd_set_mirror_mask_parsed(void *parsed_result,
7370 __attribute__((unused)) struct cmdline *cl,
7371 __attribute__((unused)) void *data)
7374 struct cmd_set_mirror_mask_result *res = parsed_result;
7375 struct rte_eth_mirror_conf mr_conf;
7377 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7379 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7381 mr_conf.dst_pool = res->dstpool_id;
7383 if (!strcmp(res->what, "pool-mirror-up")) {
7384 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7385 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7386 } else if (!strcmp(res->what, "pool-mirror-down")) {
7387 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7388 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7389 } else if (!strcmp(res->what, "vlan-mirror")) {
7390 mr_conf.rule_type = ETH_MIRROR_VLAN;
7391 nb_item = parse_item_list(res->value, "vlan",
7392 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7396 for (i = 0; i < nb_item; i++) {
7397 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7398 printf("Invalid vlan_id: must be < 4096\n");
7402 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7403 mr_conf.vlan.vlan_mask |= 1ULL << i;
7407 if (!strcmp(res->on, "on"))
7408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7411 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7414 printf("mirror rule add error: (%s)\n", strerror(-ret));
7417 cmdline_parse_inst_t cmd_set_mirror_mask = {
7418 .f = cmd_set_mirror_mask_parsed,
7420 .help_str = "set port <port_id> mirror-rule <rule_id> "
7421 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7422 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7424 (void *)&cmd_mirror_mask_set,
7425 (void *)&cmd_mirror_mask_port,
7426 (void *)&cmd_mirror_mask_portid,
7427 (void *)&cmd_mirror_mask_mirror,
7428 (void *)&cmd_mirror_mask_ruleid,
7429 (void *)&cmd_mirror_mask_what,
7430 (void *)&cmd_mirror_mask_value,
7431 (void *)&cmd_mirror_mask_dstpool,
7432 (void *)&cmd_mirror_mask_poolid,
7433 (void *)&cmd_mirror_mask_on,
7438 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7439 struct cmd_set_mirror_link_result {
7440 cmdline_fixed_string_t set;
7441 cmdline_fixed_string_t port;
7443 cmdline_fixed_string_t mirror;
7445 cmdline_fixed_string_t what;
7446 cmdline_fixed_string_t dstpool;
7448 cmdline_fixed_string_t on;
7451 cmdline_parse_token_string_t cmd_mirror_link_set =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7454 cmdline_parse_token_string_t cmd_mirror_link_port =
7455 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7457 cmdline_parse_token_num_t cmd_mirror_link_portid =
7458 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7460 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7461 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7462 mirror, "mirror-rule");
7463 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7464 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7466 cmdline_parse_token_string_t cmd_mirror_link_what =
7467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7468 what, "uplink-mirror#downlink-mirror");
7469 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7470 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7471 dstpool, "dst-pool");
7472 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7473 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7475 cmdline_parse_token_string_t cmd_mirror_link_on =
7476 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7480 cmd_set_mirror_link_parsed(void *parsed_result,
7481 __attribute__((unused)) struct cmdline *cl,
7482 __attribute__((unused)) void *data)
7485 struct cmd_set_mirror_link_result *res = parsed_result;
7486 struct rte_eth_mirror_conf mr_conf;
7488 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7489 if (!strcmp(res->what, "uplink-mirror"))
7490 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7492 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7494 mr_conf.dst_pool = res->dstpool_id;
7496 if (!strcmp(res->on, "on"))
7497 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7500 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7503 /* check the return value and print it if is < 0 */
7505 printf("mirror rule add error: (%s)\n", strerror(-ret));
7509 cmdline_parse_inst_t cmd_set_mirror_link = {
7510 .f = cmd_set_mirror_link_parsed,
7512 .help_str = "set port <port_id> mirror-rule <rule_id> "
7513 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7515 (void *)&cmd_mirror_link_set,
7516 (void *)&cmd_mirror_link_port,
7517 (void *)&cmd_mirror_link_portid,
7518 (void *)&cmd_mirror_link_mirror,
7519 (void *)&cmd_mirror_link_ruleid,
7520 (void *)&cmd_mirror_link_what,
7521 (void *)&cmd_mirror_link_dstpool,
7522 (void *)&cmd_mirror_link_poolid,
7523 (void *)&cmd_mirror_link_on,
7528 /* *** RESET VM MIRROR RULE *** */
7529 struct cmd_rm_mirror_rule_result {
7530 cmdline_fixed_string_t reset;
7531 cmdline_fixed_string_t port;
7533 cmdline_fixed_string_t mirror;
7537 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7538 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7540 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7541 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7543 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7544 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7546 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7547 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7548 mirror, "mirror-rule");
7549 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7550 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7554 cmd_reset_mirror_rule_parsed(void *parsed_result,
7555 __attribute__((unused)) struct cmdline *cl,
7556 __attribute__((unused)) void *data)
7559 struct cmd_set_mirror_link_result *res = parsed_result;
7561 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7563 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7566 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7567 .f = cmd_reset_mirror_rule_parsed,
7569 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7571 (void *)&cmd_rm_mirror_rule_reset,
7572 (void *)&cmd_rm_mirror_rule_port,
7573 (void *)&cmd_rm_mirror_rule_portid,
7574 (void *)&cmd_rm_mirror_rule_mirror,
7575 (void *)&cmd_rm_mirror_rule_ruleid,
7580 /* ******************************************************************************** */
7582 struct cmd_dump_result {
7583 cmdline_fixed_string_t dump;
7587 dump_struct_sizes(void)
7589 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7590 DUMP_SIZE(struct rte_mbuf);
7591 DUMP_SIZE(struct rte_mempool);
7592 DUMP_SIZE(struct rte_ring);
7596 static void cmd_dump_parsed(void *parsed_result,
7597 __attribute__((unused)) struct cmdline *cl,
7598 __attribute__((unused)) void *data)
7600 struct cmd_dump_result *res = parsed_result;
7602 if (!strcmp(res->dump, "dump_physmem"))
7603 rte_dump_physmem_layout(stdout);
7604 else if (!strcmp(res->dump, "dump_memzone"))
7605 rte_memzone_dump(stdout);
7606 else if (!strcmp(res->dump, "dump_struct_sizes"))
7607 dump_struct_sizes();
7608 else if (!strcmp(res->dump, "dump_ring"))
7609 rte_ring_list_dump(stdout);
7610 else if (!strcmp(res->dump, "dump_mempool"))
7611 rte_mempool_list_dump(stdout);
7612 else if (!strcmp(res->dump, "dump_devargs"))
7613 rte_eal_devargs_dump(stdout);
7616 cmdline_parse_token_string_t cmd_dump_dump =
7617 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7620 "dump_struct_sizes#"
7625 cmdline_parse_inst_t cmd_dump = {
7626 .f = cmd_dump_parsed, /* function to call */
7627 .data = NULL, /* 2nd arg of func */
7628 .help_str = "Dump status",
7629 .tokens = { /* token list, NULL terminated */
7630 (void *)&cmd_dump_dump,
7635 /* ******************************************************************************** */
7637 struct cmd_dump_one_result {
7638 cmdline_fixed_string_t dump;
7639 cmdline_fixed_string_t name;
7642 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7643 __attribute__((unused)) void *data)
7645 struct cmd_dump_one_result *res = parsed_result;
7647 if (!strcmp(res->dump, "dump_ring")) {
7649 r = rte_ring_lookup(res->name);
7651 cmdline_printf(cl, "Cannot find ring\n");
7654 rte_ring_dump(stdout, r);
7655 } else if (!strcmp(res->dump, "dump_mempool")) {
7656 struct rte_mempool *mp;
7657 mp = rte_mempool_lookup(res->name);
7659 cmdline_printf(cl, "Cannot find mempool\n");
7662 rte_mempool_dump(stdout, mp);
7666 cmdline_parse_token_string_t cmd_dump_one_dump =
7667 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7668 "dump_ring#dump_mempool");
7670 cmdline_parse_token_string_t cmd_dump_one_name =
7671 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7673 cmdline_parse_inst_t cmd_dump_one = {
7674 .f = cmd_dump_one_parsed, /* function to call */
7675 .data = NULL, /* 2nd arg of func */
7676 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7677 .tokens = { /* token list, NULL terminated */
7678 (void *)&cmd_dump_one_dump,
7679 (void *)&cmd_dump_one_name,
7684 /* *** Add/Del syn filter *** */
7685 struct cmd_syn_filter_result {
7686 cmdline_fixed_string_t filter;
7688 cmdline_fixed_string_t ops;
7689 cmdline_fixed_string_t priority;
7690 cmdline_fixed_string_t high;
7691 cmdline_fixed_string_t queue;
7696 cmd_syn_filter_parsed(void *parsed_result,
7697 __attribute__((unused)) struct cmdline *cl,
7698 __attribute__((unused)) void *data)
7700 struct cmd_syn_filter_result *res = parsed_result;
7701 struct rte_eth_syn_filter syn_filter;
7704 ret = rte_eth_dev_filter_supported(res->port_id,
7705 RTE_ETH_FILTER_SYN);
7707 printf("syn filter is not supported on port %u.\n",
7712 memset(&syn_filter, 0, sizeof(syn_filter));
7714 if (!strcmp(res->ops, "add")) {
7715 if (!strcmp(res->high, "high"))
7716 syn_filter.hig_pri = 1;
7718 syn_filter.hig_pri = 0;
7720 syn_filter.queue = res->queue_id;
7721 ret = rte_eth_dev_filter_ctrl(res->port_id,
7726 ret = rte_eth_dev_filter_ctrl(res->port_id,
7728 RTE_ETH_FILTER_DELETE,
7732 printf("syn filter programming error: (%s)\n",
7736 cmdline_parse_token_string_t cmd_syn_filter_filter =
7737 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7738 filter, "syn_filter");
7739 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7740 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7742 cmdline_parse_token_string_t cmd_syn_filter_ops =
7743 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7745 cmdline_parse_token_string_t cmd_syn_filter_priority =
7746 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7747 priority, "priority");
7748 cmdline_parse_token_string_t cmd_syn_filter_high =
7749 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7751 cmdline_parse_token_string_t cmd_syn_filter_queue =
7752 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7754 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7755 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7758 cmdline_parse_inst_t cmd_syn_filter = {
7759 .f = cmd_syn_filter_parsed,
7761 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7762 "<queue_id>: Add/Delete syn filter",
7764 (void *)&cmd_syn_filter_filter,
7765 (void *)&cmd_syn_filter_port_id,
7766 (void *)&cmd_syn_filter_ops,
7767 (void *)&cmd_syn_filter_priority,
7768 (void *)&cmd_syn_filter_high,
7769 (void *)&cmd_syn_filter_queue,
7770 (void *)&cmd_syn_filter_queue_id,
7775 /* *** ADD/REMOVE A 2tuple FILTER *** */
7776 struct cmd_2tuple_filter_result {
7777 cmdline_fixed_string_t filter;
7779 cmdline_fixed_string_t ops;
7780 cmdline_fixed_string_t dst_port;
7781 uint16_t dst_port_value;
7782 cmdline_fixed_string_t protocol;
7783 uint8_t protocol_value;
7784 cmdline_fixed_string_t mask;
7786 cmdline_fixed_string_t tcp_flags;
7787 uint8_t tcp_flags_value;
7788 cmdline_fixed_string_t priority;
7789 uint8_t priority_value;
7790 cmdline_fixed_string_t queue;
7795 cmd_2tuple_filter_parsed(void *parsed_result,
7796 __attribute__((unused)) struct cmdline *cl,
7797 __attribute__((unused)) void *data)
7799 struct rte_eth_ntuple_filter filter;
7800 struct cmd_2tuple_filter_result *res = parsed_result;
7803 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7805 printf("ntuple filter is not supported on port %u.\n",
7810 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7812 filter.flags = RTE_2TUPLE_FLAGS;
7813 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7814 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7815 filter.proto = res->protocol_value;
7816 filter.priority = res->priority_value;
7817 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7818 printf("nonzero tcp_flags is only meaningful"
7819 " when protocol is TCP.\n");
7822 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7823 printf("invalid TCP flags.\n");
7827 if (res->tcp_flags_value != 0) {
7828 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7829 filter.tcp_flags = res->tcp_flags_value;
7832 /* need convert to big endian. */
7833 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7834 filter.queue = res->queue_id;
7836 if (!strcmp(res->ops, "add"))
7837 ret = rte_eth_dev_filter_ctrl(res->port_id,
7838 RTE_ETH_FILTER_NTUPLE,
7842 ret = rte_eth_dev_filter_ctrl(res->port_id,
7843 RTE_ETH_FILTER_NTUPLE,
7844 RTE_ETH_FILTER_DELETE,
7847 printf("2tuple filter programming error: (%s)\n",
7852 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7853 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7854 filter, "2tuple_filter");
7855 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7856 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7858 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7859 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7861 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7862 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7863 dst_port, "dst_port");
7864 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7865 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7866 dst_port_value, UINT16);
7867 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7868 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7869 protocol, "protocol");
7870 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7871 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7872 protocol_value, UINT8);
7873 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7874 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7876 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7877 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7879 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7880 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7881 tcp_flags, "tcp_flags");
7882 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7883 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7884 tcp_flags_value, UINT8);
7885 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7886 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7887 priority, "priority");
7888 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7889 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7890 priority_value, UINT8);
7891 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7892 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7894 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7895 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7898 cmdline_parse_inst_t cmd_2tuple_filter = {
7899 .f = cmd_2tuple_filter_parsed,
7901 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7902 "<value> mask <value> tcp_flags <value> priority <value> queue "
7903 "<queue_id>: Add a 2tuple filter",
7905 (void *)&cmd_2tuple_filter_filter,
7906 (void *)&cmd_2tuple_filter_port_id,
7907 (void *)&cmd_2tuple_filter_ops,
7908 (void *)&cmd_2tuple_filter_dst_port,
7909 (void *)&cmd_2tuple_filter_dst_port_value,
7910 (void *)&cmd_2tuple_filter_protocol,
7911 (void *)&cmd_2tuple_filter_protocol_value,
7912 (void *)&cmd_2tuple_filter_mask,
7913 (void *)&cmd_2tuple_filter_mask_value,
7914 (void *)&cmd_2tuple_filter_tcp_flags,
7915 (void *)&cmd_2tuple_filter_tcp_flags_value,
7916 (void *)&cmd_2tuple_filter_priority,
7917 (void *)&cmd_2tuple_filter_priority_value,
7918 (void *)&cmd_2tuple_filter_queue,
7919 (void *)&cmd_2tuple_filter_queue_id,
7924 /* *** ADD/REMOVE A 5tuple FILTER *** */
7925 struct cmd_5tuple_filter_result {
7926 cmdline_fixed_string_t filter;
7928 cmdline_fixed_string_t ops;
7929 cmdline_fixed_string_t dst_ip;
7930 cmdline_ipaddr_t dst_ip_value;
7931 cmdline_fixed_string_t src_ip;
7932 cmdline_ipaddr_t src_ip_value;
7933 cmdline_fixed_string_t dst_port;
7934 uint16_t dst_port_value;
7935 cmdline_fixed_string_t src_port;
7936 uint16_t src_port_value;
7937 cmdline_fixed_string_t protocol;
7938 uint8_t protocol_value;
7939 cmdline_fixed_string_t mask;
7941 cmdline_fixed_string_t tcp_flags;
7942 uint8_t tcp_flags_value;
7943 cmdline_fixed_string_t priority;
7944 uint8_t priority_value;
7945 cmdline_fixed_string_t queue;
7950 cmd_5tuple_filter_parsed(void *parsed_result,
7951 __attribute__((unused)) struct cmdline *cl,
7952 __attribute__((unused)) void *data)
7954 struct rte_eth_ntuple_filter filter;
7955 struct cmd_5tuple_filter_result *res = parsed_result;
7958 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7960 printf("ntuple filter is not supported on port %u.\n",
7965 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7967 filter.flags = RTE_5TUPLE_FLAGS;
7968 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7969 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7970 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7971 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7972 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7973 filter.proto = res->protocol_value;
7974 filter.priority = res->priority_value;
7975 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7976 printf("nonzero tcp_flags is only meaningful"
7977 " when protocol is TCP.\n");
7980 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7981 printf("invalid TCP flags.\n");
7985 if (res->tcp_flags_value != 0) {
7986 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7987 filter.tcp_flags = res->tcp_flags_value;
7990 if (res->dst_ip_value.family == AF_INET)
7991 /* no need to convert, already big endian. */
7992 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7994 if (filter.dst_ip_mask == 0) {
7995 printf("can not support ipv6 involved compare.\n");
8001 if (res->src_ip_value.family == AF_INET)
8002 /* no need to convert, already big endian. */
8003 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8005 if (filter.src_ip_mask == 0) {
8006 printf("can not support ipv6 involved compare.\n");
8011 /* need convert to big endian. */
8012 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8013 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8014 filter.queue = res->queue_id;
8016 if (!strcmp(res->ops, "add"))
8017 ret = rte_eth_dev_filter_ctrl(res->port_id,
8018 RTE_ETH_FILTER_NTUPLE,
8022 ret = rte_eth_dev_filter_ctrl(res->port_id,
8023 RTE_ETH_FILTER_NTUPLE,
8024 RTE_ETH_FILTER_DELETE,
8027 printf("5tuple filter programming error: (%s)\n",
8031 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8032 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8033 filter, "5tuple_filter");
8034 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8035 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8037 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8038 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8040 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8041 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8043 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8044 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8046 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8047 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8049 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8050 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8052 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8053 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8054 dst_port, "dst_port");
8055 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8056 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8057 dst_port_value, UINT16);
8058 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8059 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8060 src_port, "src_port");
8061 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8062 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8063 src_port_value, UINT16);
8064 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8065 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8066 protocol, "protocol");
8067 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8068 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8069 protocol_value, UINT8);
8070 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8071 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8073 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8074 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8076 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8077 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8078 tcp_flags, "tcp_flags");
8079 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8080 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8081 tcp_flags_value, UINT8);
8082 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8083 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8084 priority, "priority");
8085 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8086 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8087 priority_value, UINT8);
8088 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8089 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8091 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8092 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8095 cmdline_parse_inst_t cmd_5tuple_filter = {
8096 .f = cmd_5tuple_filter_parsed,
8098 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8099 "src_ip <value> dst_port <value> src_port <value> "
8100 "protocol <value> mask <value> tcp_flags <value> "
8101 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8103 (void *)&cmd_5tuple_filter_filter,
8104 (void *)&cmd_5tuple_filter_port_id,
8105 (void *)&cmd_5tuple_filter_ops,
8106 (void *)&cmd_5tuple_filter_dst_ip,
8107 (void *)&cmd_5tuple_filter_dst_ip_value,
8108 (void *)&cmd_5tuple_filter_src_ip,
8109 (void *)&cmd_5tuple_filter_src_ip_value,
8110 (void *)&cmd_5tuple_filter_dst_port,
8111 (void *)&cmd_5tuple_filter_dst_port_value,
8112 (void *)&cmd_5tuple_filter_src_port,
8113 (void *)&cmd_5tuple_filter_src_port_value,
8114 (void *)&cmd_5tuple_filter_protocol,
8115 (void *)&cmd_5tuple_filter_protocol_value,
8116 (void *)&cmd_5tuple_filter_mask,
8117 (void *)&cmd_5tuple_filter_mask_value,
8118 (void *)&cmd_5tuple_filter_tcp_flags,
8119 (void *)&cmd_5tuple_filter_tcp_flags_value,
8120 (void *)&cmd_5tuple_filter_priority,
8121 (void *)&cmd_5tuple_filter_priority_value,
8122 (void *)&cmd_5tuple_filter_queue,
8123 (void *)&cmd_5tuple_filter_queue_id,
8128 /* *** ADD/REMOVE A flex FILTER *** */
8129 struct cmd_flex_filter_result {
8130 cmdline_fixed_string_t filter;
8131 cmdline_fixed_string_t ops;
8133 cmdline_fixed_string_t len;
8135 cmdline_fixed_string_t bytes;
8136 cmdline_fixed_string_t bytes_value;
8137 cmdline_fixed_string_t mask;
8138 cmdline_fixed_string_t mask_value;
8139 cmdline_fixed_string_t priority;
8140 uint8_t priority_value;
8141 cmdline_fixed_string_t queue;
8145 static int xdigit2val(unsigned char c)
8150 else if (isupper(c))
8158 cmd_flex_filter_parsed(void *parsed_result,
8159 __attribute__((unused)) struct cmdline *cl,
8160 __attribute__((unused)) void *data)
8163 struct rte_eth_flex_filter filter;
8164 struct cmd_flex_filter_result *res = parsed_result;
8165 char *bytes_ptr, *mask_ptr;
8166 uint16_t len, i, j = 0;
8171 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8172 printf("the len exceed the max length 128\n");
8175 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8176 filter.len = res->len_value;
8177 filter.priority = res->priority_value;
8178 filter.queue = res->queue_id;
8179 bytes_ptr = res->bytes_value;
8180 mask_ptr = res->mask_value;
8182 /* translate bytes string to array. */
8183 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8184 (bytes_ptr[1] == 'X')))
8186 len = strnlen(bytes_ptr, res->len_value * 2);
8187 if (len == 0 || (len % 8 != 0)) {
8188 printf("please check len and bytes input\n");
8191 for (i = 0; i < len; i++) {
8193 if (isxdigit(c) == 0) {
8194 /* invalid characters. */
8195 printf("invalid input\n");
8198 val = xdigit2val(c);
8201 filter.bytes[j] = byte;
8202 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8209 /* translate mask string to uint8_t array. */
8210 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8211 (mask_ptr[1] == 'X')))
8213 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8215 printf("invalid input\n");
8220 for (i = 0; i < len; i++) {
8222 if (isxdigit(c) == 0) {
8223 /* invalid characters. */
8224 printf("invalid input\n");
8227 val = xdigit2val(c);
8230 filter.mask[j] = byte;
8231 printf("mask[%d]:%02x ", j, filter.mask[j]);
8239 if (!strcmp(res->ops, "add"))
8240 ret = rte_eth_dev_filter_ctrl(res->port_id,
8241 RTE_ETH_FILTER_FLEXIBLE,
8245 ret = rte_eth_dev_filter_ctrl(res->port_id,
8246 RTE_ETH_FILTER_FLEXIBLE,
8247 RTE_ETH_FILTER_DELETE,
8251 printf("flex filter setting error: (%s)\n", strerror(-ret));
8254 cmdline_parse_token_string_t cmd_flex_filter_filter =
8255 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8256 filter, "flex_filter");
8257 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8258 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8260 cmdline_parse_token_string_t cmd_flex_filter_ops =
8261 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8263 cmdline_parse_token_string_t cmd_flex_filter_len =
8264 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8266 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8267 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8269 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8270 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8272 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8273 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8275 cmdline_parse_token_string_t cmd_flex_filter_mask =
8276 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8278 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8279 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8281 cmdline_parse_token_string_t cmd_flex_filter_priority =
8282 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8283 priority, "priority");
8284 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8285 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8286 priority_value, UINT8);
8287 cmdline_parse_token_string_t cmd_flex_filter_queue =
8288 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8290 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8291 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8293 cmdline_parse_inst_t cmd_flex_filter = {
8294 .f = cmd_flex_filter_parsed,
8296 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8297 "<value> mask <value> priority <value> queue <queue_id>: "
8298 "Add/Del a flex filter",
8300 (void *)&cmd_flex_filter_filter,
8301 (void *)&cmd_flex_filter_port_id,
8302 (void *)&cmd_flex_filter_ops,
8303 (void *)&cmd_flex_filter_len,
8304 (void *)&cmd_flex_filter_len_value,
8305 (void *)&cmd_flex_filter_bytes,
8306 (void *)&cmd_flex_filter_bytes_value,
8307 (void *)&cmd_flex_filter_mask,
8308 (void *)&cmd_flex_filter_mask_value,
8309 (void *)&cmd_flex_filter_priority,
8310 (void *)&cmd_flex_filter_priority_value,
8311 (void *)&cmd_flex_filter_queue,
8312 (void *)&cmd_flex_filter_queue_id,
8317 /* *** Filters Control *** */
8319 /* *** deal with ethertype filter *** */
8320 struct cmd_ethertype_filter_result {
8321 cmdline_fixed_string_t filter;
8323 cmdline_fixed_string_t ops;
8324 cmdline_fixed_string_t mac;
8325 struct ether_addr mac_addr;
8326 cmdline_fixed_string_t ethertype;
8327 uint16_t ethertype_value;
8328 cmdline_fixed_string_t drop;
8329 cmdline_fixed_string_t queue;
8333 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8334 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8335 filter, "ethertype_filter");
8336 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8337 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8339 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8340 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8342 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8343 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8344 mac, "mac_addr#mac_ignr");
8345 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8346 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8348 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8349 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8350 ethertype, "ethertype");
8351 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8352 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8353 ethertype_value, UINT16);
8354 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8355 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8357 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8358 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8360 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8361 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8365 cmd_ethertype_filter_parsed(void *parsed_result,
8366 __attribute__((unused)) struct cmdline *cl,
8367 __attribute__((unused)) void *data)
8369 struct cmd_ethertype_filter_result *res = parsed_result;
8370 struct rte_eth_ethertype_filter filter;
8373 ret = rte_eth_dev_filter_supported(res->port_id,
8374 RTE_ETH_FILTER_ETHERTYPE);
8376 printf("ethertype filter is not supported on port %u.\n",
8381 memset(&filter, 0, sizeof(filter));
8382 if (!strcmp(res->mac, "mac_addr")) {
8383 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8384 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8385 sizeof(struct ether_addr));
8387 if (!strcmp(res->drop, "drop"))
8388 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8389 filter.ether_type = res->ethertype_value;
8390 filter.queue = res->queue_id;
8392 if (!strcmp(res->ops, "add"))
8393 ret = rte_eth_dev_filter_ctrl(res->port_id,
8394 RTE_ETH_FILTER_ETHERTYPE,
8398 ret = rte_eth_dev_filter_ctrl(res->port_id,
8399 RTE_ETH_FILTER_ETHERTYPE,
8400 RTE_ETH_FILTER_DELETE,
8403 printf("ethertype filter programming error: (%s)\n",
8407 cmdline_parse_inst_t cmd_ethertype_filter = {
8408 .f = cmd_ethertype_filter_parsed,
8410 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8411 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8412 "Add or delete an ethertype filter entry",
8414 (void *)&cmd_ethertype_filter_filter,
8415 (void *)&cmd_ethertype_filter_port_id,
8416 (void *)&cmd_ethertype_filter_ops,
8417 (void *)&cmd_ethertype_filter_mac,
8418 (void *)&cmd_ethertype_filter_mac_addr,
8419 (void *)&cmd_ethertype_filter_ethertype,
8420 (void *)&cmd_ethertype_filter_ethertype_value,
8421 (void *)&cmd_ethertype_filter_drop,
8422 (void *)&cmd_ethertype_filter_queue,
8423 (void *)&cmd_ethertype_filter_queue_id,
8428 /* *** deal with flow director filter *** */
8429 struct cmd_flow_director_result {
8430 cmdline_fixed_string_t flow_director_filter;
8432 cmdline_fixed_string_t mode;
8433 cmdline_fixed_string_t mode_value;
8434 cmdline_fixed_string_t ops;
8435 cmdline_fixed_string_t flow;
8436 cmdline_fixed_string_t flow_type;
8437 cmdline_fixed_string_t ether;
8438 uint16_t ether_type;
8439 cmdline_fixed_string_t src;
8440 cmdline_ipaddr_t ip_src;
8442 cmdline_fixed_string_t dst;
8443 cmdline_ipaddr_t ip_dst;
8445 cmdline_fixed_string_t verify_tag;
8446 uint32_t verify_tag_value;
8447 cmdline_ipaddr_t tos;
8449 cmdline_ipaddr_t proto;
8450 uint8_t proto_value;
8451 cmdline_ipaddr_t ttl;
8453 cmdline_fixed_string_t vlan;
8454 uint16_t vlan_value;
8455 cmdline_fixed_string_t flexbytes;
8456 cmdline_fixed_string_t flexbytes_value;
8457 cmdline_fixed_string_t pf_vf;
8458 cmdline_fixed_string_t drop;
8459 cmdline_fixed_string_t queue;
8461 cmdline_fixed_string_t fd_id;
8462 uint32_t fd_id_value;
8463 cmdline_fixed_string_t mac;
8464 struct ether_addr mac_addr;
8465 cmdline_fixed_string_t tunnel;
8466 cmdline_fixed_string_t tunnel_type;
8467 cmdline_fixed_string_t tunnel_id;
8468 uint32_t tunnel_id_value;
8472 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8475 const char *p, *p0 = q_arg;
8477 unsigned long int_fld;
8478 char *str_fld[max_num];
8483 p = strchr(p0, '(');
8487 p0 = strchr(p, ')');
8492 if (size >= sizeof(s))
8495 snprintf(s, sizeof(s), "%.*s", size, p);
8496 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8497 if (ret < 0 || ret > max_num)
8499 for (i = 0; i < ret; i++) {
8501 int_fld = strtoul(str_fld[i], &end, 0);
8502 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8504 flexbytes[i] = (uint8_t)int_fld;
8510 str2flowtype(char *string)
8513 static const struct {
8516 } flowtype_str[] = {
8517 {"raw", RTE_ETH_FLOW_RAW},
8518 {"ipv4", RTE_ETH_FLOW_IPV4},
8519 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8520 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8521 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8522 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8523 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8524 {"ipv6", RTE_ETH_FLOW_IPV6},
8525 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8526 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8527 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8528 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8529 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8530 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8533 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8534 if (!strcmp(flowtype_str[i].str, string))
8535 return flowtype_str[i].type;
8537 return RTE_ETH_FLOW_UNKNOWN;
8540 static enum rte_eth_fdir_tunnel_type
8541 str2fdir_tunneltype(char *string)
8545 static const struct {
8547 enum rte_eth_fdir_tunnel_type type;
8548 } tunneltype_str[] = {
8549 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8550 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8553 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8554 if (!strcmp(tunneltype_str[i].str, string))
8555 return tunneltype_str[i].type;
8557 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8560 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8562 if ((ip_addr).family == AF_INET) \
8563 (ip) = (ip_addr).addr.ipv4.s_addr; \
8565 printf("invalid parameter.\n"); \
8570 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8572 if ((ip_addr).family == AF_INET6) \
8573 (void)rte_memcpy(&(ip), \
8574 &((ip_addr).addr.ipv6), \
8575 sizeof(struct in6_addr)); \
8577 printf("invalid parameter.\n"); \
8583 cmd_flow_director_filter_parsed(void *parsed_result,
8584 __attribute__((unused)) struct cmdline *cl,
8585 __attribute__((unused)) void *data)
8587 struct cmd_flow_director_result *res = parsed_result;
8588 struct rte_eth_fdir_filter entry;
8589 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8591 unsigned long vf_id;
8594 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8596 printf("flow director is not supported on port %u.\n",
8600 memset(flexbytes, 0, sizeof(flexbytes));
8601 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8603 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8604 if (strcmp(res->mode_value, "MAC-VLAN")) {
8605 printf("Please set mode to MAC-VLAN.\n");
8608 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8609 if (strcmp(res->mode_value, "Tunnel")) {
8610 printf("Please set mode to Tunnel.\n");
8614 if (strcmp(res->mode_value, "IP")) {
8615 printf("Please set mode to IP.\n");
8618 entry.input.flow_type = str2flowtype(res->flow_type);
8621 ret = parse_flexbytes(res->flexbytes_value,
8623 RTE_ETH_FDIR_MAX_FLEXLEN);
8625 printf("error: Cannot parse flexbytes input.\n");
8629 switch (entry.input.flow_type) {
8630 case RTE_ETH_FLOW_FRAG_IPV4:
8631 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8632 entry.input.flow.ip4_flow.proto = res->proto_value;
8633 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8634 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8635 IPV4_ADDR_TO_UINT(res->ip_dst,
8636 entry.input.flow.ip4_flow.dst_ip);
8637 IPV4_ADDR_TO_UINT(res->ip_src,
8638 entry.input.flow.ip4_flow.src_ip);
8639 entry.input.flow.ip4_flow.tos = res->tos_value;
8640 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8641 /* need convert to big endian. */
8642 entry.input.flow.udp4_flow.dst_port =
8643 rte_cpu_to_be_16(res->port_dst);
8644 entry.input.flow.udp4_flow.src_port =
8645 rte_cpu_to_be_16(res->port_src);
8647 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8648 IPV4_ADDR_TO_UINT(res->ip_dst,
8649 entry.input.flow.sctp4_flow.ip.dst_ip);
8650 IPV4_ADDR_TO_UINT(res->ip_src,
8651 entry.input.flow.sctp4_flow.ip.src_ip);
8652 entry.input.flow.ip4_flow.tos = res->tos_value;
8653 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8654 /* need convert to big endian. */
8655 entry.input.flow.sctp4_flow.dst_port =
8656 rte_cpu_to_be_16(res->port_dst);
8657 entry.input.flow.sctp4_flow.src_port =
8658 rte_cpu_to_be_16(res->port_src);
8659 entry.input.flow.sctp4_flow.verify_tag =
8660 rte_cpu_to_be_32(res->verify_tag_value);
8662 case RTE_ETH_FLOW_FRAG_IPV6:
8663 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8664 entry.input.flow.ipv6_flow.proto = res->proto_value;
8665 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8666 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8667 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8668 entry.input.flow.ipv6_flow.dst_ip);
8669 IPV6_ADDR_TO_ARRAY(res->ip_src,
8670 entry.input.flow.ipv6_flow.src_ip);
8671 entry.input.flow.ipv6_flow.tc = res->tos_value;
8672 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8673 /* need convert to big endian. */
8674 entry.input.flow.udp6_flow.dst_port =
8675 rte_cpu_to_be_16(res->port_dst);
8676 entry.input.flow.udp6_flow.src_port =
8677 rte_cpu_to_be_16(res->port_src);
8679 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8680 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8681 entry.input.flow.sctp6_flow.ip.dst_ip);
8682 IPV6_ADDR_TO_ARRAY(res->ip_src,
8683 entry.input.flow.sctp6_flow.ip.src_ip);
8684 entry.input.flow.ipv6_flow.tc = res->tos_value;
8685 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8686 /* need convert to big endian. */
8687 entry.input.flow.sctp6_flow.dst_port =
8688 rte_cpu_to_be_16(res->port_dst);
8689 entry.input.flow.sctp6_flow.src_port =
8690 rte_cpu_to_be_16(res->port_src);
8691 entry.input.flow.sctp6_flow.verify_tag =
8692 rte_cpu_to_be_32(res->verify_tag_value);
8694 case RTE_ETH_FLOW_L2_PAYLOAD:
8695 entry.input.flow.l2_flow.ether_type =
8696 rte_cpu_to_be_16(res->ether_type);
8702 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8703 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8705 sizeof(struct ether_addr));
8707 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8708 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8710 sizeof(struct ether_addr));
8711 entry.input.flow.tunnel_flow.tunnel_type =
8712 str2fdir_tunneltype(res->tunnel_type);
8713 entry.input.flow.tunnel_flow.tunnel_id =
8714 rte_cpu_to_be_32(res->tunnel_id_value);
8717 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8719 RTE_ETH_FDIR_MAX_FLEXLEN);
8721 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8723 entry.action.flex_off = 0; /*use 0 by default */
8724 if (!strcmp(res->drop, "drop"))
8725 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8727 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8729 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8730 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8731 if (!strcmp(res->pf_vf, "pf"))
8732 entry.input.flow_ext.is_vf = 0;
8733 else if (!strncmp(res->pf_vf, "vf", 2)) {
8734 struct rte_eth_dev_info dev_info;
8736 memset(&dev_info, 0, sizeof(dev_info));
8737 rte_eth_dev_info_get(res->port_id, &dev_info);
8739 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8740 if (errno != 0 || *end != '\0' ||
8741 vf_id >= dev_info.max_vfs) {
8742 printf("invalid parameter %s.\n", res->pf_vf);
8745 entry.input.flow_ext.is_vf = 1;
8746 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8748 printf("invalid parameter %s.\n", res->pf_vf);
8753 /* set to report FD ID by default */
8754 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8755 entry.action.rx_queue = res->queue_id;
8756 entry.soft_id = res->fd_id_value;
8757 if (!strcmp(res->ops, "add"))
8758 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8759 RTE_ETH_FILTER_ADD, &entry);
8760 else if (!strcmp(res->ops, "del"))
8761 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8762 RTE_ETH_FILTER_DELETE, &entry);
8764 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8765 RTE_ETH_FILTER_UPDATE, &entry);
8767 printf("flow director programming error: (%s)\n",
8771 cmdline_parse_token_string_t cmd_flow_director_filter =
8772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8773 flow_director_filter, "flow_director_filter");
8774 cmdline_parse_token_num_t cmd_flow_director_port_id =
8775 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8777 cmdline_parse_token_string_t cmd_flow_director_ops =
8778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8779 ops, "add#del#update");
8780 cmdline_parse_token_string_t cmd_flow_director_flow =
8781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8783 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8785 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8786 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8787 cmdline_parse_token_string_t cmd_flow_director_ether =
8788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8790 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8791 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8792 ether_type, UINT16);
8793 cmdline_parse_token_string_t cmd_flow_director_src =
8794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8796 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8797 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8799 cmdline_parse_token_num_t cmd_flow_director_port_src =
8800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8802 cmdline_parse_token_string_t cmd_flow_director_dst =
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8805 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8806 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8808 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8809 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8811 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8813 verify_tag, "verify_tag");
8814 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8815 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8816 verify_tag_value, UINT32);
8817 cmdline_parse_token_string_t cmd_flow_director_tos =
8818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8820 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8821 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8823 cmdline_parse_token_string_t cmd_flow_director_proto =
8824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8826 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8827 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8828 proto_value, UINT8);
8829 cmdline_parse_token_string_t cmd_flow_director_ttl =
8830 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8832 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8833 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8835 cmdline_parse_token_string_t cmd_flow_director_vlan =
8836 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8838 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8839 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8840 vlan_value, UINT16);
8841 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8843 flexbytes, "flexbytes");
8844 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8846 flexbytes_value, NULL);
8847 cmdline_parse_token_string_t cmd_flow_director_drop =
8848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8850 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8853 cmdline_parse_token_string_t cmd_flow_director_queue =
8854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8856 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8857 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8859 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8862 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8863 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8864 fd_id_value, UINT32);
8866 cmdline_parse_token_string_t cmd_flow_director_mode =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8872 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8874 mode_value, "MAC-VLAN");
8875 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8877 mode_value, "Tunnel");
8878 cmdline_parse_token_string_t cmd_flow_director_mac =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8882 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8887 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8889 tunnel_type, "NVGRE#VxLAN");
8890 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8892 tunnel_id, "tunnel-id");
8893 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8895 tunnel_id_value, UINT32);
8897 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8898 .f = cmd_flow_director_filter_parsed,
8900 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8901 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8902 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8903 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8904 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8905 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8906 "fd_id <fd_id_value>: "
8907 "Add or delete an ip flow director entry on NIC",
8909 (void *)&cmd_flow_director_filter,
8910 (void *)&cmd_flow_director_port_id,
8911 (void *)&cmd_flow_director_mode,
8912 (void *)&cmd_flow_director_mode_ip,
8913 (void *)&cmd_flow_director_ops,
8914 (void *)&cmd_flow_director_flow,
8915 (void *)&cmd_flow_director_flow_type,
8916 (void *)&cmd_flow_director_src,
8917 (void *)&cmd_flow_director_ip_src,
8918 (void *)&cmd_flow_director_dst,
8919 (void *)&cmd_flow_director_ip_dst,
8920 (void *)&cmd_flow_director_tos,
8921 (void *)&cmd_flow_director_tos_value,
8922 (void *)&cmd_flow_director_proto,
8923 (void *)&cmd_flow_director_proto_value,
8924 (void *)&cmd_flow_director_ttl,
8925 (void *)&cmd_flow_director_ttl_value,
8926 (void *)&cmd_flow_director_vlan,
8927 (void *)&cmd_flow_director_vlan_value,
8928 (void *)&cmd_flow_director_flexbytes,
8929 (void *)&cmd_flow_director_flexbytes_value,
8930 (void *)&cmd_flow_director_drop,
8931 (void *)&cmd_flow_director_pf_vf,
8932 (void *)&cmd_flow_director_queue,
8933 (void *)&cmd_flow_director_queue_id,
8934 (void *)&cmd_flow_director_fd_id,
8935 (void *)&cmd_flow_director_fd_id_value,
8940 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8941 .f = cmd_flow_director_filter_parsed,
8943 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8944 "director entry on NIC",
8946 (void *)&cmd_flow_director_filter,
8947 (void *)&cmd_flow_director_port_id,
8948 (void *)&cmd_flow_director_mode,
8949 (void *)&cmd_flow_director_mode_ip,
8950 (void *)&cmd_flow_director_ops,
8951 (void *)&cmd_flow_director_flow,
8952 (void *)&cmd_flow_director_flow_type,
8953 (void *)&cmd_flow_director_src,
8954 (void *)&cmd_flow_director_ip_src,
8955 (void *)&cmd_flow_director_port_src,
8956 (void *)&cmd_flow_director_dst,
8957 (void *)&cmd_flow_director_ip_dst,
8958 (void *)&cmd_flow_director_port_dst,
8959 (void *)&cmd_flow_director_tos,
8960 (void *)&cmd_flow_director_tos_value,
8961 (void *)&cmd_flow_director_ttl,
8962 (void *)&cmd_flow_director_ttl_value,
8963 (void *)&cmd_flow_director_vlan,
8964 (void *)&cmd_flow_director_vlan_value,
8965 (void *)&cmd_flow_director_flexbytes,
8966 (void *)&cmd_flow_director_flexbytes_value,
8967 (void *)&cmd_flow_director_drop,
8968 (void *)&cmd_flow_director_pf_vf,
8969 (void *)&cmd_flow_director_queue,
8970 (void *)&cmd_flow_director_queue_id,
8971 (void *)&cmd_flow_director_fd_id,
8972 (void *)&cmd_flow_director_fd_id_value,
8977 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8978 .f = cmd_flow_director_filter_parsed,
8980 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
8981 "director entry on NIC",
8983 (void *)&cmd_flow_director_filter,
8984 (void *)&cmd_flow_director_port_id,
8985 (void *)&cmd_flow_director_mode,
8986 (void *)&cmd_flow_director_mode_ip,
8987 (void *)&cmd_flow_director_ops,
8988 (void *)&cmd_flow_director_flow,
8989 (void *)&cmd_flow_director_flow_type,
8990 (void *)&cmd_flow_director_src,
8991 (void *)&cmd_flow_director_ip_src,
8992 (void *)&cmd_flow_director_port_dst,
8993 (void *)&cmd_flow_director_dst,
8994 (void *)&cmd_flow_director_ip_dst,
8995 (void *)&cmd_flow_director_port_dst,
8996 (void *)&cmd_flow_director_verify_tag,
8997 (void *)&cmd_flow_director_verify_tag_value,
8998 (void *)&cmd_flow_director_tos,
8999 (void *)&cmd_flow_director_tos_value,
9000 (void *)&cmd_flow_director_ttl,
9001 (void *)&cmd_flow_director_ttl_value,
9002 (void *)&cmd_flow_director_vlan,
9003 (void *)&cmd_flow_director_vlan_value,
9004 (void *)&cmd_flow_director_flexbytes,
9005 (void *)&cmd_flow_director_flexbytes_value,
9006 (void *)&cmd_flow_director_drop,
9007 (void *)&cmd_flow_director_pf_vf,
9008 (void *)&cmd_flow_director_queue,
9009 (void *)&cmd_flow_director_queue_id,
9010 (void *)&cmd_flow_director_fd_id,
9011 (void *)&cmd_flow_director_fd_id_value,
9016 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9017 .f = cmd_flow_director_filter_parsed,
9019 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9020 "director entry on NIC",
9022 (void *)&cmd_flow_director_filter,
9023 (void *)&cmd_flow_director_port_id,
9024 (void *)&cmd_flow_director_mode,
9025 (void *)&cmd_flow_director_mode_ip,
9026 (void *)&cmd_flow_director_ops,
9027 (void *)&cmd_flow_director_flow,
9028 (void *)&cmd_flow_director_flow_type,
9029 (void *)&cmd_flow_director_ether,
9030 (void *)&cmd_flow_director_ether_type,
9031 (void *)&cmd_flow_director_flexbytes,
9032 (void *)&cmd_flow_director_flexbytes_value,
9033 (void *)&cmd_flow_director_drop,
9034 (void *)&cmd_flow_director_pf_vf,
9035 (void *)&cmd_flow_director_queue,
9036 (void *)&cmd_flow_director_queue_id,
9037 (void *)&cmd_flow_director_fd_id,
9038 (void *)&cmd_flow_director_fd_id_value,
9043 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9044 .f = cmd_flow_director_filter_parsed,
9046 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9047 "director entry on NIC",
9049 (void *)&cmd_flow_director_filter,
9050 (void *)&cmd_flow_director_port_id,
9051 (void *)&cmd_flow_director_mode,
9052 (void *)&cmd_flow_director_mode_mac_vlan,
9053 (void *)&cmd_flow_director_ops,
9054 (void *)&cmd_flow_director_mac,
9055 (void *)&cmd_flow_director_mac_addr,
9056 (void *)&cmd_flow_director_vlan,
9057 (void *)&cmd_flow_director_vlan_value,
9058 (void *)&cmd_flow_director_flexbytes,
9059 (void *)&cmd_flow_director_flexbytes_value,
9060 (void *)&cmd_flow_director_drop,
9061 (void *)&cmd_flow_director_queue,
9062 (void *)&cmd_flow_director_queue_id,
9063 (void *)&cmd_flow_director_fd_id,
9064 (void *)&cmd_flow_director_fd_id_value,
9069 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9070 .f = cmd_flow_director_filter_parsed,
9072 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9073 "director entry on NIC",
9075 (void *)&cmd_flow_director_filter,
9076 (void *)&cmd_flow_director_port_id,
9077 (void *)&cmd_flow_director_mode,
9078 (void *)&cmd_flow_director_mode_tunnel,
9079 (void *)&cmd_flow_director_ops,
9080 (void *)&cmd_flow_director_mac,
9081 (void *)&cmd_flow_director_mac_addr,
9082 (void *)&cmd_flow_director_vlan,
9083 (void *)&cmd_flow_director_vlan_value,
9084 (void *)&cmd_flow_director_tunnel,
9085 (void *)&cmd_flow_director_tunnel_type,
9086 (void *)&cmd_flow_director_tunnel_id,
9087 (void *)&cmd_flow_director_tunnel_id_value,
9088 (void *)&cmd_flow_director_flexbytes,
9089 (void *)&cmd_flow_director_flexbytes_value,
9090 (void *)&cmd_flow_director_drop,
9091 (void *)&cmd_flow_director_queue,
9092 (void *)&cmd_flow_director_queue_id,
9093 (void *)&cmd_flow_director_fd_id,
9094 (void *)&cmd_flow_director_fd_id_value,
9099 struct cmd_flush_flow_director_result {
9100 cmdline_fixed_string_t flush_flow_director;
9104 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9105 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9106 flush_flow_director, "flush_flow_director");
9107 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9108 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9112 cmd_flush_flow_director_parsed(void *parsed_result,
9113 __attribute__((unused)) struct cmdline *cl,
9114 __attribute__((unused)) void *data)
9116 struct cmd_flow_director_result *res = parsed_result;
9119 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9121 printf("flow director is not supported on port %u.\n",
9126 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9127 RTE_ETH_FILTER_FLUSH, NULL);
9129 printf("flow director table flushing error: (%s)\n",
9133 cmdline_parse_inst_t cmd_flush_flow_director = {
9134 .f = cmd_flush_flow_director_parsed,
9136 .help_str = "flush_flow_director <port_id>: "
9137 "Flush all flow director entries of a device on NIC",
9139 (void *)&cmd_flush_flow_director_flush,
9140 (void *)&cmd_flush_flow_director_port_id,
9145 /* *** deal with flow director mask *** */
9146 struct cmd_flow_director_mask_result {
9147 cmdline_fixed_string_t flow_director_mask;
9149 cmdline_fixed_string_t mode;
9150 cmdline_fixed_string_t mode_value;
9151 cmdline_fixed_string_t vlan;
9153 cmdline_fixed_string_t src_mask;
9154 cmdline_ipaddr_t ipv4_src;
9155 cmdline_ipaddr_t ipv6_src;
9157 cmdline_fixed_string_t dst_mask;
9158 cmdline_ipaddr_t ipv4_dst;
9159 cmdline_ipaddr_t ipv6_dst;
9161 cmdline_fixed_string_t mac;
9162 uint8_t mac_addr_byte_mask;
9163 cmdline_fixed_string_t tunnel_id;
9164 uint32_t tunnel_id_mask;
9165 cmdline_fixed_string_t tunnel_type;
9166 uint8_t tunnel_type_mask;
9170 cmd_flow_director_mask_parsed(void *parsed_result,
9171 __attribute__((unused)) struct cmdline *cl,
9172 __attribute__((unused)) void *data)
9174 struct cmd_flow_director_mask_result *res = parsed_result;
9175 struct rte_eth_fdir_masks *mask;
9176 struct rte_port *port;
9178 if (res->port_id > nb_ports) {
9179 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9183 port = &ports[res->port_id];
9184 /** Check if the port is not started **/
9185 if (port->port_status != RTE_PORT_STOPPED) {
9186 printf("Please stop port %d first\n", res->port_id);
9190 mask = &port->dev_conf.fdir_conf.mask;
9192 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9193 if (strcmp(res->mode_value, "MAC-VLAN")) {
9194 printf("Please set mode to MAC-VLAN.\n");
9198 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9199 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9200 if (strcmp(res->mode_value, "Tunnel")) {
9201 printf("Please set mode to Tunnel.\n");
9205 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9206 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9207 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9208 mask->tunnel_type_mask = res->tunnel_type_mask;
9210 if (strcmp(res->mode_value, "IP")) {
9211 printf("Please set mode to IP.\n");
9215 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9216 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9217 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9218 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9219 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9220 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9221 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9224 cmd_reconfig_device_queue(res->port_id, 1, 1);
9227 cmdline_parse_token_string_t cmd_flow_director_mask =
9228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9229 flow_director_mask, "flow_director_mask");
9230 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9231 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9233 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9236 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9237 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9239 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9241 src_mask, "src_mask");
9242 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9243 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9245 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9246 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9248 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9251 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9253 dst_mask, "dst_mask");
9254 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9255 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9257 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9258 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9260 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9264 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9267 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9270 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9272 mode_value, "MAC-VLAN");
9273 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9275 mode_value, "Tunnel");
9276 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9279 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9281 mac_addr_byte_mask, UINT8);
9282 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9284 tunnel_type, "tunnel-type");
9285 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9287 tunnel_type_mask, UINT8);
9288 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9290 tunnel_id, "tunnel-id");
9291 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9293 tunnel_id_mask, UINT32);
9295 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9296 .f = cmd_flow_director_mask_parsed,
9298 .help_str = "flow_director_mask ... : "
9299 "Set IP mode flow director's mask on NIC",
9301 (void *)&cmd_flow_director_mask,
9302 (void *)&cmd_flow_director_mask_port_id,
9303 (void *)&cmd_flow_director_mask_mode,
9304 (void *)&cmd_flow_director_mask_mode_ip,
9305 (void *)&cmd_flow_director_mask_vlan,
9306 (void *)&cmd_flow_director_mask_vlan_value,
9307 (void *)&cmd_flow_director_mask_src,
9308 (void *)&cmd_flow_director_mask_ipv4_src,
9309 (void *)&cmd_flow_director_mask_ipv6_src,
9310 (void *)&cmd_flow_director_mask_port_src,
9311 (void *)&cmd_flow_director_mask_dst,
9312 (void *)&cmd_flow_director_mask_ipv4_dst,
9313 (void *)&cmd_flow_director_mask_ipv6_dst,
9314 (void *)&cmd_flow_director_mask_port_dst,
9319 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9320 .f = cmd_flow_director_mask_parsed,
9322 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9323 "flow director's mask on NIC",
9325 (void *)&cmd_flow_director_mask,
9326 (void *)&cmd_flow_director_mask_port_id,
9327 (void *)&cmd_flow_director_mask_mode,
9328 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9329 (void *)&cmd_flow_director_mask_vlan,
9330 (void *)&cmd_flow_director_mask_vlan_value,
9335 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9336 .f = cmd_flow_director_mask_parsed,
9338 .help_str = "flow_director_mask ... : Set tunnel mode "
9339 "flow director's mask on NIC",
9341 (void *)&cmd_flow_director_mask,
9342 (void *)&cmd_flow_director_mask_port_id,
9343 (void *)&cmd_flow_director_mask_mode,
9344 (void *)&cmd_flow_director_mask_mode_tunnel,
9345 (void *)&cmd_flow_director_mask_vlan,
9346 (void *)&cmd_flow_director_mask_vlan_value,
9347 (void *)&cmd_flow_director_mask_mac,
9348 (void *)&cmd_flow_director_mask_mac_value,
9349 (void *)&cmd_flow_director_mask_tunnel_type,
9350 (void *)&cmd_flow_director_mask_tunnel_type_value,
9351 (void *)&cmd_flow_director_mask_tunnel_id,
9352 (void *)&cmd_flow_director_mask_tunnel_id_value,
9357 /* *** deal with flow director mask on flexible payload *** */
9358 struct cmd_flow_director_flex_mask_result {
9359 cmdline_fixed_string_t flow_director_flexmask;
9361 cmdline_fixed_string_t flow;
9362 cmdline_fixed_string_t flow_type;
9363 cmdline_fixed_string_t mask;
9367 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9368 __attribute__((unused)) struct cmdline *cl,
9369 __attribute__((unused)) void *data)
9371 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9372 struct rte_eth_fdir_info fdir_info;
9373 struct rte_eth_fdir_flex_mask flex_mask;
9374 struct rte_port *port;
9375 uint32_t flow_type_mask;
9379 if (res->port_id > nb_ports) {
9380 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9384 port = &ports[res->port_id];
9385 /** Check if the port is not started **/
9386 if (port->port_status != RTE_PORT_STOPPED) {
9387 printf("Please stop port %d first\n", res->port_id);
9391 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9392 ret = parse_flexbytes(res->mask,
9394 RTE_ETH_FDIR_MAX_FLEXLEN);
9396 printf("error: Cannot parse mask input.\n");
9400 memset(&fdir_info, 0, sizeof(fdir_info));
9401 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9402 RTE_ETH_FILTER_INFO, &fdir_info);
9404 printf("Cannot get FDir filter info\n");
9408 if (!strcmp(res->flow_type, "none")) {
9409 /* means don't specify the flow type */
9410 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9411 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9412 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9413 0, sizeof(struct rte_eth_fdir_flex_mask));
9414 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9415 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9417 sizeof(struct rte_eth_fdir_flex_mask));
9418 cmd_reconfig_device_queue(res->port_id, 1, 1);
9421 flow_type_mask = fdir_info.flow_types_mask[0];
9422 if (!strcmp(res->flow_type, "all")) {
9423 if (!flow_type_mask) {
9424 printf("No flow type supported\n");
9427 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9428 if (flow_type_mask & (1 << i)) {
9429 flex_mask.flow_type = i;
9430 fdir_set_flex_mask(res->port_id, &flex_mask);
9433 cmd_reconfig_device_queue(res->port_id, 1, 1);
9436 flex_mask.flow_type = str2flowtype(res->flow_type);
9437 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9438 printf("Flow type %s not supported on port %d\n",
9439 res->flow_type, res->port_id);
9442 fdir_set_flex_mask(res->port_id, &flex_mask);
9443 cmd_reconfig_device_queue(res->port_id, 1, 1);
9446 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9448 flow_director_flexmask,
9449 "flow_director_flex_mask");
9450 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9453 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9456 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9458 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9459 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9460 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9464 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9465 .f = cmd_flow_director_flex_mask_parsed,
9467 .help_str = "flow_director_flex_mask ... : "
9468 "Set flow director's flex mask on NIC",
9470 (void *)&cmd_flow_director_flexmask,
9471 (void *)&cmd_flow_director_flexmask_port_id,
9472 (void *)&cmd_flow_director_flexmask_flow,
9473 (void *)&cmd_flow_director_flexmask_flow_type,
9474 (void *)&cmd_flow_director_flexmask_mask,
9479 /* *** deal with flow director flexible payload configuration *** */
9480 struct cmd_flow_director_flexpayload_result {
9481 cmdline_fixed_string_t flow_director_flexpayload;
9483 cmdline_fixed_string_t payload_layer;
9484 cmdline_fixed_string_t payload_cfg;
9488 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9491 const char *p, *p0 = q_arg;
9493 unsigned long int_fld;
9494 char *str_fld[max_num];
9499 p = strchr(p0, '(');
9503 p0 = strchr(p, ')');
9508 if (size >= sizeof(s))
9511 snprintf(s, sizeof(s), "%.*s", size, p);
9512 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9513 if (ret < 0 || ret > max_num)
9515 for (i = 0; i < ret; i++) {
9517 int_fld = strtoul(str_fld[i], &end, 0);
9518 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9520 offsets[i] = (uint16_t)int_fld;
9526 cmd_flow_director_flxpld_parsed(void *parsed_result,
9527 __attribute__((unused)) struct cmdline *cl,
9528 __attribute__((unused)) void *data)
9530 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9531 struct rte_eth_flex_payload_cfg flex_cfg;
9532 struct rte_port *port;
9535 if (res->port_id > nb_ports) {
9536 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9540 port = &ports[res->port_id];
9541 /** Check if the port is not started **/
9542 if (port->port_status != RTE_PORT_STOPPED) {
9543 printf("Please stop port %d first\n", res->port_id);
9547 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9549 if (!strcmp(res->payload_layer, "raw"))
9550 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9551 else if (!strcmp(res->payload_layer, "l2"))
9552 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9553 else if (!strcmp(res->payload_layer, "l3"))
9554 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9555 else if (!strcmp(res->payload_layer, "l4"))
9556 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9558 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9559 RTE_ETH_FDIR_MAX_FLEXLEN);
9561 printf("error: Cannot parse flex payload input.\n");
9565 fdir_set_flex_payload(res->port_id, &flex_cfg);
9566 cmd_reconfig_device_queue(res->port_id, 1, 1);
9569 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9571 flow_director_flexpayload,
9572 "flow_director_flex_payload");
9573 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9574 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9576 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9578 payload_layer, "raw#l2#l3#l4");
9579 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9583 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9584 .f = cmd_flow_director_flxpld_parsed,
9586 .help_str = "flow_director_flexpayload ... : "
9587 "Set flow director's flex payload on NIC",
9589 (void *)&cmd_flow_director_flexpayload,
9590 (void *)&cmd_flow_director_flexpayload_port_id,
9591 (void *)&cmd_flow_director_flexpayload_payload_layer,
9592 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9597 /* Generic flow interface command. */
9598 extern cmdline_parse_inst_t cmd_flow;
9600 /* *** Classification Filters Control *** */
9601 /* *** Get symmetric hash enable per port *** */
9602 struct cmd_get_sym_hash_ena_per_port_result {
9603 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9608 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9609 __rte_unused struct cmdline *cl,
9610 __rte_unused void *data)
9612 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9613 struct rte_eth_hash_filter_info info;
9616 if (rte_eth_dev_filter_supported(res->port_id,
9617 RTE_ETH_FILTER_HASH) < 0) {
9618 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9623 memset(&info, 0, sizeof(info));
9624 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9625 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9626 RTE_ETH_FILTER_GET, &info);
9629 printf("Cannot get symmetric hash enable per port "
9630 "on port %u\n", res->port_id);
9634 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9635 "enabled" : "disabled", res->port_id);
9638 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9639 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9640 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9641 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9642 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9645 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9646 .f = cmd_get_sym_hash_per_port_parsed,
9648 .help_str = "get_sym_hash_ena_per_port <port_id>",
9650 (void *)&cmd_get_sym_hash_ena_per_port_all,
9651 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9656 /* *** Set symmetric hash enable per port *** */
9657 struct cmd_set_sym_hash_ena_per_port_result {
9658 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9659 cmdline_fixed_string_t enable;
9664 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9665 __rte_unused struct cmdline *cl,
9666 __rte_unused void *data)
9668 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9669 struct rte_eth_hash_filter_info info;
9672 if (rte_eth_dev_filter_supported(res->port_id,
9673 RTE_ETH_FILTER_HASH) < 0) {
9674 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9679 memset(&info, 0, sizeof(info));
9680 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9681 if (!strcmp(res->enable, "enable"))
9682 info.info.enable = 1;
9683 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9684 RTE_ETH_FILTER_SET, &info);
9686 printf("Cannot set symmetric hash enable per port on "
9687 "port %u\n", res->port_id);
9690 printf("Symmetric hash has been set to %s on port %u\n",
9691 res->enable, res->port_id);
9694 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9695 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9696 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9697 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9698 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9700 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9701 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9702 enable, "enable#disable");
9704 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9705 .f = cmd_set_sym_hash_per_port_parsed,
9707 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9709 (void *)&cmd_set_sym_hash_ena_per_port_all,
9710 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9711 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9716 /* Get global config of hash function */
9717 struct cmd_get_hash_global_config_result {
9718 cmdline_fixed_string_t get_hash_global_config;
9723 flowtype_to_str(uint16_t ftype)
9730 {"ipv4", RTE_ETH_FLOW_IPV4},
9731 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9732 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9733 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9734 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9735 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9736 {"ipv6", RTE_ETH_FLOW_IPV6},
9737 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9738 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9739 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9740 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9741 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9742 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9743 {"port", RTE_ETH_FLOW_PORT},
9744 {"vxlan", RTE_ETH_FLOW_VXLAN},
9745 {"geneve", RTE_ETH_FLOW_GENEVE},
9746 {"nvgre", RTE_ETH_FLOW_NVGRE},
9749 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9750 if (ftype_table[i].ftype == ftype)
9751 return ftype_table[i].str;
9758 cmd_get_hash_global_config_parsed(void *parsed_result,
9759 __rte_unused struct cmdline *cl,
9760 __rte_unused void *data)
9762 struct cmd_get_hash_global_config_result *res = parsed_result;
9763 struct rte_eth_hash_filter_info info;
9764 uint32_t idx, offset;
9769 if (rte_eth_dev_filter_supported(res->port_id,
9770 RTE_ETH_FILTER_HASH) < 0) {
9771 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9776 memset(&info, 0, sizeof(info));
9777 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9778 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9779 RTE_ETH_FILTER_GET, &info);
9781 printf("Cannot get hash global configurations by port %d\n",
9786 switch (info.info.global_conf.hash_func) {
9787 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9788 printf("Hash function is Toeplitz\n");
9790 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9791 printf("Hash function is Simple XOR\n");
9794 printf("Unknown hash function\n");
9798 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9799 idx = i / UINT32_BIT;
9800 offset = i % UINT32_BIT;
9801 if (!(info.info.global_conf.valid_bit_mask[idx] &
9804 str = flowtype_to_str(i);
9807 printf("Symmetric hash is %s globally for flow type %s "
9809 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9810 (1UL << offset)) ? "enabled" : "disabled"), str,
9815 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9816 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9817 get_hash_global_config, "get_hash_global_config");
9818 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9819 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9822 cmdline_parse_inst_t cmd_get_hash_global_config = {
9823 .f = cmd_get_hash_global_config_parsed,
9825 .help_str = "get_hash_global_config <port_id>",
9827 (void *)&cmd_get_hash_global_config_all,
9828 (void *)&cmd_get_hash_global_config_port_id,
9833 /* Set global config of hash function */
9834 struct cmd_set_hash_global_config_result {
9835 cmdline_fixed_string_t set_hash_global_config;
9837 cmdline_fixed_string_t hash_func;
9838 cmdline_fixed_string_t flow_type;
9839 cmdline_fixed_string_t enable;
9843 cmd_set_hash_global_config_parsed(void *parsed_result,
9844 __rte_unused struct cmdline *cl,
9845 __rte_unused void *data)
9847 struct cmd_set_hash_global_config_result *res = parsed_result;
9848 struct rte_eth_hash_filter_info info;
9849 uint32_t ftype, idx, offset;
9852 if (rte_eth_dev_filter_supported(res->port_id,
9853 RTE_ETH_FILTER_HASH) < 0) {
9854 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9858 memset(&info, 0, sizeof(info));
9859 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9860 if (!strcmp(res->hash_func, "toeplitz"))
9861 info.info.global_conf.hash_func =
9862 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9863 else if (!strcmp(res->hash_func, "simple_xor"))
9864 info.info.global_conf.hash_func =
9865 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9866 else if (!strcmp(res->hash_func, "default"))
9867 info.info.global_conf.hash_func =
9868 RTE_ETH_HASH_FUNCTION_DEFAULT;
9870 ftype = str2flowtype(res->flow_type);
9871 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9872 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9873 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9874 if (!strcmp(res->enable, "enable"))
9875 info.info.global_conf.sym_hash_enable_mask[idx] |=
9877 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9878 RTE_ETH_FILTER_SET, &info);
9880 printf("Cannot set global hash configurations by port %d\n",
9883 printf("Global hash configurations have been set "
9884 "succcessfully by port %d\n", res->port_id);
9887 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9888 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9889 set_hash_global_config, "set_hash_global_config");
9890 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9891 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9893 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9894 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9895 hash_func, "toeplitz#simple_xor#default");
9896 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9897 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9899 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9900 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9901 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9902 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9903 enable, "enable#disable");
9905 cmdline_parse_inst_t cmd_set_hash_global_config = {
9906 .f = cmd_set_hash_global_config_parsed,
9908 .help_str = "set_hash_global_config <port_id> "
9909 "toeplitz|simple_xor|default "
9910 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9911 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9912 "l2_payload enable|disable",
9914 (void *)&cmd_set_hash_global_config_all,
9915 (void *)&cmd_set_hash_global_config_port_id,
9916 (void *)&cmd_set_hash_global_config_hash_func,
9917 (void *)&cmd_set_hash_global_config_flow_type,
9918 (void *)&cmd_set_hash_global_config_enable,
9923 /* Set hash input set */
9924 struct cmd_set_hash_input_set_result {
9925 cmdline_fixed_string_t set_hash_input_set;
9927 cmdline_fixed_string_t flow_type;
9928 cmdline_fixed_string_t inset_field;
9929 cmdline_fixed_string_t select;
9932 static enum rte_eth_input_set_field
9933 str2inset(char *string)
9937 static const struct {
9939 enum rte_eth_input_set_field inset;
9941 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9942 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9943 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9944 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9945 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9946 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9947 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9948 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9949 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9950 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9951 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9952 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9953 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9954 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9955 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9956 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9957 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9958 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9959 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9960 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9961 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9962 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9963 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9964 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9965 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9966 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9967 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9968 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9969 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9970 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9971 {"none", RTE_ETH_INPUT_SET_NONE},
9974 for (i = 0; i < RTE_DIM(inset_table); i++) {
9975 if (!strcmp(string, inset_table[i].str))
9976 return inset_table[i].inset;
9979 return RTE_ETH_INPUT_SET_UNKNOWN;
9983 cmd_set_hash_input_set_parsed(void *parsed_result,
9984 __rte_unused struct cmdline *cl,
9985 __rte_unused void *data)
9987 struct cmd_set_hash_input_set_result *res = parsed_result;
9988 struct rte_eth_hash_filter_info info;
9990 memset(&info, 0, sizeof(info));
9991 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9992 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9993 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9994 info.info.input_set_conf.inset_size = 1;
9995 if (!strcmp(res->select, "select"))
9996 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9997 else if (!strcmp(res->select, "add"))
9998 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9999 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10000 RTE_ETH_FILTER_SET, &info);
10003 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10004 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10005 set_hash_input_set, "set_hash_input_set");
10006 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10007 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10009 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10010 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10012 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10013 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10014 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10015 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10017 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10018 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10019 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10020 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10021 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10023 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10024 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10025 select, "select#add");
10027 cmdline_parse_inst_t cmd_set_hash_input_set = {
10028 .f = cmd_set_hash_input_set_parsed,
10030 .help_str = "set_hash_input_set <port_id> "
10031 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10032 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10033 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10034 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10035 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10036 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10037 "fld-7th|fld-8th|none select|add",
10039 (void *)&cmd_set_hash_input_set_cmd,
10040 (void *)&cmd_set_hash_input_set_port_id,
10041 (void *)&cmd_set_hash_input_set_flow_type,
10042 (void *)&cmd_set_hash_input_set_field,
10043 (void *)&cmd_set_hash_input_set_select,
10048 /* Set flow director input set */
10049 struct cmd_set_fdir_input_set_result {
10050 cmdline_fixed_string_t set_fdir_input_set;
10052 cmdline_fixed_string_t flow_type;
10053 cmdline_fixed_string_t inset_field;
10054 cmdline_fixed_string_t select;
10058 cmd_set_fdir_input_set_parsed(void *parsed_result,
10059 __rte_unused struct cmdline *cl,
10060 __rte_unused void *data)
10062 struct cmd_set_fdir_input_set_result *res = parsed_result;
10063 struct rte_eth_fdir_filter_info info;
10065 memset(&info, 0, sizeof(info));
10066 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10067 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10068 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10069 info.info.input_set_conf.inset_size = 1;
10070 if (!strcmp(res->select, "select"))
10071 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10072 else if (!strcmp(res->select, "add"))
10073 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10074 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10075 RTE_ETH_FILTER_SET, &info);
10078 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10079 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10080 set_fdir_input_set, "set_fdir_input_set");
10081 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10082 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10084 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10085 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10087 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10088 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10089 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10090 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10092 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10093 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10094 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10095 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10096 "sctp-veri-tag#none");
10097 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10098 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10099 select, "select#add");
10101 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10102 .f = cmd_set_fdir_input_set_parsed,
10104 .help_str = "set_fdir_input_set <port_id> "
10105 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10106 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10107 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10108 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10109 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10110 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10111 "sctp-veri-tag|none select|add",
10113 (void *)&cmd_set_fdir_input_set_cmd,
10114 (void *)&cmd_set_fdir_input_set_port_id,
10115 (void *)&cmd_set_fdir_input_set_flow_type,
10116 (void *)&cmd_set_fdir_input_set_field,
10117 (void *)&cmd_set_fdir_input_set_select,
10122 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10123 struct cmd_mcast_addr_result {
10124 cmdline_fixed_string_t mcast_addr_cmd;
10125 cmdline_fixed_string_t what;
10127 struct ether_addr mc_addr;
10130 static void cmd_mcast_addr_parsed(void *parsed_result,
10131 __attribute__((unused)) struct cmdline *cl,
10132 __attribute__((unused)) void *data)
10134 struct cmd_mcast_addr_result *res = parsed_result;
10136 if (!is_multicast_ether_addr(&res->mc_addr)) {
10137 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10138 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10139 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10140 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10143 if (strcmp(res->what, "add") == 0)
10144 mcast_addr_add(res->port_num, &res->mc_addr);
10146 mcast_addr_remove(res->port_num, &res->mc_addr);
10149 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10150 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10151 mcast_addr_cmd, "mcast_addr");
10152 cmdline_parse_token_string_t cmd_mcast_addr_what =
10153 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10155 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10156 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10157 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10158 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10160 cmdline_parse_inst_t cmd_mcast_addr = {
10161 .f = cmd_mcast_addr_parsed,
10163 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10164 "Add/Remove multicast MAC address on port_id",
10166 (void *)&cmd_mcast_addr_cmd,
10167 (void *)&cmd_mcast_addr_what,
10168 (void *)&cmd_mcast_addr_portnum,
10169 (void *)&cmd_mcast_addr_addr,
10174 /* l2 tunnel config
10175 * only support E-tag now.
10178 /* Ether type config */
10179 struct cmd_config_l2_tunnel_eth_type_result {
10180 cmdline_fixed_string_t port;
10181 cmdline_fixed_string_t config;
10182 cmdline_fixed_string_t all;
10184 cmdline_fixed_string_t l2_tunnel;
10185 cmdline_fixed_string_t l2_tunnel_type;
10186 cmdline_fixed_string_t eth_type;
10187 uint16_t eth_type_val;
10190 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10191 TOKEN_STRING_INITIALIZER
10192 (struct cmd_config_l2_tunnel_eth_type_result,
10194 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10195 TOKEN_STRING_INITIALIZER
10196 (struct cmd_config_l2_tunnel_eth_type_result,
10198 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10199 TOKEN_STRING_INITIALIZER
10200 (struct cmd_config_l2_tunnel_eth_type_result,
10202 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10203 TOKEN_NUM_INITIALIZER
10204 (struct cmd_config_l2_tunnel_eth_type_result,
10206 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10207 TOKEN_STRING_INITIALIZER
10208 (struct cmd_config_l2_tunnel_eth_type_result,
10209 l2_tunnel, "l2-tunnel");
10210 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10211 TOKEN_STRING_INITIALIZER
10212 (struct cmd_config_l2_tunnel_eth_type_result,
10213 l2_tunnel_type, "E-tag");
10214 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10215 TOKEN_STRING_INITIALIZER
10216 (struct cmd_config_l2_tunnel_eth_type_result,
10217 eth_type, "ether-type");
10218 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10219 TOKEN_NUM_INITIALIZER
10220 (struct cmd_config_l2_tunnel_eth_type_result,
10221 eth_type_val, UINT16);
10223 static enum rte_eth_tunnel_type
10224 str2fdir_l2_tunnel_type(char *string)
10228 static const struct {
10230 enum rte_eth_tunnel_type type;
10231 } l2_tunnel_type_str[] = {
10232 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10235 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10236 if (!strcmp(l2_tunnel_type_str[i].str, string))
10237 return l2_tunnel_type_str[i].type;
10239 return RTE_TUNNEL_TYPE_NONE;
10242 /* ether type config for all ports */
10244 cmd_config_l2_tunnel_eth_type_all_parsed
10245 (void *parsed_result,
10246 __attribute__((unused)) struct cmdline *cl,
10247 __attribute__((unused)) void *data)
10249 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10250 struct rte_eth_l2_tunnel_conf entry;
10253 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10254 entry.ether_type = res->eth_type_val;
10256 FOREACH_PORT(pid, ports) {
10257 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10261 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10262 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10264 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10266 (void *)&cmd_config_l2_tunnel_eth_type_port,
10267 (void *)&cmd_config_l2_tunnel_eth_type_config,
10268 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10269 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10270 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10271 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10272 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10277 /* ether type config for a specific port */
10279 cmd_config_l2_tunnel_eth_type_specific_parsed(
10280 void *parsed_result,
10281 __attribute__((unused)) struct cmdline *cl,
10282 __attribute__((unused)) void *data)
10284 struct cmd_config_l2_tunnel_eth_type_result *res =
10286 struct rte_eth_l2_tunnel_conf entry;
10288 if (port_id_is_invalid(res->id, ENABLED_WARN))
10291 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10292 entry.ether_type = res->eth_type_val;
10294 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10297 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10298 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10300 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10302 (void *)&cmd_config_l2_tunnel_eth_type_port,
10303 (void *)&cmd_config_l2_tunnel_eth_type_config,
10304 (void *)&cmd_config_l2_tunnel_eth_type_id,
10305 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10306 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10307 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10308 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10313 /* Enable/disable l2 tunnel */
10314 struct cmd_config_l2_tunnel_en_dis_result {
10315 cmdline_fixed_string_t port;
10316 cmdline_fixed_string_t config;
10317 cmdline_fixed_string_t all;
10319 cmdline_fixed_string_t l2_tunnel;
10320 cmdline_fixed_string_t l2_tunnel_type;
10321 cmdline_fixed_string_t en_dis;
10324 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10325 TOKEN_STRING_INITIALIZER
10326 (struct cmd_config_l2_tunnel_en_dis_result,
10328 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10329 TOKEN_STRING_INITIALIZER
10330 (struct cmd_config_l2_tunnel_en_dis_result,
10332 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10333 TOKEN_STRING_INITIALIZER
10334 (struct cmd_config_l2_tunnel_en_dis_result,
10336 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10337 TOKEN_NUM_INITIALIZER
10338 (struct cmd_config_l2_tunnel_en_dis_result,
10340 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10341 TOKEN_STRING_INITIALIZER
10342 (struct cmd_config_l2_tunnel_en_dis_result,
10343 l2_tunnel, "l2-tunnel");
10344 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10345 TOKEN_STRING_INITIALIZER
10346 (struct cmd_config_l2_tunnel_en_dis_result,
10347 l2_tunnel_type, "E-tag");
10348 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10349 TOKEN_STRING_INITIALIZER
10350 (struct cmd_config_l2_tunnel_en_dis_result,
10351 en_dis, "enable#disable");
10353 /* enable/disable l2 tunnel for all ports */
10355 cmd_config_l2_tunnel_en_dis_all_parsed(
10356 void *parsed_result,
10357 __attribute__((unused)) struct cmdline *cl,
10358 __attribute__((unused)) void *data)
10360 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10361 struct rte_eth_l2_tunnel_conf entry;
10365 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10367 if (!strcmp("enable", res->en_dis))
10372 FOREACH_PORT(pid, ports) {
10373 rte_eth_dev_l2_tunnel_offload_set(pid,
10375 ETH_L2_TUNNEL_ENABLE_MASK,
10380 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10381 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10383 .help_str = "port config all l2-tunnel E-tag enable|disable",
10385 (void *)&cmd_config_l2_tunnel_en_dis_port,
10386 (void *)&cmd_config_l2_tunnel_en_dis_config,
10387 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10388 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10389 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10390 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10395 /* enable/disable l2 tunnel for a port */
10397 cmd_config_l2_tunnel_en_dis_specific_parsed(
10398 void *parsed_result,
10399 __attribute__((unused)) struct cmdline *cl,
10400 __attribute__((unused)) void *data)
10402 struct cmd_config_l2_tunnel_en_dis_result *res =
10404 struct rte_eth_l2_tunnel_conf entry;
10406 if (port_id_is_invalid(res->id, ENABLED_WARN))
10409 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10411 if (!strcmp("enable", res->en_dis))
10412 rte_eth_dev_l2_tunnel_offload_set(res->id,
10414 ETH_L2_TUNNEL_ENABLE_MASK,
10417 rte_eth_dev_l2_tunnel_offload_set(res->id,
10419 ETH_L2_TUNNEL_ENABLE_MASK,
10423 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10424 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10426 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10428 (void *)&cmd_config_l2_tunnel_en_dis_port,
10429 (void *)&cmd_config_l2_tunnel_en_dis_config,
10430 (void *)&cmd_config_l2_tunnel_en_dis_id,
10431 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10432 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10433 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10438 /* E-tag configuration */
10440 /* Common result structure for all E-tag configuration */
10441 struct cmd_config_e_tag_result {
10442 cmdline_fixed_string_t e_tag;
10443 cmdline_fixed_string_t set;
10444 cmdline_fixed_string_t insertion;
10445 cmdline_fixed_string_t stripping;
10446 cmdline_fixed_string_t forwarding;
10447 cmdline_fixed_string_t filter;
10448 cmdline_fixed_string_t add;
10449 cmdline_fixed_string_t del;
10450 cmdline_fixed_string_t on;
10451 cmdline_fixed_string_t off;
10452 cmdline_fixed_string_t on_off;
10453 cmdline_fixed_string_t port_tag_id;
10454 uint32_t port_tag_id_val;
10455 cmdline_fixed_string_t e_tag_id;
10456 uint16_t e_tag_id_val;
10457 cmdline_fixed_string_t dst_pool;
10458 uint8_t dst_pool_val;
10459 cmdline_fixed_string_t port;
10461 cmdline_fixed_string_t vf;
10465 /* Common CLI fields for all E-tag configuration */
10466 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10467 TOKEN_STRING_INITIALIZER
10468 (struct cmd_config_e_tag_result,
10470 cmdline_parse_token_string_t cmd_config_e_tag_set =
10471 TOKEN_STRING_INITIALIZER
10472 (struct cmd_config_e_tag_result,
10474 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10475 TOKEN_STRING_INITIALIZER
10476 (struct cmd_config_e_tag_result,
10477 insertion, "insertion");
10478 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10479 TOKEN_STRING_INITIALIZER
10480 (struct cmd_config_e_tag_result,
10481 stripping, "stripping");
10482 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10483 TOKEN_STRING_INITIALIZER
10484 (struct cmd_config_e_tag_result,
10485 forwarding, "forwarding");
10486 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10487 TOKEN_STRING_INITIALIZER
10488 (struct cmd_config_e_tag_result,
10490 cmdline_parse_token_string_t cmd_config_e_tag_add =
10491 TOKEN_STRING_INITIALIZER
10492 (struct cmd_config_e_tag_result,
10494 cmdline_parse_token_string_t cmd_config_e_tag_del =
10495 TOKEN_STRING_INITIALIZER
10496 (struct cmd_config_e_tag_result,
10498 cmdline_parse_token_string_t cmd_config_e_tag_on =
10499 TOKEN_STRING_INITIALIZER
10500 (struct cmd_config_e_tag_result,
10502 cmdline_parse_token_string_t cmd_config_e_tag_off =
10503 TOKEN_STRING_INITIALIZER
10504 (struct cmd_config_e_tag_result,
10506 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10507 TOKEN_STRING_INITIALIZER
10508 (struct cmd_config_e_tag_result,
10510 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10511 TOKEN_STRING_INITIALIZER
10512 (struct cmd_config_e_tag_result,
10513 port_tag_id, "port-tag-id");
10514 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10515 TOKEN_NUM_INITIALIZER
10516 (struct cmd_config_e_tag_result,
10517 port_tag_id_val, UINT32);
10518 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10519 TOKEN_STRING_INITIALIZER
10520 (struct cmd_config_e_tag_result,
10521 e_tag_id, "e-tag-id");
10522 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10523 TOKEN_NUM_INITIALIZER
10524 (struct cmd_config_e_tag_result,
10525 e_tag_id_val, UINT16);
10526 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10527 TOKEN_STRING_INITIALIZER
10528 (struct cmd_config_e_tag_result,
10529 dst_pool, "dst-pool");
10530 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10531 TOKEN_NUM_INITIALIZER
10532 (struct cmd_config_e_tag_result,
10533 dst_pool_val, UINT8);
10534 cmdline_parse_token_string_t cmd_config_e_tag_port =
10535 TOKEN_STRING_INITIALIZER
10536 (struct cmd_config_e_tag_result,
10538 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10539 TOKEN_NUM_INITIALIZER
10540 (struct cmd_config_e_tag_result,
10542 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10543 TOKEN_STRING_INITIALIZER
10544 (struct cmd_config_e_tag_result,
10546 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10547 TOKEN_NUM_INITIALIZER
10548 (struct cmd_config_e_tag_result,
10551 /* E-tag insertion configuration */
10553 cmd_config_e_tag_insertion_en_parsed(
10554 void *parsed_result,
10555 __attribute__((unused)) struct cmdline *cl,
10556 __attribute__((unused)) void *data)
10558 struct cmd_config_e_tag_result *res =
10560 struct rte_eth_l2_tunnel_conf entry;
10562 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10565 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10566 entry.tunnel_id = res->port_tag_id_val;
10567 entry.vf_id = res->vf_id;
10568 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10570 ETH_L2_TUNNEL_INSERTION_MASK,
10575 cmd_config_e_tag_insertion_dis_parsed(
10576 void *parsed_result,
10577 __attribute__((unused)) struct cmdline *cl,
10578 __attribute__((unused)) void *data)
10580 struct cmd_config_e_tag_result *res =
10582 struct rte_eth_l2_tunnel_conf entry;
10584 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10587 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10588 entry.vf_id = res->vf_id;
10590 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10592 ETH_L2_TUNNEL_INSERTION_MASK,
10596 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10597 .f = cmd_config_e_tag_insertion_en_parsed,
10599 .help_str = "E-tag ... : E-tag insertion enable",
10601 (void *)&cmd_config_e_tag_e_tag,
10602 (void *)&cmd_config_e_tag_set,
10603 (void *)&cmd_config_e_tag_insertion,
10604 (void *)&cmd_config_e_tag_on,
10605 (void *)&cmd_config_e_tag_port_tag_id,
10606 (void *)&cmd_config_e_tag_port_tag_id_val,
10607 (void *)&cmd_config_e_tag_port,
10608 (void *)&cmd_config_e_tag_port_id,
10609 (void *)&cmd_config_e_tag_vf,
10610 (void *)&cmd_config_e_tag_vf_id,
10615 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10616 .f = cmd_config_e_tag_insertion_dis_parsed,
10618 .help_str = "E-tag ... : E-tag insertion disable",
10620 (void *)&cmd_config_e_tag_e_tag,
10621 (void *)&cmd_config_e_tag_set,
10622 (void *)&cmd_config_e_tag_insertion,
10623 (void *)&cmd_config_e_tag_off,
10624 (void *)&cmd_config_e_tag_port,
10625 (void *)&cmd_config_e_tag_port_id,
10626 (void *)&cmd_config_e_tag_vf,
10627 (void *)&cmd_config_e_tag_vf_id,
10632 /* E-tag stripping configuration */
10634 cmd_config_e_tag_stripping_parsed(
10635 void *parsed_result,
10636 __attribute__((unused)) struct cmdline *cl,
10637 __attribute__((unused)) void *data)
10639 struct cmd_config_e_tag_result *res =
10641 struct rte_eth_l2_tunnel_conf entry;
10643 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10646 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10648 if (!strcmp(res->on_off, "on"))
10649 rte_eth_dev_l2_tunnel_offload_set
10652 ETH_L2_TUNNEL_STRIPPING_MASK,
10655 rte_eth_dev_l2_tunnel_offload_set
10658 ETH_L2_TUNNEL_STRIPPING_MASK,
10662 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10663 .f = cmd_config_e_tag_stripping_parsed,
10665 .help_str = "E-tag ... : E-tag stripping enable/disable",
10667 (void *)&cmd_config_e_tag_e_tag,
10668 (void *)&cmd_config_e_tag_set,
10669 (void *)&cmd_config_e_tag_stripping,
10670 (void *)&cmd_config_e_tag_on_off,
10671 (void *)&cmd_config_e_tag_port,
10672 (void *)&cmd_config_e_tag_port_id,
10677 /* E-tag forwarding configuration */
10679 cmd_config_e_tag_forwarding_parsed(
10680 void *parsed_result,
10681 __attribute__((unused)) struct cmdline *cl,
10682 __attribute__((unused)) void *data)
10684 struct cmd_config_e_tag_result *res = parsed_result;
10685 struct rte_eth_l2_tunnel_conf entry;
10687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10690 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10692 if (!strcmp(res->on_off, "on"))
10693 rte_eth_dev_l2_tunnel_offload_set
10696 ETH_L2_TUNNEL_FORWARDING_MASK,
10699 rte_eth_dev_l2_tunnel_offload_set
10702 ETH_L2_TUNNEL_FORWARDING_MASK,
10706 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10707 .f = cmd_config_e_tag_forwarding_parsed,
10709 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10711 (void *)&cmd_config_e_tag_e_tag,
10712 (void *)&cmd_config_e_tag_set,
10713 (void *)&cmd_config_e_tag_forwarding,
10714 (void *)&cmd_config_e_tag_on_off,
10715 (void *)&cmd_config_e_tag_port,
10716 (void *)&cmd_config_e_tag_port_id,
10721 /* E-tag filter configuration */
10723 cmd_config_e_tag_filter_add_parsed(
10724 void *parsed_result,
10725 __attribute__((unused)) struct cmdline *cl,
10726 __attribute__((unused)) void *data)
10728 struct cmd_config_e_tag_result *res = parsed_result;
10729 struct rte_eth_l2_tunnel_conf entry;
10732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10735 if (res->e_tag_id_val > 0x3fff) {
10736 printf("e-tag-id must be equal or less than 0x3fff.\n");
10740 ret = rte_eth_dev_filter_supported(res->port_id,
10741 RTE_ETH_FILTER_L2_TUNNEL);
10743 printf("E-tag filter is not supported on port %u.\n",
10748 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10749 entry.tunnel_id = res->e_tag_id_val;
10750 entry.pool = res->dst_pool_val;
10752 ret = rte_eth_dev_filter_ctrl(res->port_id,
10753 RTE_ETH_FILTER_L2_TUNNEL,
10754 RTE_ETH_FILTER_ADD,
10757 printf("E-tag filter programming error: (%s)\n",
10761 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10762 .f = cmd_config_e_tag_filter_add_parsed,
10764 .help_str = "E-tag ... : E-tag filter add",
10766 (void *)&cmd_config_e_tag_e_tag,
10767 (void *)&cmd_config_e_tag_set,
10768 (void *)&cmd_config_e_tag_filter,
10769 (void *)&cmd_config_e_tag_add,
10770 (void *)&cmd_config_e_tag_e_tag_id,
10771 (void *)&cmd_config_e_tag_e_tag_id_val,
10772 (void *)&cmd_config_e_tag_dst_pool,
10773 (void *)&cmd_config_e_tag_dst_pool_val,
10774 (void *)&cmd_config_e_tag_port,
10775 (void *)&cmd_config_e_tag_port_id,
10781 cmd_config_e_tag_filter_del_parsed(
10782 void *parsed_result,
10783 __attribute__((unused)) struct cmdline *cl,
10784 __attribute__((unused)) void *data)
10786 struct cmd_config_e_tag_result *res = parsed_result;
10787 struct rte_eth_l2_tunnel_conf entry;
10790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10793 if (res->e_tag_id_val > 0x3fff) {
10794 printf("e-tag-id must be less than 0x3fff.\n");
10798 ret = rte_eth_dev_filter_supported(res->port_id,
10799 RTE_ETH_FILTER_L2_TUNNEL);
10801 printf("E-tag filter is not supported on port %u.\n",
10806 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10807 entry.tunnel_id = res->e_tag_id_val;
10809 ret = rte_eth_dev_filter_ctrl(res->port_id,
10810 RTE_ETH_FILTER_L2_TUNNEL,
10811 RTE_ETH_FILTER_DELETE,
10814 printf("E-tag filter programming error: (%s)\n",
10818 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10819 .f = cmd_config_e_tag_filter_del_parsed,
10821 .help_str = "E-tag ... : E-tag filter delete",
10823 (void *)&cmd_config_e_tag_e_tag,
10824 (void *)&cmd_config_e_tag_set,
10825 (void *)&cmd_config_e_tag_filter,
10826 (void *)&cmd_config_e_tag_del,
10827 (void *)&cmd_config_e_tag_e_tag_id,
10828 (void *)&cmd_config_e_tag_e_tag_id_val,
10829 (void *)&cmd_config_e_tag_port,
10830 (void *)&cmd_config_e_tag_port_id,
10834 #ifdef RTE_LIBRTE_IXGBE_PMD
10836 /* vf vlan anti spoof configuration */
10838 /* Common result structure for vf vlan anti spoof */
10839 struct cmd_vf_vlan_anti_spoof_result {
10840 cmdline_fixed_string_t set;
10841 cmdline_fixed_string_t vf;
10842 cmdline_fixed_string_t vlan;
10843 cmdline_fixed_string_t antispoof;
10846 cmdline_fixed_string_t on_off;
10849 /* Common CLI fields for vf vlan anti spoof enable disable */
10850 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10851 TOKEN_STRING_INITIALIZER
10852 (struct cmd_vf_vlan_anti_spoof_result,
10854 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10855 TOKEN_STRING_INITIALIZER
10856 (struct cmd_vf_vlan_anti_spoof_result,
10858 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10859 TOKEN_STRING_INITIALIZER
10860 (struct cmd_vf_vlan_anti_spoof_result,
10862 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10863 TOKEN_STRING_INITIALIZER
10864 (struct cmd_vf_vlan_anti_spoof_result,
10865 antispoof, "antispoof");
10866 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10867 TOKEN_NUM_INITIALIZER
10868 (struct cmd_vf_vlan_anti_spoof_result,
10870 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10871 TOKEN_NUM_INITIALIZER
10872 (struct cmd_vf_vlan_anti_spoof_result,
10874 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10875 TOKEN_STRING_INITIALIZER
10876 (struct cmd_vf_vlan_anti_spoof_result,
10880 cmd_set_vf_vlan_anti_spoof_parsed(
10881 void *parsed_result,
10882 __attribute__((unused)) struct cmdline *cl,
10883 __attribute__((unused)) void *data)
10885 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10887 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10889 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10895 printf("invalid vf_id %d\n", res->vf_id);
10898 printf("invalid port_id %d\n", res->port_id);
10901 printf("programming error: (%s)\n", strerror(-ret));
10905 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10906 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10908 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10910 (void *)&cmd_vf_vlan_anti_spoof_set,
10911 (void *)&cmd_vf_vlan_anti_spoof_vf,
10912 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10913 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10914 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10915 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10916 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10921 /* vf mac anti spoof configuration */
10923 /* Common result structure for vf mac anti spoof */
10924 struct cmd_vf_mac_anti_spoof_result {
10925 cmdline_fixed_string_t set;
10926 cmdline_fixed_string_t vf;
10927 cmdline_fixed_string_t mac;
10928 cmdline_fixed_string_t antispoof;
10931 cmdline_fixed_string_t on_off;
10934 /* Common CLI fields for vf mac anti spoof enable disable */
10935 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10936 TOKEN_STRING_INITIALIZER
10937 (struct cmd_vf_mac_anti_spoof_result,
10939 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10940 TOKEN_STRING_INITIALIZER
10941 (struct cmd_vf_mac_anti_spoof_result,
10943 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10944 TOKEN_STRING_INITIALIZER
10945 (struct cmd_vf_mac_anti_spoof_result,
10947 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10948 TOKEN_STRING_INITIALIZER
10949 (struct cmd_vf_mac_anti_spoof_result,
10950 antispoof, "antispoof");
10951 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10952 TOKEN_NUM_INITIALIZER
10953 (struct cmd_vf_mac_anti_spoof_result,
10955 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10956 TOKEN_NUM_INITIALIZER
10957 (struct cmd_vf_mac_anti_spoof_result,
10959 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10960 TOKEN_STRING_INITIALIZER
10961 (struct cmd_vf_mac_anti_spoof_result,
10965 cmd_set_vf_mac_anti_spoof_parsed(
10966 void *parsed_result,
10967 __attribute__((unused)) struct cmdline *cl,
10968 __attribute__((unused)) void *data)
10970 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10972 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10974 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10980 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10983 printf("invalid port_id %d\n", res->port_id);
10986 printf("programming error: (%s)\n", strerror(-ret));
10990 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10991 .f = cmd_set_vf_mac_anti_spoof_parsed,
10993 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10995 (void *)&cmd_vf_mac_anti_spoof_set,
10996 (void *)&cmd_vf_mac_anti_spoof_vf,
10997 (void *)&cmd_vf_mac_anti_spoof_mac,
10998 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10999 (void *)&cmd_vf_mac_anti_spoof_port_id,
11000 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11001 (void *)&cmd_vf_mac_anti_spoof_on_off,
11006 /* vf vlan strip queue configuration */
11008 /* Common result structure for vf mac anti spoof */
11009 struct cmd_vf_vlan_stripq_result {
11010 cmdline_fixed_string_t set;
11011 cmdline_fixed_string_t vf;
11012 cmdline_fixed_string_t vlan;
11013 cmdline_fixed_string_t stripq;
11016 cmdline_fixed_string_t on_off;
11019 /* Common CLI fields for vf vlan strip enable disable */
11020 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_vf_vlan_stripq_result,
11024 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11025 TOKEN_STRING_INITIALIZER
11026 (struct cmd_vf_vlan_stripq_result,
11028 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11029 TOKEN_STRING_INITIALIZER
11030 (struct cmd_vf_vlan_stripq_result,
11032 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11033 TOKEN_STRING_INITIALIZER
11034 (struct cmd_vf_vlan_stripq_result,
11036 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11037 TOKEN_NUM_INITIALIZER
11038 (struct cmd_vf_vlan_stripq_result,
11040 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11041 TOKEN_NUM_INITIALIZER
11042 (struct cmd_vf_vlan_stripq_result,
11044 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11045 TOKEN_STRING_INITIALIZER
11046 (struct cmd_vf_vlan_stripq_result,
11050 cmd_set_vf_vlan_stripq_parsed(
11051 void *parsed_result,
11052 __attribute__((unused)) struct cmdline *cl,
11053 __attribute__((unused)) void *data)
11055 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11057 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11059 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11064 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11067 printf("invalid port_id %d\n", res->port_id);
11070 printf("programming error: (%s)\n", strerror(-ret));
11074 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11075 .f = cmd_set_vf_vlan_stripq_parsed,
11077 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11079 (void *)&cmd_vf_vlan_stripq_set,
11080 (void *)&cmd_vf_vlan_stripq_vf,
11081 (void *)&cmd_vf_vlan_stripq_vlan,
11082 (void *)&cmd_vf_vlan_stripq_stripq,
11083 (void *)&cmd_vf_vlan_stripq_port_id,
11084 (void *)&cmd_vf_vlan_stripq_vf_id,
11085 (void *)&cmd_vf_vlan_stripq_on_off,
11090 /* vf vlan insert configuration */
11092 /* Common result structure for vf vlan insert */
11093 struct cmd_vf_vlan_insert_result {
11094 cmdline_fixed_string_t set;
11095 cmdline_fixed_string_t vf;
11096 cmdline_fixed_string_t vlan;
11097 cmdline_fixed_string_t insert;
11103 /* Common CLI fields for vf vlan insert enable disable */
11104 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11105 TOKEN_STRING_INITIALIZER
11106 (struct cmd_vf_vlan_insert_result,
11108 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11109 TOKEN_STRING_INITIALIZER
11110 (struct cmd_vf_vlan_insert_result,
11112 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11113 TOKEN_STRING_INITIALIZER
11114 (struct cmd_vf_vlan_insert_result,
11116 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11117 TOKEN_STRING_INITIALIZER
11118 (struct cmd_vf_vlan_insert_result,
11120 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11121 TOKEN_NUM_INITIALIZER
11122 (struct cmd_vf_vlan_insert_result,
11124 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11125 TOKEN_NUM_INITIALIZER
11126 (struct cmd_vf_vlan_insert_result,
11128 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11129 TOKEN_NUM_INITIALIZER
11130 (struct cmd_vf_vlan_insert_result,
11134 cmd_set_vf_vlan_insert_parsed(
11135 void *parsed_result,
11136 __attribute__((unused)) struct cmdline *cl,
11137 __attribute__((unused)) void *data)
11139 struct cmd_vf_vlan_insert_result *res = parsed_result;
11142 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11147 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11150 printf("invalid port_id %d\n", res->port_id);
11153 printf("programming error: (%s)\n", strerror(-ret));
11157 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11158 .f = cmd_set_vf_vlan_insert_parsed,
11160 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11162 (void *)&cmd_vf_vlan_insert_set,
11163 (void *)&cmd_vf_vlan_insert_vf,
11164 (void *)&cmd_vf_vlan_insert_vlan,
11165 (void *)&cmd_vf_vlan_insert_insert,
11166 (void *)&cmd_vf_vlan_insert_port_id,
11167 (void *)&cmd_vf_vlan_insert_vf_id,
11168 (void *)&cmd_vf_vlan_insert_vlan_id,
11173 /* tx loopback configuration */
11175 /* Common result structure for tx loopback */
11176 struct cmd_tx_loopback_result {
11177 cmdline_fixed_string_t set;
11178 cmdline_fixed_string_t tx;
11179 cmdline_fixed_string_t loopback;
11181 cmdline_fixed_string_t on_off;
11184 /* Common CLI fields for tx loopback enable disable */
11185 cmdline_parse_token_string_t cmd_tx_loopback_set =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_tx_loopback_result,
11189 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11190 TOKEN_STRING_INITIALIZER
11191 (struct cmd_tx_loopback_result,
11193 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11194 TOKEN_STRING_INITIALIZER
11195 (struct cmd_tx_loopback_result,
11196 loopback, "loopback");
11197 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11198 TOKEN_NUM_INITIALIZER
11199 (struct cmd_tx_loopback_result,
11201 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11202 TOKEN_STRING_INITIALIZER
11203 (struct cmd_tx_loopback_result,
11207 cmd_set_tx_loopback_parsed(
11208 void *parsed_result,
11209 __attribute__((unused)) struct cmdline *cl,
11210 __attribute__((unused)) void *data)
11212 struct cmd_tx_loopback_result *res = parsed_result;
11214 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11216 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11221 printf("invalid is_on %d\n", is_on);
11224 printf("invalid port_id %d\n", res->port_id);
11227 printf("programming error: (%s)\n", strerror(-ret));
11231 cmdline_parse_inst_t cmd_set_tx_loopback = {
11232 .f = cmd_set_tx_loopback_parsed,
11234 .help_str = "set tx loopback <port_id> on|off",
11236 (void *)&cmd_tx_loopback_set,
11237 (void *)&cmd_tx_loopback_tx,
11238 (void *)&cmd_tx_loopback_loopback,
11239 (void *)&cmd_tx_loopback_port_id,
11240 (void *)&cmd_tx_loopback_on_off,
11245 /* all queues drop enable configuration */
11247 /* Common result structure for all queues drop enable */
11248 struct cmd_all_queues_drop_en_result {
11249 cmdline_fixed_string_t set;
11250 cmdline_fixed_string_t all;
11251 cmdline_fixed_string_t queues;
11252 cmdline_fixed_string_t drop;
11254 cmdline_fixed_string_t on_off;
11257 /* Common CLI fields for tx loopback enable disable */
11258 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11259 TOKEN_STRING_INITIALIZER
11260 (struct cmd_all_queues_drop_en_result,
11262 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11263 TOKEN_STRING_INITIALIZER
11264 (struct cmd_all_queues_drop_en_result,
11266 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11267 TOKEN_STRING_INITIALIZER
11268 (struct cmd_all_queues_drop_en_result,
11270 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11271 TOKEN_STRING_INITIALIZER
11272 (struct cmd_all_queues_drop_en_result,
11274 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11275 TOKEN_NUM_INITIALIZER
11276 (struct cmd_all_queues_drop_en_result,
11278 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11279 TOKEN_STRING_INITIALIZER
11280 (struct cmd_all_queues_drop_en_result,
11284 cmd_set_all_queues_drop_en_parsed(
11285 void *parsed_result,
11286 __attribute__((unused)) struct cmdline *cl,
11287 __attribute__((unused)) void *data)
11289 struct cmd_all_queues_drop_en_result *res = parsed_result;
11291 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11293 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11298 printf("invalid is_on %d\n", is_on);
11301 printf("invalid port_id %d\n", res->port_id);
11304 printf("programming error: (%s)\n", strerror(-ret));
11308 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11309 .f = cmd_set_all_queues_drop_en_parsed,
11311 .help_str = "set all queues drop <port_id> on|off",
11313 (void *)&cmd_all_queues_drop_en_set,
11314 (void *)&cmd_all_queues_drop_en_all,
11315 (void *)&cmd_all_queues_drop_en_queues,
11316 (void *)&cmd_all_queues_drop_en_drop,
11317 (void *)&cmd_all_queues_drop_en_port_id,
11318 (void *)&cmd_all_queues_drop_en_on_off,
11323 /* vf split drop enable configuration */
11325 /* Common result structure for vf split drop enable */
11326 struct cmd_vf_split_drop_en_result {
11327 cmdline_fixed_string_t set;
11328 cmdline_fixed_string_t vf;
11329 cmdline_fixed_string_t split;
11330 cmdline_fixed_string_t drop;
11333 cmdline_fixed_string_t on_off;
11336 /* Common CLI fields for vf split drop enable disable */
11337 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11338 TOKEN_STRING_INITIALIZER
11339 (struct cmd_vf_split_drop_en_result,
11341 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11342 TOKEN_STRING_INITIALIZER
11343 (struct cmd_vf_split_drop_en_result,
11345 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11346 TOKEN_STRING_INITIALIZER
11347 (struct cmd_vf_split_drop_en_result,
11349 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11350 TOKEN_STRING_INITIALIZER
11351 (struct cmd_vf_split_drop_en_result,
11353 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11354 TOKEN_NUM_INITIALIZER
11355 (struct cmd_vf_split_drop_en_result,
11357 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11358 TOKEN_NUM_INITIALIZER
11359 (struct cmd_vf_split_drop_en_result,
11361 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11362 TOKEN_STRING_INITIALIZER
11363 (struct cmd_vf_split_drop_en_result,
11367 cmd_set_vf_split_drop_en_parsed(
11368 void *parsed_result,
11369 __attribute__((unused)) struct cmdline *cl,
11370 __attribute__((unused)) void *data)
11372 struct cmd_vf_split_drop_en_result *res = parsed_result;
11374 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11376 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11382 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11385 printf("invalid port_id %d\n", res->port_id);
11388 printf("programming error: (%s)\n", strerror(-ret));
11392 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11393 .f = cmd_set_vf_split_drop_en_parsed,
11395 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11397 (void *)&cmd_vf_split_drop_en_set,
11398 (void *)&cmd_vf_split_drop_en_vf,
11399 (void *)&cmd_vf_split_drop_en_split,
11400 (void *)&cmd_vf_split_drop_en_drop,
11401 (void *)&cmd_vf_split_drop_en_port_id,
11402 (void *)&cmd_vf_split_drop_en_vf_id,
11403 (void *)&cmd_vf_split_drop_en_on_off,
11408 /* vf mac address configuration */
11410 /* Common result structure for vf mac address */
11411 struct cmd_set_vf_mac_addr_result {
11412 cmdline_fixed_string_t set;
11413 cmdline_fixed_string_t vf;
11414 cmdline_fixed_string_t mac;
11415 cmdline_fixed_string_t addr;
11418 struct ether_addr mac_addr;
11422 /* Common CLI fields for vf split drop enable disable */
11423 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11424 TOKEN_STRING_INITIALIZER
11425 (struct cmd_set_vf_mac_addr_result,
11427 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11428 TOKEN_STRING_INITIALIZER
11429 (struct cmd_set_vf_mac_addr_result,
11431 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11432 TOKEN_STRING_INITIALIZER
11433 (struct cmd_set_vf_mac_addr_result,
11435 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11436 TOKEN_STRING_INITIALIZER
11437 (struct cmd_set_vf_mac_addr_result,
11439 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11440 TOKEN_NUM_INITIALIZER
11441 (struct cmd_set_vf_mac_addr_result,
11443 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11444 TOKEN_NUM_INITIALIZER
11445 (struct cmd_set_vf_mac_addr_result,
11447 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11448 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11452 cmd_set_vf_mac_addr_parsed(
11453 void *parsed_result,
11454 __attribute__((unused)) struct cmdline *cl,
11455 __attribute__((unused)) void *data)
11457 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11460 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11466 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11469 printf("invalid port_id %d\n", res->port_id);
11472 printf("programming error: (%s)\n", strerror(-ret));
11476 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11477 .f = cmd_set_vf_mac_addr_parsed,
11479 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11481 (void *)&cmd_set_vf_mac_addr_set,
11482 (void *)&cmd_set_vf_mac_addr_vf,
11483 (void *)&cmd_set_vf_mac_addr_mac,
11484 (void *)&cmd_set_vf_mac_addr_addr,
11485 (void *)&cmd_set_vf_mac_addr_port_id,
11486 (void *)&cmd_set_vf_mac_addr_vf_id,
11487 (void *)&cmd_set_vf_mac_addr_mac_addr,
11493 /* ******************************************************************************** */
11495 /* list of instructions */
11496 cmdline_parse_ctx_t main_ctx[] = {
11497 (cmdline_parse_inst_t *)&cmd_help_brief,
11498 (cmdline_parse_inst_t *)&cmd_help_long,
11499 (cmdline_parse_inst_t *)&cmd_quit,
11500 (cmdline_parse_inst_t *)&cmd_showport,
11501 (cmdline_parse_inst_t *)&cmd_showqueue,
11502 (cmdline_parse_inst_t *)&cmd_showportall,
11503 (cmdline_parse_inst_t *)&cmd_showcfg,
11504 (cmdline_parse_inst_t *)&cmd_start,
11505 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11506 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11507 (cmdline_parse_inst_t *)&cmd_set_link_up,
11508 (cmdline_parse_inst_t *)&cmd_set_link_down,
11509 (cmdline_parse_inst_t *)&cmd_reset,
11510 (cmdline_parse_inst_t *)&cmd_set_numbers,
11511 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11512 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11513 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11514 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11515 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11516 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11517 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11518 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11519 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11520 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11521 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11522 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11523 (cmdline_parse_inst_t *)&cmd_set_link_check,
11524 #ifdef RTE_NIC_BYPASS
11525 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11526 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11527 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11528 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11530 #ifdef RTE_LIBRTE_PMD_BOND
11531 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11532 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11533 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11534 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11535 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11536 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11537 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11538 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11539 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11541 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11542 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11543 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11544 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11545 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11546 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11547 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11548 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11549 (cmdline_parse_inst_t *)&cmd_csum_set,
11550 (cmdline_parse_inst_t *)&cmd_csum_show,
11551 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11552 (cmdline_parse_inst_t *)&cmd_tso_set,
11553 (cmdline_parse_inst_t *)&cmd_tso_show,
11554 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11555 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11556 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11557 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11558 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11559 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11560 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11565 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11566 (cmdline_parse_inst_t *)&cmd_config_dcb,
11567 (cmdline_parse_inst_t *)&cmd_read_reg,
11568 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11569 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11570 (cmdline_parse_inst_t *)&cmd_write_reg,
11571 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11572 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11573 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11574 (cmdline_parse_inst_t *)&cmd_stop,
11575 (cmdline_parse_inst_t *)&cmd_mac_addr,
11576 (cmdline_parse_inst_t *)&cmd_set_qmap,
11577 (cmdline_parse_inst_t *)&cmd_operate_port,
11578 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11579 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11580 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11581 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11582 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11583 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11584 (cmdline_parse_inst_t *)&cmd_config_mtu,
11585 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11586 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11587 (cmdline_parse_inst_t *)&cmd_config_rss,
11588 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11589 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11590 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11591 (cmdline_parse_inst_t *)&cmd_showport_reta,
11592 (cmdline_parse_inst_t *)&cmd_config_burst,
11593 (cmdline_parse_inst_t *)&cmd_config_thresh,
11594 (cmdline_parse_inst_t *)&cmd_config_threshold,
11595 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11596 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11597 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11598 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11599 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11600 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11601 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11602 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11603 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11604 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11605 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11606 (cmdline_parse_inst_t *)&cmd_global_config,
11607 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11608 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11609 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11610 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11611 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11612 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11613 (cmdline_parse_inst_t *)&cmd_dump,
11614 (cmdline_parse_inst_t *)&cmd_dump_one,
11615 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11616 (cmdline_parse_inst_t *)&cmd_syn_filter,
11617 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11618 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11619 (cmdline_parse_inst_t *)&cmd_flex_filter,
11620 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11621 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11622 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11623 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11624 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11625 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11626 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11627 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11628 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11629 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11630 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11631 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11632 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11633 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11634 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11635 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11636 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11637 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11638 (cmdline_parse_inst_t *)&cmd_flow,
11639 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11640 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11641 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11642 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11643 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11644 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11645 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11646 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11647 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11648 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11649 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11650 #ifdef RTE_LIBRTE_IXGBE_PMD
11651 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11652 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11653 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11654 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11655 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11656 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11657 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11658 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11663 /* prompt function, called from main on MASTER lcore */
11667 /* initialize non-constant commands */
11668 cmd_set_fwd_mode_init();
11669 cmd_set_fwd_retry_mode_init();
11671 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11672 if (testpmd_cl == NULL)
11674 cmdline_interact(testpmd_cl);
11675 cmdline_stdin_exit(testpmd_cl);
11681 if (testpmd_cl != NULL)
11682 cmdline_quit(testpmd_cl);
11686 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11688 if (id == (portid_t)RTE_PORT_ALL) {
11691 FOREACH_PORT(pid, ports) {
11692 /* check if need_reconfig has been set to 1 */
11693 if (ports[pid].need_reconfig == 0)
11694 ports[pid].need_reconfig = dev;
11695 /* check if need_reconfig_queues has been set to 1 */
11696 if (ports[pid].need_reconfig_queues == 0)
11697 ports[pid].need_reconfig_queues = queue;
11699 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11700 /* check if need_reconfig has been set to 1 */
11701 if (ports[id].need_reconfig == 0)
11702 ports[id].need_reconfig = dev;
11703 /* check if need_reconfig_queues has been set to 1 */
11704 if (ports[id].need_reconfig_queues == 0)
11705 ports[id].need_reconfig_queues = queue;