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 list {port_id} [group {group_id}] [...]\n"
835 " List existing flow rules sorted by priority,"
836 " filtered by group identifiers.\n\n"
841 cmdline_parse_token_string_t cmd_help_long_help =
842 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
844 cmdline_parse_token_string_t cmd_help_long_section =
845 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
846 "all#control#display#config#"
847 "ports#registers#filters");
849 cmdline_parse_inst_t cmd_help_long = {
850 .f = cmd_help_long_parsed,
852 .help_str = "help all|control|display|config|ports|register|filters: "
855 (void *)&cmd_help_long_help,
856 (void *)&cmd_help_long_section,
862 /* *** start/stop/close all ports *** */
863 struct cmd_operate_port_result {
864 cmdline_fixed_string_t keyword;
865 cmdline_fixed_string_t name;
866 cmdline_fixed_string_t value;
869 static void cmd_operate_port_parsed(void *parsed_result,
870 __attribute__((unused)) struct cmdline *cl,
871 __attribute__((unused)) void *data)
873 struct cmd_operate_port_result *res = parsed_result;
875 if (!strcmp(res->name, "start"))
876 start_port(RTE_PORT_ALL);
877 else if (!strcmp(res->name, "stop"))
878 stop_port(RTE_PORT_ALL);
879 else if (!strcmp(res->name, "close"))
880 close_port(RTE_PORT_ALL);
882 printf("Unknown parameter\n");
885 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
886 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
888 cmdline_parse_token_string_t cmd_operate_port_all_port =
889 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
891 cmdline_parse_token_string_t cmd_operate_port_all_all =
892 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
894 cmdline_parse_inst_t cmd_operate_port = {
895 .f = cmd_operate_port_parsed,
897 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
899 (void *)&cmd_operate_port_all_cmd,
900 (void *)&cmd_operate_port_all_port,
901 (void *)&cmd_operate_port_all_all,
906 /* *** start/stop/close specific port *** */
907 struct cmd_operate_specific_port_result {
908 cmdline_fixed_string_t keyword;
909 cmdline_fixed_string_t name;
913 static void cmd_operate_specific_port_parsed(void *parsed_result,
914 __attribute__((unused)) struct cmdline *cl,
915 __attribute__((unused)) void *data)
917 struct cmd_operate_specific_port_result *res = parsed_result;
919 if (!strcmp(res->name, "start"))
920 start_port(res->value);
921 else if (!strcmp(res->name, "stop"))
922 stop_port(res->value);
923 else if (!strcmp(res->name, "close"))
924 close_port(res->value);
926 printf("Unknown parameter\n");
929 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
930 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
932 cmdline_parse_token_string_t cmd_operate_specific_port_port =
933 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
934 name, "start#stop#close");
935 cmdline_parse_token_num_t cmd_operate_specific_port_id =
936 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
939 cmdline_parse_inst_t cmd_operate_specific_port = {
940 .f = cmd_operate_specific_port_parsed,
942 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
944 (void *)&cmd_operate_specific_port_cmd,
945 (void *)&cmd_operate_specific_port_port,
946 (void *)&cmd_operate_specific_port_id,
951 /* *** attach a specified port *** */
952 struct cmd_operate_attach_port_result {
953 cmdline_fixed_string_t port;
954 cmdline_fixed_string_t keyword;
955 cmdline_fixed_string_t identifier;
958 static void cmd_operate_attach_port_parsed(void *parsed_result,
959 __attribute__((unused)) struct cmdline *cl,
960 __attribute__((unused)) void *data)
962 struct cmd_operate_attach_port_result *res = parsed_result;
964 if (!strcmp(res->keyword, "attach"))
965 attach_port(res->identifier);
967 printf("Unknown parameter\n");
970 cmdline_parse_token_string_t cmd_operate_attach_port_port =
971 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
973 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
974 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
976 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
977 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
980 cmdline_parse_inst_t cmd_operate_attach_port = {
981 .f = cmd_operate_attach_port_parsed,
983 .help_str = "port attach <identifier>: "
984 "(identifier: pci address or virtual dev name)",
986 (void *)&cmd_operate_attach_port_port,
987 (void *)&cmd_operate_attach_port_keyword,
988 (void *)&cmd_operate_attach_port_identifier,
993 /* *** detach a specified port *** */
994 struct cmd_operate_detach_port_result {
995 cmdline_fixed_string_t port;
996 cmdline_fixed_string_t keyword;
1000 static void cmd_operate_detach_port_parsed(void *parsed_result,
1001 __attribute__((unused)) struct cmdline *cl,
1002 __attribute__((unused)) void *data)
1004 struct cmd_operate_detach_port_result *res = parsed_result;
1006 if (!strcmp(res->keyword, "detach"))
1007 detach_port(res->port_id);
1009 printf("Unknown parameter\n");
1012 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1013 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1015 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1016 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1018 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1019 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1022 cmdline_parse_inst_t cmd_operate_detach_port = {
1023 .f = cmd_operate_detach_port_parsed,
1025 .help_str = "port detach <port_id>",
1027 (void *)&cmd_operate_detach_port_port,
1028 (void *)&cmd_operate_detach_port_keyword,
1029 (void *)&cmd_operate_detach_port_port_id,
1034 /* *** configure speed for all ports *** */
1035 struct cmd_config_speed_all {
1036 cmdline_fixed_string_t port;
1037 cmdline_fixed_string_t keyword;
1038 cmdline_fixed_string_t all;
1039 cmdline_fixed_string_t item1;
1040 cmdline_fixed_string_t item2;
1041 cmdline_fixed_string_t value1;
1042 cmdline_fixed_string_t value2;
1046 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1051 if (!strcmp(duplexstr, "half")) {
1052 duplex = ETH_LINK_HALF_DUPLEX;
1053 } else if (!strcmp(duplexstr, "full")) {
1054 duplex = ETH_LINK_FULL_DUPLEX;
1055 } else if (!strcmp(duplexstr, "auto")) {
1056 duplex = ETH_LINK_FULL_DUPLEX;
1058 printf("Unknown duplex parameter\n");
1062 if (!strcmp(speedstr, "10")) {
1063 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1064 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1065 } else if (!strcmp(speedstr, "100")) {
1066 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1067 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1069 if (duplex != ETH_LINK_FULL_DUPLEX) {
1070 printf("Invalid speed/duplex parameters\n");
1073 if (!strcmp(speedstr, "1000")) {
1074 *speed = ETH_LINK_SPEED_1G;
1075 } else if (!strcmp(speedstr, "10000")) {
1076 *speed = ETH_LINK_SPEED_10G;
1077 } else if (!strcmp(speedstr, "25000")) {
1078 *speed = ETH_LINK_SPEED_25G;
1079 } else if (!strcmp(speedstr, "40000")) {
1080 *speed = ETH_LINK_SPEED_40G;
1081 } else if (!strcmp(speedstr, "50000")) {
1082 *speed = ETH_LINK_SPEED_50G;
1083 } else if (!strcmp(speedstr, "100000")) {
1084 *speed = ETH_LINK_SPEED_100G;
1085 } else if (!strcmp(speedstr, "auto")) {
1086 *speed = ETH_LINK_SPEED_AUTONEG;
1088 printf("Unknown speed parameter\n");
1097 cmd_config_speed_all_parsed(void *parsed_result,
1098 __attribute__((unused)) struct cmdline *cl,
1099 __attribute__((unused)) void *data)
1101 struct cmd_config_speed_all *res = parsed_result;
1102 uint32_t link_speed;
1105 if (!all_ports_stopped()) {
1106 printf("Please stop all ports first\n");
1110 if (parse_and_check_speed_duplex(res->value1, res->value2,
1114 FOREACH_PORT(pid, ports) {
1115 ports[pid].dev_conf.link_speeds = link_speed;
1118 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1121 cmdline_parse_token_string_t cmd_config_speed_all_port =
1122 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1123 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1124 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1126 cmdline_parse_token_string_t cmd_config_speed_all_all =
1127 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1128 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1129 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1130 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1131 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1132 "10#100#1000#10000#25000#40000#50000#100000#auto");
1133 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1134 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1135 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1139 cmdline_parse_inst_t cmd_config_speed_all = {
1140 .f = cmd_config_speed_all_parsed,
1142 .help_str = "port config all speed "
1143 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1146 (void *)&cmd_config_speed_all_port,
1147 (void *)&cmd_config_speed_all_keyword,
1148 (void *)&cmd_config_speed_all_all,
1149 (void *)&cmd_config_speed_all_item1,
1150 (void *)&cmd_config_speed_all_value1,
1151 (void *)&cmd_config_speed_all_item2,
1152 (void *)&cmd_config_speed_all_value2,
1157 /* *** configure speed for specific port *** */
1158 struct cmd_config_speed_specific {
1159 cmdline_fixed_string_t port;
1160 cmdline_fixed_string_t keyword;
1162 cmdline_fixed_string_t item1;
1163 cmdline_fixed_string_t item2;
1164 cmdline_fixed_string_t value1;
1165 cmdline_fixed_string_t value2;
1169 cmd_config_speed_specific_parsed(void *parsed_result,
1170 __attribute__((unused)) struct cmdline *cl,
1171 __attribute__((unused)) void *data)
1173 struct cmd_config_speed_specific *res = parsed_result;
1174 uint32_t link_speed;
1176 if (!all_ports_stopped()) {
1177 printf("Please stop all ports first\n");
1181 if (port_id_is_invalid(res->id, ENABLED_WARN))
1184 if (parse_and_check_speed_duplex(res->value1, res->value2,
1188 ports[res->id].dev_conf.link_speeds = link_speed;
1190 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1194 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1195 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1197 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1198 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1200 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1201 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1202 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1205 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1206 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1207 "10#100#1000#10000#25000#40000#50000#100000#auto");
1208 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1209 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1211 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1215 cmdline_parse_inst_t cmd_config_speed_specific = {
1216 .f = cmd_config_speed_specific_parsed,
1218 .help_str = "port config <port_id> speed "
1219 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1222 (void *)&cmd_config_speed_specific_port,
1223 (void *)&cmd_config_speed_specific_keyword,
1224 (void *)&cmd_config_speed_specific_id,
1225 (void *)&cmd_config_speed_specific_item1,
1226 (void *)&cmd_config_speed_specific_value1,
1227 (void *)&cmd_config_speed_specific_item2,
1228 (void *)&cmd_config_speed_specific_value2,
1233 /* *** configure txq/rxq, txd/rxd *** */
1234 struct cmd_config_rx_tx {
1235 cmdline_fixed_string_t port;
1236 cmdline_fixed_string_t keyword;
1237 cmdline_fixed_string_t all;
1238 cmdline_fixed_string_t name;
1243 cmd_config_rx_tx_parsed(void *parsed_result,
1244 __attribute__((unused)) struct cmdline *cl,
1245 __attribute__((unused)) void *data)
1247 struct cmd_config_rx_tx *res = parsed_result;
1249 if (!all_ports_stopped()) {
1250 printf("Please stop all ports first\n");
1253 if (!strcmp(res->name, "rxq")) {
1254 if (!res->value && !nb_txq) {
1255 printf("Warning: Either rx or tx queues should be non zero\n");
1258 nb_rxq = res->value;
1260 else if (!strcmp(res->name, "txq")) {
1261 if (!res->value && !nb_rxq) {
1262 printf("Warning: Either rx or tx queues should be non zero\n");
1265 nb_txq = res->value;
1267 else if (!strcmp(res->name, "rxd")) {
1268 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1269 printf("rxd %d invalid - must be > 0 && <= %d\n",
1270 res->value, RTE_TEST_RX_DESC_MAX);
1273 nb_rxd = res->value;
1274 } else if (!strcmp(res->name, "txd")) {
1275 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1276 printf("txd %d invalid - must be > 0 && <= %d\n",
1277 res->value, RTE_TEST_TX_DESC_MAX);
1280 nb_txd = res->value;
1282 printf("Unknown parameter\n");
1290 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1293 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1294 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1295 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1296 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1297 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1298 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1299 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1300 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1302 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1303 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1305 cmdline_parse_inst_t cmd_config_rx_tx = {
1306 .f = cmd_config_rx_tx_parsed,
1308 .help_str = "port config all rxq|txq|rxd|txd <value>",
1310 (void *)&cmd_config_rx_tx_port,
1311 (void *)&cmd_config_rx_tx_keyword,
1312 (void *)&cmd_config_rx_tx_all,
1313 (void *)&cmd_config_rx_tx_name,
1314 (void *)&cmd_config_rx_tx_value,
1319 /* *** config max packet length *** */
1320 struct cmd_config_max_pkt_len_result {
1321 cmdline_fixed_string_t port;
1322 cmdline_fixed_string_t keyword;
1323 cmdline_fixed_string_t all;
1324 cmdline_fixed_string_t name;
1329 cmd_config_max_pkt_len_parsed(void *parsed_result,
1330 __attribute__((unused)) struct cmdline *cl,
1331 __attribute__((unused)) void *data)
1333 struct cmd_config_max_pkt_len_result *res = parsed_result;
1335 if (!all_ports_stopped()) {
1336 printf("Please stop all ports first\n");
1340 if (!strcmp(res->name, "max-pkt-len")) {
1341 if (res->value < ETHER_MIN_LEN) {
1342 printf("max-pkt-len can not be less than %d\n",
1346 if (res->value == rx_mode.max_rx_pkt_len)
1349 rx_mode.max_rx_pkt_len = res->value;
1350 if (res->value > ETHER_MAX_LEN)
1351 rx_mode.jumbo_frame = 1;
1353 rx_mode.jumbo_frame = 0;
1355 printf("Unknown parameter\n");
1361 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1364 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1365 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1367 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1370 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1371 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1373 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1374 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1376 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1377 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1380 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1381 .f = cmd_config_max_pkt_len_parsed,
1383 .help_str = "port config all max-pkt-len <value>",
1385 (void *)&cmd_config_max_pkt_len_port,
1386 (void *)&cmd_config_max_pkt_len_keyword,
1387 (void *)&cmd_config_max_pkt_len_all,
1388 (void *)&cmd_config_max_pkt_len_name,
1389 (void *)&cmd_config_max_pkt_len_value,
1394 /* *** configure port MTU *** */
1395 struct cmd_config_mtu_result {
1396 cmdline_fixed_string_t port;
1397 cmdline_fixed_string_t keyword;
1398 cmdline_fixed_string_t mtu;
1404 cmd_config_mtu_parsed(void *parsed_result,
1405 __attribute__((unused)) struct cmdline *cl,
1406 __attribute__((unused)) void *data)
1408 struct cmd_config_mtu_result *res = parsed_result;
1410 if (res->value < ETHER_MIN_LEN) {
1411 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1414 port_mtu_set(res->port_id, res->value);
1417 cmdline_parse_token_string_t cmd_config_mtu_port =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1420 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1423 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1426 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1427 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1428 cmdline_parse_token_num_t cmd_config_mtu_value =
1429 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1431 cmdline_parse_inst_t cmd_config_mtu = {
1432 .f = cmd_config_mtu_parsed,
1434 .help_str = "port config mtu <port_id> <value>",
1436 (void *)&cmd_config_mtu_port,
1437 (void *)&cmd_config_mtu_keyword,
1438 (void *)&cmd_config_mtu_mtu,
1439 (void *)&cmd_config_mtu_port_id,
1440 (void *)&cmd_config_mtu_value,
1445 /* *** configure rx mode *** */
1446 struct cmd_config_rx_mode_flag {
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t keyword;
1449 cmdline_fixed_string_t all;
1450 cmdline_fixed_string_t name;
1451 cmdline_fixed_string_t value;
1455 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1456 __attribute__((unused)) struct cmdline *cl,
1457 __attribute__((unused)) void *data)
1459 struct cmd_config_rx_mode_flag *res = parsed_result;
1461 if (!all_ports_stopped()) {
1462 printf("Please stop all ports first\n");
1466 if (!strcmp(res->name, "crc-strip")) {
1467 if (!strcmp(res->value, "on"))
1468 rx_mode.hw_strip_crc = 1;
1469 else if (!strcmp(res->value, "off"))
1470 rx_mode.hw_strip_crc = 0;
1472 printf("Unknown parameter\n");
1475 } else if (!strcmp(res->name, "scatter")) {
1476 if (!strcmp(res->value, "on"))
1477 rx_mode.enable_scatter = 1;
1478 else if (!strcmp(res->value, "off"))
1479 rx_mode.enable_scatter = 0;
1481 printf("Unknown parameter\n");
1484 } else if (!strcmp(res->name, "rx-cksum")) {
1485 if (!strcmp(res->value, "on"))
1486 rx_mode.hw_ip_checksum = 1;
1487 else if (!strcmp(res->value, "off"))
1488 rx_mode.hw_ip_checksum = 0;
1490 printf("Unknown parameter\n");
1493 } else if (!strcmp(res->name, "hw-vlan")) {
1494 if (!strcmp(res->value, "on")) {
1495 rx_mode.hw_vlan_filter = 1;
1496 rx_mode.hw_vlan_strip = 1;
1498 else if (!strcmp(res->value, "off")) {
1499 rx_mode.hw_vlan_filter = 0;
1500 rx_mode.hw_vlan_strip = 0;
1503 printf("Unknown parameter\n");
1506 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1507 if (!strcmp(res->value, "on"))
1508 rx_mode.hw_vlan_filter = 1;
1509 else if (!strcmp(res->value, "off"))
1510 rx_mode.hw_vlan_filter = 0;
1512 printf("Unknown parameter\n");
1515 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1516 if (!strcmp(res->value, "on"))
1517 rx_mode.hw_vlan_strip = 1;
1518 else if (!strcmp(res->value, "off"))
1519 rx_mode.hw_vlan_strip = 0;
1521 printf("Unknown parameter\n");
1524 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1525 if (!strcmp(res->value, "on"))
1526 rx_mode.hw_vlan_extend = 1;
1527 else if (!strcmp(res->value, "off"))
1528 rx_mode.hw_vlan_extend = 0;
1530 printf("Unknown parameter\n");
1533 } else if (!strcmp(res->name, "drop-en")) {
1534 if (!strcmp(res->value, "on"))
1536 else if (!strcmp(res->value, "off"))
1539 printf("Unknown parameter\n");
1543 printf("Unknown parameter\n");
1549 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1552 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1554 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1557 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1559 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1561 "crc-strip#scatter#rx-cksum#hw-vlan#"
1562 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1563 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1567 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1568 .f = cmd_config_rx_mode_flag_parsed,
1570 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1571 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1573 (void *)&cmd_config_rx_mode_flag_port,
1574 (void *)&cmd_config_rx_mode_flag_keyword,
1575 (void *)&cmd_config_rx_mode_flag_all,
1576 (void *)&cmd_config_rx_mode_flag_name,
1577 (void *)&cmd_config_rx_mode_flag_value,
1582 /* *** configure rss *** */
1583 struct cmd_config_rss {
1584 cmdline_fixed_string_t port;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t all;
1587 cmdline_fixed_string_t name;
1588 cmdline_fixed_string_t value;
1592 cmd_config_rss_parsed(void *parsed_result,
1593 __attribute__((unused)) struct cmdline *cl,
1594 __attribute__((unused)) void *data)
1596 struct cmd_config_rss *res = parsed_result;
1597 struct rte_eth_rss_conf rss_conf;
1601 if (!strcmp(res->value, "all"))
1602 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1603 ETH_RSS_UDP | ETH_RSS_SCTP |
1605 else if (!strcmp(res->value, "ip"))
1606 rss_conf.rss_hf = ETH_RSS_IP;
1607 else if (!strcmp(res->value, "udp"))
1608 rss_conf.rss_hf = ETH_RSS_UDP;
1609 else if (!strcmp(res->value, "tcp"))
1610 rss_conf.rss_hf = ETH_RSS_TCP;
1611 else if (!strcmp(res->value, "sctp"))
1612 rss_conf.rss_hf = ETH_RSS_SCTP;
1613 else if (!strcmp(res->value, "ether"))
1614 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1615 else if (!strcmp(res->value, "port"))
1616 rss_conf.rss_hf = ETH_RSS_PORT;
1617 else if (!strcmp(res->value, "vxlan"))
1618 rss_conf.rss_hf = ETH_RSS_VXLAN;
1619 else if (!strcmp(res->value, "geneve"))
1620 rss_conf.rss_hf = ETH_RSS_GENEVE;
1621 else if (!strcmp(res->value, "nvgre"))
1622 rss_conf.rss_hf = ETH_RSS_NVGRE;
1623 else if (!strcmp(res->value, "none"))
1624 rss_conf.rss_hf = 0;
1626 printf("Unknown parameter\n");
1629 rss_conf.rss_key = NULL;
1630 for (i = 0; i < rte_eth_dev_count(); i++) {
1631 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1633 printf("Configuration of RSS hash at ethernet port %d "
1634 "failed with error (%d): %s.\n",
1635 i, -diag, strerror(-diag));
1639 cmdline_parse_token_string_t cmd_config_rss_port =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1641 cmdline_parse_token_string_t cmd_config_rss_keyword =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1643 cmdline_parse_token_string_t cmd_config_rss_all =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1645 cmdline_parse_token_string_t cmd_config_rss_name =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1647 cmdline_parse_token_string_t cmd_config_rss_value =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1649 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1651 cmdline_parse_inst_t cmd_config_rss = {
1652 .f = cmd_config_rss_parsed,
1654 .help_str = "port config all rss "
1655 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1657 (void *)&cmd_config_rss_port,
1658 (void *)&cmd_config_rss_keyword,
1659 (void *)&cmd_config_rss_all,
1660 (void *)&cmd_config_rss_name,
1661 (void *)&cmd_config_rss_value,
1666 /* *** configure rss hash key *** */
1667 struct cmd_config_rss_hash_key {
1668 cmdline_fixed_string_t port;
1669 cmdline_fixed_string_t config;
1671 cmdline_fixed_string_t rss_hash_key;
1672 cmdline_fixed_string_t rss_type;
1673 cmdline_fixed_string_t key;
1677 hexa_digit_to_value(char hexa_digit)
1679 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1680 return (uint8_t) (hexa_digit - '0');
1681 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1682 return (uint8_t) ((hexa_digit - 'a') + 10);
1683 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1684 return (uint8_t) ((hexa_digit - 'A') + 10);
1685 /* Invalid hexa digit */
1690 parse_and_check_key_hexa_digit(char *key, int idx)
1694 hexa_v = hexa_digit_to_value(key[idx]);
1696 printf("invalid key: character %c at position %d is not a "
1697 "valid hexa digit\n", key[idx], idx);
1702 cmd_config_rss_hash_key_parsed(void *parsed_result,
1703 __attribute__((unused)) struct cmdline *cl,
1704 __attribute__((unused)) void *data)
1706 struct cmd_config_rss_hash_key *res = parsed_result;
1707 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1711 struct rte_eth_dev_info dev_info;
1712 uint8_t hash_key_size;
1715 memset(&dev_info, 0, sizeof(dev_info));
1716 rte_eth_dev_info_get(res->port_id, &dev_info);
1717 if (dev_info.hash_key_size > 0 &&
1718 dev_info.hash_key_size <= sizeof(hash_key))
1719 hash_key_size = dev_info.hash_key_size;
1721 printf("dev_info did not provide a valid hash key size\n");
1724 /* Check the length of the RSS hash key */
1725 key_len = strlen(res->key);
1726 if (key_len != (hash_key_size * 2)) {
1727 printf("key length: %d invalid - key must be a string of %d"
1728 " hexa-decimal numbers\n",
1729 (int) key_len, hash_key_size * 2);
1732 /* Translate RSS hash key into binary representation */
1733 for (i = 0; i < hash_key_size; i++) {
1734 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1737 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1740 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1742 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1746 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1747 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1748 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1749 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1751 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1752 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1753 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1755 rss_hash_key, "rss-hash-key");
1756 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1758 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1759 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1760 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1761 "ipv6-tcp-ex#ipv6-udp-ex");
1762 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1765 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1766 .f = cmd_config_rss_hash_key_parsed,
1768 .help_str = "port config <port_id> rss-hash-key "
1769 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1770 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1771 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1772 "<string of hex digits (variable length, NIC dependent)>",
1774 (void *)&cmd_config_rss_hash_key_port,
1775 (void *)&cmd_config_rss_hash_key_config,
1776 (void *)&cmd_config_rss_hash_key_port_id,
1777 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1778 (void *)&cmd_config_rss_hash_key_rss_type,
1779 (void *)&cmd_config_rss_hash_key_value,
1784 /* *** configure port rxq/txq start/stop *** */
1785 struct cmd_config_rxtx_queue {
1786 cmdline_fixed_string_t port;
1788 cmdline_fixed_string_t rxtxq;
1790 cmdline_fixed_string_t opname;
1794 cmd_config_rxtx_queue_parsed(void *parsed_result,
1795 __attribute__((unused)) struct cmdline *cl,
1796 __attribute__((unused)) void *data)
1798 struct cmd_config_rxtx_queue *res = parsed_result;
1803 if (test_done == 0) {
1804 printf("Please stop forwarding first\n");
1808 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1811 if (port_is_started(res->portid) != 1) {
1812 printf("Please start port %u first\n", res->portid);
1816 if (!strcmp(res->rxtxq, "rxq"))
1818 else if (!strcmp(res->rxtxq, "txq"))
1821 printf("Unknown parameter\n");
1825 if (isrx && rx_queue_id_is_invalid(res->qid))
1827 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1830 if (!strcmp(res->opname, "start"))
1832 else if (!strcmp(res->opname, "stop"))
1835 printf("Unknown parameter\n");
1839 if (isstart && isrx)
1840 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1841 else if (!isstart && isrx)
1842 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1843 else if (isstart && !isrx)
1844 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1846 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1848 if (ret == -ENOTSUP)
1849 printf("Function not supported in PMD driver\n");
1852 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1854 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1855 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1856 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1858 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1859 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1860 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1864 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1865 .f = cmd_config_rxtx_queue_parsed,
1867 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1869 (void *)&cmd_config_speed_all_port,
1870 (void *)&cmd_config_rxtx_queue_portid,
1871 (void *)&cmd_config_rxtx_queue_rxtxq,
1872 (void *)&cmd_config_rxtx_queue_qid,
1873 (void *)&cmd_config_rxtx_queue_opname,
1878 /* *** Configure RSS RETA *** */
1879 struct cmd_config_rss_reta {
1880 cmdline_fixed_string_t port;
1881 cmdline_fixed_string_t keyword;
1883 cmdline_fixed_string_t name;
1884 cmdline_fixed_string_t list_name;
1885 cmdline_fixed_string_t list_of_items;
1889 parse_reta_config(const char *str,
1890 struct rte_eth_rss_reta_entry64 *reta_conf,
1891 uint16_t nb_entries)
1895 uint16_t hash_index, idx, shift;
1898 const char *p, *p0 = str;
1905 unsigned long int_fld[_NUM_FLD];
1906 char *str_fld[_NUM_FLD];
1908 while ((p = strchr(p0,'(')) != NULL) {
1910 if((p0 = strchr(p,')')) == NULL)
1914 if(size >= sizeof(s))
1917 snprintf(s, sizeof(s), "%.*s", size, p);
1918 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1920 for (i = 0; i < _NUM_FLD; i++) {
1922 int_fld[i] = strtoul(str_fld[i], &end, 0);
1923 if (errno != 0 || end == str_fld[i] ||
1928 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1929 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1931 if (hash_index >= nb_entries) {
1932 printf("Invalid RETA hash index=%d\n", hash_index);
1936 idx = hash_index / RTE_RETA_GROUP_SIZE;
1937 shift = hash_index % RTE_RETA_GROUP_SIZE;
1938 reta_conf[idx].mask |= (1ULL << shift);
1939 reta_conf[idx].reta[shift] = nb_queue;
1946 cmd_set_rss_reta_parsed(void *parsed_result,
1947 __attribute__((unused)) struct cmdline *cl,
1948 __attribute__((unused)) void *data)
1951 struct rte_eth_dev_info dev_info;
1952 struct rte_eth_rss_reta_entry64 reta_conf[8];
1953 struct cmd_config_rss_reta *res = parsed_result;
1955 memset(&dev_info, 0, sizeof(dev_info));
1956 rte_eth_dev_info_get(res->port_id, &dev_info);
1957 if (dev_info.reta_size == 0) {
1958 printf("Redirection table size is 0 which is "
1959 "invalid for RSS\n");
1962 printf("The reta size of port %d is %u\n",
1963 res->port_id, dev_info.reta_size);
1964 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1965 printf("Currently do not support more than %u entries of "
1966 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1970 memset(reta_conf, 0, sizeof(reta_conf));
1971 if (!strcmp(res->list_name, "reta")) {
1972 if (parse_reta_config(res->list_of_items, reta_conf,
1973 dev_info.reta_size)) {
1974 printf("Invalid RSS Redirection Table "
1975 "config entered\n");
1978 ret = rte_eth_dev_rss_reta_update(res->port_id,
1979 reta_conf, dev_info.reta_size);
1981 printf("Bad redirection table parameter, "
1982 "return code = %d \n", ret);
1986 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1987 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1988 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1989 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1990 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1991 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1992 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1994 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1996 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1999 cmdline_parse_inst_t cmd_config_rss_reta = {
2000 .f = cmd_set_rss_reta_parsed,
2002 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2004 (void *)&cmd_config_rss_reta_port,
2005 (void *)&cmd_config_rss_reta_keyword,
2006 (void *)&cmd_config_rss_reta_port_id,
2007 (void *)&cmd_config_rss_reta_name,
2008 (void *)&cmd_config_rss_reta_list_name,
2009 (void *)&cmd_config_rss_reta_list_of_items,
2014 /* *** SHOW PORT RETA INFO *** */
2015 struct cmd_showport_reta {
2016 cmdline_fixed_string_t show;
2017 cmdline_fixed_string_t port;
2019 cmdline_fixed_string_t rss;
2020 cmdline_fixed_string_t reta;
2022 cmdline_fixed_string_t list_of_items;
2026 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2027 uint16_t nb_entries,
2031 const char *p, *p0 = str;
2035 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2038 p = strchr(p0, '(');
2042 p0 = strchr(p, ')');
2046 if (size >= sizeof(s)) {
2047 printf("The string size exceeds the internal buffer size\n");
2050 snprintf(s, sizeof(s), "%.*s", size, p);
2051 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2052 if (ret <= 0 || ret != num) {
2053 printf("The bits of masks do not match the number of "
2054 "reta entries: %u\n", num);
2057 for (i = 0; i < ret; i++)
2058 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2064 cmd_showport_reta_parsed(void *parsed_result,
2065 __attribute__((unused)) struct cmdline *cl,
2066 __attribute__((unused)) void *data)
2068 struct cmd_showport_reta *res = parsed_result;
2069 struct rte_eth_rss_reta_entry64 reta_conf[8];
2070 struct rte_eth_dev_info dev_info;
2072 memset(&dev_info, 0, sizeof(dev_info));
2073 rte_eth_dev_info_get(res->port_id, &dev_info);
2074 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2075 res->size > ETH_RSS_RETA_SIZE_512) {
2076 printf("Invalid redirection table size: %u\n", res->size);
2080 memset(reta_conf, 0, sizeof(reta_conf));
2081 if (showport_parse_reta_config(reta_conf, res->size,
2082 res->list_of_items) < 0) {
2083 printf("Invalid string: %s for reta masks\n",
2084 res->list_of_items);
2087 port_rss_reta_info(res->port_id, reta_conf, res->size);
2090 cmdline_parse_token_string_t cmd_showport_reta_show =
2091 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2092 cmdline_parse_token_string_t cmd_showport_reta_port =
2093 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2094 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2095 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2096 cmdline_parse_token_string_t cmd_showport_reta_rss =
2097 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2098 cmdline_parse_token_string_t cmd_showport_reta_reta =
2099 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2100 cmdline_parse_token_num_t cmd_showport_reta_size =
2101 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2102 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2103 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2104 list_of_items, NULL);
2106 cmdline_parse_inst_t cmd_showport_reta = {
2107 .f = cmd_showport_reta_parsed,
2109 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2111 (void *)&cmd_showport_reta_show,
2112 (void *)&cmd_showport_reta_port,
2113 (void *)&cmd_showport_reta_port_id,
2114 (void *)&cmd_showport_reta_rss,
2115 (void *)&cmd_showport_reta_reta,
2116 (void *)&cmd_showport_reta_size,
2117 (void *)&cmd_showport_reta_list_of_items,
2122 /* *** Show RSS hash configuration *** */
2123 struct cmd_showport_rss_hash {
2124 cmdline_fixed_string_t show;
2125 cmdline_fixed_string_t port;
2127 cmdline_fixed_string_t rss_hash;
2128 cmdline_fixed_string_t rss_type;
2129 cmdline_fixed_string_t key; /* optional argument */
2132 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2133 __attribute__((unused)) struct cmdline *cl,
2136 struct cmd_showport_rss_hash *res = parsed_result;
2138 port_rss_hash_conf_show(res->port_id, res->rss_type,
2139 show_rss_key != NULL);
2142 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2143 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2144 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2145 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2146 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2147 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2148 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2149 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2151 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2152 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2153 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2154 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2155 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2156 "ipv6-tcp-ex#ipv6-udp-ex");
2157 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2158 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2160 cmdline_parse_inst_t cmd_showport_rss_hash = {
2161 .f = cmd_showport_rss_hash_parsed,
2163 .help_str = "show port <port_id> rss-hash "
2164 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2165 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2166 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2168 (void *)&cmd_showport_rss_hash_show,
2169 (void *)&cmd_showport_rss_hash_port,
2170 (void *)&cmd_showport_rss_hash_port_id,
2171 (void *)&cmd_showport_rss_hash_rss_hash,
2172 (void *)&cmd_showport_rss_hash_rss_hash_info,
2177 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2178 .f = cmd_showport_rss_hash_parsed,
2180 .help_str = "show port <port_id> rss-hash "
2181 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2182 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2183 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2185 (void *)&cmd_showport_rss_hash_show,
2186 (void *)&cmd_showport_rss_hash_port,
2187 (void *)&cmd_showport_rss_hash_port_id,
2188 (void *)&cmd_showport_rss_hash_rss_hash,
2189 (void *)&cmd_showport_rss_hash_rss_hash_info,
2190 (void *)&cmd_showport_rss_hash_rss_key,
2195 /* *** Configure DCB *** */
2196 struct cmd_config_dcb {
2197 cmdline_fixed_string_t port;
2198 cmdline_fixed_string_t config;
2200 cmdline_fixed_string_t dcb;
2201 cmdline_fixed_string_t vt;
2202 cmdline_fixed_string_t vt_en;
2204 cmdline_fixed_string_t pfc;
2205 cmdline_fixed_string_t pfc_en;
2209 cmd_config_dcb_parsed(void *parsed_result,
2210 __attribute__((unused)) struct cmdline *cl,
2211 __attribute__((unused)) void *data)
2213 struct cmd_config_dcb *res = parsed_result;
2214 portid_t port_id = res->port_id;
2215 struct rte_port *port;
2219 port = &ports[port_id];
2220 /** Check if the port is not started **/
2221 if (port->port_status != RTE_PORT_STOPPED) {
2222 printf("Please stop port %d first\n", port_id);
2226 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2227 printf("The invalid number of traffic class,"
2228 " only 4 or 8 allowed.\n");
2232 if (nb_fwd_lcores < res->num_tcs) {
2233 printf("nb_cores shouldn't be less than number of TCs.\n");
2236 if (!strncmp(res->pfc_en, "on", 2))
2241 /* DCB in VT mode */
2242 if (!strncmp(res->vt_en, "on", 2))
2243 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2244 (enum rte_eth_nb_tcs)res->num_tcs,
2247 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2248 (enum rte_eth_nb_tcs)res->num_tcs,
2253 printf("Cannot initialize network ports.\n");
2257 cmd_reconfig_device_queue(port_id, 1, 1);
2260 cmdline_parse_token_string_t cmd_config_dcb_port =
2261 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2262 cmdline_parse_token_string_t cmd_config_dcb_config =
2263 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2264 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2265 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2266 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2268 cmdline_parse_token_string_t cmd_config_dcb_vt =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2270 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2271 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2272 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2273 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2274 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2276 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2279 cmdline_parse_inst_t cmd_config_dcb = {
2280 .f = cmd_config_dcb_parsed,
2282 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2284 (void *)&cmd_config_dcb_port,
2285 (void *)&cmd_config_dcb_config,
2286 (void *)&cmd_config_dcb_port_id,
2287 (void *)&cmd_config_dcb_dcb,
2288 (void *)&cmd_config_dcb_vt,
2289 (void *)&cmd_config_dcb_vt_en,
2290 (void *)&cmd_config_dcb_num_tcs,
2291 (void *)&cmd_config_dcb_pfc,
2292 (void *)&cmd_config_dcb_pfc_en,
2297 /* *** configure number of packets per burst *** */
2298 struct cmd_config_burst {
2299 cmdline_fixed_string_t port;
2300 cmdline_fixed_string_t keyword;
2301 cmdline_fixed_string_t all;
2302 cmdline_fixed_string_t name;
2307 cmd_config_burst_parsed(void *parsed_result,
2308 __attribute__((unused)) struct cmdline *cl,
2309 __attribute__((unused)) void *data)
2311 struct cmd_config_burst *res = parsed_result;
2313 if (!all_ports_stopped()) {
2314 printf("Please stop all ports first\n");
2318 if (!strcmp(res->name, "burst")) {
2319 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2320 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2323 nb_pkt_per_burst = res->value;
2325 printf("Unknown parameter\n");
2331 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2334 cmdline_parse_token_string_t cmd_config_burst_port =
2335 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2336 cmdline_parse_token_string_t cmd_config_burst_keyword =
2337 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2338 cmdline_parse_token_string_t cmd_config_burst_all =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2340 cmdline_parse_token_string_t cmd_config_burst_name =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2342 cmdline_parse_token_num_t cmd_config_burst_value =
2343 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2345 cmdline_parse_inst_t cmd_config_burst = {
2346 .f = cmd_config_burst_parsed,
2348 .help_str = "port config all burst <value>",
2350 (void *)&cmd_config_burst_port,
2351 (void *)&cmd_config_burst_keyword,
2352 (void *)&cmd_config_burst_all,
2353 (void *)&cmd_config_burst_name,
2354 (void *)&cmd_config_burst_value,
2359 /* *** configure rx/tx queues *** */
2360 struct cmd_config_thresh {
2361 cmdline_fixed_string_t port;
2362 cmdline_fixed_string_t keyword;
2363 cmdline_fixed_string_t all;
2364 cmdline_fixed_string_t name;
2369 cmd_config_thresh_parsed(void *parsed_result,
2370 __attribute__((unused)) struct cmdline *cl,
2371 __attribute__((unused)) void *data)
2373 struct cmd_config_thresh *res = parsed_result;
2375 if (!all_ports_stopped()) {
2376 printf("Please stop all ports first\n");
2380 if (!strcmp(res->name, "txpt"))
2381 tx_pthresh = res->value;
2382 else if(!strcmp(res->name, "txht"))
2383 tx_hthresh = res->value;
2384 else if(!strcmp(res->name, "txwt"))
2385 tx_wthresh = res->value;
2386 else if(!strcmp(res->name, "rxpt"))
2387 rx_pthresh = res->value;
2388 else if(!strcmp(res->name, "rxht"))
2389 rx_hthresh = res->value;
2390 else if(!strcmp(res->name, "rxwt"))
2391 rx_wthresh = res->value;
2393 printf("Unknown parameter\n");
2399 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2402 cmdline_parse_token_string_t cmd_config_thresh_port =
2403 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2404 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2405 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2406 cmdline_parse_token_string_t cmd_config_thresh_all =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2408 cmdline_parse_token_string_t cmd_config_thresh_name =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2410 "txpt#txht#txwt#rxpt#rxht#rxwt");
2411 cmdline_parse_token_num_t cmd_config_thresh_value =
2412 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2414 cmdline_parse_inst_t cmd_config_thresh = {
2415 .f = cmd_config_thresh_parsed,
2417 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2419 (void *)&cmd_config_thresh_port,
2420 (void *)&cmd_config_thresh_keyword,
2421 (void *)&cmd_config_thresh_all,
2422 (void *)&cmd_config_thresh_name,
2423 (void *)&cmd_config_thresh_value,
2428 /* *** configure free/rs threshold *** */
2429 struct cmd_config_threshold {
2430 cmdline_fixed_string_t port;
2431 cmdline_fixed_string_t keyword;
2432 cmdline_fixed_string_t all;
2433 cmdline_fixed_string_t name;
2438 cmd_config_threshold_parsed(void *parsed_result,
2439 __attribute__((unused)) struct cmdline *cl,
2440 __attribute__((unused)) void *data)
2442 struct cmd_config_threshold *res = parsed_result;
2444 if (!all_ports_stopped()) {
2445 printf("Please stop all ports first\n");
2449 if (!strcmp(res->name, "txfreet"))
2450 tx_free_thresh = res->value;
2451 else if (!strcmp(res->name, "txrst"))
2452 tx_rs_thresh = res->value;
2453 else if (!strcmp(res->name, "rxfreet"))
2454 rx_free_thresh = res->value;
2456 printf("Unknown parameter\n");
2462 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2465 cmdline_parse_token_string_t cmd_config_threshold_port =
2466 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2467 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2468 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2470 cmdline_parse_token_string_t cmd_config_threshold_all =
2471 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2472 cmdline_parse_token_string_t cmd_config_threshold_name =
2473 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2474 "txfreet#txrst#rxfreet");
2475 cmdline_parse_token_num_t cmd_config_threshold_value =
2476 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2478 cmdline_parse_inst_t cmd_config_threshold = {
2479 .f = cmd_config_threshold_parsed,
2481 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2483 (void *)&cmd_config_threshold_port,
2484 (void *)&cmd_config_threshold_keyword,
2485 (void *)&cmd_config_threshold_all,
2486 (void *)&cmd_config_threshold_name,
2487 (void *)&cmd_config_threshold_value,
2493 struct cmd_stop_result {
2494 cmdline_fixed_string_t stop;
2497 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2498 __attribute__((unused)) struct cmdline *cl,
2499 __attribute__((unused)) void *data)
2501 stop_packet_forwarding();
2504 cmdline_parse_token_string_t cmd_stop_stop =
2505 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2507 cmdline_parse_inst_t cmd_stop = {
2508 .f = cmd_stop_parsed,
2510 .help_str = "stop: Stop packet forwarding",
2512 (void *)&cmd_stop_stop,
2517 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2520 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2521 unsigned int *parsed_items, int check_unique_values)
2523 unsigned int nb_item;
2531 * First parse all items in the list and store their value.
2536 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2538 if ((c >= '0') && (c <= '9')) {
2539 value = (unsigned int) (value * 10 + (c - '0'));
2544 printf("character %c is not a decimal digit\n", c);
2548 printf("No valid value before comma\n");
2551 if (nb_item < max_items) {
2552 parsed_items[nb_item] = value;
2558 if (nb_item >= max_items) {
2559 printf("Number of %s = %u > %u (maximum items)\n",
2560 item_name, nb_item + 1, max_items);
2563 parsed_items[nb_item++] = value;
2564 if (! check_unique_values)
2568 * Then, check that all values in the list are differents.
2569 * No optimization here...
2571 for (i = 0; i < nb_item; i++) {
2572 for (j = i + 1; j < nb_item; j++) {
2573 if (parsed_items[j] == parsed_items[i]) {
2574 printf("duplicated %s %u at index %u and %u\n",
2575 item_name, parsed_items[i], i, j);
2583 struct cmd_set_list_result {
2584 cmdline_fixed_string_t cmd_keyword;
2585 cmdline_fixed_string_t list_name;
2586 cmdline_fixed_string_t list_of_items;
2589 static void cmd_set_list_parsed(void *parsed_result,
2590 __attribute__((unused)) struct cmdline *cl,
2591 __attribute__((unused)) void *data)
2593 struct cmd_set_list_result *res;
2595 unsigned int lcorelist[RTE_MAX_LCORE];
2596 unsigned int portlist[RTE_MAX_ETHPORTS];
2598 unsigned int nb_item;
2600 if (test_done == 0) {
2601 printf("Please stop forwarding first\n");
2605 res = parsed_result;
2606 if (!strcmp(res->list_name, "corelist")) {
2607 nb_item = parse_item_list(res->list_of_items, "core",
2609 parsed_items.lcorelist, 1);
2611 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2616 if (!strcmp(res->list_name, "portlist")) {
2617 nb_item = parse_item_list(res->list_of_items, "port",
2619 parsed_items.portlist, 1);
2621 set_fwd_ports_list(parsed_items.portlist, nb_item);
2627 cmdline_parse_token_string_t cmd_set_list_keyword =
2628 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2630 cmdline_parse_token_string_t cmd_set_list_name =
2631 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2632 "corelist#portlist");
2633 cmdline_parse_token_string_t cmd_set_list_of_items =
2634 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2637 cmdline_parse_inst_t cmd_set_fwd_list = {
2638 .f = cmd_set_list_parsed,
2640 .help_str = "set corelist|portlist <list0[,list1]*>",
2642 (void *)&cmd_set_list_keyword,
2643 (void *)&cmd_set_list_name,
2644 (void *)&cmd_set_list_of_items,
2649 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2651 struct cmd_setmask_result {
2652 cmdline_fixed_string_t set;
2653 cmdline_fixed_string_t mask;
2657 static void cmd_set_mask_parsed(void *parsed_result,
2658 __attribute__((unused)) struct cmdline *cl,
2659 __attribute__((unused)) void *data)
2661 struct cmd_setmask_result *res = parsed_result;
2663 if (test_done == 0) {
2664 printf("Please stop forwarding first\n");
2667 if (!strcmp(res->mask, "coremask")) {
2668 set_fwd_lcores_mask(res->hexavalue);
2670 } else if (!strcmp(res->mask, "portmask")) {
2671 set_fwd_ports_mask(res->hexavalue);
2676 cmdline_parse_token_string_t cmd_setmask_set =
2677 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2678 cmdline_parse_token_string_t cmd_setmask_mask =
2679 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2680 "coremask#portmask");
2681 cmdline_parse_token_num_t cmd_setmask_value =
2682 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2684 cmdline_parse_inst_t cmd_set_fwd_mask = {
2685 .f = cmd_set_mask_parsed,
2687 .help_str = "set coremask|portmask <hexadecimal value>",
2689 (void *)&cmd_setmask_set,
2690 (void *)&cmd_setmask_mask,
2691 (void *)&cmd_setmask_value,
2697 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2699 struct cmd_set_result {
2700 cmdline_fixed_string_t set;
2701 cmdline_fixed_string_t what;
2705 static void cmd_set_parsed(void *parsed_result,
2706 __attribute__((unused)) struct cmdline *cl,
2707 __attribute__((unused)) void *data)
2709 struct cmd_set_result *res = parsed_result;
2710 if (!strcmp(res->what, "nbport")) {
2711 set_fwd_ports_number(res->value);
2713 } else if (!strcmp(res->what, "nbcore")) {
2714 set_fwd_lcores_number(res->value);
2716 } else if (!strcmp(res->what, "burst"))
2717 set_nb_pkt_per_burst(res->value);
2718 else if (!strcmp(res->what, "verbose"))
2719 set_verbose_level(res->value);
2722 cmdline_parse_token_string_t cmd_set_set =
2723 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2724 cmdline_parse_token_string_t cmd_set_what =
2725 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2726 "nbport#nbcore#burst#verbose");
2727 cmdline_parse_token_num_t cmd_set_value =
2728 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2730 cmdline_parse_inst_t cmd_set_numbers = {
2731 .f = cmd_set_parsed,
2733 .help_str = "set nbport|nbcore|burst|verbose <value>",
2735 (void *)&cmd_set_set,
2736 (void *)&cmd_set_what,
2737 (void *)&cmd_set_value,
2742 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2744 struct cmd_set_txpkts_result {
2745 cmdline_fixed_string_t cmd_keyword;
2746 cmdline_fixed_string_t txpkts;
2747 cmdline_fixed_string_t seg_lengths;
2751 cmd_set_txpkts_parsed(void *parsed_result,
2752 __attribute__((unused)) struct cmdline *cl,
2753 __attribute__((unused)) void *data)
2755 struct cmd_set_txpkts_result *res;
2756 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2757 unsigned int nb_segs;
2759 res = parsed_result;
2760 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2761 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2763 set_tx_pkt_segments(seg_lengths, nb_segs);
2766 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2767 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2768 cmd_keyword, "set");
2769 cmdline_parse_token_string_t cmd_set_txpkts_name =
2770 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2772 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2773 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2776 cmdline_parse_inst_t cmd_set_txpkts = {
2777 .f = cmd_set_txpkts_parsed,
2779 .help_str = "set txpkts <len0[,len1]*>",
2781 (void *)&cmd_set_txpkts_keyword,
2782 (void *)&cmd_set_txpkts_name,
2783 (void *)&cmd_set_txpkts_lengths,
2788 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2790 struct cmd_set_txsplit_result {
2791 cmdline_fixed_string_t cmd_keyword;
2792 cmdline_fixed_string_t txsplit;
2793 cmdline_fixed_string_t mode;
2797 cmd_set_txsplit_parsed(void *parsed_result,
2798 __attribute__((unused)) struct cmdline *cl,
2799 __attribute__((unused)) void *data)
2801 struct cmd_set_txsplit_result *res;
2803 res = parsed_result;
2804 set_tx_pkt_split(res->mode);
2807 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2808 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2809 cmd_keyword, "set");
2810 cmdline_parse_token_string_t cmd_set_txsplit_name =
2811 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2812 txsplit, "txsplit");
2813 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2814 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2817 cmdline_parse_inst_t cmd_set_txsplit = {
2818 .f = cmd_set_txsplit_parsed,
2820 .help_str = "set txsplit on|off|rand",
2822 (void *)&cmd_set_txsplit_keyword,
2823 (void *)&cmd_set_txsplit_name,
2824 (void *)&cmd_set_txsplit_mode,
2829 /* *** CONFIG TX QUEUE FLAGS *** */
2831 struct cmd_config_txqflags_result {
2832 cmdline_fixed_string_t port;
2833 cmdline_fixed_string_t config;
2834 cmdline_fixed_string_t all;
2835 cmdline_fixed_string_t what;
2839 static void cmd_config_txqflags_parsed(void *parsed_result,
2840 __attribute__((unused)) struct cmdline *cl,
2841 __attribute__((unused)) void *data)
2843 struct cmd_config_txqflags_result *res = parsed_result;
2845 if (!all_ports_stopped()) {
2846 printf("Please stop all ports first\n");
2850 if (strcmp(res->what, "txqflags")) {
2851 printf("Unknown parameter\n");
2855 if (res->hexvalue >= 0) {
2856 txq_flags = res->hexvalue;
2858 printf("txqflags must be >= 0\n");
2864 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2867 cmdline_parse_token_string_t cmd_config_txqflags_port =
2868 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2870 cmdline_parse_token_string_t cmd_config_txqflags_config =
2871 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2873 cmdline_parse_token_string_t cmd_config_txqflags_all =
2874 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2876 cmdline_parse_token_string_t cmd_config_txqflags_what =
2877 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2879 cmdline_parse_token_num_t cmd_config_txqflags_value =
2880 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2883 cmdline_parse_inst_t cmd_config_txqflags = {
2884 .f = cmd_config_txqflags_parsed,
2886 .help_str = "port config all txqflags <value>",
2888 (void *)&cmd_config_txqflags_port,
2889 (void *)&cmd_config_txqflags_config,
2890 (void *)&cmd_config_txqflags_all,
2891 (void *)&cmd_config_txqflags_what,
2892 (void *)&cmd_config_txqflags_value,
2897 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2898 struct cmd_rx_vlan_filter_all_result {
2899 cmdline_fixed_string_t rx_vlan;
2900 cmdline_fixed_string_t what;
2901 cmdline_fixed_string_t all;
2906 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2907 __attribute__((unused)) struct cmdline *cl,
2908 __attribute__((unused)) void *data)
2910 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2912 if (!strcmp(res->what, "add"))
2913 rx_vlan_all_filter_set(res->port_id, 1);
2915 rx_vlan_all_filter_set(res->port_id, 0);
2918 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2919 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2920 rx_vlan, "rx_vlan");
2921 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2922 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2924 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2925 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2927 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2928 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2931 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2932 .f = cmd_rx_vlan_filter_all_parsed,
2934 .help_str = "rx_vlan add|rm all <port_id>: "
2935 "Add/Remove all identifiers to/from the set of VLAN "
2936 "identifiers filtered by a port",
2938 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2939 (void *)&cmd_rx_vlan_filter_all_what,
2940 (void *)&cmd_rx_vlan_filter_all_all,
2941 (void *)&cmd_rx_vlan_filter_all_portid,
2946 /* *** VLAN OFFLOAD SET ON A PORT *** */
2947 struct cmd_vlan_offload_result {
2948 cmdline_fixed_string_t vlan;
2949 cmdline_fixed_string_t set;
2950 cmdline_fixed_string_t vlan_type;
2951 cmdline_fixed_string_t what;
2952 cmdline_fixed_string_t on;
2953 cmdline_fixed_string_t port_id;
2957 cmd_vlan_offload_parsed(void *parsed_result,
2958 __attribute__((unused)) struct cmdline *cl,
2959 __attribute__((unused)) void *data)
2962 struct cmd_vlan_offload_result *res = parsed_result;
2965 portid_t port_id = 0;
2969 len = strnlen(str, STR_TOKEN_SIZE);
2971 /* Get port_id first */
2979 tmp = strtoul(str, NULL, 0);
2980 /* If port_id greater that what portid_t can represent, return */
2981 if(tmp >= RTE_MAX_ETHPORTS)
2983 port_id = (portid_t)tmp;
2985 if (!strcmp(res->on, "on"))
2990 if (!strcmp(res->what, "strip"))
2991 rx_vlan_strip_set(port_id, on);
2992 else if(!strcmp(res->what, "stripq")){
2993 uint16_t queue_id = 0;
2995 /* No queue_id, return */
2997 printf("must specify (port,queue_id)\n");
3000 tmp = strtoul(str + i + 1, NULL, 0);
3001 /* If queue_id greater that what 16-bits can represent, return */
3005 queue_id = (uint16_t)tmp;
3006 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3008 else if (!strcmp(res->what, "filter"))
3009 rx_vlan_filter_set(port_id, on);
3011 vlan_extend_set(port_id, on);
3016 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3017 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3019 cmdline_parse_token_string_t cmd_vlan_offload_set =
3020 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3022 cmdline_parse_token_string_t cmd_vlan_offload_what =
3023 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3024 what, "strip#filter#qinq#stripq");
3025 cmdline_parse_token_string_t cmd_vlan_offload_on =
3026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3028 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3032 cmdline_parse_inst_t cmd_vlan_offload = {
3033 .f = cmd_vlan_offload_parsed,
3035 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3036 "<port_id[,queue_id]>: "
3037 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3039 (void *)&cmd_vlan_offload_vlan,
3040 (void *)&cmd_vlan_offload_set,
3041 (void *)&cmd_vlan_offload_what,
3042 (void *)&cmd_vlan_offload_on,
3043 (void *)&cmd_vlan_offload_portid,
3048 /* *** VLAN TPID SET ON A PORT *** */
3049 struct cmd_vlan_tpid_result {
3050 cmdline_fixed_string_t vlan;
3051 cmdline_fixed_string_t set;
3052 cmdline_fixed_string_t vlan_type;
3053 cmdline_fixed_string_t what;
3059 cmd_vlan_tpid_parsed(void *parsed_result,
3060 __attribute__((unused)) struct cmdline *cl,
3061 __attribute__((unused)) void *data)
3063 struct cmd_vlan_tpid_result *res = parsed_result;
3064 enum rte_vlan_type vlan_type;
3066 if (!strcmp(res->vlan_type, "inner"))
3067 vlan_type = ETH_VLAN_TYPE_INNER;
3068 else if (!strcmp(res->vlan_type, "outer"))
3069 vlan_type = ETH_VLAN_TYPE_OUTER;
3071 printf("Unknown vlan type\n");
3074 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3077 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3078 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3080 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3081 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3083 cmdline_parse_token_string_t cmd_vlan_type =
3084 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3085 vlan_type, "inner#outer");
3086 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3089 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3090 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3092 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3093 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3096 cmdline_parse_inst_t cmd_vlan_tpid = {
3097 .f = cmd_vlan_tpid_parsed,
3099 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3100 "Set the VLAN Ether type",
3102 (void *)&cmd_vlan_tpid_vlan,
3103 (void *)&cmd_vlan_tpid_set,
3104 (void *)&cmd_vlan_type,
3105 (void *)&cmd_vlan_tpid_what,
3106 (void *)&cmd_vlan_tpid_tpid,
3107 (void *)&cmd_vlan_tpid_portid,
3112 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3113 struct cmd_rx_vlan_filter_result {
3114 cmdline_fixed_string_t rx_vlan;
3115 cmdline_fixed_string_t what;
3121 cmd_rx_vlan_filter_parsed(void *parsed_result,
3122 __attribute__((unused)) struct cmdline *cl,
3123 __attribute__((unused)) void *data)
3125 struct cmd_rx_vlan_filter_result *res = parsed_result;
3127 if (!strcmp(res->what, "add"))
3128 rx_vft_set(res->port_id, res->vlan_id, 1);
3130 rx_vft_set(res->port_id, res->vlan_id, 0);
3133 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3135 rx_vlan, "rx_vlan");
3136 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3139 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3140 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3142 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3146 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3147 .f = cmd_rx_vlan_filter_parsed,
3149 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3150 "Add/Remove a VLAN identifier to/from the set of VLAN "
3151 "identifiers filtered by a port",
3153 (void *)&cmd_rx_vlan_filter_rx_vlan,
3154 (void *)&cmd_rx_vlan_filter_what,
3155 (void *)&cmd_rx_vlan_filter_vlanid,
3156 (void *)&cmd_rx_vlan_filter_portid,
3161 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3162 struct cmd_tx_vlan_set_result {
3163 cmdline_fixed_string_t tx_vlan;
3164 cmdline_fixed_string_t set;
3170 cmd_tx_vlan_set_parsed(void *parsed_result,
3171 __attribute__((unused)) struct cmdline *cl,
3172 __attribute__((unused)) void *data)
3174 struct cmd_tx_vlan_set_result *res = parsed_result;
3176 tx_vlan_set(res->port_id, res->vlan_id);
3179 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3180 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3181 tx_vlan, "tx_vlan");
3182 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3183 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3185 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3186 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3188 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3189 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3192 cmdline_parse_inst_t cmd_tx_vlan_set = {
3193 .f = cmd_tx_vlan_set_parsed,
3195 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3196 "Enable hardware insertion of a single VLAN header "
3197 "with a given TAG Identifier in packets sent on a port",
3199 (void *)&cmd_tx_vlan_set_tx_vlan,
3200 (void *)&cmd_tx_vlan_set_set,
3201 (void *)&cmd_tx_vlan_set_portid,
3202 (void *)&cmd_tx_vlan_set_vlanid,
3207 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3208 struct cmd_tx_vlan_set_qinq_result {
3209 cmdline_fixed_string_t tx_vlan;
3210 cmdline_fixed_string_t set;
3213 uint16_t vlan_id_outer;
3217 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3218 __attribute__((unused)) struct cmdline *cl,
3219 __attribute__((unused)) void *data)
3221 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3223 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3226 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3227 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3228 tx_vlan, "tx_vlan");
3229 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3232 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3233 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3235 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3236 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3238 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3239 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3240 vlan_id_outer, UINT16);
3242 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3243 .f = cmd_tx_vlan_set_qinq_parsed,
3245 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3246 "Enable hardware insertion of double VLAN header "
3247 "with given TAG Identifiers in packets sent on a port",
3249 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3250 (void *)&cmd_tx_vlan_set_qinq_set,
3251 (void *)&cmd_tx_vlan_set_qinq_portid,
3252 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3253 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3258 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3259 struct cmd_tx_vlan_set_pvid_result {
3260 cmdline_fixed_string_t tx_vlan;
3261 cmdline_fixed_string_t set;
3262 cmdline_fixed_string_t pvid;
3265 cmdline_fixed_string_t mode;
3269 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3270 __attribute__((unused)) struct cmdline *cl,
3271 __attribute__((unused)) void *data)
3273 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3275 if (strcmp(res->mode, "on") == 0)
3276 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3278 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3281 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3282 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3283 tx_vlan, "tx_vlan");
3284 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3285 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3287 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3288 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3290 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3291 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3293 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3294 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3296 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3300 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3301 .f = cmd_tx_vlan_set_pvid_parsed,
3303 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3305 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3306 (void *)&cmd_tx_vlan_set_pvid_set,
3307 (void *)&cmd_tx_vlan_set_pvid_pvid,
3308 (void *)&cmd_tx_vlan_set_pvid_port_id,
3309 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3310 (void *)&cmd_tx_vlan_set_pvid_mode,
3315 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3316 struct cmd_tx_vlan_reset_result {
3317 cmdline_fixed_string_t tx_vlan;
3318 cmdline_fixed_string_t reset;
3323 cmd_tx_vlan_reset_parsed(void *parsed_result,
3324 __attribute__((unused)) struct cmdline *cl,
3325 __attribute__((unused)) void *data)
3327 struct cmd_tx_vlan_reset_result *res = parsed_result;
3329 tx_vlan_reset(res->port_id);
3332 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3333 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3334 tx_vlan, "tx_vlan");
3335 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3338 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3339 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3342 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3343 .f = cmd_tx_vlan_reset_parsed,
3345 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3346 "VLAN header in packets sent on a port",
3348 (void *)&cmd_tx_vlan_reset_tx_vlan,
3349 (void *)&cmd_tx_vlan_reset_reset,
3350 (void *)&cmd_tx_vlan_reset_portid,
3356 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3357 struct cmd_csum_result {
3358 cmdline_fixed_string_t csum;
3359 cmdline_fixed_string_t mode;
3360 cmdline_fixed_string_t proto;
3361 cmdline_fixed_string_t hwsw;
3366 csum_show(int port_id)
3368 struct rte_eth_dev_info dev_info;
3371 ol_flags = ports[port_id].tx_ol_flags;
3372 printf("Parse tunnel is %s\n",
3373 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3374 printf("IP checksum offload is %s\n",
3375 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3376 printf("UDP checksum offload is %s\n",
3377 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3378 printf("TCP checksum offload is %s\n",
3379 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3380 printf("SCTP checksum offload is %s\n",
3381 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3382 printf("Outer-Ip checksum offload is %s\n",
3383 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3385 /* display warnings if configuration is not supported by the NIC */
3386 rte_eth_dev_info_get(port_id, &dev_info);
3387 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3388 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3389 printf("Warning: hardware IP checksum enabled but not "
3390 "supported by port %d\n", port_id);
3392 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3393 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3394 printf("Warning: hardware UDP checksum enabled but not "
3395 "supported by port %d\n", port_id);
3397 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3398 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3399 printf("Warning: hardware TCP checksum enabled but not "
3400 "supported by port %d\n", port_id);
3402 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3403 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3404 printf("Warning: hardware SCTP checksum enabled but not "
3405 "supported by port %d\n", port_id);
3407 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3408 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3409 printf("Warning: hardware outer IP checksum enabled but not "
3410 "supported by port %d\n", port_id);
3415 cmd_csum_parsed(void *parsed_result,
3416 __attribute__((unused)) struct cmdline *cl,
3417 __attribute__((unused)) void *data)
3419 struct cmd_csum_result *res = parsed_result;
3423 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3424 printf("invalid port %d\n", res->port_id);
3428 if (!strcmp(res->mode, "set")) {
3430 if (!strcmp(res->hwsw, "hw"))
3433 if (!strcmp(res->proto, "ip")) {
3434 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3435 } else if (!strcmp(res->proto, "udp")) {
3436 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3437 } else if (!strcmp(res->proto, "tcp")) {
3438 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3439 } else if (!strcmp(res->proto, "sctp")) {
3440 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3441 } else if (!strcmp(res->proto, "outer-ip")) {
3442 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3446 ports[res->port_id].tx_ol_flags |= mask;
3448 ports[res->port_id].tx_ol_flags &= (~mask);
3450 csum_show(res->port_id);
3453 cmdline_parse_token_string_t cmd_csum_csum =
3454 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3456 cmdline_parse_token_string_t cmd_csum_mode =
3457 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3459 cmdline_parse_token_string_t cmd_csum_proto =
3460 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3461 proto, "ip#tcp#udp#sctp#outer-ip");
3462 cmdline_parse_token_string_t cmd_csum_hwsw =
3463 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3465 cmdline_parse_token_num_t cmd_csum_portid =
3466 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3469 cmdline_parse_inst_t cmd_csum_set = {
3470 .f = cmd_csum_parsed,
3472 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3473 "Enable/Disable hardware calculation of L3/L4 checksum when "
3474 "using csum forward engine",
3476 (void *)&cmd_csum_csum,
3477 (void *)&cmd_csum_mode,
3478 (void *)&cmd_csum_proto,
3479 (void *)&cmd_csum_hwsw,
3480 (void *)&cmd_csum_portid,
3485 cmdline_parse_token_string_t cmd_csum_mode_show =
3486 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3489 cmdline_parse_inst_t cmd_csum_show = {
3490 .f = cmd_csum_parsed,
3492 .help_str = "csum show <port_id>: Show checksum offload configuration",
3494 (void *)&cmd_csum_csum,
3495 (void *)&cmd_csum_mode_show,
3496 (void *)&cmd_csum_portid,
3501 /* Enable/disable tunnel parsing */
3502 struct cmd_csum_tunnel_result {
3503 cmdline_fixed_string_t csum;
3504 cmdline_fixed_string_t parse;
3505 cmdline_fixed_string_t onoff;
3510 cmd_csum_tunnel_parsed(void *parsed_result,
3511 __attribute__((unused)) struct cmdline *cl,
3512 __attribute__((unused)) void *data)
3514 struct cmd_csum_tunnel_result *res = parsed_result;
3516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3519 if (!strcmp(res->onoff, "on"))
3520 ports[res->port_id].tx_ol_flags |=
3521 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3523 ports[res->port_id].tx_ol_flags &=
3524 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3526 csum_show(res->port_id);
3529 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3530 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3532 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3533 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3534 parse, "parse_tunnel");
3535 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3536 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3538 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3539 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3542 cmdline_parse_inst_t cmd_csum_tunnel = {
3543 .f = cmd_csum_tunnel_parsed,
3545 .help_str = "csum parse_tunnel on|off <port_id>: "
3546 "Enable/Disable parsing of tunnels for csum engine",
3548 (void *)&cmd_csum_tunnel_csum,
3549 (void *)&cmd_csum_tunnel_parse,
3550 (void *)&cmd_csum_tunnel_onoff,
3551 (void *)&cmd_csum_tunnel_portid,
3556 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3557 struct cmd_tso_set_result {
3558 cmdline_fixed_string_t tso;
3559 cmdline_fixed_string_t mode;
3565 cmd_tso_set_parsed(void *parsed_result,
3566 __attribute__((unused)) struct cmdline *cl,
3567 __attribute__((unused)) void *data)
3569 struct cmd_tso_set_result *res = parsed_result;
3570 struct rte_eth_dev_info dev_info;
3572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3575 if (!strcmp(res->mode, "set"))
3576 ports[res->port_id].tso_segsz = res->tso_segsz;
3578 if (ports[res->port_id].tso_segsz == 0)
3579 printf("TSO for non-tunneled packets is disabled\n");
3581 printf("TSO segment size for non-tunneled packets is %d\n",
3582 ports[res->port_id].tso_segsz);
3584 /* display warnings if configuration is not supported by the NIC */
3585 rte_eth_dev_info_get(res->port_id, &dev_info);
3586 if ((ports[res->port_id].tso_segsz != 0) &&
3587 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3588 printf("Warning: TSO enabled but not "
3589 "supported by port %d\n", res->port_id);
3593 cmdline_parse_token_string_t cmd_tso_set_tso =
3594 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3596 cmdline_parse_token_string_t cmd_tso_set_mode =
3597 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3599 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3600 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3602 cmdline_parse_token_num_t cmd_tso_set_portid =
3603 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3606 cmdline_parse_inst_t cmd_tso_set = {
3607 .f = cmd_tso_set_parsed,
3609 .help_str = "tso set <tso_segsz> <port_id>: "
3610 "Set TSO segment size of non-tunneled packets for csum engine "
3613 (void *)&cmd_tso_set_tso,
3614 (void *)&cmd_tso_set_mode,
3615 (void *)&cmd_tso_set_tso_segsz,
3616 (void *)&cmd_tso_set_portid,
3621 cmdline_parse_token_string_t cmd_tso_show_mode =
3622 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3626 cmdline_parse_inst_t cmd_tso_show = {
3627 .f = cmd_tso_set_parsed,
3629 .help_str = "tso show <port_id>: "
3630 "Show TSO segment size of non-tunneled packets for csum engine",
3632 (void *)&cmd_tso_set_tso,
3633 (void *)&cmd_tso_show_mode,
3634 (void *)&cmd_tso_set_portid,
3639 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3640 struct cmd_tunnel_tso_set_result {
3641 cmdline_fixed_string_t tso;
3642 cmdline_fixed_string_t mode;
3648 check_tunnel_tso_nic_support(uint8_t port_id)
3650 struct rte_eth_dev_info dev_info;
3652 rte_eth_dev_info_get(port_id, &dev_info);
3653 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3654 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3655 "supported by port %d\n", port_id);
3656 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3657 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3658 "supported by port %d\n", port_id);
3659 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3660 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3661 "supported by port %d\n", port_id);
3662 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3663 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3664 "supported by port %d\n", port_id);
3668 cmd_tunnel_tso_set_parsed(void *parsed_result,
3669 __attribute__((unused)) struct cmdline *cl,
3670 __attribute__((unused)) void *data)
3672 struct cmd_tunnel_tso_set_result *res = parsed_result;
3674 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3677 if (!strcmp(res->mode, "set"))
3678 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3680 if (ports[res->port_id].tunnel_tso_segsz == 0)
3681 printf("TSO for tunneled packets is disabled\n");
3683 printf("TSO segment size for tunneled packets is %d\n",
3684 ports[res->port_id].tunnel_tso_segsz);
3686 /* Below conditions are needed to make it work:
3687 * (1) tunnel TSO is supported by the NIC;
3688 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3690 * (3) for tunneled pkts with outer L3 of IPv4,
3691 * "csum set outer-ip" must be set to hw, because after tso,
3692 * total_len of outer IP header is changed, and the checksum
3693 * of outer IP header calculated by sw should be wrong; that
3694 * is not necessary for IPv6 tunneled pkts because there's no
3695 * checksum in IP header anymore.
3697 check_tunnel_tso_nic_support(res->port_id);
3699 if (!(ports[res->port_id].tx_ol_flags &
3700 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3701 printf("Warning: csum parse_tunnel must be set "
3702 "so that tunneled packets are recognized\n");
3703 if (!(ports[res->port_id].tx_ol_flags &
3704 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3705 printf("Warning: csum set outer-ip must be set to hw "
3706 "if outer L3 is IPv4; not necessary for IPv6\n");
3710 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3711 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3713 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3714 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3716 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3717 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3719 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3720 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3723 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3724 .f = cmd_tunnel_tso_set_parsed,
3726 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3727 "Set TSO segment size of tunneled packets for csum engine "
3730 (void *)&cmd_tunnel_tso_set_tso,
3731 (void *)&cmd_tunnel_tso_set_mode,
3732 (void *)&cmd_tunnel_tso_set_tso_segsz,
3733 (void *)&cmd_tunnel_tso_set_portid,
3738 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3739 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3743 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3744 .f = cmd_tunnel_tso_set_parsed,
3746 .help_str = "tunnel_tso show <port_id> "
3747 "Show TSO segment size of tunneled packets for csum engine",
3749 (void *)&cmd_tunnel_tso_set_tso,
3750 (void *)&cmd_tunnel_tso_show_mode,
3751 (void *)&cmd_tunnel_tso_set_portid,
3756 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3757 struct cmd_set_flush_rx {
3758 cmdline_fixed_string_t set;
3759 cmdline_fixed_string_t flush_rx;
3760 cmdline_fixed_string_t mode;
3764 cmd_set_flush_rx_parsed(void *parsed_result,
3765 __attribute__((unused)) struct cmdline *cl,
3766 __attribute__((unused)) void *data)
3768 struct cmd_set_flush_rx *res = parsed_result;
3769 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3772 cmdline_parse_token_string_t cmd_setflushrx_set =
3773 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3775 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3777 flush_rx, "flush_rx");
3778 cmdline_parse_token_string_t cmd_setflushrx_mode =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3783 cmdline_parse_inst_t cmd_set_flush_rx = {
3784 .f = cmd_set_flush_rx_parsed,
3785 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3788 (void *)&cmd_setflushrx_set,
3789 (void *)&cmd_setflushrx_flush_rx,
3790 (void *)&cmd_setflushrx_mode,
3795 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3796 struct cmd_set_link_check {
3797 cmdline_fixed_string_t set;
3798 cmdline_fixed_string_t link_check;
3799 cmdline_fixed_string_t mode;
3803 cmd_set_link_check_parsed(void *parsed_result,
3804 __attribute__((unused)) struct cmdline *cl,
3805 __attribute__((unused)) void *data)
3807 struct cmd_set_link_check *res = parsed_result;
3808 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3811 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3812 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3814 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3815 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3816 link_check, "link_check");
3817 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3818 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3822 cmdline_parse_inst_t cmd_set_link_check = {
3823 .f = cmd_set_link_check_parsed,
3824 .help_str = "set link_check on|off: Enable/Disable link status check "
3825 "when starting/stopping a port",
3828 (void *)&cmd_setlinkcheck_set,
3829 (void *)&cmd_setlinkcheck_link_check,
3830 (void *)&cmd_setlinkcheck_mode,
3835 #ifdef RTE_NIC_BYPASS
3836 /* *** SET NIC BYPASS MODE *** */
3837 struct cmd_set_bypass_mode_result {
3838 cmdline_fixed_string_t set;
3839 cmdline_fixed_string_t bypass;
3840 cmdline_fixed_string_t mode;
3841 cmdline_fixed_string_t value;
3846 cmd_set_bypass_mode_parsed(void *parsed_result,
3847 __attribute__((unused)) struct cmdline *cl,
3848 __attribute__((unused)) void *data)
3850 struct cmd_set_bypass_mode_result *res = parsed_result;
3851 portid_t port_id = res->port_id;
3852 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3854 if (!strcmp(res->value, "bypass"))
3855 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3856 else if (!strcmp(res->value, "isolate"))
3857 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3859 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3861 /* Set the bypass mode for the relevant port. */
3862 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3863 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3867 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3868 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3870 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3873 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3876 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3878 value, "normal#bypass#isolate");
3879 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3880 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3883 cmdline_parse_inst_t cmd_set_bypass_mode = {
3884 .f = cmd_set_bypass_mode_parsed,
3885 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3886 "Set the NIC bypass mode for port_id",
3889 (void *)&cmd_setbypass_mode_set,
3890 (void *)&cmd_setbypass_mode_bypass,
3891 (void *)&cmd_setbypass_mode_mode,
3892 (void *)&cmd_setbypass_mode_value,
3893 (void *)&cmd_setbypass_mode_port,
3898 /* *** SET NIC BYPASS EVENT *** */
3899 struct cmd_set_bypass_event_result {
3900 cmdline_fixed_string_t set;
3901 cmdline_fixed_string_t bypass;
3902 cmdline_fixed_string_t event;
3903 cmdline_fixed_string_t event_value;
3904 cmdline_fixed_string_t mode;
3905 cmdline_fixed_string_t mode_value;
3910 cmd_set_bypass_event_parsed(void *parsed_result,
3911 __attribute__((unused)) struct cmdline *cl,
3912 __attribute__((unused)) void *data)
3915 struct cmd_set_bypass_event_result *res = parsed_result;
3916 portid_t port_id = res->port_id;
3917 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3918 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3920 if (!strcmp(res->event_value, "timeout"))
3921 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3922 else if (!strcmp(res->event_value, "os_on"))
3923 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3924 else if (!strcmp(res->event_value, "os_off"))
3925 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3926 else if (!strcmp(res->event_value, "power_on"))
3927 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3928 else if (!strcmp(res->event_value, "power_off"))
3929 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3931 bypass_event = RTE_BYPASS_EVENT_NONE;
3933 if (!strcmp(res->mode_value, "bypass"))
3934 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3935 else if (!strcmp(res->mode_value, "isolate"))
3936 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3938 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3940 /* Set the watchdog timeout. */
3941 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3944 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3945 (rc = rte_eth_dev_wd_timeout_store(port_id,
3946 bypass_timeout)) != 0) {
3947 printf("Failed to set timeout value %u "
3948 "for port %d, errto code: %d.\n",
3949 bypass_timeout, port_id, rc);
3953 /* Set the bypass event to transition to bypass mode. */
3954 if (0 != rte_eth_dev_bypass_event_store(port_id,
3955 bypass_event, bypass_mode)) {
3956 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3961 cmdline_parse_token_string_t cmd_setbypass_event_set =
3962 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3964 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3965 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3967 cmdline_parse_token_string_t cmd_setbypass_event_event =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3970 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3971 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3972 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3973 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3976 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3977 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3978 mode_value, "normal#bypass#isolate");
3979 cmdline_parse_token_num_t cmd_setbypass_event_port =
3980 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3983 cmdline_parse_inst_t cmd_set_bypass_event = {
3984 .f = cmd_set_bypass_event_parsed,
3985 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
3986 "power_off mode normal|bypass|isolate <port_id>: "
3987 "Set the NIC bypass event mode for port_id",
3990 (void *)&cmd_setbypass_event_set,
3991 (void *)&cmd_setbypass_event_bypass,
3992 (void *)&cmd_setbypass_event_event,
3993 (void *)&cmd_setbypass_event_event_value,
3994 (void *)&cmd_setbypass_event_mode,
3995 (void *)&cmd_setbypass_event_mode_value,
3996 (void *)&cmd_setbypass_event_port,
4002 /* *** SET NIC BYPASS TIMEOUT *** */
4003 struct cmd_set_bypass_timeout_result {
4004 cmdline_fixed_string_t set;
4005 cmdline_fixed_string_t bypass;
4006 cmdline_fixed_string_t timeout;
4007 cmdline_fixed_string_t value;
4011 cmd_set_bypass_timeout_parsed(void *parsed_result,
4012 __attribute__((unused)) struct cmdline *cl,
4013 __attribute__((unused)) void *data)
4015 struct cmd_set_bypass_timeout_result *res = parsed_result;
4017 if (!strcmp(res->value, "1.5"))
4018 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4019 else if (!strcmp(res->value, "2"))
4020 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4021 else if (!strcmp(res->value, "3"))
4022 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4023 else if (!strcmp(res->value, "4"))
4024 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4025 else if (!strcmp(res->value, "8"))
4026 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4027 else if (!strcmp(res->value, "16"))
4028 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4029 else if (!strcmp(res->value, "32"))
4030 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4032 bypass_timeout = RTE_BYPASS_TMT_OFF;
4035 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4036 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4038 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4039 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4041 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4042 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4043 timeout, "timeout");
4044 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4046 value, "0#1.5#2#3#4#8#16#32");
4048 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4049 .f = cmd_set_bypass_timeout_parsed,
4050 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4051 "Set the NIC bypass watchdog timeout in seconds",
4054 (void *)&cmd_setbypass_timeout_set,
4055 (void *)&cmd_setbypass_timeout_bypass,
4056 (void *)&cmd_setbypass_timeout_timeout,
4057 (void *)&cmd_setbypass_timeout_value,
4062 /* *** SHOW NIC BYPASS MODE *** */
4063 struct cmd_show_bypass_config_result {
4064 cmdline_fixed_string_t show;
4065 cmdline_fixed_string_t bypass;
4066 cmdline_fixed_string_t config;
4071 cmd_show_bypass_config_parsed(void *parsed_result,
4072 __attribute__((unused)) struct cmdline *cl,
4073 __attribute__((unused)) void *data)
4075 struct cmd_show_bypass_config_result *res = parsed_result;
4076 uint32_t event_mode;
4077 uint32_t bypass_mode;
4078 portid_t port_id = res->port_id;
4079 uint32_t timeout = bypass_timeout;
4082 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4083 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4084 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4085 {"UNKNOWN", "normal", "bypass", "isolate"};
4086 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4093 int num_events = (sizeof events) / (sizeof events[0]);
4095 /* Display the bypass mode.*/
4096 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4097 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4101 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4102 bypass_mode = RTE_BYPASS_MODE_NONE;
4104 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4107 /* Display the bypass timeout.*/
4108 if (!RTE_BYPASS_TMT_VALID(timeout))
4109 timeout = RTE_BYPASS_TMT_OFF;
4111 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4113 /* Display the bypass events and associated modes. */
4114 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4116 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4117 printf("\tFailed to get bypass mode for event = %s\n",
4120 if (!RTE_BYPASS_MODE_VALID(event_mode))
4121 event_mode = RTE_BYPASS_MODE_NONE;
4123 printf("\tbypass event: %-16s = %s\n", events[i],
4129 cmdline_parse_token_string_t cmd_showbypass_config_show =
4130 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4132 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4133 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4135 cmdline_parse_token_string_t cmd_showbypass_config_config =
4136 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4138 cmdline_parse_token_num_t cmd_showbypass_config_port =
4139 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4142 cmdline_parse_inst_t cmd_show_bypass_config = {
4143 .f = cmd_show_bypass_config_parsed,
4144 .help_str = "show bypass config <port_id>: "
4145 "Show the NIC bypass config for port_id",
4148 (void *)&cmd_showbypass_config_show,
4149 (void *)&cmd_showbypass_config_bypass,
4150 (void *)&cmd_showbypass_config_config,
4151 (void *)&cmd_showbypass_config_port,
4157 #ifdef RTE_LIBRTE_PMD_BOND
4158 /* *** SET BONDING MODE *** */
4159 struct cmd_set_bonding_mode_result {
4160 cmdline_fixed_string_t set;
4161 cmdline_fixed_string_t bonding;
4162 cmdline_fixed_string_t mode;
4167 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4168 __attribute__((unused)) struct cmdline *cl,
4169 __attribute__((unused)) void *data)
4171 struct cmd_set_bonding_mode_result *res = parsed_result;
4172 portid_t port_id = res->port_id;
4174 /* Set the bonding mode for the relevant port. */
4175 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4176 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4179 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4180 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4182 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4183 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4184 bonding, "bonding");
4185 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4186 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4188 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4189 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4191 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4192 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4195 cmdline_parse_inst_t cmd_set_bonding_mode = {
4196 .f = cmd_set_bonding_mode_parsed,
4197 .help_str = "set bonding mode <mode_value> <port_id>: "
4198 "Set the bonding mode for port_id",
4201 (void *) &cmd_setbonding_mode_set,
4202 (void *) &cmd_setbonding_mode_bonding,
4203 (void *) &cmd_setbonding_mode_mode,
4204 (void *) &cmd_setbonding_mode_value,
4205 (void *) &cmd_setbonding_mode_port,
4210 /* *** SET BALANCE XMIT POLICY *** */
4211 struct cmd_set_bonding_balance_xmit_policy_result {
4212 cmdline_fixed_string_t set;
4213 cmdline_fixed_string_t bonding;
4214 cmdline_fixed_string_t balance_xmit_policy;
4216 cmdline_fixed_string_t policy;
4219 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4220 __attribute__((unused)) struct cmdline *cl,
4221 __attribute__((unused)) void *data)
4223 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4224 portid_t port_id = res->port_id;
4227 if (!strcmp(res->policy, "l2")) {
4228 policy = BALANCE_XMIT_POLICY_LAYER2;
4229 } else if (!strcmp(res->policy, "l23")) {
4230 policy = BALANCE_XMIT_POLICY_LAYER23;
4231 } else if (!strcmp(res->policy, "l34")) {
4232 policy = BALANCE_XMIT_POLICY_LAYER34;
4234 printf("\t Invalid xmit policy selection");
4238 /* Set the bonding mode for the relevant port. */
4239 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4240 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4245 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4246 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4248 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4249 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4250 bonding, "bonding");
4251 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4252 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4253 balance_xmit_policy, "balance_xmit_policy");
4254 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4255 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4257 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4259 policy, "l2#l23#l34");
4261 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4262 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4263 .help_str = "set bonding balance_xmit_policy <port_id> "
4265 "Set the bonding balance_xmit_policy for port_id",
4268 (void *)&cmd_setbonding_balance_xmit_policy_set,
4269 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4270 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4271 (void *)&cmd_setbonding_balance_xmit_policy_port,
4272 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4277 /* *** SHOW NIC BONDING CONFIGURATION *** */
4278 struct cmd_show_bonding_config_result {
4279 cmdline_fixed_string_t show;
4280 cmdline_fixed_string_t bonding;
4281 cmdline_fixed_string_t config;
4285 static void cmd_show_bonding_config_parsed(void *parsed_result,
4286 __attribute__((unused)) struct cmdline *cl,
4287 __attribute__((unused)) void *data)
4289 struct cmd_show_bonding_config_result *res = parsed_result;
4291 uint8_t slaves[RTE_MAX_ETHPORTS];
4292 int num_slaves, num_active_slaves;
4295 portid_t port_id = res->port_id;
4297 /* Display the bonding mode.*/
4298 bonding_mode = rte_eth_bond_mode_get(port_id);
4299 if (bonding_mode < 0) {
4300 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4303 printf("\tBonding mode: %d\n", bonding_mode);
4305 if (bonding_mode == BONDING_MODE_BALANCE) {
4306 int balance_xmit_policy;
4308 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4309 if (balance_xmit_policy < 0) {
4310 printf("\tFailed to get balance xmit policy for port = %d\n",
4314 printf("\tBalance Xmit Policy: ");
4316 switch (balance_xmit_policy) {
4317 case BALANCE_XMIT_POLICY_LAYER2:
4318 printf("BALANCE_XMIT_POLICY_LAYER2");
4320 case BALANCE_XMIT_POLICY_LAYER23:
4321 printf("BALANCE_XMIT_POLICY_LAYER23");
4323 case BALANCE_XMIT_POLICY_LAYER34:
4324 printf("BALANCE_XMIT_POLICY_LAYER34");
4331 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4333 if (num_slaves < 0) {
4334 printf("\tFailed to get slave list for port = %d\n", port_id);
4337 if (num_slaves > 0) {
4338 printf("\tSlaves (%d): [", num_slaves);
4339 for (i = 0; i < num_slaves - 1; i++)
4340 printf("%d ", slaves[i]);
4342 printf("%d]\n", slaves[num_slaves - 1]);
4344 printf("\tSlaves: []\n");
4348 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4351 if (num_active_slaves < 0) {
4352 printf("\tFailed to get active slave list for port = %d\n", port_id);
4355 if (num_active_slaves > 0) {
4356 printf("\tActive Slaves (%d): [", num_active_slaves);
4357 for (i = 0; i < num_active_slaves - 1; i++)
4358 printf("%d ", slaves[i]);
4360 printf("%d]\n", slaves[num_active_slaves - 1]);
4363 printf("\tActive Slaves: []\n");
4367 primary_id = rte_eth_bond_primary_get(port_id);
4368 if (primary_id < 0) {
4369 printf("\tFailed to get primary slave for port = %d\n", port_id);
4372 printf("\tPrimary: [%d]\n", primary_id);
4376 cmdline_parse_token_string_t cmd_showbonding_config_show =
4377 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4379 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4380 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4381 bonding, "bonding");
4382 cmdline_parse_token_string_t cmd_showbonding_config_config =
4383 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4385 cmdline_parse_token_num_t cmd_showbonding_config_port =
4386 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4389 cmdline_parse_inst_t cmd_show_bonding_config = {
4390 .f = cmd_show_bonding_config_parsed,
4391 .help_str = "show bonding config <port_id>: "
4392 "Show the bonding config for port_id",
4395 (void *)&cmd_showbonding_config_show,
4396 (void *)&cmd_showbonding_config_bonding,
4397 (void *)&cmd_showbonding_config_config,
4398 (void *)&cmd_showbonding_config_port,
4403 /* *** SET BONDING PRIMARY *** */
4404 struct cmd_set_bonding_primary_result {
4405 cmdline_fixed_string_t set;
4406 cmdline_fixed_string_t bonding;
4407 cmdline_fixed_string_t primary;
4412 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4413 __attribute__((unused)) struct cmdline *cl,
4414 __attribute__((unused)) void *data)
4416 struct cmd_set_bonding_primary_result *res = parsed_result;
4417 portid_t master_port_id = res->port_id;
4418 portid_t slave_port_id = res->slave_id;
4420 /* Set the primary slave for a bonded device. */
4421 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4422 printf("\t Failed to set primary slave for port = %d.\n",
4429 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4430 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4432 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4433 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4434 bonding, "bonding");
4435 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4436 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4437 primary, "primary");
4438 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4439 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4441 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4442 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4445 cmdline_parse_inst_t cmd_set_bonding_primary = {
4446 .f = cmd_set_bonding_primary_parsed,
4447 .help_str = "set bonding primary <slave_id> <port_id>: "
4448 "Set the primary slave for port_id",
4451 (void *)&cmd_setbonding_primary_set,
4452 (void *)&cmd_setbonding_primary_bonding,
4453 (void *)&cmd_setbonding_primary_primary,
4454 (void *)&cmd_setbonding_primary_slave,
4455 (void *)&cmd_setbonding_primary_port,
4460 /* *** ADD SLAVE *** */
4461 struct cmd_add_bonding_slave_result {
4462 cmdline_fixed_string_t add;
4463 cmdline_fixed_string_t bonding;
4464 cmdline_fixed_string_t slave;
4469 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4470 __attribute__((unused)) struct cmdline *cl,
4471 __attribute__((unused)) void *data)
4473 struct cmd_add_bonding_slave_result *res = parsed_result;
4474 portid_t master_port_id = res->port_id;
4475 portid_t slave_port_id = res->slave_id;
4477 /* Set the primary slave for a bonded device. */
4478 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4479 printf("\t Failed to add slave %d to master port = %d.\n",
4480 slave_port_id, master_port_id);
4484 set_port_slave_flag(slave_port_id);
4487 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4488 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4490 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4491 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4492 bonding, "bonding");
4493 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4494 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4496 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4497 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4499 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4500 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4503 cmdline_parse_inst_t cmd_add_bonding_slave = {
4504 .f = cmd_add_bonding_slave_parsed,
4505 .help_str = "add bonding slave <slave_id> <port_id>: "
4506 "Add a slave device to a bonded device",
4509 (void *)&cmd_addbonding_slave_add,
4510 (void *)&cmd_addbonding_slave_bonding,
4511 (void *)&cmd_addbonding_slave_slave,
4512 (void *)&cmd_addbonding_slave_slaveid,
4513 (void *)&cmd_addbonding_slave_port,
4518 /* *** REMOVE SLAVE *** */
4519 struct cmd_remove_bonding_slave_result {
4520 cmdline_fixed_string_t remove;
4521 cmdline_fixed_string_t bonding;
4522 cmdline_fixed_string_t slave;
4527 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4528 __attribute__((unused)) struct cmdline *cl,
4529 __attribute__((unused)) void *data)
4531 struct cmd_remove_bonding_slave_result *res = parsed_result;
4532 portid_t master_port_id = res->port_id;
4533 portid_t slave_port_id = res->slave_id;
4535 /* Set the primary slave for a bonded device. */
4536 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4537 printf("\t Failed to remove slave %d from master port = %d.\n",
4538 slave_port_id, master_port_id);
4542 clear_port_slave_flag(slave_port_id);
4545 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4546 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4548 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4549 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4550 bonding, "bonding");
4551 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4552 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4554 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4555 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4557 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4558 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4561 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4562 .f = cmd_remove_bonding_slave_parsed,
4563 .help_str = "remove bonding slave <slave_id> <port_id>: "
4564 "Remove a slave device from a bonded device",
4567 (void *)&cmd_removebonding_slave_remove,
4568 (void *)&cmd_removebonding_slave_bonding,
4569 (void *)&cmd_removebonding_slave_slave,
4570 (void *)&cmd_removebonding_slave_slaveid,
4571 (void *)&cmd_removebonding_slave_port,
4576 /* *** CREATE BONDED DEVICE *** */
4577 struct cmd_create_bonded_device_result {
4578 cmdline_fixed_string_t create;
4579 cmdline_fixed_string_t bonded;
4580 cmdline_fixed_string_t device;
4585 static int bond_dev_num = 0;
4587 static void cmd_create_bonded_device_parsed(void *parsed_result,
4588 __attribute__((unused)) struct cmdline *cl,
4589 __attribute__((unused)) void *data)
4591 struct cmd_create_bonded_device_result *res = parsed_result;
4592 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4595 if (test_done == 0) {
4596 printf("Please stop forwarding first\n");
4600 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4603 /* Create a new bonded device. */
4604 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4606 printf("\t Failed to create bonded device.\n");
4609 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4612 /* Update number of ports */
4613 nb_ports = rte_eth_dev_count();
4614 reconfig(port_id, res->socket);
4615 rte_eth_promiscuous_enable(port_id);
4616 ports[port_id].enabled = 1;
4621 cmdline_parse_token_string_t cmd_createbonded_device_create =
4622 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4624 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4625 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4627 cmdline_parse_token_string_t cmd_createbonded_device_device =
4628 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4630 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4631 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4633 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4634 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4637 cmdline_parse_inst_t cmd_create_bonded_device = {
4638 .f = cmd_create_bonded_device_parsed,
4639 .help_str = "create bonded device <mode> <socket>: "
4640 "Create a new bonded device with specific bonding mode and socket",
4643 (void *)&cmd_createbonded_device_create,
4644 (void *)&cmd_createbonded_device_bonded,
4645 (void *)&cmd_createbonded_device_device,
4646 (void *)&cmd_createbonded_device_mode,
4647 (void *)&cmd_createbonded_device_socket,
4652 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4653 struct cmd_set_bond_mac_addr_result {
4654 cmdline_fixed_string_t set;
4655 cmdline_fixed_string_t bonding;
4656 cmdline_fixed_string_t mac_addr;
4658 struct ether_addr address;
4661 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4662 __attribute__((unused)) struct cmdline *cl,
4663 __attribute__((unused)) void *data)
4665 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4668 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4671 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4673 /* check the return value and print it if is < 0 */
4675 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4678 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4679 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4680 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4681 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4683 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4684 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4686 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4687 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4688 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4691 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4692 .f = cmd_set_bond_mac_addr_parsed,
4694 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4696 (void *)&cmd_set_bond_mac_addr_set,
4697 (void *)&cmd_set_bond_mac_addr_bonding,
4698 (void *)&cmd_set_bond_mac_addr_mac,
4699 (void *)&cmd_set_bond_mac_addr_portnum,
4700 (void *)&cmd_set_bond_mac_addr_addr,
4706 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4707 struct cmd_set_bond_mon_period_result {
4708 cmdline_fixed_string_t set;
4709 cmdline_fixed_string_t bonding;
4710 cmdline_fixed_string_t mon_period;
4715 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4716 __attribute__((unused)) struct cmdline *cl,
4717 __attribute__((unused)) void *data)
4719 struct cmd_set_bond_mon_period_result *res = parsed_result;
4722 if (res->port_num >= nb_ports) {
4723 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4727 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4729 /* check the return value and print it if is < 0 */
4731 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4734 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4735 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4737 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4738 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4739 bonding, "bonding");
4740 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4741 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4742 mon_period, "mon_period");
4743 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4744 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4746 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4747 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4750 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4751 .f = cmd_set_bond_mon_period_parsed,
4753 .help_str = "set bonding mon_period <port_id> <period_ms>",
4755 (void *)&cmd_set_bond_mon_period_set,
4756 (void *)&cmd_set_bond_mon_period_bonding,
4757 (void *)&cmd_set_bond_mon_period_mon_period,
4758 (void *)&cmd_set_bond_mon_period_portnum,
4759 (void *)&cmd_set_bond_mon_period_period_ms,
4764 #endif /* RTE_LIBRTE_PMD_BOND */
4766 /* *** SET FORWARDING MODE *** */
4767 struct cmd_set_fwd_mode_result {
4768 cmdline_fixed_string_t set;
4769 cmdline_fixed_string_t fwd;
4770 cmdline_fixed_string_t mode;
4773 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4774 __attribute__((unused)) struct cmdline *cl,
4775 __attribute__((unused)) void *data)
4777 struct cmd_set_fwd_mode_result *res = parsed_result;
4780 set_pkt_forwarding_mode(res->mode);
4783 cmdline_parse_token_string_t cmd_setfwd_set =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4785 cmdline_parse_token_string_t cmd_setfwd_fwd =
4786 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4787 cmdline_parse_token_string_t cmd_setfwd_mode =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4789 "" /* defined at init */);
4791 cmdline_parse_inst_t cmd_set_fwd_mode = {
4792 .f = cmd_set_fwd_mode_parsed,
4794 .help_str = NULL, /* defined at init */
4796 (void *)&cmd_setfwd_set,
4797 (void *)&cmd_setfwd_fwd,
4798 (void *)&cmd_setfwd_mode,
4803 static void cmd_set_fwd_mode_init(void)
4806 static char token[128];
4807 static char help[256];
4808 cmdline_parse_token_string_t *token_struct;
4810 modes = list_pkt_forwarding_modes();
4811 snprintf(help, sizeof(help), "set fwd %s: "
4812 "Set packet forwarding mode", modes);
4813 cmd_set_fwd_mode.help_str = help;
4815 /* string token separator is # */
4816 for (c = token; *modes != '\0'; modes++)
4821 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4822 token_struct->string_data.str = token;
4825 /* *** SET RETRY FORWARDING MODE *** */
4826 struct cmd_set_fwd_retry_mode_result {
4827 cmdline_fixed_string_t set;
4828 cmdline_fixed_string_t fwd;
4829 cmdline_fixed_string_t mode;
4830 cmdline_fixed_string_t retry;
4833 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4837 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4840 set_pkt_forwarding_mode(res->mode);
4843 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4844 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4846 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4847 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4849 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4850 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4852 "" /* defined at init */);
4853 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4857 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4858 .f = cmd_set_fwd_retry_mode_parsed,
4860 .help_str = NULL, /* defined at init */
4862 (void *)&cmd_setfwd_retry_set,
4863 (void *)&cmd_setfwd_retry_fwd,
4864 (void *)&cmd_setfwd_retry_mode,
4865 (void *)&cmd_setfwd_retry_retry,
4870 static void cmd_set_fwd_retry_mode_init(void)
4873 static char token[128];
4874 static char help[256];
4875 cmdline_parse_token_string_t *token_struct;
4877 modes = list_pkt_forwarding_retry_modes();
4878 snprintf(help, sizeof(help), "set fwd %s retry: "
4879 "Set packet forwarding mode with retry", modes);
4880 cmd_set_fwd_retry_mode.help_str = help;
4882 /* string token separator is # */
4883 for (c = token; *modes != '\0'; modes++)
4888 token_struct = (cmdline_parse_token_string_t *)
4889 cmd_set_fwd_retry_mode.tokens[2];
4890 token_struct->string_data.str = token;
4893 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4894 struct cmd_set_burst_tx_retry_result {
4895 cmdline_fixed_string_t set;
4896 cmdline_fixed_string_t burst;
4897 cmdline_fixed_string_t tx;
4898 cmdline_fixed_string_t delay;
4900 cmdline_fixed_string_t retry;
4904 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4905 __attribute__((unused)) struct cmdline *cl,
4906 __attribute__((unused)) void *data)
4908 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4910 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4911 && !strcmp(res->tx, "tx")) {
4912 if (!strcmp(res->delay, "delay"))
4913 burst_tx_delay_time = res->time;
4914 if (!strcmp(res->retry, "retry"))
4915 burst_tx_retry_num = res->retry_num;
4920 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4921 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4922 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4925 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4927 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4928 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4929 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4930 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4931 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4933 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4934 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4936 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4937 .f = cmd_set_burst_tx_retry_parsed,
4938 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4940 (void *)&cmd_set_burst_tx_retry_set,
4941 (void *)&cmd_set_burst_tx_retry_burst,
4942 (void *)&cmd_set_burst_tx_retry_tx,
4943 (void *)&cmd_set_burst_tx_retry_delay,
4944 (void *)&cmd_set_burst_tx_retry_time,
4945 (void *)&cmd_set_burst_tx_retry_retry,
4946 (void *)&cmd_set_burst_tx_retry_retry_num,
4951 /* *** SET PROMISC MODE *** */
4952 struct cmd_set_promisc_mode_result {
4953 cmdline_fixed_string_t set;
4954 cmdline_fixed_string_t promisc;
4955 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4956 uint8_t port_num; /* valid if "allports" argument == 0 */
4957 cmdline_fixed_string_t mode;
4960 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4961 __attribute__((unused)) struct cmdline *cl,
4964 struct cmd_set_promisc_mode_result *res = parsed_result;
4968 if (!strcmp(res->mode, "on"))
4975 FOREACH_PORT(i, ports) {
4977 rte_eth_promiscuous_enable(i);
4979 rte_eth_promiscuous_disable(i);
4984 rte_eth_promiscuous_enable(res->port_num);
4986 rte_eth_promiscuous_disable(res->port_num);
4990 cmdline_parse_token_string_t cmd_setpromisc_set =
4991 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4992 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4993 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4995 cmdline_parse_token_string_t cmd_setpromisc_portall =
4996 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4998 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4999 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5001 cmdline_parse_token_string_t cmd_setpromisc_mode =
5002 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5005 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5006 .f = cmd_set_promisc_mode_parsed,
5008 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5010 (void *)&cmd_setpromisc_set,
5011 (void *)&cmd_setpromisc_promisc,
5012 (void *)&cmd_setpromisc_portall,
5013 (void *)&cmd_setpromisc_mode,
5018 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5019 .f = cmd_set_promisc_mode_parsed,
5021 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5023 (void *)&cmd_setpromisc_set,
5024 (void *)&cmd_setpromisc_promisc,
5025 (void *)&cmd_setpromisc_portnum,
5026 (void *)&cmd_setpromisc_mode,
5031 /* *** SET ALLMULTI MODE *** */
5032 struct cmd_set_allmulti_mode_result {
5033 cmdline_fixed_string_t set;
5034 cmdline_fixed_string_t allmulti;
5035 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5036 uint8_t port_num; /* valid if "allports" argument == 0 */
5037 cmdline_fixed_string_t mode;
5040 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5041 __attribute__((unused)) struct cmdline *cl,
5044 struct cmd_set_allmulti_mode_result *res = parsed_result;
5048 if (!strcmp(res->mode, "on"))
5055 FOREACH_PORT(i, ports) {
5057 rte_eth_allmulticast_enable(i);
5059 rte_eth_allmulticast_disable(i);
5064 rte_eth_allmulticast_enable(res->port_num);
5066 rte_eth_allmulticast_disable(res->port_num);
5070 cmdline_parse_token_string_t cmd_setallmulti_set =
5071 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5072 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5073 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5075 cmdline_parse_token_string_t cmd_setallmulti_portall =
5076 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5078 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5079 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5081 cmdline_parse_token_string_t cmd_setallmulti_mode =
5082 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5085 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5086 .f = cmd_set_allmulti_mode_parsed,
5088 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5090 (void *)&cmd_setallmulti_set,
5091 (void *)&cmd_setallmulti_allmulti,
5092 (void *)&cmd_setallmulti_portall,
5093 (void *)&cmd_setallmulti_mode,
5098 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5099 .f = cmd_set_allmulti_mode_parsed,
5101 .help_str = "set allmulti <port_id> on|off: "
5102 "Set allmulti mode on port_id",
5104 (void *)&cmd_setallmulti_set,
5105 (void *)&cmd_setallmulti_allmulti,
5106 (void *)&cmd_setallmulti_portnum,
5107 (void *)&cmd_setallmulti_mode,
5112 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5113 struct cmd_link_flow_ctrl_set_result {
5114 cmdline_fixed_string_t set;
5115 cmdline_fixed_string_t flow_ctrl;
5116 cmdline_fixed_string_t rx;
5117 cmdline_fixed_string_t rx_lfc_mode;
5118 cmdline_fixed_string_t tx;
5119 cmdline_fixed_string_t tx_lfc_mode;
5120 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5121 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5122 cmdline_fixed_string_t autoneg_str;
5123 cmdline_fixed_string_t autoneg;
5124 cmdline_fixed_string_t hw_str;
5125 uint32_t high_water;
5126 cmdline_fixed_string_t lw_str;
5128 cmdline_fixed_string_t pt_str;
5129 uint16_t pause_time;
5130 cmdline_fixed_string_t xon_str;
5135 cmdline_parse_token_string_t cmd_lfc_set_set =
5136 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5138 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5139 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5140 flow_ctrl, "flow_ctrl");
5141 cmdline_parse_token_string_t cmd_lfc_set_rx =
5142 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5144 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5145 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5146 rx_lfc_mode, "on#off");
5147 cmdline_parse_token_string_t cmd_lfc_set_tx =
5148 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5150 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5152 tx_lfc_mode, "on#off");
5153 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5155 hw_str, "high_water");
5156 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5157 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5158 high_water, UINT32);
5159 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5160 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5161 lw_str, "low_water");
5162 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5163 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5165 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5166 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5167 pt_str, "pause_time");
5168 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5169 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5170 pause_time, UINT16);
5171 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5172 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5173 xon_str, "send_xon");
5174 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5175 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5178 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5179 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5180 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5181 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5182 mac_ctrl_frame_fwd_mode, "on#off");
5183 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5184 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5185 autoneg_str, "autoneg");
5186 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5187 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 cmdline_parse_token_num_t cmd_lfc_set_portid =
5190 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5193 /* forward declaration */
5195 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5198 cmdline_parse_inst_t cmd_link_flow_control_set = {
5199 .f = cmd_link_flow_ctrl_set_parsed,
5201 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5202 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5203 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5205 (void *)&cmd_lfc_set_set,
5206 (void *)&cmd_lfc_set_flow_ctrl,
5207 (void *)&cmd_lfc_set_rx,
5208 (void *)&cmd_lfc_set_rx_mode,
5209 (void *)&cmd_lfc_set_tx,
5210 (void *)&cmd_lfc_set_tx_mode,
5211 (void *)&cmd_lfc_set_high_water,
5212 (void *)&cmd_lfc_set_low_water,
5213 (void *)&cmd_lfc_set_pause_time,
5214 (void *)&cmd_lfc_set_send_xon,
5215 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5216 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5217 (void *)&cmd_lfc_set_autoneg_str,
5218 (void *)&cmd_lfc_set_autoneg,
5219 (void *)&cmd_lfc_set_portid,
5224 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5225 .f = cmd_link_flow_ctrl_set_parsed,
5226 .data = (void *)&cmd_link_flow_control_set_rx,
5227 .help_str = "set flow_ctrl rx on|off <port_id>: "
5228 "Change rx flow control parameter",
5230 (void *)&cmd_lfc_set_set,
5231 (void *)&cmd_lfc_set_flow_ctrl,
5232 (void *)&cmd_lfc_set_rx,
5233 (void *)&cmd_lfc_set_rx_mode,
5234 (void *)&cmd_lfc_set_portid,
5239 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5240 .f = cmd_link_flow_ctrl_set_parsed,
5241 .data = (void *)&cmd_link_flow_control_set_tx,
5242 .help_str = "set flow_ctrl tx on|off <port_id>: "
5243 "Change tx flow control parameter",
5245 (void *)&cmd_lfc_set_set,
5246 (void *)&cmd_lfc_set_flow_ctrl,
5247 (void *)&cmd_lfc_set_tx,
5248 (void *)&cmd_lfc_set_tx_mode,
5249 (void *)&cmd_lfc_set_portid,
5254 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5255 .f = cmd_link_flow_ctrl_set_parsed,
5256 .data = (void *)&cmd_link_flow_control_set_hw,
5257 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5258 "Change high water flow control parameter",
5260 (void *)&cmd_lfc_set_set,
5261 (void *)&cmd_lfc_set_flow_ctrl,
5262 (void *)&cmd_lfc_set_high_water_str,
5263 (void *)&cmd_lfc_set_high_water,
5264 (void *)&cmd_lfc_set_portid,
5269 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5270 .f = cmd_link_flow_ctrl_set_parsed,
5271 .data = (void *)&cmd_link_flow_control_set_lw,
5272 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5273 "Change low water flow control parameter",
5275 (void *)&cmd_lfc_set_set,
5276 (void *)&cmd_lfc_set_flow_ctrl,
5277 (void *)&cmd_lfc_set_low_water_str,
5278 (void *)&cmd_lfc_set_low_water,
5279 (void *)&cmd_lfc_set_portid,
5284 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5285 .f = cmd_link_flow_ctrl_set_parsed,
5286 .data = (void *)&cmd_link_flow_control_set_pt,
5287 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5288 "Change pause time flow control parameter",
5290 (void *)&cmd_lfc_set_set,
5291 (void *)&cmd_lfc_set_flow_ctrl,
5292 (void *)&cmd_lfc_set_pause_time_str,
5293 (void *)&cmd_lfc_set_pause_time,
5294 (void *)&cmd_lfc_set_portid,
5299 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5300 .f = cmd_link_flow_ctrl_set_parsed,
5301 .data = (void *)&cmd_link_flow_control_set_xon,
5302 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5303 "Change send_xon flow control parameter",
5305 (void *)&cmd_lfc_set_set,
5306 (void *)&cmd_lfc_set_flow_ctrl,
5307 (void *)&cmd_lfc_set_send_xon_str,
5308 (void *)&cmd_lfc_set_send_xon,
5309 (void *)&cmd_lfc_set_portid,
5314 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5315 .f = cmd_link_flow_ctrl_set_parsed,
5316 .data = (void *)&cmd_link_flow_control_set_macfwd,
5317 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5318 "Change mac ctrl fwd flow control parameter",
5320 (void *)&cmd_lfc_set_set,
5321 (void *)&cmd_lfc_set_flow_ctrl,
5322 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5323 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5324 (void *)&cmd_lfc_set_portid,
5329 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5330 .f = cmd_link_flow_ctrl_set_parsed,
5331 .data = (void *)&cmd_link_flow_control_set_autoneg,
5332 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5333 "Change autoneg flow control parameter",
5335 (void *)&cmd_lfc_set_set,
5336 (void *)&cmd_lfc_set_flow_ctrl,
5337 (void *)&cmd_lfc_set_autoneg_str,
5338 (void *)&cmd_lfc_set_autoneg,
5339 (void *)&cmd_lfc_set_portid,
5345 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5346 __attribute__((unused)) struct cmdline *cl,
5349 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5350 cmdline_parse_inst_t *cmd = data;
5351 struct rte_eth_fc_conf fc_conf;
5357 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5358 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5359 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5360 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5362 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5363 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5366 /* Partial command line, retrieve current configuration */
5368 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5370 printf("cannot get current flow ctrl parameters, return"
5371 "code = %d\n", ret);
5375 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5376 (fc_conf.mode == RTE_FC_FULL))
5378 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5379 (fc_conf.mode == RTE_FC_FULL))
5383 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5384 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5386 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5387 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5389 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5391 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5392 fc_conf.high_water = res->high_water;
5394 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5395 fc_conf.low_water = res->low_water;
5397 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5398 fc_conf.pause_time = res->pause_time;
5400 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5401 fc_conf.send_xon = res->send_xon;
5403 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5404 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5405 fc_conf.mac_ctrl_frame_fwd = 1;
5407 fc_conf.mac_ctrl_frame_fwd = 0;
5410 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5411 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5413 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5415 printf("bad flow contrl parameter, return code = %d \n", ret);
5418 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5419 struct cmd_priority_flow_ctrl_set_result {
5420 cmdline_fixed_string_t set;
5421 cmdline_fixed_string_t pfc_ctrl;
5422 cmdline_fixed_string_t rx;
5423 cmdline_fixed_string_t rx_pfc_mode;
5424 cmdline_fixed_string_t tx;
5425 cmdline_fixed_string_t tx_pfc_mode;
5426 uint32_t high_water;
5428 uint16_t pause_time;
5434 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5435 __attribute__((unused)) struct cmdline *cl,
5436 __attribute__((unused)) void *data)
5438 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5439 struct rte_eth_pfc_conf pfc_conf;
5440 int rx_fc_enable, tx_fc_enable;
5444 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5445 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5446 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5447 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5449 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5450 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5453 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5454 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5455 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5456 pfc_conf.fc.high_water = res->high_water;
5457 pfc_conf.fc.low_water = res->low_water;
5458 pfc_conf.fc.pause_time = res->pause_time;
5459 pfc_conf.priority = res->priority;
5461 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5463 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5466 cmdline_parse_token_string_t cmd_pfc_set_set =
5467 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5469 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5470 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5471 pfc_ctrl, "pfc_ctrl");
5472 cmdline_parse_token_string_t cmd_pfc_set_rx =
5473 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5475 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5476 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5477 rx_pfc_mode, "on#off");
5478 cmdline_parse_token_string_t cmd_pfc_set_tx =
5479 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5481 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5482 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5483 tx_pfc_mode, "on#off");
5484 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5485 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5486 high_water, UINT32);
5487 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5488 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5490 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5491 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5492 pause_time, UINT16);
5493 cmdline_parse_token_num_t cmd_pfc_set_priority =
5494 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5496 cmdline_parse_token_num_t cmd_pfc_set_portid =
5497 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5500 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5501 .f = cmd_priority_flow_ctrl_set_parsed,
5503 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5504 "<pause_time> <priority> <port_id>: "
5505 "Configure the Ethernet priority flow control",
5507 (void *)&cmd_pfc_set_set,
5508 (void *)&cmd_pfc_set_flow_ctrl,
5509 (void *)&cmd_pfc_set_rx,
5510 (void *)&cmd_pfc_set_rx_mode,
5511 (void *)&cmd_pfc_set_tx,
5512 (void *)&cmd_pfc_set_tx_mode,
5513 (void *)&cmd_pfc_set_high_water,
5514 (void *)&cmd_pfc_set_low_water,
5515 (void *)&cmd_pfc_set_pause_time,
5516 (void *)&cmd_pfc_set_priority,
5517 (void *)&cmd_pfc_set_portid,
5522 /* *** RESET CONFIGURATION *** */
5523 struct cmd_reset_result {
5524 cmdline_fixed_string_t reset;
5525 cmdline_fixed_string_t def;
5528 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5530 __attribute__((unused)) void *data)
5532 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5533 set_def_fwd_config();
5536 cmdline_parse_token_string_t cmd_reset_set =
5537 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5538 cmdline_parse_token_string_t cmd_reset_def =
5539 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5542 cmdline_parse_inst_t cmd_reset = {
5543 .f = cmd_reset_parsed,
5545 .help_str = "set default: Reset default forwarding configuration",
5547 (void *)&cmd_reset_set,
5548 (void *)&cmd_reset_def,
5553 /* *** START FORWARDING *** */
5554 struct cmd_start_result {
5555 cmdline_fixed_string_t start;
5558 cmdline_parse_token_string_t cmd_start_start =
5559 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5561 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5562 __attribute__((unused)) struct cmdline *cl,
5563 __attribute__((unused)) void *data)
5565 start_packet_forwarding(0);
5568 cmdline_parse_inst_t cmd_start = {
5569 .f = cmd_start_parsed,
5571 .help_str = "start: Start packet forwarding",
5573 (void *)&cmd_start_start,
5578 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5579 struct cmd_start_tx_first_result {
5580 cmdline_fixed_string_t start;
5581 cmdline_fixed_string_t tx_first;
5585 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5586 __attribute__((unused)) struct cmdline *cl,
5587 __attribute__((unused)) void *data)
5589 start_packet_forwarding(1);
5592 cmdline_parse_token_string_t cmd_start_tx_first_start =
5593 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5595 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5596 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5597 tx_first, "tx_first");
5599 cmdline_parse_inst_t cmd_start_tx_first = {
5600 .f = cmd_start_tx_first_parsed,
5602 .help_str = "start tx_first: Start packet forwarding, "
5603 "after sending 1 burst of packets",
5605 (void *)&cmd_start_tx_first_start,
5606 (void *)&cmd_start_tx_first_tx_first,
5611 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5612 struct cmd_start_tx_first_n_result {
5613 cmdline_fixed_string_t start;
5614 cmdline_fixed_string_t tx_first;
5619 cmd_start_tx_first_n_parsed(void *parsed_result,
5620 __attribute__((unused)) struct cmdline *cl,
5621 __attribute__((unused)) void *data)
5623 struct cmd_start_tx_first_n_result *res = parsed_result;
5625 start_packet_forwarding(res->tx_num);
5628 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5629 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5631 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5632 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5633 tx_first, "tx_first");
5634 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5635 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5638 cmdline_parse_inst_t cmd_start_tx_first_n = {
5639 .f = cmd_start_tx_first_n_parsed,
5641 .help_str = "start tx_first <num>: "
5642 "packet forwarding, after sending <num> bursts of packets",
5644 (void *)&cmd_start_tx_first_n_start,
5645 (void *)&cmd_start_tx_first_n_tx_first,
5646 (void *)&cmd_start_tx_first_n_tx_num,
5651 /* *** SET LINK UP *** */
5652 struct cmd_set_link_up_result {
5653 cmdline_fixed_string_t set;
5654 cmdline_fixed_string_t link_up;
5655 cmdline_fixed_string_t port;
5659 cmdline_parse_token_string_t cmd_set_link_up_set =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5661 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5664 cmdline_parse_token_string_t cmd_set_link_up_port =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5666 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5667 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5669 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5670 __attribute__((unused)) struct cmdline *cl,
5671 __attribute__((unused)) void *data)
5673 struct cmd_set_link_up_result *res = parsed_result;
5674 dev_set_link_up(res->port_id);
5677 cmdline_parse_inst_t cmd_set_link_up = {
5678 .f = cmd_set_link_up_parsed,
5680 .help_str = "set link-up port <port id>",
5682 (void *)&cmd_set_link_up_set,
5683 (void *)&cmd_set_link_up_link_up,
5684 (void *)&cmd_set_link_up_port,
5685 (void *)&cmd_set_link_up_port_id,
5690 /* *** SET LINK DOWN *** */
5691 struct cmd_set_link_down_result {
5692 cmdline_fixed_string_t set;
5693 cmdline_fixed_string_t link_down;
5694 cmdline_fixed_string_t port;
5698 cmdline_parse_token_string_t cmd_set_link_down_set =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5700 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5703 cmdline_parse_token_string_t cmd_set_link_down_port =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5705 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5706 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5708 static void cmd_set_link_down_parsed(
5709 __attribute__((unused)) void *parsed_result,
5710 __attribute__((unused)) struct cmdline *cl,
5711 __attribute__((unused)) void *data)
5713 struct cmd_set_link_down_result *res = parsed_result;
5714 dev_set_link_down(res->port_id);
5717 cmdline_parse_inst_t cmd_set_link_down = {
5718 .f = cmd_set_link_down_parsed,
5720 .help_str = "set link-down port <port id>",
5722 (void *)&cmd_set_link_down_set,
5723 (void *)&cmd_set_link_down_link_down,
5724 (void *)&cmd_set_link_down_port,
5725 (void *)&cmd_set_link_down_port_id,
5730 /* *** SHOW CFG *** */
5731 struct cmd_showcfg_result {
5732 cmdline_fixed_string_t show;
5733 cmdline_fixed_string_t cfg;
5734 cmdline_fixed_string_t what;
5737 static void cmd_showcfg_parsed(void *parsed_result,
5738 __attribute__((unused)) struct cmdline *cl,
5739 __attribute__((unused)) void *data)
5741 struct cmd_showcfg_result *res = parsed_result;
5742 if (!strcmp(res->what, "rxtx"))
5743 rxtx_config_display();
5744 else if (!strcmp(res->what, "cores"))
5745 fwd_lcores_config_display();
5746 else if (!strcmp(res->what, "fwd"))
5747 pkt_fwd_config_display(&cur_fwd_config);
5748 else if (!strcmp(res->what, "txpkts"))
5749 show_tx_pkt_segments();
5752 cmdline_parse_token_string_t cmd_showcfg_show =
5753 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5754 cmdline_parse_token_string_t cmd_showcfg_port =
5755 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5756 cmdline_parse_token_string_t cmd_showcfg_what =
5757 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5758 "rxtx#cores#fwd#txpkts");
5760 cmdline_parse_inst_t cmd_showcfg = {
5761 .f = cmd_showcfg_parsed,
5763 .help_str = "show config rxtx|cores|fwd|txpkts",
5765 (void *)&cmd_showcfg_show,
5766 (void *)&cmd_showcfg_port,
5767 (void *)&cmd_showcfg_what,
5772 /* *** SHOW ALL PORT INFO *** */
5773 struct cmd_showportall_result {
5774 cmdline_fixed_string_t show;
5775 cmdline_fixed_string_t port;
5776 cmdline_fixed_string_t what;
5777 cmdline_fixed_string_t all;
5780 static void cmd_showportall_parsed(void *parsed_result,
5781 __attribute__((unused)) struct cmdline *cl,
5782 __attribute__((unused)) void *data)
5786 struct cmd_showportall_result *res = parsed_result;
5787 if (!strcmp(res->show, "clear")) {
5788 if (!strcmp(res->what, "stats"))
5789 FOREACH_PORT(i, ports)
5791 else if (!strcmp(res->what, "xstats"))
5792 FOREACH_PORT(i, ports)
5793 nic_xstats_clear(i);
5794 } else if (!strcmp(res->what, "info"))
5795 FOREACH_PORT(i, ports)
5796 port_infos_display(i);
5797 else if (!strcmp(res->what, "stats"))
5798 FOREACH_PORT(i, ports)
5799 nic_stats_display(i);
5800 else if (!strcmp(res->what, "xstats"))
5801 FOREACH_PORT(i, ports)
5802 nic_xstats_display(i);
5803 else if (!strcmp(res->what, "fdir"))
5804 FOREACH_PORT(i, ports)
5806 else if (!strcmp(res->what, "stat_qmap"))
5807 FOREACH_PORT(i, ports)
5808 nic_stats_mapping_display(i);
5809 else if (!strcmp(res->what, "dcb_tc"))
5810 FOREACH_PORT(i, ports)
5811 port_dcb_info_display(i);
5814 cmdline_parse_token_string_t cmd_showportall_show =
5815 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5817 cmdline_parse_token_string_t cmd_showportall_port =
5818 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5819 cmdline_parse_token_string_t cmd_showportall_what =
5820 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5821 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5822 cmdline_parse_token_string_t cmd_showportall_all =
5823 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5824 cmdline_parse_inst_t cmd_showportall = {
5825 .f = cmd_showportall_parsed,
5827 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5829 (void *)&cmd_showportall_show,
5830 (void *)&cmd_showportall_port,
5831 (void *)&cmd_showportall_what,
5832 (void *)&cmd_showportall_all,
5837 /* *** SHOW PORT INFO *** */
5838 struct cmd_showport_result {
5839 cmdline_fixed_string_t show;
5840 cmdline_fixed_string_t port;
5841 cmdline_fixed_string_t what;
5845 static void cmd_showport_parsed(void *parsed_result,
5846 __attribute__((unused)) struct cmdline *cl,
5847 __attribute__((unused)) void *data)
5849 struct cmd_showport_result *res = parsed_result;
5850 if (!strcmp(res->show, "clear")) {
5851 if (!strcmp(res->what, "stats"))
5852 nic_stats_clear(res->portnum);
5853 else if (!strcmp(res->what, "xstats"))
5854 nic_xstats_clear(res->portnum);
5855 } else if (!strcmp(res->what, "info"))
5856 port_infos_display(res->portnum);
5857 else if (!strcmp(res->what, "stats"))
5858 nic_stats_display(res->portnum);
5859 else if (!strcmp(res->what, "xstats"))
5860 nic_xstats_display(res->portnum);
5861 else if (!strcmp(res->what, "fdir"))
5862 fdir_get_infos(res->portnum);
5863 else if (!strcmp(res->what, "stat_qmap"))
5864 nic_stats_mapping_display(res->portnum);
5865 else if (!strcmp(res->what, "dcb_tc"))
5866 port_dcb_info_display(res->portnum);
5869 cmdline_parse_token_string_t cmd_showport_show =
5870 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5872 cmdline_parse_token_string_t cmd_showport_port =
5873 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5874 cmdline_parse_token_string_t cmd_showport_what =
5875 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5876 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5877 cmdline_parse_token_num_t cmd_showport_portnum =
5878 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5880 cmdline_parse_inst_t cmd_showport = {
5881 .f = cmd_showport_parsed,
5883 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc "
5886 (void *)&cmd_showport_show,
5887 (void *)&cmd_showport_port,
5888 (void *)&cmd_showport_what,
5889 (void *)&cmd_showport_portnum,
5894 /* *** SHOW QUEUE INFO *** */
5895 struct cmd_showqueue_result {
5896 cmdline_fixed_string_t show;
5897 cmdline_fixed_string_t type;
5898 cmdline_fixed_string_t what;
5904 cmd_showqueue_parsed(void *parsed_result,
5905 __attribute__((unused)) struct cmdline *cl,
5906 __attribute__((unused)) void *data)
5908 struct cmd_showqueue_result *res = parsed_result;
5910 if (!strcmp(res->type, "rxq"))
5911 rx_queue_infos_display(res->portnum, res->queuenum);
5912 else if (!strcmp(res->type, "txq"))
5913 tx_queue_infos_display(res->portnum, res->queuenum);
5916 cmdline_parse_token_string_t cmd_showqueue_show =
5917 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5918 cmdline_parse_token_string_t cmd_showqueue_type =
5919 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5920 cmdline_parse_token_string_t cmd_showqueue_what =
5921 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5922 cmdline_parse_token_num_t cmd_showqueue_portnum =
5923 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5924 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5925 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5927 cmdline_parse_inst_t cmd_showqueue = {
5928 .f = cmd_showqueue_parsed,
5930 .help_str = "show rxq|txq info <port_id> <queue_id>",
5932 (void *)&cmd_showqueue_show,
5933 (void *)&cmd_showqueue_type,
5934 (void *)&cmd_showqueue_what,
5935 (void *)&cmd_showqueue_portnum,
5936 (void *)&cmd_showqueue_queuenum,
5941 /* *** READ PORT REGISTER *** */
5942 struct cmd_read_reg_result {
5943 cmdline_fixed_string_t read;
5944 cmdline_fixed_string_t reg;
5950 cmd_read_reg_parsed(void *parsed_result,
5951 __attribute__((unused)) struct cmdline *cl,
5952 __attribute__((unused)) void *data)
5954 struct cmd_read_reg_result *res = parsed_result;
5955 port_reg_display(res->port_id, res->reg_off);
5958 cmdline_parse_token_string_t cmd_read_reg_read =
5959 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5960 cmdline_parse_token_string_t cmd_read_reg_reg =
5961 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5962 cmdline_parse_token_num_t cmd_read_reg_port_id =
5963 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5964 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5965 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5967 cmdline_parse_inst_t cmd_read_reg = {
5968 .f = cmd_read_reg_parsed,
5970 .help_str = "read reg <port_id> <reg_off>",
5972 (void *)&cmd_read_reg_read,
5973 (void *)&cmd_read_reg_reg,
5974 (void *)&cmd_read_reg_port_id,
5975 (void *)&cmd_read_reg_reg_off,
5980 /* *** READ PORT REGISTER BIT FIELD *** */
5981 struct cmd_read_reg_bit_field_result {
5982 cmdline_fixed_string_t read;
5983 cmdline_fixed_string_t regfield;
5991 cmd_read_reg_bit_field_parsed(void *parsed_result,
5992 __attribute__((unused)) struct cmdline *cl,
5993 __attribute__((unused)) void *data)
5995 struct cmd_read_reg_bit_field_result *res = parsed_result;
5996 port_reg_bit_field_display(res->port_id, res->reg_off,
5997 res->bit1_pos, res->bit2_pos);
6000 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6001 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6003 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6004 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6005 regfield, "regfield");
6006 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6007 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6009 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6010 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6012 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6013 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6015 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6016 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6019 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6020 .f = cmd_read_reg_bit_field_parsed,
6022 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6023 "Read register bit field between bit_x and bit_y included",
6025 (void *)&cmd_read_reg_bit_field_read,
6026 (void *)&cmd_read_reg_bit_field_regfield,
6027 (void *)&cmd_read_reg_bit_field_port_id,
6028 (void *)&cmd_read_reg_bit_field_reg_off,
6029 (void *)&cmd_read_reg_bit_field_bit1_pos,
6030 (void *)&cmd_read_reg_bit_field_bit2_pos,
6035 /* *** READ PORT REGISTER BIT *** */
6036 struct cmd_read_reg_bit_result {
6037 cmdline_fixed_string_t read;
6038 cmdline_fixed_string_t regbit;
6045 cmd_read_reg_bit_parsed(void *parsed_result,
6046 __attribute__((unused)) struct cmdline *cl,
6047 __attribute__((unused)) void *data)
6049 struct cmd_read_reg_bit_result *res = parsed_result;
6050 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6053 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6054 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6055 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6056 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6058 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6059 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6060 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6061 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6062 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6063 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6065 cmdline_parse_inst_t cmd_read_reg_bit = {
6066 .f = cmd_read_reg_bit_parsed,
6068 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6070 (void *)&cmd_read_reg_bit_read,
6071 (void *)&cmd_read_reg_bit_regbit,
6072 (void *)&cmd_read_reg_bit_port_id,
6073 (void *)&cmd_read_reg_bit_reg_off,
6074 (void *)&cmd_read_reg_bit_bit_pos,
6079 /* *** WRITE PORT REGISTER *** */
6080 struct cmd_write_reg_result {
6081 cmdline_fixed_string_t write;
6082 cmdline_fixed_string_t reg;
6089 cmd_write_reg_parsed(void *parsed_result,
6090 __attribute__((unused)) struct cmdline *cl,
6091 __attribute__((unused)) void *data)
6093 struct cmd_write_reg_result *res = parsed_result;
6094 port_reg_set(res->port_id, res->reg_off, res->value);
6097 cmdline_parse_token_string_t cmd_write_reg_write =
6098 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6099 cmdline_parse_token_string_t cmd_write_reg_reg =
6100 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6101 cmdline_parse_token_num_t cmd_write_reg_port_id =
6102 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6103 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6104 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6105 cmdline_parse_token_num_t cmd_write_reg_value =
6106 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6108 cmdline_parse_inst_t cmd_write_reg = {
6109 .f = cmd_write_reg_parsed,
6111 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6113 (void *)&cmd_write_reg_write,
6114 (void *)&cmd_write_reg_reg,
6115 (void *)&cmd_write_reg_port_id,
6116 (void *)&cmd_write_reg_reg_off,
6117 (void *)&cmd_write_reg_value,
6122 /* *** WRITE PORT REGISTER BIT FIELD *** */
6123 struct cmd_write_reg_bit_field_result {
6124 cmdline_fixed_string_t write;
6125 cmdline_fixed_string_t regfield;
6134 cmd_write_reg_bit_field_parsed(void *parsed_result,
6135 __attribute__((unused)) struct cmdline *cl,
6136 __attribute__((unused)) void *data)
6138 struct cmd_write_reg_bit_field_result *res = parsed_result;
6139 port_reg_bit_field_set(res->port_id, res->reg_off,
6140 res->bit1_pos, res->bit2_pos, res->value);
6143 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6144 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6146 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6147 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6148 regfield, "regfield");
6149 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6150 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6152 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6155 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6156 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6158 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6159 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6161 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6162 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6165 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6166 .f = cmd_write_reg_bit_field_parsed,
6168 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6170 "Set register bit field between bit_x and bit_y included",
6172 (void *)&cmd_write_reg_bit_field_write,
6173 (void *)&cmd_write_reg_bit_field_regfield,
6174 (void *)&cmd_write_reg_bit_field_port_id,
6175 (void *)&cmd_write_reg_bit_field_reg_off,
6176 (void *)&cmd_write_reg_bit_field_bit1_pos,
6177 (void *)&cmd_write_reg_bit_field_bit2_pos,
6178 (void *)&cmd_write_reg_bit_field_value,
6183 /* *** WRITE PORT REGISTER BIT *** */
6184 struct cmd_write_reg_bit_result {
6185 cmdline_fixed_string_t write;
6186 cmdline_fixed_string_t regbit;
6194 cmd_write_reg_bit_parsed(void *parsed_result,
6195 __attribute__((unused)) struct cmdline *cl,
6196 __attribute__((unused)) void *data)
6198 struct cmd_write_reg_bit_result *res = parsed_result;
6199 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6202 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6203 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6205 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6206 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6208 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6209 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6210 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6211 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6212 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6213 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6214 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6215 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6217 cmdline_parse_inst_t cmd_write_reg_bit = {
6218 .f = cmd_write_reg_bit_parsed,
6220 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6223 (void *)&cmd_write_reg_bit_write,
6224 (void *)&cmd_write_reg_bit_regbit,
6225 (void *)&cmd_write_reg_bit_port_id,
6226 (void *)&cmd_write_reg_bit_reg_off,
6227 (void *)&cmd_write_reg_bit_bit_pos,
6228 (void *)&cmd_write_reg_bit_value,
6233 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6234 struct cmd_read_rxd_txd_result {
6235 cmdline_fixed_string_t read;
6236 cmdline_fixed_string_t rxd_txd;
6243 cmd_read_rxd_txd_parsed(void *parsed_result,
6244 __attribute__((unused)) struct cmdline *cl,
6245 __attribute__((unused)) void *data)
6247 struct cmd_read_rxd_txd_result *res = parsed_result;
6249 if (!strcmp(res->rxd_txd, "rxd"))
6250 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6251 else if (!strcmp(res->rxd_txd, "txd"))
6252 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6255 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6256 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6257 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6258 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6260 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6261 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6262 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6263 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6264 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6265 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6267 cmdline_parse_inst_t cmd_read_rxd_txd = {
6268 .f = cmd_read_rxd_txd_parsed,
6270 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6272 (void *)&cmd_read_rxd_txd_read,
6273 (void *)&cmd_read_rxd_txd_rxd_txd,
6274 (void *)&cmd_read_rxd_txd_port_id,
6275 (void *)&cmd_read_rxd_txd_queue_id,
6276 (void *)&cmd_read_rxd_txd_desc_id,
6282 struct cmd_quit_result {
6283 cmdline_fixed_string_t quit;
6286 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6288 __attribute__((unused)) void *data)
6294 cmdline_parse_token_string_t cmd_quit_quit =
6295 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6297 cmdline_parse_inst_t cmd_quit = {
6298 .f = cmd_quit_parsed,
6300 .help_str = "quit: Exit application",
6302 (void *)&cmd_quit_quit,
6307 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6308 struct cmd_mac_addr_result {
6309 cmdline_fixed_string_t mac_addr_cmd;
6310 cmdline_fixed_string_t what;
6312 struct ether_addr address;
6315 static void cmd_mac_addr_parsed(void *parsed_result,
6316 __attribute__((unused)) struct cmdline *cl,
6317 __attribute__((unused)) void *data)
6319 struct cmd_mac_addr_result *res = parsed_result;
6322 if (strcmp(res->what, "add") == 0)
6323 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6325 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6327 /* check the return value and print it if is < 0 */
6329 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6333 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6334 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6336 cmdline_parse_token_string_t cmd_mac_addr_what =
6337 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6339 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6340 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6341 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6342 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6344 cmdline_parse_inst_t cmd_mac_addr = {
6345 .f = cmd_mac_addr_parsed,
6347 .help_str = "mac_addr add|remove <port_id> <mac_addr>: "
6348 "Add/Remove MAC address on port_id",
6350 (void *)&cmd_mac_addr_cmd,
6351 (void *)&cmd_mac_addr_what,
6352 (void *)&cmd_mac_addr_portnum,
6353 (void *)&cmd_mac_addr_addr,
6359 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6360 struct cmd_set_qmap_result {
6361 cmdline_fixed_string_t set;
6362 cmdline_fixed_string_t qmap;
6363 cmdline_fixed_string_t what;
6370 cmd_set_qmap_parsed(void *parsed_result,
6371 __attribute__((unused)) struct cmdline *cl,
6372 __attribute__((unused)) void *data)
6374 struct cmd_set_qmap_result *res = parsed_result;
6375 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6377 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6380 cmdline_parse_token_string_t cmd_setqmap_set =
6381 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6383 cmdline_parse_token_string_t cmd_setqmap_qmap =
6384 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6386 cmdline_parse_token_string_t cmd_setqmap_what =
6387 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6389 cmdline_parse_token_num_t cmd_setqmap_portid =
6390 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6392 cmdline_parse_token_num_t cmd_setqmap_queueid =
6393 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6395 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6396 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6399 cmdline_parse_inst_t cmd_set_qmap = {
6400 .f = cmd_set_qmap_parsed,
6402 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6403 "Set statistics mapping value on tx|rx queue_id of port_id",
6405 (void *)&cmd_setqmap_set,
6406 (void *)&cmd_setqmap_qmap,
6407 (void *)&cmd_setqmap_what,
6408 (void *)&cmd_setqmap_portid,
6409 (void *)&cmd_setqmap_queueid,
6410 (void *)&cmd_setqmap_mapvalue,
6415 /* *** CONFIGURE UNICAST HASH TABLE *** */
6416 struct cmd_set_uc_hash_table {
6417 cmdline_fixed_string_t set;
6418 cmdline_fixed_string_t port;
6420 cmdline_fixed_string_t what;
6421 struct ether_addr address;
6422 cmdline_fixed_string_t mode;
6426 cmd_set_uc_hash_parsed(void *parsed_result,
6427 __attribute__((unused)) struct cmdline *cl,
6428 __attribute__((unused)) void *data)
6431 struct cmd_set_uc_hash_table *res = parsed_result;
6433 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6435 if (strcmp(res->what, "uta") == 0)
6436 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6437 &res->address,(uint8_t)is_on);
6439 printf("bad unicast hash table parameter, return code = %d \n", ret);
6443 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6444 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6446 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6447 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6449 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6450 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6452 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6453 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6455 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6456 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6458 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6459 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6462 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6463 .f = cmd_set_uc_hash_parsed,
6465 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6467 (void *)&cmd_set_uc_hash_set,
6468 (void *)&cmd_set_uc_hash_port,
6469 (void *)&cmd_set_uc_hash_portid,
6470 (void *)&cmd_set_uc_hash_what,
6471 (void *)&cmd_set_uc_hash_mac,
6472 (void *)&cmd_set_uc_hash_mode,
6477 struct cmd_set_uc_all_hash_table {
6478 cmdline_fixed_string_t set;
6479 cmdline_fixed_string_t port;
6481 cmdline_fixed_string_t what;
6482 cmdline_fixed_string_t value;
6483 cmdline_fixed_string_t mode;
6487 cmd_set_uc_all_hash_parsed(void *parsed_result,
6488 __attribute__((unused)) struct cmdline *cl,
6489 __attribute__((unused)) void *data)
6492 struct cmd_set_uc_all_hash_table *res = parsed_result;
6494 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6496 if ((strcmp(res->what, "uta") == 0) &&
6497 (strcmp(res->value, "all") == 0))
6498 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6500 printf("bad unicast hash table parameter,"
6501 "return code = %d \n", ret);
6504 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6507 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6510 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6511 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6513 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6514 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6516 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6519 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6523 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6524 .f = cmd_set_uc_all_hash_parsed,
6526 .help_str = "set port <port_id> uta all on|off",
6528 (void *)&cmd_set_uc_all_hash_set,
6529 (void *)&cmd_set_uc_all_hash_port,
6530 (void *)&cmd_set_uc_all_hash_portid,
6531 (void *)&cmd_set_uc_all_hash_what,
6532 (void *)&cmd_set_uc_all_hash_value,
6533 (void *)&cmd_set_uc_all_hash_mode,
6538 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6539 struct cmd_set_vf_macvlan_filter {
6540 cmdline_fixed_string_t set;
6541 cmdline_fixed_string_t port;
6543 cmdline_fixed_string_t vf;
6545 struct ether_addr address;
6546 cmdline_fixed_string_t filter_type;
6547 cmdline_fixed_string_t mode;
6551 cmd_set_vf_macvlan_parsed(void *parsed_result,
6552 __attribute__((unused)) struct cmdline *cl,
6553 __attribute__((unused)) void *data)
6556 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6557 struct rte_eth_mac_filter filter;
6559 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6561 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6563 /* set VF MAC filter */
6567 filter.dst_id = res->vf_id;
6569 if (!strcmp(res->filter_type, "exact-mac"))
6570 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6571 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6572 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6573 else if (!strcmp(res->filter_type, "hashmac"))
6574 filter.filter_type = RTE_MAC_HASH_MATCH;
6575 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6576 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6578 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6581 ret = rte_eth_dev_filter_ctrl(res->port_id,
6582 RTE_ETH_FILTER_MACVLAN,
6586 ret = rte_eth_dev_filter_ctrl(res->port_id,
6587 RTE_ETH_FILTER_MACVLAN,
6588 RTE_ETH_FILTER_DELETE,
6592 printf("bad set MAC hash parameter, return code = %d\n", ret);
6596 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6597 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6599 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6602 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6603 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6605 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6606 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6608 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6609 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6611 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6612 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6614 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6615 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6616 filter_type, "exact-mac#exact-mac-vlan"
6617 "#hashmac#hashmac-vlan");
6618 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6622 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6623 .f = cmd_set_vf_macvlan_parsed,
6625 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6626 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6627 "Exact match rule: exact match of MAC or MAC and VLAN; "
6628 "hash match rule: hash match of MAC and exact match of VLAN",
6630 (void *)&cmd_set_vf_macvlan_set,
6631 (void *)&cmd_set_vf_macvlan_port,
6632 (void *)&cmd_set_vf_macvlan_portid,
6633 (void *)&cmd_set_vf_macvlan_vf,
6634 (void *)&cmd_set_vf_macvlan_vf_id,
6635 (void *)&cmd_set_vf_macvlan_mac,
6636 (void *)&cmd_set_vf_macvlan_filter_type,
6637 (void *)&cmd_set_vf_macvlan_mode,
6642 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6643 struct cmd_set_vf_traffic {
6644 cmdline_fixed_string_t set;
6645 cmdline_fixed_string_t port;
6647 cmdline_fixed_string_t vf;
6649 cmdline_fixed_string_t what;
6650 cmdline_fixed_string_t mode;
6654 cmd_set_vf_traffic_parsed(void *parsed_result,
6655 __attribute__((unused)) struct cmdline *cl,
6656 __attribute__((unused)) void *data)
6658 struct cmd_set_vf_traffic *res = parsed_result;
6659 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6660 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6662 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6665 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6666 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6668 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6671 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6672 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6674 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6677 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6678 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6680 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6683 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6687 cmdline_parse_inst_t cmd_set_vf_traffic = {
6688 .f = cmd_set_vf_traffic_parsed,
6690 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6692 (void *)&cmd_setvf_traffic_set,
6693 (void *)&cmd_setvf_traffic_port,
6694 (void *)&cmd_setvf_traffic_portid,
6695 (void *)&cmd_setvf_traffic_vf,
6696 (void *)&cmd_setvf_traffic_vfid,
6697 (void *)&cmd_setvf_traffic_what,
6698 (void *)&cmd_setvf_traffic_mode,
6703 /* *** CONFIGURE VF RECEIVE MODE *** */
6704 struct cmd_set_vf_rxmode {
6705 cmdline_fixed_string_t set;
6706 cmdline_fixed_string_t port;
6708 cmdline_fixed_string_t vf;
6710 cmdline_fixed_string_t what;
6711 cmdline_fixed_string_t mode;
6712 cmdline_fixed_string_t on;
6716 cmd_set_vf_rxmode_parsed(void *parsed_result,
6717 __attribute__((unused)) struct cmdline *cl,
6718 __attribute__((unused)) void *data)
6721 uint16_t rx_mode = 0;
6722 struct cmd_set_vf_rxmode *res = parsed_result;
6724 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6725 if (!strcmp(res->what,"rxmode")) {
6726 if (!strcmp(res->mode, "AUPE"))
6727 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6728 else if (!strcmp(res->mode, "ROPE"))
6729 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6730 else if (!strcmp(res->mode, "BAM"))
6731 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6732 else if (!strncmp(res->mode, "MPE",3))
6733 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6736 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6738 printf("bad VF receive mode parameter, return code = %d \n",
6742 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6745 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6748 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6749 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6751 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6752 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6754 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6755 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6757 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6760 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6762 mode, "AUPE#ROPE#BAM#MPE");
6763 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6767 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6768 .f = cmd_set_vf_rxmode_parsed,
6770 .help_str = "set port <port_id> vf <vf_id> rxmode "
6771 "AUPE|ROPE|BAM|MPE on|off",
6773 (void *)&cmd_set_vf_rxmode_set,
6774 (void *)&cmd_set_vf_rxmode_port,
6775 (void *)&cmd_set_vf_rxmode_portid,
6776 (void *)&cmd_set_vf_rxmode_vf,
6777 (void *)&cmd_set_vf_rxmode_vfid,
6778 (void *)&cmd_set_vf_rxmode_what,
6779 (void *)&cmd_set_vf_rxmode_mode,
6780 (void *)&cmd_set_vf_rxmode_on,
6785 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6786 struct cmd_vf_mac_addr_result {
6787 cmdline_fixed_string_t mac_addr_cmd;
6788 cmdline_fixed_string_t what;
6789 cmdline_fixed_string_t port;
6791 cmdline_fixed_string_t vf;
6793 struct ether_addr address;
6796 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6797 __attribute__((unused)) struct cmdline *cl,
6798 __attribute__((unused)) void *data)
6800 struct cmd_vf_mac_addr_result *res = parsed_result;
6803 if (strcmp(res->what, "add") == 0)
6804 ret = rte_eth_dev_mac_addr_add(res->port_num,
6805 &res->address, res->vf_num);
6807 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6811 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6812 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6813 mac_addr_cmd,"mac_addr");
6814 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6815 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6817 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6818 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6820 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6821 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6823 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6824 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6826 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6827 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6829 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6830 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6833 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6834 .f = cmd_vf_mac_addr_parsed,
6836 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6837 "Add MAC address filtering for a VF on port_id",
6839 (void *)&cmd_vf_mac_addr_cmd,
6840 (void *)&cmd_vf_mac_addr_what,
6841 (void *)&cmd_vf_mac_addr_port,
6842 (void *)&cmd_vf_mac_addr_portnum,
6843 (void *)&cmd_vf_mac_addr_vf,
6844 (void *)&cmd_vf_mac_addr_vfnum,
6845 (void *)&cmd_vf_mac_addr_addr,
6850 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6851 struct cmd_vf_rx_vlan_filter {
6852 cmdline_fixed_string_t rx_vlan;
6853 cmdline_fixed_string_t what;
6855 cmdline_fixed_string_t port;
6857 cmdline_fixed_string_t vf;
6862 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6863 __attribute__((unused)) struct cmdline *cl,
6864 __attribute__((unused)) void *data)
6866 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6868 if (!strcmp(res->what, "add"))
6869 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6871 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6874 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6875 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6876 rx_vlan, "rx_vlan");
6877 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6878 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6880 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6881 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6883 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6884 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6886 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6887 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6889 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6890 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6892 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6893 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6896 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6897 .f = cmd_vf_rx_vlan_filter_parsed,
6899 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6900 "(vf_mask = hexadecimal VF mask)",
6902 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6903 (void *)&cmd_vf_rx_vlan_filter_what,
6904 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6905 (void *)&cmd_vf_rx_vlan_filter_port,
6906 (void *)&cmd_vf_rx_vlan_filter_portid,
6907 (void *)&cmd_vf_rx_vlan_filter_vf,
6908 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6913 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6914 struct cmd_queue_rate_limit_result {
6915 cmdline_fixed_string_t set;
6916 cmdline_fixed_string_t port;
6918 cmdline_fixed_string_t queue;
6920 cmdline_fixed_string_t rate;
6924 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6925 __attribute__((unused)) struct cmdline *cl,
6926 __attribute__((unused)) void *data)
6928 struct cmd_queue_rate_limit_result *res = parsed_result;
6931 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6932 && (strcmp(res->queue, "queue") == 0)
6933 && (strcmp(res->rate, "rate") == 0))
6934 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6937 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6941 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6942 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6944 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6945 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6947 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6948 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6950 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6951 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6953 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6954 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6956 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6957 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6959 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6960 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6963 cmdline_parse_inst_t cmd_queue_rate_limit = {
6964 .f = cmd_queue_rate_limit_parsed,
6966 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
6967 "Set rate limit for a queue on port_id",
6969 (void *)&cmd_queue_rate_limit_set,
6970 (void *)&cmd_queue_rate_limit_port,
6971 (void *)&cmd_queue_rate_limit_portnum,
6972 (void *)&cmd_queue_rate_limit_queue,
6973 (void *)&cmd_queue_rate_limit_queuenum,
6974 (void *)&cmd_queue_rate_limit_rate,
6975 (void *)&cmd_queue_rate_limit_ratenum,
6980 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6981 struct cmd_vf_rate_limit_result {
6982 cmdline_fixed_string_t set;
6983 cmdline_fixed_string_t port;
6985 cmdline_fixed_string_t vf;
6987 cmdline_fixed_string_t rate;
6989 cmdline_fixed_string_t q_msk;
6993 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6994 __attribute__((unused)) struct cmdline *cl,
6995 __attribute__((unused)) void *data)
6997 struct cmd_vf_rate_limit_result *res = parsed_result;
7000 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7001 && (strcmp(res->vf, "vf") == 0)
7002 && (strcmp(res->rate, "rate") == 0)
7003 && (strcmp(res->q_msk, "queue_mask") == 0))
7004 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7005 res->rate_num, res->q_msk_val);
7007 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7011 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7012 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7014 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7015 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7017 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7018 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7020 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7021 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7023 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7024 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7026 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7027 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7029 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7030 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7032 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7033 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7034 q_msk, "queue_mask");
7035 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7036 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7039 cmdline_parse_inst_t cmd_vf_rate_limit = {
7040 .f = cmd_vf_rate_limit_parsed,
7042 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7043 "queue_mask <queue_mask_value>: "
7044 "Set rate limit for queues of VF on port_id",
7046 (void *)&cmd_vf_rate_limit_set,
7047 (void *)&cmd_vf_rate_limit_port,
7048 (void *)&cmd_vf_rate_limit_portnum,
7049 (void *)&cmd_vf_rate_limit_vf,
7050 (void *)&cmd_vf_rate_limit_vfnum,
7051 (void *)&cmd_vf_rate_limit_rate,
7052 (void *)&cmd_vf_rate_limit_ratenum,
7053 (void *)&cmd_vf_rate_limit_q_msk,
7054 (void *)&cmd_vf_rate_limit_q_msk_val,
7059 /* *** ADD TUNNEL FILTER OF A PORT *** */
7060 struct cmd_tunnel_filter_result {
7061 cmdline_fixed_string_t cmd;
7062 cmdline_fixed_string_t what;
7064 struct ether_addr outer_mac;
7065 struct ether_addr inner_mac;
7066 cmdline_ipaddr_t ip_value;
7067 uint16_t inner_vlan;
7068 cmdline_fixed_string_t tunnel_type;
7069 cmdline_fixed_string_t filter_type;
7075 cmd_tunnel_filter_parsed(void *parsed_result,
7076 __attribute__((unused)) struct cmdline *cl,
7077 __attribute__((unused)) void *data)
7079 struct cmd_tunnel_filter_result *res = parsed_result;
7080 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7083 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7085 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7086 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7087 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7089 if (res->ip_value.family == AF_INET) {
7090 tunnel_filter_conf.ip_addr.ipv4_addr =
7091 res->ip_value.addr.ipv4.s_addr;
7092 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7094 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7095 &(res->ip_value.addr.ipv6),
7096 sizeof(struct in6_addr));
7097 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7100 if (!strcmp(res->filter_type, "imac-ivlan"))
7101 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7102 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7103 tunnel_filter_conf.filter_type =
7104 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7105 else if (!strcmp(res->filter_type, "imac-tenid"))
7106 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7107 else if (!strcmp(res->filter_type, "imac"))
7108 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7109 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7110 tunnel_filter_conf.filter_type =
7111 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7112 else if (!strcmp(res->filter_type, "oip"))
7113 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7114 else if (!strcmp(res->filter_type, "iip"))
7115 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7117 printf("The filter type is not supported");
7121 if (!strcmp(res->tunnel_type, "vxlan"))
7122 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7123 else if (!strcmp(res->tunnel_type, "nvgre"))
7124 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7125 else if (!strcmp(res->tunnel_type, "ipingre"))
7126 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7128 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7132 tunnel_filter_conf.tenant_id = res->tenant_id;
7133 tunnel_filter_conf.queue_id = res->queue_num;
7134 if (!strcmp(res->what, "add"))
7135 ret = rte_eth_dev_filter_ctrl(res->port_id,
7136 RTE_ETH_FILTER_TUNNEL,
7138 &tunnel_filter_conf);
7140 ret = rte_eth_dev_filter_ctrl(res->port_id,
7141 RTE_ETH_FILTER_TUNNEL,
7142 RTE_ETH_FILTER_DELETE,
7143 &tunnel_filter_conf);
7145 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7149 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7150 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7151 cmd, "tunnel_filter");
7152 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7153 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7155 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7156 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7158 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7159 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7161 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7164 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7165 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7166 inner_vlan, UINT16);
7167 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7168 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7170 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7171 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7172 tunnel_type, "vxlan#nvgre#ipingre");
7174 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7175 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7176 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7177 "imac#omac-imac-tenid");
7178 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7179 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7181 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7182 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7185 cmdline_parse_inst_t cmd_tunnel_filter = {
7186 .f = cmd_tunnel_filter_parsed,
7188 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7189 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7190 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7191 "<queue_id>: Add/Rm tunnel filter of a port",
7193 (void *)&cmd_tunnel_filter_cmd,
7194 (void *)&cmd_tunnel_filter_what,
7195 (void *)&cmd_tunnel_filter_port_id,
7196 (void *)&cmd_tunnel_filter_outer_mac,
7197 (void *)&cmd_tunnel_filter_inner_mac,
7198 (void *)&cmd_tunnel_filter_ip_value,
7199 (void *)&cmd_tunnel_filter_innner_vlan,
7200 (void *)&cmd_tunnel_filter_tunnel_type,
7201 (void *)&cmd_tunnel_filter_filter_type,
7202 (void *)&cmd_tunnel_filter_tenant_id,
7203 (void *)&cmd_tunnel_filter_queue_num,
7208 /* *** CONFIGURE TUNNEL UDP PORT *** */
7209 struct cmd_tunnel_udp_config {
7210 cmdline_fixed_string_t cmd;
7211 cmdline_fixed_string_t what;
7217 cmd_tunnel_udp_config_parsed(void *parsed_result,
7218 __attribute__((unused)) struct cmdline *cl,
7219 __attribute__((unused)) void *data)
7221 struct cmd_tunnel_udp_config *res = parsed_result;
7222 struct rte_eth_udp_tunnel tunnel_udp;
7225 tunnel_udp.udp_port = res->udp_port;
7227 if (!strcmp(res->cmd, "rx_vxlan_port"))
7228 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7230 if (!strcmp(res->what, "add"))
7231 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7234 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7238 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7241 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7242 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7243 cmd, "rx_vxlan_port");
7244 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7245 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7247 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7248 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7250 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7251 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7254 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7255 .f = cmd_tunnel_udp_config_parsed,
7257 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7258 "Add/Remove a tunneling UDP port filter",
7260 (void *)&cmd_tunnel_udp_config_cmd,
7261 (void *)&cmd_tunnel_udp_config_what,
7262 (void *)&cmd_tunnel_udp_config_udp_port,
7263 (void *)&cmd_tunnel_udp_config_port_id,
7268 /* *** GLOBAL CONFIG *** */
7269 struct cmd_global_config_result {
7270 cmdline_fixed_string_t cmd;
7272 cmdline_fixed_string_t cfg_type;
7277 cmd_global_config_parsed(void *parsed_result,
7278 __attribute__((unused)) struct cmdline *cl,
7279 __attribute__((unused)) void *data)
7281 struct cmd_global_config_result *res = parsed_result;
7282 struct rte_eth_global_cfg conf;
7285 memset(&conf, 0, sizeof(conf));
7286 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7287 conf.cfg.gre_key_len = res->len;
7288 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7289 RTE_ETH_FILTER_SET, &conf);
7291 printf("Global config error\n");
7294 cmdline_parse_token_string_t cmd_global_config_cmd =
7295 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7297 cmdline_parse_token_num_t cmd_global_config_port_id =
7298 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7299 cmdline_parse_token_string_t cmd_global_config_type =
7300 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7301 cfg_type, "gre-key-len");
7302 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7303 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7306 cmdline_parse_inst_t cmd_global_config = {
7307 .f = cmd_global_config_parsed,
7308 .data = (void *)NULL,
7309 .help_str = "global_config <port_id> gre-key-len <key_len>",
7311 (void *)&cmd_global_config_cmd,
7312 (void *)&cmd_global_config_port_id,
7313 (void *)&cmd_global_config_type,
7314 (void *)&cmd_global_config_gre_key_len,
7319 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7320 struct cmd_set_mirror_mask_result {
7321 cmdline_fixed_string_t set;
7322 cmdline_fixed_string_t port;
7324 cmdline_fixed_string_t mirror;
7326 cmdline_fixed_string_t what;
7327 cmdline_fixed_string_t value;
7328 cmdline_fixed_string_t dstpool;
7330 cmdline_fixed_string_t on;
7333 cmdline_parse_token_string_t cmd_mirror_mask_set =
7334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7336 cmdline_parse_token_string_t cmd_mirror_mask_port =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7339 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7340 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7342 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7344 mirror, "mirror-rule");
7345 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7346 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7348 cmdline_parse_token_string_t cmd_mirror_mask_what =
7349 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7350 what, "pool-mirror-up#pool-mirror-down"
7352 cmdline_parse_token_string_t cmd_mirror_mask_value =
7353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7355 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7357 dstpool, "dst-pool");
7358 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7359 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7361 cmdline_parse_token_string_t cmd_mirror_mask_on =
7362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7366 cmd_set_mirror_mask_parsed(void *parsed_result,
7367 __attribute__((unused)) struct cmdline *cl,
7368 __attribute__((unused)) void *data)
7371 struct cmd_set_mirror_mask_result *res = parsed_result;
7372 struct rte_eth_mirror_conf mr_conf;
7374 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7376 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7378 mr_conf.dst_pool = res->dstpool_id;
7380 if (!strcmp(res->what, "pool-mirror-up")) {
7381 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7382 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7383 } else if (!strcmp(res->what, "pool-mirror-down")) {
7384 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7385 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7386 } else if (!strcmp(res->what, "vlan-mirror")) {
7387 mr_conf.rule_type = ETH_MIRROR_VLAN;
7388 nb_item = parse_item_list(res->value, "vlan",
7389 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7393 for (i = 0; i < nb_item; i++) {
7394 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7395 printf("Invalid vlan_id: must be < 4096\n");
7399 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7400 mr_conf.vlan.vlan_mask |= 1ULL << i;
7404 if (!strcmp(res->on, "on"))
7405 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7411 printf("mirror rule add error: (%s)\n", strerror(-ret));
7414 cmdline_parse_inst_t cmd_set_mirror_mask = {
7415 .f = cmd_set_mirror_mask_parsed,
7417 .help_str = "set port <port_id> mirror-rule <rule_id> "
7418 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7419 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7421 (void *)&cmd_mirror_mask_set,
7422 (void *)&cmd_mirror_mask_port,
7423 (void *)&cmd_mirror_mask_portid,
7424 (void *)&cmd_mirror_mask_mirror,
7425 (void *)&cmd_mirror_mask_ruleid,
7426 (void *)&cmd_mirror_mask_what,
7427 (void *)&cmd_mirror_mask_value,
7428 (void *)&cmd_mirror_mask_dstpool,
7429 (void *)&cmd_mirror_mask_poolid,
7430 (void *)&cmd_mirror_mask_on,
7435 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7436 struct cmd_set_mirror_link_result {
7437 cmdline_fixed_string_t set;
7438 cmdline_fixed_string_t port;
7440 cmdline_fixed_string_t mirror;
7442 cmdline_fixed_string_t what;
7443 cmdline_fixed_string_t dstpool;
7445 cmdline_fixed_string_t on;
7448 cmdline_parse_token_string_t cmd_mirror_link_set =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7451 cmdline_parse_token_string_t cmd_mirror_link_port =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7454 cmdline_parse_token_num_t cmd_mirror_link_portid =
7455 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7457 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7458 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7459 mirror, "mirror-rule");
7460 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7461 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7463 cmdline_parse_token_string_t cmd_mirror_link_what =
7464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7465 what, "uplink-mirror#downlink-mirror");
7466 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7467 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7468 dstpool, "dst-pool");
7469 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7470 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7472 cmdline_parse_token_string_t cmd_mirror_link_on =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7477 cmd_set_mirror_link_parsed(void *parsed_result,
7478 __attribute__((unused)) struct cmdline *cl,
7479 __attribute__((unused)) void *data)
7482 struct cmd_set_mirror_link_result *res = parsed_result;
7483 struct rte_eth_mirror_conf mr_conf;
7485 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7486 if (!strcmp(res->what, "uplink-mirror"))
7487 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7489 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7491 mr_conf.dst_pool = res->dstpool_id;
7493 if (!strcmp(res->on, "on"))
7494 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7497 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7500 /* check the return value and print it if is < 0 */
7502 printf("mirror rule add error: (%s)\n", strerror(-ret));
7506 cmdline_parse_inst_t cmd_set_mirror_link = {
7507 .f = cmd_set_mirror_link_parsed,
7509 .help_str = "set port <port_id> mirror-rule <rule_id> "
7510 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7512 (void *)&cmd_mirror_link_set,
7513 (void *)&cmd_mirror_link_port,
7514 (void *)&cmd_mirror_link_portid,
7515 (void *)&cmd_mirror_link_mirror,
7516 (void *)&cmd_mirror_link_ruleid,
7517 (void *)&cmd_mirror_link_what,
7518 (void *)&cmd_mirror_link_dstpool,
7519 (void *)&cmd_mirror_link_poolid,
7520 (void *)&cmd_mirror_link_on,
7525 /* *** RESET VM MIRROR RULE *** */
7526 struct cmd_rm_mirror_rule_result {
7527 cmdline_fixed_string_t reset;
7528 cmdline_fixed_string_t port;
7530 cmdline_fixed_string_t mirror;
7534 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7535 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7537 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7538 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7540 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7541 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7543 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7544 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7545 mirror, "mirror-rule");
7546 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7547 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7551 cmd_reset_mirror_rule_parsed(void *parsed_result,
7552 __attribute__((unused)) struct cmdline *cl,
7553 __attribute__((unused)) void *data)
7556 struct cmd_set_mirror_link_result *res = parsed_result;
7558 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7560 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7563 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7564 .f = cmd_reset_mirror_rule_parsed,
7566 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7568 (void *)&cmd_rm_mirror_rule_reset,
7569 (void *)&cmd_rm_mirror_rule_port,
7570 (void *)&cmd_rm_mirror_rule_portid,
7571 (void *)&cmd_rm_mirror_rule_mirror,
7572 (void *)&cmd_rm_mirror_rule_ruleid,
7577 /* ******************************************************************************** */
7579 struct cmd_dump_result {
7580 cmdline_fixed_string_t dump;
7584 dump_struct_sizes(void)
7586 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7587 DUMP_SIZE(struct rte_mbuf);
7588 DUMP_SIZE(struct rte_mempool);
7589 DUMP_SIZE(struct rte_ring);
7593 static void cmd_dump_parsed(void *parsed_result,
7594 __attribute__((unused)) struct cmdline *cl,
7595 __attribute__((unused)) void *data)
7597 struct cmd_dump_result *res = parsed_result;
7599 if (!strcmp(res->dump, "dump_physmem"))
7600 rte_dump_physmem_layout(stdout);
7601 else if (!strcmp(res->dump, "dump_memzone"))
7602 rte_memzone_dump(stdout);
7603 else if (!strcmp(res->dump, "dump_struct_sizes"))
7604 dump_struct_sizes();
7605 else if (!strcmp(res->dump, "dump_ring"))
7606 rte_ring_list_dump(stdout);
7607 else if (!strcmp(res->dump, "dump_mempool"))
7608 rte_mempool_list_dump(stdout);
7609 else if (!strcmp(res->dump, "dump_devargs"))
7610 rte_eal_devargs_dump(stdout);
7613 cmdline_parse_token_string_t cmd_dump_dump =
7614 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7617 "dump_struct_sizes#"
7622 cmdline_parse_inst_t cmd_dump = {
7623 .f = cmd_dump_parsed, /* function to call */
7624 .data = NULL, /* 2nd arg of func */
7625 .help_str = "Dump status",
7626 .tokens = { /* token list, NULL terminated */
7627 (void *)&cmd_dump_dump,
7632 /* ******************************************************************************** */
7634 struct cmd_dump_one_result {
7635 cmdline_fixed_string_t dump;
7636 cmdline_fixed_string_t name;
7639 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7640 __attribute__((unused)) void *data)
7642 struct cmd_dump_one_result *res = parsed_result;
7644 if (!strcmp(res->dump, "dump_ring")) {
7646 r = rte_ring_lookup(res->name);
7648 cmdline_printf(cl, "Cannot find ring\n");
7651 rte_ring_dump(stdout, r);
7652 } else if (!strcmp(res->dump, "dump_mempool")) {
7653 struct rte_mempool *mp;
7654 mp = rte_mempool_lookup(res->name);
7656 cmdline_printf(cl, "Cannot find mempool\n");
7659 rte_mempool_dump(stdout, mp);
7663 cmdline_parse_token_string_t cmd_dump_one_dump =
7664 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7665 "dump_ring#dump_mempool");
7667 cmdline_parse_token_string_t cmd_dump_one_name =
7668 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7670 cmdline_parse_inst_t cmd_dump_one = {
7671 .f = cmd_dump_one_parsed, /* function to call */
7672 .data = NULL, /* 2nd arg of func */
7673 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7674 .tokens = { /* token list, NULL terminated */
7675 (void *)&cmd_dump_one_dump,
7676 (void *)&cmd_dump_one_name,
7681 /* *** Add/Del syn filter *** */
7682 struct cmd_syn_filter_result {
7683 cmdline_fixed_string_t filter;
7685 cmdline_fixed_string_t ops;
7686 cmdline_fixed_string_t priority;
7687 cmdline_fixed_string_t high;
7688 cmdline_fixed_string_t queue;
7693 cmd_syn_filter_parsed(void *parsed_result,
7694 __attribute__((unused)) struct cmdline *cl,
7695 __attribute__((unused)) void *data)
7697 struct cmd_syn_filter_result *res = parsed_result;
7698 struct rte_eth_syn_filter syn_filter;
7701 ret = rte_eth_dev_filter_supported(res->port_id,
7702 RTE_ETH_FILTER_SYN);
7704 printf("syn filter is not supported on port %u.\n",
7709 memset(&syn_filter, 0, sizeof(syn_filter));
7711 if (!strcmp(res->ops, "add")) {
7712 if (!strcmp(res->high, "high"))
7713 syn_filter.hig_pri = 1;
7715 syn_filter.hig_pri = 0;
7717 syn_filter.queue = res->queue_id;
7718 ret = rte_eth_dev_filter_ctrl(res->port_id,
7723 ret = rte_eth_dev_filter_ctrl(res->port_id,
7725 RTE_ETH_FILTER_DELETE,
7729 printf("syn filter programming error: (%s)\n",
7733 cmdline_parse_token_string_t cmd_syn_filter_filter =
7734 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7735 filter, "syn_filter");
7736 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7737 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7739 cmdline_parse_token_string_t cmd_syn_filter_ops =
7740 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7742 cmdline_parse_token_string_t cmd_syn_filter_priority =
7743 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7744 priority, "priority");
7745 cmdline_parse_token_string_t cmd_syn_filter_high =
7746 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7748 cmdline_parse_token_string_t cmd_syn_filter_queue =
7749 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7751 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7752 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7755 cmdline_parse_inst_t cmd_syn_filter = {
7756 .f = cmd_syn_filter_parsed,
7758 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7759 "<queue_id>: Add/Delete syn filter",
7761 (void *)&cmd_syn_filter_filter,
7762 (void *)&cmd_syn_filter_port_id,
7763 (void *)&cmd_syn_filter_ops,
7764 (void *)&cmd_syn_filter_priority,
7765 (void *)&cmd_syn_filter_high,
7766 (void *)&cmd_syn_filter_queue,
7767 (void *)&cmd_syn_filter_queue_id,
7772 /* *** ADD/REMOVE A 2tuple FILTER *** */
7773 struct cmd_2tuple_filter_result {
7774 cmdline_fixed_string_t filter;
7776 cmdline_fixed_string_t ops;
7777 cmdline_fixed_string_t dst_port;
7778 uint16_t dst_port_value;
7779 cmdline_fixed_string_t protocol;
7780 uint8_t protocol_value;
7781 cmdline_fixed_string_t mask;
7783 cmdline_fixed_string_t tcp_flags;
7784 uint8_t tcp_flags_value;
7785 cmdline_fixed_string_t priority;
7786 uint8_t priority_value;
7787 cmdline_fixed_string_t queue;
7792 cmd_2tuple_filter_parsed(void *parsed_result,
7793 __attribute__((unused)) struct cmdline *cl,
7794 __attribute__((unused)) void *data)
7796 struct rte_eth_ntuple_filter filter;
7797 struct cmd_2tuple_filter_result *res = parsed_result;
7800 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7802 printf("ntuple filter is not supported on port %u.\n",
7807 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7809 filter.flags = RTE_2TUPLE_FLAGS;
7810 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7811 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7812 filter.proto = res->protocol_value;
7813 filter.priority = res->priority_value;
7814 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7815 printf("nonzero tcp_flags is only meaningful"
7816 " when protocol is TCP.\n");
7819 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7820 printf("invalid TCP flags.\n");
7824 if (res->tcp_flags_value != 0) {
7825 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7826 filter.tcp_flags = res->tcp_flags_value;
7829 /* need convert to big endian. */
7830 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7831 filter.queue = res->queue_id;
7833 if (!strcmp(res->ops, "add"))
7834 ret = rte_eth_dev_filter_ctrl(res->port_id,
7835 RTE_ETH_FILTER_NTUPLE,
7839 ret = rte_eth_dev_filter_ctrl(res->port_id,
7840 RTE_ETH_FILTER_NTUPLE,
7841 RTE_ETH_FILTER_DELETE,
7844 printf("2tuple filter programming error: (%s)\n",
7849 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7850 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7851 filter, "2tuple_filter");
7852 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7853 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7855 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7856 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7858 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7859 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7860 dst_port, "dst_port");
7861 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7862 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7863 dst_port_value, UINT16);
7864 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7865 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7866 protocol, "protocol");
7867 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7868 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7869 protocol_value, UINT8);
7870 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7871 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7873 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7874 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7876 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7877 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7878 tcp_flags, "tcp_flags");
7879 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7880 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7881 tcp_flags_value, UINT8);
7882 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7883 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7884 priority, "priority");
7885 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7886 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7887 priority_value, UINT8);
7888 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7889 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7891 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7892 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7895 cmdline_parse_inst_t cmd_2tuple_filter = {
7896 .f = cmd_2tuple_filter_parsed,
7898 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7899 "<value> mask <value> tcp_flags <value> priority <value> queue "
7900 "<queue_id>: Add a 2tuple filter",
7902 (void *)&cmd_2tuple_filter_filter,
7903 (void *)&cmd_2tuple_filter_port_id,
7904 (void *)&cmd_2tuple_filter_ops,
7905 (void *)&cmd_2tuple_filter_dst_port,
7906 (void *)&cmd_2tuple_filter_dst_port_value,
7907 (void *)&cmd_2tuple_filter_protocol,
7908 (void *)&cmd_2tuple_filter_protocol_value,
7909 (void *)&cmd_2tuple_filter_mask,
7910 (void *)&cmd_2tuple_filter_mask_value,
7911 (void *)&cmd_2tuple_filter_tcp_flags,
7912 (void *)&cmd_2tuple_filter_tcp_flags_value,
7913 (void *)&cmd_2tuple_filter_priority,
7914 (void *)&cmd_2tuple_filter_priority_value,
7915 (void *)&cmd_2tuple_filter_queue,
7916 (void *)&cmd_2tuple_filter_queue_id,
7921 /* *** ADD/REMOVE A 5tuple FILTER *** */
7922 struct cmd_5tuple_filter_result {
7923 cmdline_fixed_string_t filter;
7925 cmdline_fixed_string_t ops;
7926 cmdline_fixed_string_t dst_ip;
7927 cmdline_ipaddr_t dst_ip_value;
7928 cmdline_fixed_string_t src_ip;
7929 cmdline_ipaddr_t src_ip_value;
7930 cmdline_fixed_string_t dst_port;
7931 uint16_t dst_port_value;
7932 cmdline_fixed_string_t src_port;
7933 uint16_t src_port_value;
7934 cmdline_fixed_string_t protocol;
7935 uint8_t protocol_value;
7936 cmdline_fixed_string_t mask;
7938 cmdline_fixed_string_t tcp_flags;
7939 uint8_t tcp_flags_value;
7940 cmdline_fixed_string_t priority;
7941 uint8_t priority_value;
7942 cmdline_fixed_string_t queue;
7947 cmd_5tuple_filter_parsed(void *parsed_result,
7948 __attribute__((unused)) struct cmdline *cl,
7949 __attribute__((unused)) void *data)
7951 struct rte_eth_ntuple_filter filter;
7952 struct cmd_5tuple_filter_result *res = parsed_result;
7955 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7957 printf("ntuple filter is not supported on port %u.\n",
7962 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7964 filter.flags = RTE_5TUPLE_FLAGS;
7965 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7966 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7967 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7968 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7969 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7970 filter.proto = res->protocol_value;
7971 filter.priority = res->priority_value;
7972 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7973 printf("nonzero tcp_flags is only meaningful"
7974 " when protocol is TCP.\n");
7977 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7978 printf("invalid TCP flags.\n");
7982 if (res->tcp_flags_value != 0) {
7983 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7984 filter.tcp_flags = res->tcp_flags_value;
7987 if (res->dst_ip_value.family == AF_INET)
7988 /* no need to convert, already big endian. */
7989 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7991 if (filter.dst_ip_mask == 0) {
7992 printf("can not support ipv6 involved compare.\n");
7998 if (res->src_ip_value.family == AF_INET)
7999 /* no need to convert, already big endian. */
8000 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8002 if (filter.src_ip_mask == 0) {
8003 printf("can not support ipv6 involved compare.\n");
8008 /* need convert to big endian. */
8009 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8010 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8011 filter.queue = res->queue_id;
8013 if (!strcmp(res->ops, "add"))
8014 ret = rte_eth_dev_filter_ctrl(res->port_id,
8015 RTE_ETH_FILTER_NTUPLE,
8019 ret = rte_eth_dev_filter_ctrl(res->port_id,
8020 RTE_ETH_FILTER_NTUPLE,
8021 RTE_ETH_FILTER_DELETE,
8024 printf("5tuple filter programming error: (%s)\n",
8028 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8029 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8030 filter, "5tuple_filter");
8031 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8032 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8034 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8035 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8037 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8038 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8040 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8041 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8043 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8044 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8046 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8047 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8049 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8050 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8051 dst_port, "dst_port");
8052 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8053 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8054 dst_port_value, UINT16);
8055 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8056 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8057 src_port, "src_port");
8058 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8059 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8060 src_port_value, UINT16);
8061 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8062 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8063 protocol, "protocol");
8064 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8065 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8066 protocol_value, UINT8);
8067 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8068 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8070 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8071 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8073 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8074 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8075 tcp_flags, "tcp_flags");
8076 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8077 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8078 tcp_flags_value, UINT8);
8079 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8080 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8081 priority, "priority");
8082 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8083 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8084 priority_value, UINT8);
8085 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8086 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8088 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8089 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8092 cmdline_parse_inst_t cmd_5tuple_filter = {
8093 .f = cmd_5tuple_filter_parsed,
8095 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8096 "src_ip <value> dst_port <value> src_port <value> "
8097 "protocol <value> mask <value> tcp_flags <value> "
8098 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8100 (void *)&cmd_5tuple_filter_filter,
8101 (void *)&cmd_5tuple_filter_port_id,
8102 (void *)&cmd_5tuple_filter_ops,
8103 (void *)&cmd_5tuple_filter_dst_ip,
8104 (void *)&cmd_5tuple_filter_dst_ip_value,
8105 (void *)&cmd_5tuple_filter_src_ip,
8106 (void *)&cmd_5tuple_filter_src_ip_value,
8107 (void *)&cmd_5tuple_filter_dst_port,
8108 (void *)&cmd_5tuple_filter_dst_port_value,
8109 (void *)&cmd_5tuple_filter_src_port,
8110 (void *)&cmd_5tuple_filter_src_port_value,
8111 (void *)&cmd_5tuple_filter_protocol,
8112 (void *)&cmd_5tuple_filter_protocol_value,
8113 (void *)&cmd_5tuple_filter_mask,
8114 (void *)&cmd_5tuple_filter_mask_value,
8115 (void *)&cmd_5tuple_filter_tcp_flags,
8116 (void *)&cmd_5tuple_filter_tcp_flags_value,
8117 (void *)&cmd_5tuple_filter_priority,
8118 (void *)&cmd_5tuple_filter_priority_value,
8119 (void *)&cmd_5tuple_filter_queue,
8120 (void *)&cmd_5tuple_filter_queue_id,
8125 /* *** ADD/REMOVE A flex FILTER *** */
8126 struct cmd_flex_filter_result {
8127 cmdline_fixed_string_t filter;
8128 cmdline_fixed_string_t ops;
8130 cmdline_fixed_string_t len;
8132 cmdline_fixed_string_t bytes;
8133 cmdline_fixed_string_t bytes_value;
8134 cmdline_fixed_string_t mask;
8135 cmdline_fixed_string_t mask_value;
8136 cmdline_fixed_string_t priority;
8137 uint8_t priority_value;
8138 cmdline_fixed_string_t queue;
8142 static int xdigit2val(unsigned char c)
8147 else if (isupper(c))
8155 cmd_flex_filter_parsed(void *parsed_result,
8156 __attribute__((unused)) struct cmdline *cl,
8157 __attribute__((unused)) void *data)
8160 struct rte_eth_flex_filter filter;
8161 struct cmd_flex_filter_result *res = parsed_result;
8162 char *bytes_ptr, *mask_ptr;
8163 uint16_t len, i, j = 0;
8168 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8169 printf("the len exceed the max length 128\n");
8172 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8173 filter.len = res->len_value;
8174 filter.priority = res->priority_value;
8175 filter.queue = res->queue_id;
8176 bytes_ptr = res->bytes_value;
8177 mask_ptr = res->mask_value;
8179 /* translate bytes string to array. */
8180 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8181 (bytes_ptr[1] == 'X')))
8183 len = strnlen(bytes_ptr, res->len_value * 2);
8184 if (len == 0 || (len % 8 != 0)) {
8185 printf("please check len and bytes input\n");
8188 for (i = 0; i < len; i++) {
8190 if (isxdigit(c) == 0) {
8191 /* invalid characters. */
8192 printf("invalid input\n");
8195 val = xdigit2val(c);
8198 filter.bytes[j] = byte;
8199 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8206 /* translate mask string to uint8_t array. */
8207 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8208 (mask_ptr[1] == 'X')))
8210 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8212 printf("invalid input\n");
8217 for (i = 0; i < len; i++) {
8219 if (isxdigit(c) == 0) {
8220 /* invalid characters. */
8221 printf("invalid input\n");
8224 val = xdigit2val(c);
8227 filter.mask[j] = byte;
8228 printf("mask[%d]:%02x ", j, filter.mask[j]);
8236 if (!strcmp(res->ops, "add"))
8237 ret = rte_eth_dev_filter_ctrl(res->port_id,
8238 RTE_ETH_FILTER_FLEXIBLE,
8242 ret = rte_eth_dev_filter_ctrl(res->port_id,
8243 RTE_ETH_FILTER_FLEXIBLE,
8244 RTE_ETH_FILTER_DELETE,
8248 printf("flex filter setting error: (%s)\n", strerror(-ret));
8251 cmdline_parse_token_string_t cmd_flex_filter_filter =
8252 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8253 filter, "flex_filter");
8254 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8255 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8257 cmdline_parse_token_string_t cmd_flex_filter_ops =
8258 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8260 cmdline_parse_token_string_t cmd_flex_filter_len =
8261 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8263 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8264 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8266 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8267 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8269 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8270 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8272 cmdline_parse_token_string_t cmd_flex_filter_mask =
8273 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8275 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8276 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8278 cmdline_parse_token_string_t cmd_flex_filter_priority =
8279 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8280 priority, "priority");
8281 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8282 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8283 priority_value, UINT8);
8284 cmdline_parse_token_string_t cmd_flex_filter_queue =
8285 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8287 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8288 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8290 cmdline_parse_inst_t cmd_flex_filter = {
8291 .f = cmd_flex_filter_parsed,
8293 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8294 "<value> mask <value> priority <value> queue <queue_id>: "
8295 "Add/Del a flex filter",
8297 (void *)&cmd_flex_filter_filter,
8298 (void *)&cmd_flex_filter_port_id,
8299 (void *)&cmd_flex_filter_ops,
8300 (void *)&cmd_flex_filter_len,
8301 (void *)&cmd_flex_filter_len_value,
8302 (void *)&cmd_flex_filter_bytes,
8303 (void *)&cmd_flex_filter_bytes_value,
8304 (void *)&cmd_flex_filter_mask,
8305 (void *)&cmd_flex_filter_mask_value,
8306 (void *)&cmd_flex_filter_priority,
8307 (void *)&cmd_flex_filter_priority_value,
8308 (void *)&cmd_flex_filter_queue,
8309 (void *)&cmd_flex_filter_queue_id,
8314 /* *** Filters Control *** */
8316 /* *** deal with ethertype filter *** */
8317 struct cmd_ethertype_filter_result {
8318 cmdline_fixed_string_t filter;
8320 cmdline_fixed_string_t ops;
8321 cmdline_fixed_string_t mac;
8322 struct ether_addr mac_addr;
8323 cmdline_fixed_string_t ethertype;
8324 uint16_t ethertype_value;
8325 cmdline_fixed_string_t drop;
8326 cmdline_fixed_string_t queue;
8330 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8331 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8332 filter, "ethertype_filter");
8333 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8334 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8336 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8337 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8339 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8340 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8341 mac, "mac_addr#mac_ignr");
8342 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8343 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8345 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8346 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8347 ethertype, "ethertype");
8348 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8349 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8350 ethertype_value, UINT16);
8351 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8352 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8354 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8355 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8357 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8358 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8362 cmd_ethertype_filter_parsed(void *parsed_result,
8363 __attribute__((unused)) struct cmdline *cl,
8364 __attribute__((unused)) void *data)
8366 struct cmd_ethertype_filter_result *res = parsed_result;
8367 struct rte_eth_ethertype_filter filter;
8370 ret = rte_eth_dev_filter_supported(res->port_id,
8371 RTE_ETH_FILTER_ETHERTYPE);
8373 printf("ethertype filter is not supported on port %u.\n",
8378 memset(&filter, 0, sizeof(filter));
8379 if (!strcmp(res->mac, "mac_addr")) {
8380 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8381 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8382 sizeof(struct ether_addr));
8384 if (!strcmp(res->drop, "drop"))
8385 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8386 filter.ether_type = res->ethertype_value;
8387 filter.queue = res->queue_id;
8389 if (!strcmp(res->ops, "add"))
8390 ret = rte_eth_dev_filter_ctrl(res->port_id,
8391 RTE_ETH_FILTER_ETHERTYPE,
8395 ret = rte_eth_dev_filter_ctrl(res->port_id,
8396 RTE_ETH_FILTER_ETHERTYPE,
8397 RTE_ETH_FILTER_DELETE,
8400 printf("ethertype filter programming error: (%s)\n",
8404 cmdline_parse_inst_t cmd_ethertype_filter = {
8405 .f = cmd_ethertype_filter_parsed,
8407 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8408 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8409 "Add or delete an ethertype filter entry",
8411 (void *)&cmd_ethertype_filter_filter,
8412 (void *)&cmd_ethertype_filter_port_id,
8413 (void *)&cmd_ethertype_filter_ops,
8414 (void *)&cmd_ethertype_filter_mac,
8415 (void *)&cmd_ethertype_filter_mac_addr,
8416 (void *)&cmd_ethertype_filter_ethertype,
8417 (void *)&cmd_ethertype_filter_ethertype_value,
8418 (void *)&cmd_ethertype_filter_drop,
8419 (void *)&cmd_ethertype_filter_queue,
8420 (void *)&cmd_ethertype_filter_queue_id,
8425 /* *** deal with flow director filter *** */
8426 struct cmd_flow_director_result {
8427 cmdline_fixed_string_t flow_director_filter;
8429 cmdline_fixed_string_t mode;
8430 cmdline_fixed_string_t mode_value;
8431 cmdline_fixed_string_t ops;
8432 cmdline_fixed_string_t flow;
8433 cmdline_fixed_string_t flow_type;
8434 cmdline_fixed_string_t ether;
8435 uint16_t ether_type;
8436 cmdline_fixed_string_t src;
8437 cmdline_ipaddr_t ip_src;
8439 cmdline_fixed_string_t dst;
8440 cmdline_ipaddr_t ip_dst;
8442 cmdline_fixed_string_t verify_tag;
8443 uint32_t verify_tag_value;
8444 cmdline_ipaddr_t tos;
8446 cmdline_ipaddr_t proto;
8447 uint8_t proto_value;
8448 cmdline_ipaddr_t ttl;
8450 cmdline_fixed_string_t vlan;
8451 uint16_t vlan_value;
8452 cmdline_fixed_string_t flexbytes;
8453 cmdline_fixed_string_t flexbytes_value;
8454 cmdline_fixed_string_t pf_vf;
8455 cmdline_fixed_string_t drop;
8456 cmdline_fixed_string_t queue;
8458 cmdline_fixed_string_t fd_id;
8459 uint32_t fd_id_value;
8460 cmdline_fixed_string_t mac;
8461 struct ether_addr mac_addr;
8462 cmdline_fixed_string_t tunnel;
8463 cmdline_fixed_string_t tunnel_type;
8464 cmdline_fixed_string_t tunnel_id;
8465 uint32_t tunnel_id_value;
8469 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8472 const char *p, *p0 = q_arg;
8474 unsigned long int_fld;
8475 char *str_fld[max_num];
8480 p = strchr(p0, '(');
8484 p0 = strchr(p, ')');
8489 if (size >= sizeof(s))
8492 snprintf(s, sizeof(s), "%.*s", size, p);
8493 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8494 if (ret < 0 || ret > max_num)
8496 for (i = 0; i < ret; i++) {
8498 int_fld = strtoul(str_fld[i], &end, 0);
8499 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8501 flexbytes[i] = (uint8_t)int_fld;
8507 str2flowtype(char *string)
8510 static const struct {
8513 } flowtype_str[] = {
8514 {"raw", RTE_ETH_FLOW_RAW},
8515 {"ipv4", RTE_ETH_FLOW_IPV4},
8516 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8517 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8518 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8519 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8520 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8521 {"ipv6", RTE_ETH_FLOW_IPV6},
8522 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8523 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8524 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8525 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8526 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8527 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8530 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8531 if (!strcmp(flowtype_str[i].str, string))
8532 return flowtype_str[i].type;
8534 return RTE_ETH_FLOW_UNKNOWN;
8537 static enum rte_eth_fdir_tunnel_type
8538 str2fdir_tunneltype(char *string)
8542 static const struct {
8544 enum rte_eth_fdir_tunnel_type type;
8545 } tunneltype_str[] = {
8546 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8547 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8550 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8551 if (!strcmp(tunneltype_str[i].str, string))
8552 return tunneltype_str[i].type;
8554 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8557 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8559 if ((ip_addr).family == AF_INET) \
8560 (ip) = (ip_addr).addr.ipv4.s_addr; \
8562 printf("invalid parameter.\n"); \
8567 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8569 if ((ip_addr).family == AF_INET6) \
8570 (void)rte_memcpy(&(ip), \
8571 &((ip_addr).addr.ipv6), \
8572 sizeof(struct in6_addr)); \
8574 printf("invalid parameter.\n"); \
8580 cmd_flow_director_filter_parsed(void *parsed_result,
8581 __attribute__((unused)) struct cmdline *cl,
8582 __attribute__((unused)) void *data)
8584 struct cmd_flow_director_result *res = parsed_result;
8585 struct rte_eth_fdir_filter entry;
8586 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8588 unsigned long vf_id;
8591 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8593 printf("flow director is not supported on port %u.\n",
8597 memset(flexbytes, 0, sizeof(flexbytes));
8598 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8600 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8601 if (strcmp(res->mode_value, "MAC-VLAN")) {
8602 printf("Please set mode to MAC-VLAN.\n");
8605 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8606 if (strcmp(res->mode_value, "Tunnel")) {
8607 printf("Please set mode to Tunnel.\n");
8611 if (strcmp(res->mode_value, "IP")) {
8612 printf("Please set mode to IP.\n");
8615 entry.input.flow_type = str2flowtype(res->flow_type);
8618 ret = parse_flexbytes(res->flexbytes_value,
8620 RTE_ETH_FDIR_MAX_FLEXLEN);
8622 printf("error: Cannot parse flexbytes input.\n");
8626 switch (entry.input.flow_type) {
8627 case RTE_ETH_FLOW_FRAG_IPV4:
8628 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8629 entry.input.flow.ip4_flow.proto = res->proto_value;
8630 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8631 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8632 IPV4_ADDR_TO_UINT(res->ip_dst,
8633 entry.input.flow.ip4_flow.dst_ip);
8634 IPV4_ADDR_TO_UINT(res->ip_src,
8635 entry.input.flow.ip4_flow.src_ip);
8636 entry.input.flow.ip4_flow.tos = res->tos_value;
8637 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8638 /* need convert to big endian. */
8639 entry.input.flow.udp4_flow.dst_port =
8640 rte_cpu_to_be_16(res->port_dst);
8641 entry.input.flow.udp4_flow.src_port =
8642 rte_cpu_to_be_16(res->port_src);
8644 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8645 IPV4_ADDR_TO_UINT(res->ip_dst,
8646 entry.input.flow.sctp4_flow.ip.dst_ip);
8647 IPV4_ADDR_TO_UINT(res->ip_src,
8648 entry.input.flow.sctp4_flow.ip.src_ip);
8649 entry.input.flow.ip4_flow.tos = res->tos_value;
8650 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8651 /* need convert to big endian. */
8652 entry.input.flow.sctp4_flow.dst_port =
8653 rte_cpu_to_be_16(res->port_dst);
8654 entry.input.flow.sctp4_flow.src_port =
8655 rte_cpu_to_be_16(res->port_src);
8656 entry.input.flow.sctp4_flow.verify_tag =
8657 rte_cpu_to_be_32(res->verify_tag_value);
8659 case RTE_ETH_FLOW_FRAG_IPV6:
8660 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8661 entry.input.flow.ipv6_flow.proto = res->proto_value;
8662 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8663 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8664 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8665 entry.input.flow.ipv6_flow.dst_ip);
8666 IPV6_ADDR_TO_ARRAY(res->ip_src,
8667 entry.input.flow.ipv6_flow.src_ip);
8668 entry.input.flow.ipv6_flow.tc = res->tos_value;
8669 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8670 /* need convert to big endian. */
8671 entry.input.flow.udp6_flow.dst_port =
8672 rte_cpu_to_be_16(res->port_dst);
8673 entry.input.flow.udp6_flow.src_port =
8674 rte_cpu_to_be_16(res->port_src);
8676 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8677 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8678 entry.input.flow.sctp6_flow.ip.dst_ip);
8679 IPV6_ADDR_TO_ARRAY(res->ip_src,
8680 entry.input.flow.sctp6_flow.ip.src_ip);
8681 entry.input.flow.ipv6_flow.tc = res->tos_value;
8682 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8683 /* need convert to big endian. */
8684 entry.input.flow.sctp6_flow.dst_port =
8685 rte_cpu_to_be_16(res->port_dst);
8686 entry.input.flow.sctp6_flow.src_port =
8687 rte_cpu_to_be_16(res->port_src);
8688 entry.input.flow.sctp6_flow.verify_tag =
8689 rte_cpu_to_be_32(res->verify_tag_value);
8691 case RTE_ETH_FLOW_L2_PAYLOAD:
8692 entry.input.flow.l2_flow.ether_type =
8693 rte_cpu_to_be_16(res->ether_type);
8699 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8700 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8702 sizeof(struct ether_addr));
8704 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8705 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8707 sizeof(struct ether_addr));
8708 entry.input.flow.tunnel_flow.tunnel_type =
8709 str2fdir_tunneltype(res->tunnel_type);
8710 entry.input.flow.tunnel_flow.tunnel_id =
8711 rte_cpu_to_be_32(res->tunnel_id_value);
8714 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8716 RTE_ETH_FDIR_MAX_FLEXLEN);
8718 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8720 entry.action.flex_off = 0; /*use 0 by default */
8721 if (!strcmp(res->drop, "drop"))
8722 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8724 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8726 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8727 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8728 if (!strcmp(res->pf_vf, "pf"))
8729 entry.input.flow_ext.is_vf = 0;
8730 else if (!strncmp(res->pf_vf, "vf", 2)) {
8731 struct rte_eth_dev_info dev_info;
8733 memset(&dev_info, 0, sizeof(dev_info));
8734 rte_eth_dev_info_get(res->port_id, &dev_info);
8736 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8737 if (errno != 0 || *end != '\0' ||
8738 vf_id >= dev_info.max_vfs) {
8739 printf("invalid parameter %s.\n", res->pf_vf);
8742 entry.input.flow_ext.is_vf = 1;
8743 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8745 printf("invalid parameter %s.\n", res->pf_vf);
8750 /* set to report FD ID by default */
8751 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8752 entry.action.rx_queue = res->queue_id;
8753 entry.soft_id = res->fd_id_value;
8754 if (!strcmp(res->ops, "add"))
8755 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8756 RTE_ETH_FILTER_ADD, &entry);
8757 else if (!strcmp(res->ops, "del"))
8758 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8759 RTE_ETH_FILTER_DELETE, &entry);
8761 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8762 RTE_ETH_FILTER_UPDATE, &entry);
8764 printf("flow director programming error: (%s)\n",
8768 cmdline_parse_token_string_t cmd_flow_director_filter =
8769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8770 flow_director_filter, "flow_director_filter");
8771 cmdline_parse_token_num_t cmd_flow_director_port_id =
8772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8774 cmdline_parse_token_string_t cmd_flow_director_ops =
8775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8776 ops, "add#del#update");
8777 cmdline_parse_token_string_t cmd_flow_director_flow =
8778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8780 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8782 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8783 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8784 cmdline_parse_token_string_t cmd_flow_director_ether =
8785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8787 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8788 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8789 ether_type, UINT16);
8790 cmdline_parse_token_string_t cmd_flow_director_src =
8791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8793 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8794 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8796 cmdline_parse_token_num_t cmd_flow_director_port_src =
8797 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8799 cmdline_parse_token_string_t cmd_flow_director_dst =
8800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8802 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8803 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8805 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8806 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8808 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8810 verify_tag, "verify_tag");
8811 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8812 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8813 verify_tag_value, UINT32);
8814 cmdline_parse_token_string_t cmd_flow_director_tos =
8815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8817 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8818 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8820 cmdline_parse_token_string_t cmd_flow_director_proto =
8821 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8823 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8824 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8825 proto_value, UINT8);
8826 cmdline_parse_token_string_t cmd_flow_director_ttl =
8827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8829 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8830 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8832 cmdline_parse_token_string_t cmd_flow_director_vlan =
8833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8835 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8836 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8837 vlan_value, UINT16);
8838 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8840 flexbytes, "flexbytes");
8841 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8843 flexbytes_value, NULL);
8844 cmdline_parse_token_string_t cmd_flow_director_drop =
8845 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8847 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8850 cmdline_parse_token_string_t cmd_flow_director_queue =
8851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8853 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8854 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8856 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8859 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8860 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8861 fd_id_value, UINT32);
8863 cmdline_parse_token_string_t cmd_flow_director_mode =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8866 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8869 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8871 mode_value, "MAC-VLAN");
8872 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8874 mode_value, "Tunnel");
8875 cmdline_parse_token_string_t cmd_flow_director_mac =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8878 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8879 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8886 tunnel_type, "NVGRE#VxLAN");
8887 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8889 tunnel_id, "tunnel-id");
8890 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8892 tunnel_id_value, UINT32);
8894 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8895 .f = cmd_flow_director_filter_parsed,
8897 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8898 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8899 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8900 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8901 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8902 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8903 "fd_id <fd_id_value>: "
8904 "Add or delete an ip flow director entry on NIC",
8906 (void *)&cmd_flow_director_filter,
8907 (void *)&cmd_flow_director_port_id,
8908 (void *)&cmd_flow_director_mode,
8909 (void *)&cmd_flow_director_mode_ip,
8910 (void *)&cmd_flow_director_ops,
8911 (void *)&cmd_flow_director_flow,
8912 (void *)&cmd_flow_director_flow_type,
8913 (void *)&cmd_flow_director_src,
8914 (void *)&cmd_flow_director_ip_src,
8915 (void *)&cmd_flow_director_dst,
8916 (void *)&cmd_flow_director_ip_dst,
8917 (void *)&cmd_flow_director_tos,
8918 (void *)&cmd_flow_director_tos_value,
8919 (void *)&cmd_flow_director_proto,
8920 (void *)&cmd_flow_director_proto_value,
8921 (void *)&cmd_flow_director_ttl,
8922 (void *)&cmd_flow_director_ttl_value,
8923 (void *)&cmd_flow_director_vlan,
8924 (void *)&cmd_flow_director_vlan_value,
8925 (void *)&cmd_flow_director_flexbytes,
8926 (void *)&cmd_flow_director_flexbytes_value,
8927 (void *)&cmd_flow_director_drop,
8928 (void *)&cmd_flow_director_pf_vf,
8929 (void *)&cmd_flow_director_queue,
8930 (void *)&cmd_flow_director_queue_id,
8931 (void *)&cmd_flow_director_fd_id,
8932 (void *)&cmd_flow_director_fd_id_value,
8937 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8938 .f = cmd_flow_director_filter_parsed,
8940 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
8941 "director entry on NIC",
8943 (void *)&cmd_flow_director_filter,
8944 (void *)&cmd_flow_director_port_id,
8945 (void *)&cmd_flow_director_mode,
8946 (void *)&cmd_flow_director_mode_ip,
8947 (void *)&cmd_flow_director_ops,
8948 (void *)&cmd_flow_director_flow,
8949 (void *)&cmd_flow_director_flow_type,
8950 (void *)&cmd_flow_director_src,
8951 (void *)&cmd_flow_director_ip_src,
8952 (void *)&cmd_flow_director_port_src,
8953 (void *)&cmd_flow_director_dst,
8954 (void *)&cmd_flow_director_ip_dst,
8955 (void *)&cmd_flow_director_port_dst,
8956 (void *)&cmd_flow_director_tos,
8957 (void *)&cmd_flow_director_tos_value,
8958 (void *)&cmd_flow_director_ttl,
8959 (void *)&cmd_flow_director_ttl_value,
8960 (void *)&cmd_flow_director_vlan,
8961 (void *)&cmd_flow_director_vlan_value,
8962 (void *)&cmd_flow_director_flexbytes,
8963 (void *)&cmd_flow_director_flexbytes_value,
8964 (void *)&cmd_flow_director_drop,
8965 (void *)&cmd_flow_director_pf_vf,
8966 (void *)&cmd_flow_director_queue,
8967 (void *)&cmd_flow_director_queue_id,
8968 (void *)&cmd_flow_director_fd_id,
8969 (void *)&cmd_flow_director_fd_id_value,
8974 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8975 .f = cmd_flow_director_filter_parsed,
8977 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
8978 "director entry on NIC",
8980 (void *)&cmd_flow_director_filter,
8981 (void *)&cmd_flow_director_port_id,
8982 (void *)&cmd_flow_director_mode,
8983 (void *)&cmd_flow_director_mode_ip,
8984 (void *)&cmd_flow_director_ops,
8985 (void *)&cmd_flow_director_flow,
8986 (void *)&cmd_flow_director_flow_type,
8987 (void *)&cmd_flow_director_src,
8988 (void *)&cmd_flow_director_ip_src,
8989 (void *)&cmd_flow_director_port_dst,
8990 (void *)&cmd_flow_director_dst,
8991 (void *)&cmd_flow_director_ip_dst,
8992 (void *)&cmd_flow_director_port_dst,
8993 (void *)&cmd_flow_director_verify_tag,
8994 (void *)&cmd_flow_director_verify_tag_value,
8995 (void *)&cmd_flow_director_tos,
8996 (void *)&cmd_flow_director_tos_value,
8997 (void *)&cmd_flow_director_ttl,
8998 (void *)&cmd_flow_director_ttl_value,
8999 (void *)&cmd_flow_director_vlan,
9000 (void *)&cmd_flow_director_vlan_value,
9001 (void *)&cmd_flow_director_flexbytes,
9002 (void *)&cmd_flow_director_flexbytes_value,
9003 (void *)&cmd_flow_director_drop,
9004 (void *)&cmd_flow_director_pf_vf,
9005 (void *)&cmd_flow_director_queue,
9006 (void *)&cmd_flow_director_queue_id,
9007 (void *)&cmd_flow_director_fd_id,
9008 (void *)&cmd_flow_director_fd_id_value,
9013 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9014 .f = cmd_flow_director_filter_parsed,
9016 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9017 "director entry on NIC",
9019 (void *)&cmd_flow_director_filter,
9020 (void *)&cmd_flow_director_port_id,
9021 (void *)&cmd_flow_director_mode,
9022 (void *)&cmd_flow_director_mode_ip,
9023 (void *)&cmd_flow_director_ops,
9024 (void *)&cmd_flow_director_flow,
9025 (void *)&cmd_flow_director_flow_type,
9026 (void *)&cmd_flow_director_ether,
9027 (void *)&cmd_flow_director_ether_type,
9028 (void *)&cmd_flow_director_flexbytes,
9029 (void *)&cmd_flow_director_flexbytes_value,
9030 (void *)&cmd_flow_director_drop,
9031 (void *)&cmd_flow_director_pf_vf,
9032 (void *)&cmd_flow_director_queue,
9033 (void *)&cmd_flow_director_queue_id,
9034 (void *)&cmd_flow_director_fd_id,
9035 (void *)&cmd_flow_director_fd_id_value,
9040 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9041 .f = cmd_flow_director_filter_parsed,
9043 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9044 "director entry on NIC",
9046 (void *)&cmd_flow_director_filter,
9047 (void *)&cmd_flow_director_port_id,
9048 (void *)&cmd_flow_director_mode,
9049 (void *)&cmd_flow_director_mode_mac_vlan,
9050 (void *)&cmd_flow_director_ops,
9051 (void *)&cmd_flow_director_mac,
9052 (void *)&cmd_flow_director_mac_addr,
9053 (void *)&cmd_flow_director_vlan,
9054 (void *)&cmd_flow_director_vlan_value,
9055 (void *)&cmd_flow_director_flexbytes,
9056 (void *)&cmd_flow_director_flexbytes_value,
9057 (void *)&cmd_flow_director_drop,
9058 (void *)&cmd_flow_director_queue,
9059 (void *)&cmd_flow_director_queue_id,
9060 (void *)&cmd_flow_director_fd_id,
9061 (void *)&cmd_flow_director_fd_id_value,
9066 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9067 .f = cmd_flow_director_filter_parsed,
9069 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9070 "director entry on NIC",
9072 (void *)&cmd_flow_director_filter,
9073 (void *)&cmd_flow_director_port_id,
9074 (void *)&cmd_flow_director_mode,
9075 (void *)&cmd_flow_director_mode_tunnel,
9076 (void *)&cmd_flow_director_ops,
9077 (void *)&cmd_flow_director_mac,
9078 (void *)&cmd_flow_director_mac_addr,
9079 (void *)&cmd_flow_director_vlan,
9080 (void *)&cmd_flow_director_vlan_value,
9081 (void *)&cmd_flow_director_tunnel,
9082 (void *)&cmd_flow_director_tunnel_type,
9083 (void *)&cmd_flow_director_tunnel_id,
9084 (void *)&cmd_flow_director_tunnel_id_value,
9085 (void *)&cmd_flow_director_flexbytes,
9086 (void *)&cmd_flow_director_flexbytes_value,
9087 (void *)&cmd_flow_director_drop,
9088 (void *)&cmd_flow_director_queue,
9089 (void *)&cmd_flow_director_queue_id,
9090 (void *)&cmd_flow_director_fd_id,
9091 (void *)&cmd_flow_director_fd_id_value,
9096 struct cmd_flush_flow_director_result {
9097 cmdline_fixed_string_t flush_flow_director;
9101 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9102 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9103 flush_flow_director, "flush_flow_director");
9104 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9105 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9109 cmd_flush_flow_director_parsed(void *parsed_result,
9110 __attribute__((unused)) struct cmdline *cl,
9111 __attribute__((unused)) void *data)
9113 struct cmd_flow_director_result *res = parsed_result;
9116 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9118 printf("flow director is not supported on port %u.\n",
9123 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9124 RTE_ETH_FILTER_FLUSH, NULL);
9126 printf("flow director table flushing error: (%s)\n",
9130 cmdline_parse_inst_t cmd_flush_flow_director = {
9131 .f = cmd_flush_flow_director_parsed,
9133 .help_str = "flush_flow_director <port_id>: "
9134 "Flush all flow director entries of a device on NIC",
9136 (void *)&cmd_flush_flow_director_flush,
9137 (void *)&cmd_flush_flow_director_port_id,
9142 /* *** deal with flow director mask *** */
9143 struct cmd_flow_director_mask_result {
9144 cmdline_fixed_string_t flow_director_mask;
9146 cmdline_fixed_string_t mode;
9147 cmdline_fixed_string_t mode_value;
9148 cmdline_fixed_string_t vlan;
9150 cmdline_fixed_string_t src_mask;
9151 cmdline_ipaddr_t ipv4_src;
9152 cmdline_ipaddr_t ipv6_src;
9154 cmdline_fixed_string_t dst_mask;
9155 cmdline_ipaddr_t ipv4_dst;
9156 cmdline_ipaddr_t ipv6_dst;
9158 cmdline_fixed_string_t mac;
9159 uint8_t mac_addr_byte_mask;
9160 cmdline_fixed_string_t tunnel_id;
9161 uint32_t tunnel_id_mask;
9162 cmdline_fixed_string_t tunnel_type;
9163 uint8_t tunnel_type_mask;
9167 cmd_flow_director_mask_parsed(void *parsed_result,
9168 __attribute__((unused)) struct cmdline *cl,
9169 __attribute__((unused)) void *data)
9171 struct cmd_flow_director_mask_result *res = parsed_result;
9172 struct rte_eth_fdir_masks *mask;
9173 struct rte_port *port;
9175 if (res->port_id > nb_ports) {
9176 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9180 port = &ports[res->port_id];
9181 /** Check if the port is not started **/
9182 if (port->port_status != RTE_PORT_STOPPED) {
9183 printf("Please stop port %d first\n", res->port_id);
9187 mask = &port->dev_conf.fdir_conf.mask;
9189 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9190 if (strcmp(res->mode_value, "MAC-VLAN")) {
9191 printf("Please set mode to MAC-VLAN.\n");
9195 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9196 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9197 if (strcmp(res->mode_value, "Tunnel")) {
9198 printf("Please set mode to Tunnel.\n");
9202 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9203 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9204 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9205 mask->tunnel_type_mask = res->tunnel_type_mask;
9207 if (strcmp(res->mode_value, "IP")) {
9208 printf("Please set mode to IP.\n");
9212 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9213 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9214 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9215 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9216 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9217 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9218 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9221 cmd_reconfig_device_queue(res->port_id, 1, 1);
9224 cmdline_parse_token_string_t cmd_flow_director_mask =
9225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9226 flow_director_mask, "flow_director_mask");
9227 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9228 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9230 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9233 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9236 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9238 src_mask, "src_mask");
9239 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9240 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9242 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9243 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9245 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9248 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9250 dst_mask, "dst_mask");
9251 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9252 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9254 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9255 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9257 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9261 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9264 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9267 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9269 mode_value, "MAC-VLAN");
9270 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9272 mode_value, "Tunnel");
9273 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9276 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9278 mac_addr_byte_mask, UINT8);
9279 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9281 tunnel_type, "tunnel-type");
9282 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9284 tunnel_type_mask, UINT8);
9285 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9287 tunnel_id, "tunnel-id");
9288 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9290 tunnel_id_mask, UINT32);
9292 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9293 .f = cmd_flow_director_mask_parsed,
9295 .help_str = "flow_director_mask ... : "
9296 "Set IP mode flow director's mask on NIC",
9298 (void *)&cmd_flow_director_mask,
9299 (void *)&cmd_flow_director_mask_port_id,
9300 (void *)&cmd_flow_director_mask_mode,
9301 (void *)&cmd_flow_director_mask_mode_ip,
9302 (void *)&cmd_flow_director_mask_vlan,
9303 (void *)&cmd_flow_director_mask_vlan_value,
9304 (void *)&cmd_flow_director_mask_src,
9305 (void *)&cmd_flow_director_mask_ipv4_src,
9306 (void *)&cmd_flow_director_mask_ipv6_src,
9307 (void *)&cmd_flow_director_mask_port_src,
9308 (void *)&cmd_flow_director_mask_dst,
9309 (void *)&cmd_flow_director_mask_ipv4_dst,
9310 (void *)&cmd_flow_director_mask_ipv6_dst,
9311 (void *)&cmd_flow_director_mask_port_dst,
9316 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9317 .f = cmd_flow_director_mask_parsed,
9319 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9320 "flow director's mask on NIC",
9322 (void *)&cmd_flow_director_mask,
9323 (void *)&cmd_flow_director_mask_port_id,
9324 (void *)&cmd_flow_director_mask_mode,
9325 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9326 (void *)&cmd_flow_director_mask_vlan,
9327 (void *)&cmd_flow_director_mask_vlan_value,
9332 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9333 .f = cmd_flow_director_mask_parsed,
9335 .help_str = "flow_director_mask ... : Set tunnel mode "
9336 "flow director's mask on NIC",
9338 (void *)&cmd_flow_director_mask,
9339 (void *)&cmd_flow_director_mask_port_id,
9340 (void *)&cmd_flow_director_mask_mode,
9341 (void *)&cmd_flow_director_mask_mode_tunnel,
9342 (void *)&cmd_flow_director_mask_vlan,
9343 (void *)&cmd_flow_director_mask_vlan_value,
9344 (void *)&cmd_flow_director_mask_mac,
9345 (void *)&cmd_flow_director_mask_mac_value,
9346 (void *)&cmd_flow_director_mask_tunnel_type,
9347 (void *)&cmd_flow_director_mask_tunnel_type_value,
9348 (void *)&cmd_flow_director_mask_tunnel_id,
9349 (void *)&cmd_flow_director_mask_tunnel_id_value,
9354 /* *** deal with flow director mask on flexible payload *** */
9355 struct cmd_flow_director_flex_mask_result {
9356 cmdline_fixed_string_t flow_director_flexmask;
9358 cmdline_fixed_string_t flow;
9359 cmdline_fixed_string_t flow_type;
9360 cmdline_fixed_string_t mask;
9364 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9365 __attribute__((unused)) struct cmdline *cl,
9366 __attribute__((unused)) void *data)
9368 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9369 struct rte_eth_fdir_info fdir_info;
9370 struct rte_eth_fdir_flex_mask flex_mask;
9371 struct rte_port *port;
9372 uint32_t flow_type_mask;
9376 if (res->port_id > nb_ports) {
9377 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9381 port = &ports[res->port_id];
9382 /** Check if the port is not started **/
9383 if (port->port_status != RTE_PORT_STOPPED) {
9384 printf("Please stop port %d first\n", res->port_id);
9388 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9389 ret = parse_flexbytes(res->mask,
9391 RTE_ETH_FDIR_MAX_FLEXLEN);
9393 printf("error: Cannot parse mask input.\n");
9397 memset(&fdir_info, 0, sizeof(fdir_info));
9398 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9399 RTE_ETH_FILTER_INFO, &fdir_info);
9401 printf("Cannot get FDir filter info\n");
9405 if (!strcmp(res->flow_type, "none")) {
9406 /* means don't specify the flow type */
9407 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9408 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9409 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9410 0, sizeof(struct rte_eth_fdir_flex_mask));
9411 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9412 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9414 sizeof(struct rte_eth_fdir_flex_mask));
9415 cmd_reconfig_device_queue(res->port_id, 1, 1);
9418 flow_type_mask = fdir_info.flow_types_mask[0];
9419 if (!strcmp(res->flow_type, "all")) {
9420 if (!flow_type_mask) {
9421 printf("No flow type supported\n");
9424 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9425 if (flow_type_mask & (1 << i)) {
9426 flex_mask.flow_type = i;
9427 fdir_set_flex_mask(res->port_id, &flex_mask);
9430 cmd_reconfig_device_queue(res->port_id, 1, 1);
9433 flex_mask.flow_type = str2flowtype(res->flow_type);
9434 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9435 printf("Flow type %s not supported on port %d\n",
9436 res->flow_type, res->port_id);
9439 fdir_set_flex_mask(res->port_id, &flex_mask);
9440 cmd_reconfig_device_queue(res->port_id, 1, 1);
9443 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9445 flow_director_flexmask,
9446 "flow_director_flex_mask");
9447 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9448 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9450 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9453 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9455 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9456 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9457 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9458 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9461 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9462 .f = cmd_flow_director_flex_mask_parsed,
9464 .help_str = "flow_director_flex_mask ... : "
9465 "Set flow director's flex mask on NIC",
9467 (void *)&cmd_flow_director_flexmask,
9468 (void *)&cmd_flow_director_flexmask_port_id,
9469 (void *)&cmd_flow_director_flexmask_flow,
9470 (void *)&cmd_flow_director_flexmask_flow_type,
9471 (void *)&cmd_flow_director_flexmask_mask,
9476 /* *** deal with flow director flexible payload configuration *** */
9477 struct cmd_flow_director_flexpayload_result {
9478 cmdline_fixed_string_t flow_director_flexpayload;
9480 cmdline_fixed_string_t payload_layer;
9481 cmdline_fixed_string_t payload_cfg;
9485 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9488 const char *p, *p0 = q_arg;
9490 unsigned long int_fld;
9491 char *str_fld[max_num];
9496 p = strchr(p0, '(');
9500 p0 = strchr(p, ')');
9505 if (size >= sizeof(s))
9508 snprintf(s, sizeof(s), "%.*s", size, p);
9509 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9510 if (ret < 0 || ret > max_num)
9512 for (i = 0; i < ret; i++) {
9514 int_fld = strtoul(str_fld[i], &end, 0);
9515 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9517 offsets[i] = (uint16_t)int_fld;
9523 cmd_flow_director_flxpld_parsed(void *parsed_result,
9524 __attribute__((unused)) struct cmdline *cl,
9525 __attribute__((unused)) void *data)
9527 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9528 struct rte_eth_flex_payload_cfg flex_cfg;
9529 struct rte_port *port;
9532 if (res->port_id > nb_ports) {
9533 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9537 port = &ports[res->port_id];
9538 /** Check if the port is not started **/
9539 if (port->port_status != RTE_PORT_STOPPED) {
9540 printf("Please stop port %d first\n", res->port_id);
9544 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9546 if (!strcmp(res->payload_layer, "raw"))
9547 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9548 else if (!strcmp(res->payload_layer, "l2"))
9549 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9550 else if (!strcmp(res->payload_layer, "l3"))
9551 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9552 else if (!strcmp(res->payload_layer, "l4"))
9553 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9555 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9556 RTE_ETH_FDIR_MAX_FLEXLEN);
9558 printf("error: Cannot parse flex payload input.\n");
9562 fdir_set_flex_payload(res->port_id, &flex_cfg);
9563 cmd_reconfig_device_queue(res->port_id, 1, 1);
9566 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9567 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9568 flow_director_flexpayload,
9569 "flow_director_flex_payload");
9570 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9571 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9573 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9575 payload_layer, "raw#l2#l3#l4");
9576 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9580 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9581 .f = cmd_flow_director_flxpld_parsed,
9583 .help_str = "flow_director_flexpayload ... : "
9584 "Set flow director's flex payload on NIC",
9586 (void *)&cmd_flow_director_flexpayload,
9587 (void *)&cmd_flow_director_flexpayload_port_id,
9588 (void *)&cmd_flow_director_flexpayload_payload_layer,
9589 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9594 /* Generic flow interface command. */
9595 extern cmdline_parse_inst_t cmd_flow;
9597 /* *** Classification Filters Control *** */
9598 /* *** Get symmetric hash enable per port *** */
9599 struct cmd_get_sym_hash_ena_per_port_result {
9600 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9605 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9606 __rte_unused struct cmdline *cl,
9607 __rte_unused void *data)
9609 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9610 struct rte_eth_hash_filter_info info;
9613 if (rte_eth_dev_filter_supported(res->port_id,
9614 RTE_ETH_FILTER_HASH) < 0) {
9615 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9620 memset(&info, 0, sizeof(info));
9621 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9622 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9623 RTE_ETH_FILTER_GET, &info);
9626 printf("Cannot get symmetric hash enable per port "
9627 "on port %u\n", res->port_id);
9631 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9632 "enabled" : "disabled", res->port_id);
9635 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9636 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9637 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9638 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9639 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9642 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9643 .f = cmd_get_sym_hash_per_port_parsed,
9645 .help_str = "get_sym_hash_ena_per_port <port_id>",
9647 (void *)&cmd_get_sym_hash_ena_per_port_all,
9648 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9653 /* *** Set symmetric hash enable per port *** */
9654 struct cmd_set_sym_hash_ena_per_port_result {
9655 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9656 cmdline_fixed_string_t enable;
9661 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9662 __rte_unused struct cmdline *cl,
9663 __rte_unused void *data)
9665 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9666 struct rte_eth_hash_filter_info info;
9669 if (rte_eth_dev_filter_supported(res->port_id,
9670 RTE_ETH_FILTER_HASH) < 0) {
9671 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9676 memset(&info, 0, sizeof(info));
9677 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9678 if (!strcmp(res->enable, "enable"))
9679 info.info.enable = 1;
9680 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9681 RTE_ETH_FILTER_SET, &info);
9683 printf("Cannot set symmetric hash enable per port on "
9684 "port %u\n", res->port_id);
9687 printf("Symmetric hash has been set to %s on port %u\n",
9688 res->enable, res->port_id);
9691 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9692 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9693 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9694 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9695 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9697 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9698 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9699 enable, "enable#disable");
9701 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9702 .f = cmd_set_sym_hash_per_port_parsed,
9704 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9706 (void *)&cmd_set_sym_hash_ena_per_port_all,
9707 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9708 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9713 /* Get global config of hash function */
9714 struct cmd_get_hash_global_config_result {
9715 cmdline_fixed_string_t get_hash_global_config;
9720 flowtype_to_str(uint16_t ftype)
9727 {"ipv4", RTE_ETH_FLOW_IPV4},
9728 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9729 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9730 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9731 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9732 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9733 {"ipv6", RTE_ETH_FLOW_IPV6},
9734 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9735 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9736 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9737 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9738 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9739 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9740 {"port", RTE_ETH_FLOW_PORT},
9741 {"vxlan", RTE_ETH_FLOW_VXLAN},
9742 {"geneve", RTE_ETH_FLOW_GENEVE},
9743 {"nvgre", RTE_ETH_FLOW_NVGRE},
9746 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9747 if (ftype_table[i].ftype == ftype)
9748 return ftype_table[i].str;
9755 cmd_get_hash_global_config_parsed(void *parsed_result,
9756 __rte_unused struct cmdline *cl,
9757 __rte_unused void *data)
9759 struct cmd_get_hash_global_config_result *res = parsed_result;
9760 struct rte_eth_hash_filter_info info;
9761 uint32_t idx, offset;
9766 if (rte_eth_dev_filter_supported(res->port_id,
9767 RTE_ETH_FILTER_HASH) < 0) {
9768 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9773 memset(&info, 0, sizeof(info));
9774 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9775 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9776 RTE_ETH_FILTER_GET, &info);
9778 printf("Cannot get hash global configurations by port %d\n",
9783 switch (info.info.global_conf.hash_func) {
9784 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9785 printf("Hash function is Toeplitz\n");
9787 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9788 printf("Hash function is Simple XOR\n");
9791 printf("Unknown hash function\n");
9795 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9796 idx = i / UINT32_BIT;
9797 offset = i % UINT32_BIT;
9798 if (!(info.info.global_conf.valid_bit_mask[idx] &
9801 str = flowtype_to_str(i);
9804 printf("Symmetric hash is %s globally for flow type %s "
9806 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9807 (1UL << offset)) ? "enabled" : "disabled"), str,
9812 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9813 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9814 get_hash_global_config, "get_hash_global_config");
9815 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9816 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9819 cmdline_parse_inst_t cmd_get_hash_global_config = {
9820 .f = cmd_get_hash_global_config_parsed,
9822 .help_str = "get_hash_global_config <port_id>",
9824 (void *)&cmd_get_hash_global_config_all,
9825 (void *)&cmd_get_hash_global_config_port_id,
9830 /* Set global config of hash function */
9831 struct cmd_set_hash_global_config_result {
9832 cmdline_fixed_string_t set_hash_global_config;
9834 cmdline_fixed_string_t hash_func;
9835 cmdline_fixed_string_t flow_type;
9836 cmdline_fixed_string_t enable;
9840 cmd_set_hash_global_config_parsed(void *parsed_result,
9841 __rte_unused struct cmdline *cl,
9842 __rte_unused void *data)
9844 struct cmd_set_hash_global_config_result *res = parsed_result;
9845 struct rte_eth_hash_filter_info info;
9846 uint32_t ftype, idx, offset;
9849 if (rte_eth_dev_filter_supported(res->port_id,
9850 RTE_ETH_FILTER_HASH) < 0) {
9851 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9855 memset(&info, 0, sizeof(info));
9856 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9857 if (!strcmp(res->hash_func, "toeplitz"))
9858 info.info.global_conf.hash_func =
9859 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9860 else if (!strcmp(res->hash_func, "simple_xor"))
9861 info.info.global_conf.hash_func =
9862 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9863 else if (!strcmp(res->hash_func, "default"))
9864 info.info.global_conf.hash_func =
9865 RTE_ETH_HASH_FUNCTION_DEFAULT;
9867 ftype = str2flowtype(res->flow_type);
9868 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9869 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9870 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9871 if (!strcmp(res->enable, "enable"))
9872 info.info.global_conf.sym_hash_enable_mask[idx] |=
9874 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9875 RTE_ETH_FILTER_SET, &info);
9877 printf("Cannot set global hash configurations by port %d\n",
9880 printf("Global hash configurations have been set "
9881 "succcessfully by port %d\n", res->port_id);
9884 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9885 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9886 set_hash_global_config, "set_hash_global_config");
9887 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9888 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9890 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9891 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9892 hash_func, "toeplitz#simple_xor#default");
9893 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9894 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9896 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9897 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9898 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9899 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9900 enable, "enable#disable");
9902 cmdline_parse_inst_t cmd_set_hash_global_config = {
9903 .f = cmd_set_hash_global_config_parsed,
9905 .help_str = "set_hash_global_config <port_id> "
9906 "toeplitz|simple_xor|default "
9907 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9908 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9909 "l2_payload enable|disable",
9911 (void *)&cmd_set_hash_global_config_all,
9912 (void *)&cmd_set_hash_global_config_port_id,
9913 (void *)&cmd_set_hash_global_config_hash_func,
9914 (void *)&cmd_set_hash_global_config_flow_type,
9915 (void *)&cmd_set_hash_global_config_enable,
9920 /* Set hash input set */
9921 struct cmd_set_hash_input_set_result {
9922 cmdline_fixed_string_t set_hash_input_set;
9924 cmdline_fixed_string_t flow_type;
9925 cmdline_fixed_string_t inset_field;
9926 cmdline_fixed_string_t select;
9929 static enum rte_eth_input_set_field
9930 str2inset(char *string)
9934 static const struct {
9936 enum rte_eth_input_set_field inset;
9938 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9939 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9940 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9941 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9942 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9943 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9944 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9945 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9946 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9947 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9948 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9949 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9950 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9951 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9952 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9953 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9954 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9955 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9956 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9957 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9958 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9959 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9960 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9961 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9962 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9963 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9964 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9965 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9966 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9967 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9968 {"none", RTE_ETH_INPUT_SET_NONE},
9971 for (i = 0; i < RTE_DIM(inset_table); i++) {
9972 if (!strcmp(string, inset_table[i].str))
9973 return inset_table[i].inset;
9976 return RTE_ETH_INPUT_SET_UNKNOWN;
9980 cmd_set_hash_input_set_parsed(void *parsed_result,
9981 __rte_unused struct cmdline *cl,
9982 __rte_unused void *data)
9984 struct cmd_set_hash_input_set_result *res = parsed_result;
9985 struct rte_eth_hash_filter_info info;
9987 memset(&info, 0, sizeof(info));
9988 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9989 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9990 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9991 info.info.input_set_conf.inset_size = 1;
9992 if (!strcmp(res->select, "select"))
9993 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9994 else if (!strcmp(res->select, "add"))
9995 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9996 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9997 RTE_ETH_FILTER_SET, &info);
10000 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10001 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10002 set_hash_input_set, "set_hash_input_set");
10003 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10004 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10006 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10007 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10009 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10010 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10011 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10012 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10014 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10015 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10016 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10017 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10018 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10020 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10021 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10022 select, "select#add");
10024 cmdline_parse_inst_t cmd_set_hash_input_set = {
10025 .f = cmd_set_hash_input_set_parsed,
10027 .help_str = "set_hash_input_set <port_id> "
10028 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10029 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10030 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10031 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10032 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10033 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10034 "fld-7th|fld-8th|none select|add",
10036 (void *)&cmd_set_hash_input_set_cmd,
10037 (void *)&cmd_set_hash_input_set_port_id,
10038 (void *)&cmd_set_hash_input_set_flow_type,
10039 (void *)&cmd_set_hash_input_set_field,
10040 (void *)&cmd_set_hash_input_set_select,
10045 /* Set flow director input set */
10046 struct cmd_set_fdir_input_set_result {
10047 cmdline_fixed_string_t set_fdir_input_set;
10049 cmdline_fixed_string_t flow_type;
10050 cmdline_fixed_string_t inset_field;
10051 cmdline_fixed_string_t select;
10055 cmd_set_fdir_input_set_parsed(void *parsed_result,
10056 __rte_unused struct cmdline *cl,
10057 __rte_unused void *data)
10059 struct cmd_set_fdir_input_set_result *res = parsed_result;
10060 struct rte_eth_fdir_filter_info info;
10062 memset(&info, 0, sizeof(info));
10063 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10064 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10065 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10066 info.info.input_set_conf.inset_size = 1;
10067 if (!strcmp(res->select, "select"))
10068 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10069 else if (!strcmp(res->select, "add"))
10070 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10071 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10072 RTE_ETH_FILTER_SET, &info);
10075 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10076 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10077 set_fdir_input_set, "set_fdir_input_set");
10078 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10079 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10081 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10082 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10084 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10085 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10086 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10087 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10089 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10090 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10091 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10092 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10093 "sctp-veri-tag#none");
10094 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10095 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10096 select, "select#add");
10098 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10099 .f = cmd_set_fdir_input_set_parsed,
10101 .help_str = "set_fdir_input_set <port_id> "
10102 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10103 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10104 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10105 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10106 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10107 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10108 "sctp-veri-tag|none select|add",
10110 (void *)&cmd_set_fdir_input_set_cmd,
10111 (void *)&cmd_set_fdir_input_set_port_id,
10112 (void *)&cmd_set_fdir_input_set_flow_type,
10113 (void *)&cmd_set_fdir_input_set_field,
10114 (void *)&cmd_set_fdir_input_set_select,
10119 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10120 struct cmd_mcast_addr_result {
10121 cmdline_fixed_string_t mcast_addr_cmd;
10122 cmdline_fixed_string_t what;
10124 struct ether_addr mc_addr;
10127 static void cmd_mcast_addr_parsed(void *parsed_result,
10128 __attribute__((unused)) struct cmdline *cl,
10129 __attribute__((unused)) void *data)
10131 struct cmd_mcast_addr_result *res = parsed_result;
10133 if (!is_multicast_ether_addr(&res->mc_addr)) {
10134 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10135 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10136 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10137 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10140 if (strcmp(res->what, "add") == 0)
10141 mcast_addr_add(res->port_num, &res->mc_addr);
10143 mcast_addr_remove(res->port_num, &res->mc_addr);
10146 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10147 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10148 mcast_addr_cmd, "mcast_addr");
10149 cmdline_parse_token_string_t cmd_mcast_addr_what =
10150 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10152 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10153 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10154 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10157 cmdline_parse_inst_t cmd_mcast_addr = {
10158 .f = cmd_mcast_addr_parsed,
10160 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10161 "Add/Remove multicast MAC address on port_id",
10163 (void *)&cmd_mcast_addr_cmd,
10164 (void *)&cmd_mcast_addr_what,
10165 (void *)&cmd_mcast_addr_portnum,
10166 (void *)&cmd_mcast_addr_addr,
10171 /* l2 tunnel config
10172 * only support E-tag now.
10175 /* Ether type config */
10176 struct cmd_config_l2_tunnel_eth_type_result {
10177 cmdline_fixed_string_t port;
10178 cmdline_fixed_string_t config;
10179 cmdline_fixed_string_t all;
10181 cmdline_fixed_string_t l2_tunnel;
10182 cmdline_fixed_string_t l2_tunnel_type;
10183 cmdline_fixed_string_t eth_type;
10184 uint16_t eth_type_val;
10187 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10188 TOKEN_STRING_INITIALIZER
10189 (struct cmd_config_l2_tunnel_eth_type_result,
10191 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10192 TOKEN_STRING_INITIALIZER
10193 (struct cmd_config_l2_tunnel_eth_type_result,
10195 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10196 TOKEN_STRING_INITIALIZER
10197 (struct cmd_config_l2_tunnel_eth_type_result,
10199 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10200 TOKEN_NUM_INITIALIZER
10201 (struct cmd_config_l2_tunnel_eth_type_result,
10203 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10204 TOKEN_STRING_INITIALIZER
10205 (struct cmd_config_l2_tunnel_eth_type_result,
10206 l2_tunnel, "l2-tunnel");
10207 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10208 TOKEN_STRING_INITIALIZER
10209 (struct cmd_config_l2_tunnel_eth_type_result,
10210 l2_tunnel_type, "E-tag");
10211 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10212 TOKEN_STRING_INITIALIZER
10213 (struct cmd_config_l2_tunnel_eth_type_result,
10214 eth_type, "ether-type");
10215 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10216 TOKEN_NUM_INITIALIZER
10217 (struct cmd_config_l2_tunnel_eth_type_result,
10218 eth_type_val, UINT16);
10220 static enum rte_eth_tunnel_type
10221 str2fdir_l2_tunnel_type(char *string)
10225 static const struct {
10227 enum rte_eth_tunnel_type type;
10228 } l2_tunnel_type_str[] = {
10229 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10232 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10233 if (!strcmp(l2_tunnel_type_str[i].str, string))
10234 return l2_tunnel_type_str[i].type;
10236 return RTE_TUNNEL_TYPE_NONE;
10239 /* ether type config for all ports */
10241 cmd_config_l2_tunnel_eth_type_all_parsed
10242 (void *parsed_result,
10243 __attribute__((unused)) struct cmdline *cl,
10244 __attribute__((unused)) void *data)
10246 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10247 struct rte_eth_l2_tunnel_conf entry;
10250 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10251 entry.ether_type = res->eth_type_val;
10253 FOREACH_PORT(pid, ports) {
10254 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10258 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10259 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10261 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10263 (void *)&cmd_config_l2_tunnel_eth_type_port,
10264 (void *)&cmd_config_l2_tunnel_eth_type_config,
10265 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10266 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10267 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10268 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10269 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10274 /* ether type config for a specific port */
10276 cmd_config_l2_tunnel_eth_type_specific_parsed(
10277 void *parsed_result,
10278 __attribute__((unused)) struct cmdline *cl,
10279 __attribute__((unused)) void *data)
10281 struct cmd_config_l2_tunnel_eth_type_result *res =
10283 struct rte_eth_l2_tunnel_conf entry;
10285 if (port_id_is_invalid(res->id, ENABLED_WARN))
10288 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10289 entry.ether_type = res->eth_type_val;
10291 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10294 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10295 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10297 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10299 (void *)&cmd_config_l2_tunnel_eth_type_port,
10300 (void *)&cmd_config_l2_tunnel_eth_type_config,
10301 (void *)&cmd_config_l2_tunnel_eth_type_id,
10302 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10303 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10304 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10305 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10310 /* Enable/disable l2 tunnel */
10311 struct cmd_config_l2_tunnel_en_dis_result {
10312 cmdline_fixed_string_t port;
10313 cmdline_fixed_string_t config;
10314 cmdline_fixed_string_t all;
10316 cmdline_fixed_string_t l2_tunnel;
10317 cmdline_fixed_string_t l2_tunnel_type;
10318 cmdline_fixed_string_t en_dis;
10321 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10322 TOKEN_STRING_INITIALIZER
10323 (struct cmd_config_l2_tunnel_en_dis_result,
10325 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10326 TOKEN_STRING_INITIALIZER
10327 (struct cmd_config_l2_tunnel_en_dis_result,
10329 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10330 TOKEN_STRING_INITIALIZER
10331 (struct cmd_config_l2_tunnel_en_dis_result,
10333 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10334 TOKEN_NUM_INITIALIZER
10335 (struct cmd_config_l2_tunnel_en_dis_result,
10337 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10338 TOKEN_STRING_INITIALIZER
10339 (struct cmd_config_l2_tunnel_en_dis_result,
10340 l2_tunnel, "l2-tunnel");
10341 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10342 TOKEN_STRING_INITIALIZER
10343 (struct cmd_config_l2_tunnel_en_dis_result,
10344 l2_tunnel_type, "E-tag");
10345 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10346 TOKEN_STRING_INITIALIZER
10347 (struct cmd_config_l2_tunnel_en_dis_result,
10348 en_dis, "enable#disable");
10350 /* enable/disable l2 tunnel for all ports */
10352 cmd_config_l2_tunnel_en_dis_all_parsed(
10353 void *parsed_result,
10354 __attribute__((unused)) struct cmdline *cl,
10355 __attribute__((unused)) void *data)
10357 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10358 struct rte_eth_l2_tunnel_conf entry;
10362 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10364 if (!strcmp("enable", res->en_dis))
10369 FOREACH_PORT(pid, ports) {
10370 rte_eth_dev_l2_tunnel_offload_set(pid,
10372 ETH_L2_TUNNEL_ENABLE_MASK,
10377 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10378 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10380 .help_str = "port config all l2-tunnel E-tag enable|disable",
10382 (void *)&cmd_config_l2_tunnel_en_dis_port,
10383 (void *)&cmd_config_l2_tunnel_en_dis_config,
10384 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10385 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10386 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10387 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10392 /* enable/disable l2 tunnel for a port */
10394 cmd_config_l2_tunnel_en_dis_specific_parsed(
10395 void *parsed_result,
10396 __attribute__((unused)) struct cmdline *cl,
10397 __attribute__((unused)) void *data)
10399 struct cmd_config_l2_tunnel_en_dis_result *res =
10401 struct rte_eth_l2_tunnel_conf entry;
10403 if (port_id_is_invalid(res->id, ENABLED_WARN))
10406 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10408 if (!strcmp("enable", res->en_dis))
10409 rte_eth_dev_l2_tunnel_offload_set(res->id,
10411 ETH_L2_TUNNEL_ENABLE_MASK,
10414 rte_eth_dev_l2_tunnel_offload_set(res->id,
10416 ETH_L2_TUNNEL_ENABLE_MASK,
10420 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10421 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10423 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10425 (void *)&cmd_config_l2_tunnel_en_dis_port,
10426 (void *)&cmd_config_l2_tunnel_en_dis_config,
10427 (void *)&cmd_config_l2_tunnel_en_dis_id,
10428 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10429 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10430 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10435 /* E-tag configuration */
10437 /* Common result structure for all E-tag configuration */
10438 struct cmd_config_e_tag_result {
10439 cmdline_fixed_string_t e_tag;
10440 cmdline_fixed_string_t set;
10441 cmdline_fixed_string_t insertion;
10442 cmdline_fixed_string_t stripping;
10443 cmdline_fixed_string_t forwarding;
10444 cmdline_fixed_string_t filter;
10445 cmdline_fixed_string_t add;
10446 cmdline_fixed_string_t del;
10447 cmdline_fixed_string_t on;
10448 cmdline_fixed_string_t off;
10449 cmdline_fixed_string_t on_off;
10450 cmdline_fixed_string_t port_tag_id;
10451 uint32_t port_tag_id_val;
10452 cmdline_fixed_string_t e_tag_id;
10453 uint16_t e_tag_id_val;
10454 cmdline_fixed_string_t dst_pool;
10455 uint8_t dst_pool_val;
10456 cmdline_fixed_string_t port;
10458 cmdline_fixed_string_t vf;
10462 /* Common CLI fields for all E-tag configuration */
10463 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10464 TOKEN_STRING_INITIALIZER
10465 (struct cmd_config_e_tag_result,
10467 cmdline_parse_token_string_t cmd_config_e_tag_set =
10468 TOKEN_STRING_INITIALIZER
10469 (struct cmd_config_e_tag_result,
10471 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10472 TOKEN_STRING_INITIALIZER
10473 (struct cmd_config_e_tag_result,
10474 insertion, "insertion");
10475 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10476 TOKEN_STRING_INITIALIZER
10477 (struct cmd_config_e_tag_result,
10478 stripping, "stripping");
10479 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10480 TOKEN_STRING_INITIALIZER
10481 (struct cmd_config_e_tag_result,
10482 forwarding, "forwarding");
10483 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10484 TOKEN_STRING_INITIALIZER
10485 (struct cmd_config_e_tag_result,
10487 cmdline_parse_token_string_t cmd_config_e_tag_add =
10488 TOKEN_STRING_INITIALIZER
10489 (struct cmd_config_e_tag_result,
10491 cmdline_parse_token_string_t cmd_config_e_tag_del =
10492 TOKEN_STRING_INITIALIZER
10493 (struct cmd_config_e_tag_result,
10495 cmdline_parse_token_string_t cmd_config_e_tag_on =
10496 TOKEN_STRING_INITIALIZER
10497 (struct cmd_config_e_tag_result,
10499 cmdline_parse_token_string_t cmd_config_e_tag_off =
10500 TOKEN_STRING_INITIALIZER
10501 (struct cmd_config_e_tag_result,
10503 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10504 TOKEN_STRING_INITIALIZER
10505 (struct cmd_config_e_tag_result,
10507 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10508 TOKEN_STRING_INITIALIZER
10509 (struct cmd_config_e_tag_result,
10510 port_tag_id, "port-tag-id");
10511 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10512 TOKEN_NUM_INITIALIZER
10513 (struct cmd_config_e_tag_result,
10514 port_tag_id_val, UINT32);
10515 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10516 TOKEN_STRING_INITIALIZER
10517 (struct cmd_config_e_tag_result,
10518 e_tag_id, "e-tag-id");
10519 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10520 TOKEN_NUM_INITIALIZER
10521 (struct cmd_config_e_tag_result,
10522 e_tag_id_val, UINT16);
10523 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10524 TOKEN_STRING_INITIALIZER
10525 (struct cmd_config_e_tag_result,
10526 dst_pool, "dst-pool");
10527 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10528 TOKEN_NUM_INITIALIZER
10529 (struct cmd_config_e_tag_result,
10530 dst_pool_val, UINT8);
10531 cmdline_parse_token_string_t cmd_config_e_tag_port =
10532 TOKEN_STRING_INITIALIZER
10533 (struct cmd_config_e_tag_result,
10535 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10536 TOKEN_NUM_INITIALIZER
10537 (struct cmd_config_e_tag_result,
10539 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10540 TOKEN_STRING_INITIALIZER
10541 (struct cmd_config_e_tag_result,
10543 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10544 TOKEN_NUM_INITIALIZER
10545 (struct cmd_config_e_tag_result,
10548 /* E-tag insertion configuration */
10550 cmd_config_e_tag_insertion_en_parsed(
10551 void *parsed_result,
10552 __attribute__((unused)) struct cmdline *cl,
10553 __attribute__((unused)) void *data)
10555 struct cmd_config_e_tag_result *res =
10557 struct rte_eth_l2_tunnel_conf entry;
10559 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10562 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10563 entry.tunnel_id = res->port_tag_id_val;
10564 entry.vf_id = res->vf_id;
10565 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10567 ETH_L2_TUNNEL_INSERTION_MASK,
10572 cmd_config_e_tag_insertion_dis_parsed(
10573 void *parsed_result,
10574 __attribute__((unused)) struct cmdline *cl,
10575 __attribute__((unused)) void *data)
10577 struct cmd_config_e_tag_result *res =
10579 struct rte_eth_l2_tunnel_conf entry;
10581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10584 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10585 entry.vf_id = res->vf_id;
10587 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10589 ETH_L2_TUNNEL_INSERTION_MASK,
10593 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10594 .f = cmd_config_e_tag_insertion_en_parsed,
10596 .help_str = "E-tag ... : E-tag insertion enable",
10598 (void *)&cmd_config_e_tag_e_tag,
10599 (void *)&cmd_config_e_tag_set,
10600 (void *)&cmd_config_e_tag_insertion,
10601 (void *)&cmd_config_e_tag_on,
10602 (void *)&cmd_config_e_tag_port_tag_id,
10603 (void *)&cmd_config_e_tag_port_tag_id_val,
10604 (void *)&cmd_config_e_tag_port,
10605 (void *)&cmd_config_e_tag_port_id,
10606 (void *)&cmd_config_e_tag_vf,
10607 (void *)&cmd_config_e_tag_vf_id,
10612 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10613 .f = cmd_config_e_tag_insertion_dis_parsed,
10615 .help_str = "E-tag ... : E-tag insertion disable",
10617 (void *)&cmd_config_e_tag_e_tag,
10618 (void *)&cmd_config_e_tag_set,
10619 (void *)&cmd_config_e_tag_insertion,
10620 (void *)&cmd_config_e_tag_off,
10621 (void *)&cmd_config_e_tag_port,
10622 (void *)&cmd_config_e_tag_port_id,
10623 (void *)&cmd_config_e_tag_vf,
10624 (void *)&cmd_config_e_tag_vf_id,
10629 /* E-tag stripping configuration */
10631 cmd_config_e_tag_stripping_parsed(
10632 void *parsed_result,
10633 __attribute__((unused)) struct cmdline *cl,
10634 __attribute__((unused)) void *data)
10636 struct cmd_config_e_tag_result *res =
10638 struct rte_eth_l2_tunnel_conf entry;
10640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10643 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10645 if (!strcmp(res->on_off, "on"))
10646 rte_eth_dev_l2_tunnel_offload_set
10649 ETH_L2_TUNNEL_STRIPPING_MASK,
10652 rte_eth_dev_l2_tunnel_offload_set
10655 ETH_L2_TUNNEL_STRIPPING_MASK,
10659 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10660 .f = cmd_config_e_tag_stripping_parsed,
10662 .help_str = "E-tag ... : E-tag stripping enable/disable",
10664 (void *)&cmd_config_e_tag_e_tag,
10665 (void *)&cmd_config_e_tag_set,
10666 (void *)&cmd_config_e_tag_stripping,
10667 (void *)&cmd_config_e_tag_on_off,
10668 (void *)&cmd_config_e_tag_port,
10669 (void *)&cmd_config_e_tag_port_id,
10674 /* E-tag forwarding configuration */
10676 cmd_config_e_tag_forwarding_parsed(
10677 void *parsed_result,
10678 __attribute__((unused)) struct cmdline *cl,
10679 __attribute__((unused)) void *data)
10681 struct cmd_config_e_tag_result *res = parsed_result;
10682 struct rte_eth_l2_tunnel_conf entry;
10684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10687 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10689 if (!strcmp(res->on_off, "on"))
10690 rte_eth_dev_l2_tunnel_offload_set
10693 ETH_L2_TUNNEL_FORWARDING_MASK,
10696 rte_eth_dev_l2_tunnel_offload_set
10699 ETH_L2_TUNNEL_FORWARDING_MASK,
10703 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10704 .f = cmd_config_e_tag_forwarding_parsed,
10706 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10708 (void *)&cmd_config_e_tag_e_tag,
10709 (void *)&cmd_config_e_tag_set,
10710 (void *)&cmd_config_e_tag_forwarding,
10711 (void *)&cmd_config_e_tag_on_off,
10712 (void *)&cmd_config_e_tag_port,
10713 (void *)&cmd_config_e_tag_port_id,
10718 /* E-tag filter configuration */
10720 cmd_config_e_tag_filter_add_parsed(
10721 void *parsed_result,
10722 __attribute__((unused)) struct cmdline *cl,
10723 __attribute__((unused)) void *data)
10725 struct cmd_config_e_tag_result *res = parsed_result;
10726 struct rte_eth_l2_tunnel_conf entry;
10729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10732 if (res->e_tag_id_val > 0x3fff) {
10733 printf("e-tag-id must be equal or less than 0x3fff.\n");
10737 ret = rte_eth_dev_filter_supported(res->port_id,
10738 RTE_ETH_FILTER_L2_TUNNEL);
10740 printf("E-tag filter is not supported on port %u.\n",
10745 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10746 entry.tunnel_id = res->e_tag_id_val;
10747 entry.pool = res->dst_pool_val;
10749 ret = rte_eth_dev_filter_ctrl(res->port_id,
10750 RTE_ETH_FILTER_L2_TUNNEL,
10751 RTE_ETH_FILTER_ADD,
10754 printf("E-tag filter programming error: (%s)\n",
10758 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10759 .f = cmd_config_e_tag_filter_add_parsed,
10761 .help_str = "E-tag ... : E-tag filter add",
10763 (void *)&cmd_config_e_tag_e_tag,
10764 (void *)&cmd_config_e_tag_set,
10765 (void *)&cmd_config_e_tag_filter,
10766 (void *)&cmd_config_e_tag_add,
10767 (void *)&cmd_config_e_tag_e_tag_id,
10768 (void *)&cmd_config_e_tag_e_tag_id_val,
10769 (void *)&cmd_config_e_tag_dst_pool,
10770 (void *)&cmd_config_e_tag_dst_pool_val,
10771 (void *)&cmd_config_e_tag_port,
10772 (void *)&cmd_config_e_tag_port_id,
10778 cmd_config_e_tag_filter_del_parsed(
10779 void *parsed_result,
10780 __attribute__((unused)) struct cmdline *cl,
10781 __attribute__((unused)) void *data)
10783 struct cmd_config_e_tag_result *res = parsed_result;
10784 struct rte_eth_l2_tunnel_conf entry;
10787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10790 if (res->e_tag_id_val > 0x3fff) {
10791 printf("e-tag-id must be less than 0x3fff.\n");
10795 ret = rte_eth_dev_filter_supported(res->port_id,
10796 RTE_ETH_FILTER_L2_TUNNEL);
10798 printf("E-tag filter is not supported on port %u.\n",
10803 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10804 entry.tunnel_id = res->e_tag_id_val;
10806 ret = rte_eth_dev_filter_ctrl(res->port_id,
10807 RTE_ETH_FILTER_L2_TUNNEL,
10808 RTE_ETH_FILTER_DELETE,
10811 printf("E-tag filter programming error: (%s)\n",
10815 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10816 .f = cmd_config_e_tag_filter_del_parsed,
10818 .help_str = "E-tag ... : E-tag filter delete",
10820 (void *)&cmd_config_e_tag_e_tag,
10821 (void *)&cmd_config_e_tag_set,
10822 (void *)&cmd_config_e_tag_filter,
10823 (void *)&cmd_config_e_tag_del,
10824 (void *)&cmd_config_e_tag_e_tag_id,
10825 (void *)&cmd_config_e_tag_e_tag_id_val,
10826 (void *)&cmd_config_e_tag_port,
10827 (void *)&cmd_config_e_tag_port_id,
10831 #ifdef RTE_LIBRTE_IXGBE_PMD
10833 /* vf vlan anti spoof configuration */
10835 /* Common result structure for vf vlan anti spoof */
10836 struct cmd_vf_vlan_anti_spoof_result {
10837 cmdline_fixed_string_t set;
10838 cmdline_fixed_string_t vf;
10839 cmdline_fixed_string_t vlan;
10840 cmdline_fixed_string_t antispoof;
10843 cmdline_fixed_string_t on_off;
10846 /* Common CLI fields for vf vlan anti spoof enable disable */
10847 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10848 TOKEN_STRING_INITIALIZER
10849 (struct cmd_vf_vlan_anti_spoof_result,
10851 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10852 TOKEN_STRING_INITIALIZER
10853 (struct cmd_vf_vlan_anti_spoof_result,
10855 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10856 TOKEN_STRING_INITIALIZER
10857 (struct cmd_vf_vlan_anti_spoof_result,
10859 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10860 TOKEN_STRING_INITIALIZER
10861 (struct cmd_vf_vlan_anti_spoof_result,
10862 antispoof, "antispoof");
10863 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10864 TOKEN_NUM_INITIALIZER
10865 (struct cmd_vf_vlan_anti_spoof_result,
10867 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10868 TOKEN_NUM_INITIALIZER
10869 (struct cmd_vf_vlan_anti_spoof_result,
10871 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10872 TOKEN_STRING_INITIALIZER
10873 (struct cmd_vf_vlan_anti_spoof_result,
10877 cmd_set_vf_vlan_anti_spoof_parsed(
10878 void *parsed_result,
10879 __attribute__((unused)) struct cmdline *cl,
10880 __attribute__((unused)) void *data)
10882 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10884 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10886 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id,
10892 printf("invalid vf_id %d\n", res->vf_id);
10895 printf("invalid port_id %d\n", res->port_id);
10898 printf("programming error: (%s)\n", strerror(-ret));
10902 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10903 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10905 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10907 (void *)&cmd_vf_vlan_anti_spoof_set,
10908 (void *)&cmd_vf_vlan_anti_spoof_vf,
10909 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10910 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10911 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10912 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10913 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10918 /* vf mac anti spoof configuration */
10920 /* Common result structure for vf mac anti spoof */
10921 struct cmd_vf_mac_anti_spoof_result {
10922 cmdline_fixed_string_t set;
10923 cmdline_fixed_string_t vf;
10924 cmdline_fixed_string_t mac;
10925 cmdline_fixed_string_t antispoof;
10928 cmdline_fixed_string_t on_off;
10931 /* Common CLI fields for vf mac anti spoof enable disable */
10932 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10933 TOKEN_STRING_INITIALIZER
10934 (struct cmd_vf_mac_anti_spoof_result,
10936 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10937 TOKEN_STRING_INITIALIZER
10938 (struct cmd_vf_mac_anti_spoof_result,
10940 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10941 TOKEN_STRING_INITIALIZER
10942 (struct cmd_vf_mac_anti_spoof_result,
10944 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10945 TOKEN_STRING_INITIALIZER
10946 (struct cmd_vf_mac_anti_spoof_result,
10947 antispoof, "antispoof");
10948 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10949 TOKEN_NUM_INITIALIZER
10950 (struct cmd_vf_mac_anti_spoof_result,
10952 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10953 TOKEN_NUM_INITIALIZER
10954 (struct cmd_vf_mac_anti_spoof_result,
10956 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10957 TOKEN_STRING_INITIALIZER
10958 (struct cmd_vf_mac_anti_spoof_result,
10962 cmd_set_vf_mac_anti_spoof_parsed(
10963 void *parsed_result,
10964 __attribute__((unused)) struct cmdline *cl,
10965 __attribute__((unused)) void *data)
10967 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10969 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10971 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id,
10977 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10980 printf("invalid port_id %d\n", res->port_id);
10983 printf("programming error: (%s)\n", strerror(-ret));
10987 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10988 .f = cmd_set_vf_mac_anti_spoof_parsed,
10990 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10992 (void *)&cmd_vf_mac_anti_spoof_set,
10993 (void *)&cmd_vf_mac_anti_spoof_vf,
10994 (void *)&cmd_vf_mac_anti_spoof_mac,
10995 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10996 (void *)&cmd_vf_mac_anti_spoof_port_id,
10997 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10998 (void *)&cmd_vf_mac_anti_spoof_on_off,
11003 /* vf vlan strip queue configuration */
11005 /* Common result structure for vf mac anti spoof */
11006 struct cmd_vf_vlan_stripq_result {
11007 cmdline_fixed_string_t set;
11008 cmdline_fixed_string_t vf;
11009 cmdline_fixed_string_t vlan;
11010 cmdline_fixed_string_t stripq;
11013 cmdline_fixed_string_t on_off;
11016 /* Common CLI fields for vf vlan strip enable disable */
11017 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11018 TOKEN_STRING_INITIALIZER
11019 (struct cmd_vf_vlan_stripq_result,
11021 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11022 TOKEN_STRING_INITIALIZER
11023 (struct cmd_vf_vlan_stripq_result,
11025 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_vf_vlan_stripq_result,
11029 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_vf_vlan_stripq_result,
11033 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11034 TOKEN_NUM_INITIALIZER
11035 (struct cmd_vf_vlan_stripq_result,
11037 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11038 TOKEN_NUM_INITIALIZER
11039 (struct cmd_vf_vlan_stripq_result,
11041 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11042 TOKEN_STRING_INITIALIZER
11043 (struct cmd_vf_vlan_stripq_result,
11047 cmd_set_vf_vlan_stripq_parsed(
11048 void *parsed_result,
11049 __attribute__((unused)) struct cmdline *cl,
11050 __attribute__((unused)) void *data)
11052 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11054 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11056 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
11061 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11064 printf("invalid port_id %d\n", res->port_id);
11067 printf("programming error: (%s)\n", strerror(-ret));
11071 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11072 .f = cmd_set_vf_vlan_stripq_parsed,
11074 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11076 (void *)&cmd_vf_vlan_stripq_set,
11077 (void *)&cmd_vf_vlan_stripq_vf,
11078 (void *)&cmd_vf_vlan_stripq_vlan,
11079 (void *)&cmd_vf_vlan_stripq_stripq,
11080 (void *)&cmd_vf_vlan_stripq_port_id,
11081 (void *)&cmd_vf_vlan_stripq_vf_id,
11082 (void *)&cmd_vf_vlan_stripq_on_off,
11087 /* vf vlan insert configuration */
11089 /* Common result structure for vf vlan insert */
11090 struct cmd_vf_vlan_insert_result {
11091 cmdline_fixed_string_t set;
11092 cmdline_fixed_string_t vf;
11093 cmdline_fixed_string_t vlan;
11094 cmdline_fixed_string_t insert;
11100 /* Common CLI fields for vf vlan insert enable disable */
11101 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11102 TOKEN_STRING_INITIALIZER
11103 (struct cmd_vf_vlan_insert_result,
11105 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11106 TOKEN_STRING_INITIALIZER
11107 (struct cmd_vf_vlan_insert_result,
11109 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11110 TOKEN_STRING_INITIALIZER
11111 (struct cmd_vf_vlan_insert_result,
11113 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11114 TOKEN_STRING_INITIALIZER
11115 (struct cmd_vf_vlan_insert_result,
11117 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11118 TOKEN_NUM_INITIALIZER
11119 (struct cmd_vf_vlan_insert_result,
11121 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11122 TOKEN_NUM_INITIALIZER
11123 (struct cmd_vf_vlan_insert_result,
11125 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11126 TOKEN_NUM_INITIALIZER
11127 (struct cmd_vf_vlan_insert_result,
11131 cmd_set_vf_vlan_insert_parsed(
11132 void *parsed_result,
11133 __attribute__((unused)) struct cmdline *cl,
11134 __attribute__((unused)) void *data)
11136 struct cmd_vf_vlan_insert_result *res = parsed_result;
11139 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, res->vlan_id);
11144 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11147 printf("invalid port_id %d\n", res->port_id);
11150 printf("programming error: (%s)\n", strerror(-ret));
11154 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11155 .f = cmd_set_vf_vlan_insert_parsed,
11157 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11159 (void *)&cmd_vf_vlan_insert_set,
11160 (void *)&cmd_vf_vlan_insert_vf,
11161 (void *)&cmd_vf_vlan_insert_vlan,
11162 (void *)&cmd_vf_vlan_insert_insert,
11163 (void *)&cmd_vf_vlan_insert_port_id,
11164 (void *)&cmd_vf_vlan_insert_vf_id,
11165 (void *)&cmd_vf_vlan_insert_vlan_id,
11170 /* tx loopback configuration */
11172 /* Common result structure for tx loopback */
11173 struct cmd_tx_loopback_result {
11174 cmdline_fixed_string_t set;
11175 cmdline_fixed_string_t tx;
11176 cmdline_fixed_string_t loopback;
11178 cmdline_fixed_string_t on_off;
11181 /* Common CLI fields for tx loopback enable disable */
11182 cmdline_parse_token_string_t cmd_tx_loopback_set =
11183 TOKEN_STRING_INITIALIZER
11184 (struct cmd_tx_loopback_result,
11186 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11187 TOKEN_STRING_INITIALIZER
11188 (struct cmd_tx_loopback_result,
11190 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11191 TOKEN_STRING_INITIALIZER
11192 (struct cmd_tx_loopback_result,
11193 loopback, "loopback");
11194 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11195 TOKEN_NUM_INITIALIZER
11196 (struct cmd_tx_loopback_result,
11198 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11199 TOKEN_STRING_INITIALIZER
11200 (struct cmd_tx_loopback_result,
11204 cmd_set_tx_loopback_parsed(
11205 void *parsed_result,
11206 __attribute__((unused)) struct cmdline *cl,
11207 __attribute__((unused)) void *data)
11209 struct cmd_tx_loopback_result *res = parsed_result;
11211 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11213 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11218 printf("invalid is_on %d\n", is_on);
11221 printf("invalid port_id %d\n", res->port_id);
11224 printf("programming error: (%s)\n", strerror(-ret));
11228 cmdline_parse_inst_t cmd_set_tx_loopback = {
11229 .f = cmd_set_tx_loopback_parsed,
11231 .help_str = "set tx loopback <port_id> on|off",
11233 (void *)&cmd_tx_loopback_set,
11234 (void *)&cmd_tx_loopback_tx,
11235 (void *)&cmd_tx_loopback_loopback,
11236 (void *)&cmd_tx_loopback_port_id,
11237 (void *)&cmd_tx_loopback_on_off,
11242 /* all queues drop enable configuration */
11244 /* Common result structure for all queues drop enable */
11245 struct cmd_all_queues_drop_en_result {
11246 cmdline_fixed_string_t set;
11247 cmdline_fixed_string_t all;
11248 cmdline_fixed_string_t queues;
11249 cmdline_fixed_string_t drop;
11251 cmdline_fixed_string_t on_off;
11254 /* Common CLI fields for tx loopback enable disable */
11255 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11256 TOKEN_STRING_INITIALIZER
11257 (struct cmd_all_queues_drop_en_result,
11259 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11260 TOKEN_STRING_INITIALIZER
11261 (struct cmd_all_queues_drop_en_result,
11263 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11264 TOKEN_STRING_INITIALIZER
11265 (struct cmd_all_queues_drop_en_result,
11267 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11268 TOKEN_STRING_INITIALIZER
11269 (struct cmd_all_queues_drop_en_result,
11271 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11272 TOKEN_NUM_INITIALIZER
11273 (struct cmd_all_queues_drop_en_result,
11275 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11276 TOKEN_STRING_INITIALIZER
11277 (struct cmd_all_queues_drop_en_result,
11281 cmd_set_all_queues_drop_en_parsed(
11282 void *parsed_result,
11283 __attribute__((unused)) struct cmdline *cl,
11284 __attribute__((unused)) void *data)
11286 struct cmd_all_queues_drop_en_result *res = parsed_result;
11288 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11290 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11295 printf("invalid is_on %d\n", is_on);
11298 printf("invalid port_id %d\n", res->port_id);
11301 printf("programming error: (%s)\n", strerror(-ret));
11305 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11306 .f = cmd_set_all_queues_drop_en_parsed,
11308 .help_str = "set all queues drop <port_id> on|off",
11310 (void *)&cmd_all_queues_drop_en_set,
11311 (void *)&cmd_all_queues_drop_en_all,
11312 (void *)&cmd_all_queues_drop_en_queues,
11313 (void *)&cmd_all_queues_drop_en_drop,
11314 (void *)&cmd_all_queues_drop_en_port_id,
11315 (void *)&cmd_all_queues_drop_en_on_off,
11320 /* vf split drop enable configuration */
11322 /* Common result structure for vf split drop enable */
11323 struct cmd_vf_split_drop_en_result {
11324 cmdline_fixed_string_t set;
11325 cmdline_fixed_string_t vf;
11326 cmdline_fixed_string_t split;
11327 cmdline_fixed_string_t drop;
11330 cmdline_fixed_string_t on_off;
11333 /* Common CLI fields for vf split drop enable disable */
11334 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11335 TOKEN_STRING_INITIALIZER
11336 (struct cmd_vf_split_drop_en_result,
11338 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11339 TOKEN_STRING_INITIALIZER
11340 (struct cmd_vf_split_drop_en_result,
11342 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11343 TOKEN_STRING_INITIALIZER
11344 (struct cmd_vf_split_drop_en_result,
11346 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11347 TOKEN_STRING_INITIALIZER
11348 (struct cmd_vf_split_drop_en_result,
11350 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11351 TOKEN_NUM_INITIALIZER
11352 (struct cmd_vf_split_drop_en_result,
11354 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11355 TOKEN_NUM_INITIALIZER
11356 (struct cmd_vf_split_drop_en_result,
11358 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11359 TOKEN_STRING_INITIALIZER
11360 (struct cmd_vf_split_drop_en_result,
11364 cmd_set_vf_split_drop_en_parsed(
11365 void *parsed_result,
11366 __attribute__((unused)) struct cmdline *cl,
11367 __attribute__((unused)) void *data)
11369 struct cmd_vf_split_drop_en_result *res = parsed_result;
11371 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11373 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11379 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11382 printf("invalid port_id %d\n", res->port_id);
11385 printf("programming error: (%s)\n", strerror(-ret));
11389 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11390 .f = cmd_set_vf_split_drop_en_parsed,
11392 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11394 (void *)&cmd_vf_split_drop_en_set,
11395 (void *)&cmd_vf_split_drop_en_vf,
11396 (void *)&cmd_vf_split_drop_en_split,
11397 (void *)&cmd_vf_split_drop_en_drop,
11398 (void *)&cmd_vf_split_drop_en_port_id,
11399 (void *)&cmd_vf_split_drop_en_vf_id,
11400 (void *)&cmd_vf_split_drop_en_on_off,
11405 /* vf mac address configuration */
11407 /* Common result structure for vf mac address */
11408 struct cmd_set_vf_mac_addr_result {
11409 cmdline_fixed_string_t set;
11410 cmdline_fixed_string_t vf;
11411 cmdline_fixed_string_t mac;
11412 cmdline_fixed_string_t addr;
11415 struct ether_addr mac_addr;
11419 /* Common CLI fields for vf split drop enable disable */
11420 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_set_vf_mac_addr_result,
11424 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_set_vf_mac_addr_result,
11428 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11429 TOKEN_STRING_INITIALIZER
11430 (struct cmd_set_vf_mac_addr_result,
11432 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11433 TOKEN_STRING_INITIALIZER
11434 (struct cmd_set_vf_mac_addr_result,
11436 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11437 TOKEN_NUM_INITIALIZER
11438 (struct cmd_set_vf_mac_addr_result,
11440 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11441 TOKEN_NUM_INITIALIZER
11442 (struct cmd_set_vf_mac_addr_result,
11444 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11449 cmd_set_vf_mac_addr_parsed(
11450 void *parsed_result,
11451 __attribute__((unused)) struct cmdline *cl,
11452 __attribute__((unused)) void *data)
11454 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11457 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11463 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11466 printf("invalid port_id %d\n", res->port_id);
11469 printf("programming error: (%s)\n", strerror(-ret));
11473 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11474 .f = cmd_set_vf_mac_addr_parsed,
11476 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11478 (void *)&cmd_set_vf_mac_addr_set,
11479 (void *)&cmd_set_vf_mac_addr_vf,
11480 (void *)&cmd_set_vf_mac_addr_mac,
11481 (void *)&cmd_set_vf_mac_addr_addr,
11482 (void *)&cmd_set_vf_mac_addr_port_id,
11483 (void *)&cmd_set_vf_mac_addr_vf_id,
11484 (void *)&cmd_set_vf_mac_addr_mac_addr,
11490 /* ******************************************************************************** */
11492 /* list of instructions */
11493 cmdline_parse_ctx_t main_ctx[] = {
11494 (cmdline_parse_inst_t *)&cmd_help_brief,
11495 (cmdline_parse_inst_t *)&cmd_help_long,
11496 (cmdline_parse_inst_t *)&cmd_quit,
11497 (cmdline_parse_inst_t *)&cmd_showport,
11498 (cmdline_parse_inst_t *)&cmd_showqueue,
11499 (cmdline_parse_inst_t *)&cmd_showportall,
11500 (cmdline_parse_inst_t *)&cmd_showcfg,
11501 (cmdline_parse_inst_t *)&cmd_start,
11502 (cmdline_parse_inst_t *)&cmd_start_tx_first,
11503 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
11504 (cmdline_parse_inst_t *)&cmd_set_link_up,
11505 (cmdline_parse_inst_t *)&cmd_set_link_down,
11506 (cmdline_parse_inst_t *)&cmd_reset,
11507 (cmdline_parse_inst_t *)&cmd_set_numbers,
11508 (cmdline_parse_inst_t *)&cmd_set_txpkts,
11509 (cmdline_parse_inst_t *)&cmd_set_txsplit,
11510 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
11511 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
11512 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
11513 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
11514 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
11515 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
11516 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
11517 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
11518 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
11519 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
11520 (cmdline_parse_inst_t *)&cmd_set_link_check,
11521 #ifdef RTE_NIC_BYPASS
11522 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
11523 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
11524 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
11525 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
11527 #ifdef RTE_LIBRTE_PMD_BOND
11528 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
11529 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
11530 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
11531 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
11532 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
11533 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
11534 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
11535 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
11536 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
11538 (cmdline_parse_inst_t *)&cmd_vlan_offload,
11539 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
11540 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
11541 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
11542 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
11543 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
11544 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
11545 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
11546 (cmdline_parse_inst_t *)&cmd_csum_set,
11547 (cmdline_parse_inst_t *)&cmd_csum_show,
11548 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
11549 (cmdline_parse_inst_t *)&cmd_tso_set,
11550 (cmdline_parse_inst_t *)&cmd_tso_show,
11551 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
11552 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
11553 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
11554 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
11555 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
11556 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
11557 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
11558 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
11559 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
11560 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
11561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
11562 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
11563 (cmdline_parse_inst_t *)&cmd_config_dcb,
11564 (cmdline_parse_inst_t *)&cmd_read_reg,
11565 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
11566 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
11567 (cmdline_parse_inst_t *)&cmd_write_reg,
11568 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
11569 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
11570 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
11571 (cmdline_parse_inst_t *)&cmd_stop,
11572 (cmdline_parse_inst_t *)&cmd_mac_addr,
11573 (cmdline_parse_inst_t *)&cmd_set_qmap,
11574 (cmdline_parse_inst_t *)&cmd_operate_port,
11575 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
11576 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
11577 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
11578 (cmdline_parse_inst_t *)&cmd_config_speed_all,
11579 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
11580 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
11581 (cmdline_parse_inst_t *)&cmd_config_mtu,
11582 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
11583 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
11584 (cmdline_parse_inst_t *)&cmd_config_rss,
11585 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
11586 (cmdline_parse_inst_t *)&cmd_config_txqflags,
11587 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
11588 (cmdline_parse_inst_t *)&cmd_showport_reta,
11589 (cmdline_parse_inst_t *)&cmd_config_burst,
11590 (cmdline_parse_inst_t *)&cmd_config_thresh,
11591 (cmdline_parse_inst_t *)&cmd_config_threshold,
11592 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
11593 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
11594 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
11595 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
11596 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
11597 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
11598 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
11599 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
11600 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
11601 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
11602 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
11603 (cmdline_parse_inst_t *)&cmd_global_config,
11604 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
11605 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
11606 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
11607 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
11608 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
11609 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
11610 (cmdline_parse_inst_t *)&cmd_dump,
11611 (cmdline_parse_inst_t *)&cmd_dump_one,
11612 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
11613 (cmdline_parse_inst_t *)&cmd_syn_filter,
11614 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
11615 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
11616 (cmdline_parse_inst_t *)&cmd_flex_filter,
11617 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
11618 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
11619 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
11620 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
11621 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
11622 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
11623 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
11624 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
11625 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
11626 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
11627 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
11628 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
11629 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
11630 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
11631 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
11632 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
11633 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
11634 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
11635 (cmdline_parse_inst_t *)&cmd_flow,
11636 (cmdline_parse_inst_t *)&cmd_mcast_addr,
11637 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
11638 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
11639 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
11640 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
11641 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
11642 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
11643 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
11644 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
11645 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
11646 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
11647 #ifdef RTE_LIBRTE_IXGBE_PMD
11648 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
11649 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
11650 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
11651 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
11652 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
11653 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
11654 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
11655 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
11660 /* prompt function, called from main on MASTER lcore */
11664 /* initialize non-constant commands */
11665 cmd_set_fwd_mode_init();
11666 cmd_set_fwd_retry_mode_init();
11668 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
11669 if (testpmd_cl == NULL)
11671 cmdline_interact(testpmd_cl);
11672 cmdline_stdin_exit(testpmd_cl);
11678 if (testpmd_cl != NULL)
11679 cmdline_quit(testpmd_cl);
11683 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
11685 if (id == (portid_t)RTE_PORT_ALL) {
11688 FOREACH_PORT(pid, ports) {
11689 /* check if need_reconfig has been set to 1 */
11690 if (ports[pid].need_reconfig == 0)
11691 ports[pid].need_reconfig = dev;
11692 /* check if need_reconfig_queues has been set to 1 */
11693 if (ports[pid].need_reconfig_queues == 0)
11694 ports[pid].need_reconfig_queues = queue;
11696 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
11697 /* check if need_reconfig has been set to 1 */
11698 if (ports[id].need_reconfig == 0)
11699 ports[id].need_reconfig = dev;
11700 /* check if need_reconfig_queues has been set to 1 */
11701 if (ports[id].need_reconfig_queues == 0)
11702 ports[id].need_reconfig_queues = queue;