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>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static struct cmdline *testpmd_cl;
95 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
98 uint8_t bypass_is_supported(portid_t port_id);
101 /* *** Help command with introduction. *** */
102 struct cmd_help_brief_result {
103 cmdline_fixed_string_t help;
106 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
108 __attribute__((unused)) void *data)
113 "Help is available for the following sections:\n\n"
114 " help control : Start and stop forwarding.\n"
115 " help display : Displaying port, stats and config "
117 " help config : Configuration information.\n"
118 " help ports : Configuring ports.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
196 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
197 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
198 " Display the RSS hash functions and RSS hash key"
201 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
202 " Clear information for port_id, or all.\n\n"
204 "show (rxq|txq) info (port_id) (queue_id)\n"
205 " Display information for configured RX/TX queue.\n\n"
207 "show config (rxtx|cores|fwd|txpkts)\n"
208 " Display the given configuration.\n\n"
210 "read rxd (port_id) (queue_id) (rxd_id)\n"
211 " Display an RX descriptor of a port RX queue.\n\n"
213 "read txd (port_id) (queue_id) (txd_id)\n"
214 " Display a TX descriptor of a port TX queue.\n\n"
218 if (show_all || !strcmp(res->section, "config")) {
224 "Configuration changes only become active when"
225 " forwarding is started/restarted.\n\n"
228 " Reset forwarding to the default configuration.\n\n"
230 "set verbose (level)\n"
231 " Set the debug verbosity level X.\n\n"
234 " Set number of ports.\n\n"
237 " Set number of cores.\n\n"
239 "set coremask (mask)\n"
240 " Set the forwarding cores hexadecimal mask.\n\n"
242 "set portmask (mask)\n"
243 " Set the forwarding ports hexadecimal mask.\n\n"
246 " Set number of packets per burst.\n\n"
248 "set burst tx delay (microseconds) retry (num)\n"
249 " Set the transmit delay time and number of retries,"
250 " effective when retry is enabled.\n\n"
252 "set txpkts (x[,y]*)\n"
253 " Set the length of each segment of TXONLY"
254 " and optionally CSUM packets.\n\n"
256 "set txsplit (off|on|rand)\n"
257 " Set the split policy for the TX packets."
258 " Right now only applicable for CSUM and TXONLY"
261 "set corelist (x[,y]*)\n"
262 " Set the list of forwarding cores.\n\n"
264 "set portlist (x[,y]*)\n"
265 " Set the list of forwarding ports.\n\n"
267 "vlan set strip (on|off) (port_id)\n"
268 " Set the VLAN strip on a port.\n\n"
270 "vlan set stripq (on|off) (port_id,queue_id)\n"
271 " Set the VLAN strip for a queue on a port.\n\n"
273 "vlan set filter (on|off) (port_id)\n"
274 " Set the VLAN filter on a port.\n\n"
276 "vlan set qinq (on|off) (port_id)\n"
277 " Set the VLAN QinQ (extended queue in queue)"
280 "vlan set (inner|outer) tpid (value) (port_id)\n"
281 " Set the VLAN TPID for Packet Filtering on"
284 "rx_vlan add (vlan_id|all) (port_id)\n"
285 " Add a vlan_id, or all identifiers, to the set"
286 " of VLAN identifiers filtered by port_id.\n\n"
288 "rx_vlan rm (vlan_id|all) (port_id)\n"
289 " Remove a vlan_id, or all identifiers, from the set"
290 " of VLAN identifiers filtered by port_id.\n\n"
292 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
293 " Add a vlan_id, to the set of VLAN identifiers"
294 "filtered for VF(s) from port_id.\n\n"
296 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
297 " Remove a vlan_id, to the set of VLAN identifiers"
298 "filtered for VF(s) from port_id.\n\n"
300 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
301 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
302 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
303 " add a tunnel filter of a port.\n\n"
305 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
306 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
307 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
308 " remove a tunnel filter of a port.\n\n"
310 "rx_vxlan_port add (udp_port) (port_id)\n"
311 " Add an UDP port for VXLAN packet filter on a port\n\n"
313 "rx_vxlan_port rm (udp_port) (port_id)\n"
314 " Remove an UDP port for VXLAN packet filter on a port\n\n"
316 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
317 " Set hardware insertion of VLAN IDs (single or double VLAN "
318 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
320 "tx_vlan set pvid port_id vlan_id (on|off)\n"
321 " Set port based TX VLAN insertion.\n\n"
323 "tx_vlan reset (port_id)\n"
324 " Disable hardware insertion of a VLAN header in"
325 " packets sent on a port.\n\n"
327 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
328 " Select hardware or software calculation of the"
329 " checksum when transmitting a packet using the"
330 " csum forward engine.\n"
331 " ip|udp|tcp|sctp always concern the inner layer.\n"
332 " outer-ip concerns the outer IP layer in"
333 " case the packet is recognized as a tunnel packet by"
334 " the forward engine (vxlan, gre and ipip are supported)\n"
335 " Please check the NIC datasheet for HW limits.\n\n"
337 "csum parse-tunnel (on|off) (tx_port_id)\n"
338 " If disabled, treat tunnel packets as non-tunneled"
339 " packets (treat inner headers as payload). The port\n"
340 " argument is the port used for TX in csum forward"
343 "csum show (port_id)\n"
344 " Display tx checksum offload configuration\n\n"
346 "tso set (segsize) (portid)\n"
347 " Enable TCP Segmentation Offload in csum forward"
349 " Please check the NIC datasheet for HW limits.\n\n"
352 " Display the status of TCP Segmentation Offload.\n\n"
355 " Set packet forwarding mode.\n\n"
357 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
358 " Add a MAC address on port_id.\n\n"
360 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
361 " Remove a MAC address from port_id.\n\n"
363 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
364 " Add a MAC address for a VF on the port.\n\n"
366 "set port (port_id) uta (mac_address|all) (on|off)\n"
367 " Add/Remove a or all unicast hash filter(s)"
370 "set promisc (port_id|all) (on|off)\n"
371 " Set the promiscuous mode on port_id, or all.\n\n"
373 "set allmulti (port_id|all) (on|off)\n"
374 " Set the allmulti mode on port_id, or all.\n\n"
376 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
377 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
378 " (on|off) autoneg (on|off) (port_id)\n"
379 "set flow_ctrl rx (on|off) (portid)\n"
380 "set flow_ctrl tx (on|off) (portid)\n"
381 "set flow_ctrl high_water (high_water) (portid)\n"
382 "set flow_ctrl low_water (low_water) (portid)\n"
383 "set flow_ctrl pause_time (pause_time) (portid)\n"
384 "set flow_ctrl send_xon (send_xon) (portid)\n"
385 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
386 "set flow_ctrl autoneg (on|off) (port_id)\n"
387 " Set the link flow control parameter on a port.\n\n"
389 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
390 " (low_water) (pause_time) (priority) (port_id)\n"
391 " Set the priority flow control parameter on a"
394 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
395 " Set statistics mapping (qmapping 0..15) for RX/TX"
397 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
398 " on port 0 to mapping 5.\n\n"
400 "set port (port_id) vf (vf_id) rx|tx on|off\n"
401 " Enable/Disable a VF receive/tranmit from a port\n\n"
403 "set port (port_id) vf (vf_id) (mac_addr)"
404 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
405 " Add/Remove unicast or multicast MAC addr filter"
408 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
410 " AUPE:accepts untagged VLAN;"
411 "ROPE:accept unicast hash\n\n"
412 " BAM:accepts broadcast packets;"
413 "MPE:accepts all multicast packets\n\n"
414 " Enable/Disable a VF receive mode of a port\n\n"
416 "set port (port_id) queue (queue_id) rate (rate_num)\n"
417 " Set rate limit for a queue of a port\n\n"
419 "set port (port_id) vf (vf_id) rate (rate_num) "
420 "queue_mask (queue_mask_value)\n"
421 " Set rate limit for queues in VF of a port\n\n"
423 "set port (port_id) mirror-rule (rule_id)"
424 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
425 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
426 " Set pool or vlan type mirror rule on a port.\n"
427 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
428 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
431 "set port (port_id) mirror-rule (rule_id)"
432 " (uplink-mirror|downlink-mirror) dst-pool"
433 " (pool_id) (on|off)\n"
434 " Set uplink or downlink type mirror rule on a port.\n"
435 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
436 " 0 on' enable mirror income traffic to pool 0.\n\n"
438 "reset port (port_id) mirror-rule (rule_id)\n"
439 " Reset a mirror rule.\n\n"
441 "set flush_rx (on|off)\n"
442 " Flush (default) or don't flush RX streams before"
443 " forwarding. Mainly used with PCAP drivers.\n\n"
445 #ifdef RTE_NIC_BYPASS
446 "set bypass mode (normal|bypass|isolate) (port_id)\n"
447 " Set the bypass mode for the lowest port on bypass enabled"
450 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
451 "mode (normal|bypass|isolate) (port_id)\n"
452 " Set the event required to initiate specified bypass mode for"
453 " the lowest port on a bypass enabled NIC where:\n"
454 " timeout = enable bypass after watchdog timeout.\n"
455 " os_on = enable bypass when OS/board is powered on.\n"
456 " os_off = enable bypass when OS/board is powered off.\n"
457 " power_on = enable bypass when power supply is turned on.\n"
458 " power_off = enable bypass when power supply is turned off."
461 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
462 " Set the bypass watchdog timeout to 'n' seconds"
463 " where 0 = instant.\n\n"
465 "show bypass config (port_id)\n"
466 " Show the bypass configuration for a bypass enabled NIC"
467 " using the lowest port on the NIC.\n\n"
469 #ifdef RTE_LIBRTE_PMD_BOND
470 "create bonded device (mode) (socket)\n"
471 " Create a new bonded device with specific bonding mode and socket.\n\n"
473 "add bonding slave (slave_id) (port_id)\n"
474 " Add a slave device to a bonded device.\n\n"
476 "remove bonding slave (slave_id) (port_id)\n"
477 " Remove a slave device from a bonded device.\n\n"
479 "set bonding mode (value) (port_id)\n"
480 " Set the bonding mode on a bonded device.\n\n"
482 "set bonding primary (slave_id) (port_id)\n"
483 " Set the primary slave for a bonded device.\n\n"
485 "show bonding config (port_id)\n"
486 " Show the bonding config for port_id.\n\n"
488 "set bonding mac_addr (port_id) (address)\n"
489 " Set the MAC address of a bonded device.\n\n"
491 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
492 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
494 "set bonding mon_period (port_id) (value)\n"
495 " Set the bonding link status monitoring polling period in ms.\n\n"
497 "set link-up port (port_id)\n"
498 " Set link up for a port.\n\n"
500 "set link-down port (port_id)\n"
501 " Set link down for a port.\n\n"
503 "E-tag set insertion on port-tag-id (value)"
504 " port (port_id) vf (vf_id)\n"
505 " Enable E-tag insertion for a VF on a port\n\n"
507 "E-tag set insertion off port (port_id) vf (vf_id)\n"
508 " Disable E-tag insertion for a VF on a port\n\n"
510 "E-tag set stripping (on|off) port (port_id)\n"
511 " Enable/disable E-tag stripping on a port\n\n"
513 "E-tag set forwarding (on|off) port (port_id)\n"
514 " Enable/disable E-tag based forwarding"
517 "E-tag set filter add e-tag-id (value) dst-pool"
518 " (pool_id) port (port_id)\n"
519 " Add an E-tag forwarding filter on a port\n\n"
521 "E-tag set filter del e-tag-id (value) port (port_id)\n"
522 " Delete an E-tag forwarding filter on a port\n\n"
524 , list_pkt_forwarding_modes()
528 if (show_all || !strcmp(res->section, "ports")) {
534 "----------------\n\n"
536 "port start (port_id|all)\n"
537 " Start all ports or port_id.\n\n"
539 "port stop (port_id|all)\n"
540 " Stop all ports or port_id.\n\n"
542 "port close (port_id|all)\n"
543 " Close all ports or port_id.\n\n"
545 "port attach (ident)\n"
546 " Attach physical or virtual dev by pci address or virtual device name\n\n"
548 "port detach (port_id)\n"
549 " Detach physical or virtual dev by port_id\n\n"
551 "port config (port_id|all)"
552 " speed (10|100|1000|10000|40000|100000|auto)"
553 " duplex (half|full|auto)\n"
554 " Set speed and duplex for all ports or port_id\n\n"
556 "port config all (rxq|txq|rxd|txd) (value)\n"
557 " Set number for rxq/txq/rxd/txd.\n\n"
559 "port config all max-pkt-len (value)\n"
560 " Set the max packet length.\n\n"
562 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
563 "hw-vlan-strip|hw-vlan-extend|drop-en)"
565 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
568 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
569 " Set the RSS mode.\n\n"
571 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
572 " Set the RSS redirection table.\n\n"
574 "port config (port_id) dcb vt (on|off) (traffic_class)"
576 " Set the DCB mode.\n\n"
578 "port config all burst (value)\n"
579 " Set the number of packets per burst.\n\n"
581 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
583 " Set the ring prefetch/host/writeback threshold"
584 " for tx/rx queue.\n\n"
586 "port config all (txfreet|txrst|rxfreet) (value)\n"
587 " Set free threshold for rx/tx, or set"
588 " tx rs bit threshold.\n\n"
589 "port config mtu X value\n"
590 " Set the MTU of port X to a given value\n\n"
592 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
593 " Start/stop a rx/tx queue of port X. Only take effect"
594 " when port X is started\n\n"
596 "port config (port_id|all) l2-tunnel E-tag ether-type"
598 " Set the value of E-tag ether-type.\n\n"
600 "port config (port_id|all) l2-tunnel E-tag"
601 " (enable|disable)\n"
602 " Enable/disable the E-tag support.\n\n"
606 if (show_all || !strcmp(res->section, "registers")) {
614 "read reg (port_id) (address)\n"
615 " Display value of a port register.\n\n"
617 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
618 " Display a port register bit field.\n\n"
620 "read regbit (port_id) (address) (bit_x)\n"
621 " Display a single port register bit.\n\n"
623 "write reg (port_id) (address) (value)\n"
624 " Set value of a port register.\n\n"
626 "write regfield (port_id) (address) (bit_x) (bit_y)"
628 " Set bit field of a port register.\n\n"
630 "write regbit (port_id) (address) (bit_x) (value)\n"
631 " Set single bit value of a port register.\n\n"
634 if (show_all || !strcmp(res->section, "filters")) {
642 "ethertype_filter (port_id) (add|del)"
643 " (mac_addr|mac_ignr) (mac_address) ethertype"
644 " (ether_type) (drop|fwd) queue (queue_id)\n"
645 " Add/Del an ethertype filter.\n\n"
647 "2tuple_filter (port_id) (add|del)"
648 " dst_port (dst_port_value) protocol (protocol_value)"
649 " mask (mask_value) tcp_flags (tcp_flags_value)"
650 " priority (prio_value) queue (queue_id)\n"
651 " Add/Del a 2tuple filter.\n\n"
653 "5tuple_filter (port_id) (add|del)"
654 " dst_ip (dst_address) src_ip (src_address)"
655 " dst_port (dst_port_value) src_port (src_port_value)"
656 " protocol (protocol_value)"
657 " mask (mask_value) tcp_flags (tcp_flags_value)"
658 " priority (prio_value) queue (queue_id)\n"
659 " Add/Del a 5tuple filter.\n\n"
661 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
662 " Add/Del syn filter.\n\n"
664 "flex_filter (port_id) (add|del) len (len_value)"
665 " bytes (bytes_value) mask (mask_value)"
666 " priority (prio_value) queue (queue_id)\n"
667 " Add/Del a flex filter.\n\n"
669 "flow_director_filter (port_id) mode IP (add|del|update)"
670 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
671 " src (src_ip_address) dst (dst_ip_address)"
672 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
673 " vlan (vlan_value) flexbytes (flexbytes_value)"
674 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
675 " fd_id (fd_id_value)\n"
676 " Add/Del an IP type flow director filter.\n\n"
678 "flow_director_filter (port_id) mode IP (add|del|update)"
679 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
680 " src (src_ip_address) (src_port)"
681 " dst (dst_ip_address) (dst_port)"
682 " tos (tos_value) ttl (ttl_value)"
683 " vlan (vlan_value) flexbytes (flexbytes_value)"
684 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
685 " fd_id (fd_id_value)\n"
686 " Add/Del an UDP/TCP type flow director filter.\n\n"
688 "flow_director_filter (port_id) mode IP (add|del|update)"
689 " flow (ipv4-sctp|ipv6-sctp)"
690 " src (src_ip_address) (src_port)"
691 " dst (dst_ip_address) (dst_port)"
692 " tag (verification_tag) "
693 " tos (tos_value) ttl (ttl_value)"
695 " flexbytes (flexbytes_value) (drop|fwd)"
696 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
697 " Add/Del a SCTP type flow director filter.\n\n"
699 "flow_director_filter (port_id) mode IP (add|del|update)"
700 " flow l2_payload ether (ethertype)"
701 " flexbytes (flexbytes_value) (drop|fwd)"
702 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
703 " Add/Del a l2 payload type flow director filter.\n\n"
705 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
706 " mac (mac_address) vlan (vlan_value)"
707 " flexbytes (flexbytes_value) (drop|fwd)"
708 " queue (queue_id) fd_id (fd_id_value)\n"
709 " Add/Del a MAC-VLAN flow director filter.\n\n"
711 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
712 " mac (mac_address) vlan (vlan_value)"
713 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
714 " flexbytes (flexbytes_value) (drop|fwd)"
715 " queue (queue_id) fd_id (fd_id_value)\n"
716 " Add/Del a Tunnel flow director filter.\n\n"
718 "flush_flow_director (port_id)\n"
719 " Flush all flow director entries of a device.\n\n"
721 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
722 " src_mask (ipv4_src) (ipv6_src) (src_port)"
723 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
724 " Set flow director IP mask.\n\n"
726 "flow_director_mask (port_id) mode MAC-VLAN"
727 " vlan (vlan_value) mac (mac_value)\n"
728 " Set flow director MAC-VLAN mask.\n\n"
730 "flow_director_mask (port_id) mode Tunnel"
731 " vlan (vlan_value) mac (mac_value)"
732 " tunnel-type (tunnel_type_value)"
733 " tunnel-id (tunnel_id_value)\n"
734 " Set flow director Tunnel mask.\n\n"
736 "flow_director_flex_mask (port_id)"
737 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
738 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
740 " Configure mask of flex payload.\n\n"
742 "flow_director_flex_payload (port_id)"
743 " (raw|l2|l3|l4) (config)\n"
744 " Configure flex payload selection.\n\n"
746 "get_sym_hash_ena_per_port (port_id)\n"
747 " get symmetric hash enable configuration per port.\n\n"
749 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
750 " set symmetric hash enable configuration per port"
751 " to enable or disable.\n\n"
753 "get_hash_global_config (port_id)\n"
754 " Get the global configurations of hash filters.\n\n"
756 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
757 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
758 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
759 " (enable|disable)\n"
760 " Set the global configurations of hash filters.\n\n"
762 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
763 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
764 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
765 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
766 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
767 "ipv6-next-header|udp-src-port|udp-dst-port|"
768 "tcp-src-port|tcp-dst-port|sctp-src-port|"
769 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
770 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
771 "fld-8th|none) (select|add)\n"
772 " Set the input set for hash.\n\n"
774 "set_fdir_input_set (port_id) "
775 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
776 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
777 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
778 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
779 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
780 "udp-dst-port|tcp-src-port|tcp-dst-port|"
781 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
783 " Set the input set for FDir.\n\n"
788 cmdline_parse_token_string_t cmd_help_long_help =
789 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
791 cmdline_parse_token_string_t cmd_help_long_section =
792 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
793 "all#control#display#config#"
794 "ports#registers#filters");
796 cmdline_parse_inst_t cmd_help_long = {
797 .f = cmd_help_long_parsed,
799 .help_str = "show help",
801 (void *)&cmd_help_long_help,
802 (void *)&cmd_help_long_section,
808 /* *** start/stop/close all ports *** */
809 struct cmd_operate_port_result {
810 cmdline_fixed_string_t keyword;
811 cmdline_fixed_string_t name;
812 cmdline_fixed_string_t value;
815 static void cmd_operate_port_parsed(void *parsed_result,
816 __attribute__((unused)) struct cmdline *cl,
817 __attribute__((unused)) void *data)
819 struct cmd_operate_port_result *res = parsed_result;
821 if (!strcmp(res->name, "start"))
822 start_port(RTE_PORT_ALL);
823 else if (!strcmp(res->name, "stop"))
824 stop_port(RTE_PORT_ALL);
825 else if (!strcmp(res->name, "close"))
826 close_port(RTE_PORT_ALL);
828 printf("Unknown parameter\n");
831 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
832 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
834 cmdline_parse_token_string_t cmd_operate_port_all_port =
835 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
837 cmdline_parse_token_string_t cmd_operate_port_all_all =
838 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
840 cmdline_parse_inst_t cmd_operate_port = {
841 .f = cmd_operate_port_parsed,
843 .help_str = "port start|stop|close all: start/stop/close all ports",
845 (void *)&cmd_operate_port_all_cmd,
846 (void *)&cmd_operate_port_all_port,
847 (void *)&cmd_operate_port_all_all,
852 /* *** start/stop/close specific port *** */
853 struct cmd_operate_specific_port_result {
854 cmdline_fixed_string_t keyword;
855 cmdline_fixed_string_t name;
859 static void cmd_operate_specific_port_parsed(void *parsed_result,
860 __attribute__((unused)) struct cmdline *cl,
861 __attribute__((unused)) void *data)
863 struct cmd_operate_specific_port_result *res = parsed_result;
865 if (!strcmp(res->name, "start"))
866 start_port(res->value);
867 else if (!strcmp(res->name, "stop"))
868 stop_port(res->value);
869 else if (!strcmp(res->name, "close"))
870 close_port(res->value);
872 printf("Unknown parameter\n");
875 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
876 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
878 cmdline_parse_token_string_t cmd_operate_specific_port_port =
879 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
880 name, "start#stop#close");
881 cmdline_parse_token_num_t cmd_operate_specific_port_id =
882 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
885 cmdline_parse_inst_t cmd_operate_specific_port = {
886 .f = cmd_operate_specific_port_parsed,
888 .help_str = "port start|stop|close X: start/stop/close port X",
890 (void *)&cmd_operate_specific_port_cmd,
891 (void *)&cmd_operate_specific_port_port,
892 (void *)&cmd_operate_specific_port_id,
897 /* *** attach a specified port *** */
898 struct cmd_operate_attach_port_result {
899 cmdline_fixed_string_t port;
900 cmdline_fixed_string_t keyword;
901 cmdline_fixed_string_t identifier;
904 static void cmd_operate_attach_port_parsed(void *parsed_result,
905 __attribute__((unused)) struct cmdline *cl,
906 __attribute__((unused)) void *data)
908 struct cmd_operate_attach_port_result *res = parsed_result;
910 if (!strcmp(res->keyword, "attach"))
911 attach_port(res->identifier);
913 printf("Unknown parameter\n");
916 cmdline_parse_token_string_t cmd_operate_attach_port_port =
917 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
919 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
920 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
922 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
923 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
926 cmdline_parse_inst_t cmd_operate_attach_port = {
927 .f = cmd_operate_attach_port_parsed,
929 .help_str = "port attach identifier, "
930 "identifier: pci address or virtual dev name",
932 (void *)&cmd_operate_attach_port_port,
933 (void *)&cmd_operate_attach_port_keyword,
934 (void *)&cmd_operate_attach_port_identifier,
939 /* *** detach a specified port *** */
940 struct cmd_operate_detach_port_result {
941 cmdline_fixed_string_t port;
942 cmdline_fixed_string_t keyword;
946 static void cmd_operate_detach_port_parsed(void *parsed_result,
947 __attribute__((unused)) struct cmdline *cl,
948 __attribute__((unused)) void *data)
950 struct cmd_operate_detach_port_result *res = parsed_result;
952 if (!strcmp(res->keyword, "detach"))
953 detach_port(res->port_id);
955 printf("Unknown parameter\n");
958 cmdline_parse_token_string_t cmd_operate_detach_port_port =
959 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
961 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
962 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
964 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
965 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
968 cmdline_parse_inst_t cmd_operate_detach_port = {
969 .f = cmd_operate_detach_port_parsed,
971 .help_str = "port detach port_id",
973 (void *)&cmd_operate_detach_port_port,
974 (void *)&cmd_operate_detach_port_keyword,
975 (void *)&cmd_operate_detach_port_port_id,
980 /* *** configure speed for all ports *** */
981 struct cmd_config_speed_all {
982 cmdline_fixed_string_t port;
983 cmdline_fixed_string_t keyword;
984 cmdline_fixed_string_t all;
985 cmdline_fixed_string_t item1;
986 cmdline_fixed_string_t item2;
987 cmdline_fixed_string_t value1;
988 cmdline_fixed_string_t value2;
992 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
997 if (!strcmp(duplexstr, "half")) {
998 duplex = ETH_LINK_HALF_DUPLEX;
999 } else if (!strcmp(duplexstr, "full")) {
1000 duplex = ETH_LINK_FULL_DUPLEX;
1001 } else if (!strcmp(duplexstr, "auto")) {
1002 duplex = ETH_LINK_FULL_DUPLEX;
1004 printf("Unknown duplex parameter\n");
1008 if (!strcmp(speedstr, "10")) {
1009 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1010 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1011 } else if (!strcmp(speedstr, "100")) {
1012 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1013 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1015 if (duplex != ETH_LINK_FULL_DUPLEX) {
1016 printf("Invalid speed/duplex parameters\n");
1019 if (!strcmp(speedstr, "1000")) {
1020 *speed = ETH_LINK_SPEED_1G;
1021 } else if (!strcmp(speedstr, "10000")) {
1022 *speed = ETH_LINK_SPEED_10G;
1023 } else if (!strcmp(speedstr, "40000")) {
1024 *speed = ETH_LINK_SPEED_40G;
1025 } else if (!strcmp(speedstr, "100000")) {
1026 *speed = ETH_LINK_SPEED_100G;
1027 } else if (!strcmp(speedstr, "auto")) {
1028 *speed = ETH_LINK_SPEED_AUTONEG;
1030 printf("Unknown speed parameter\n");
1039 cmd_config_speed_all_parsed(void *parsed_result,
1040 __attribute__((unused)) struct cmdline *cl,
1041 __attribute__((unused)) void *data)
1043 struct cmd_config_speed_all *res = parsed_result;
1044 uint32_t link_speed;
1047 if (!all_ports_stopped()) {
1048 printf("Please stop all ports first\n");
1052 if (parse_and_check_speed_duplex(res->value1, res->value2,
1056 FOREACH_PORT(pid, ports) {
1057 ports[pid].dev_conf.link_speeds = link_speed;
1060 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1063 cmdline_parse_token_string_t cmd_config_speed_all_port =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1065 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1068 cmdline_parse_token_string_t cmd_config_speed_all_all =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1070 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1071 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1072 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1074 "10#100#1000#10000#40000#100000#auto");
1075 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1076 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1077 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1078 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1081 cmdline_parse_inst_t cmd_config_speed_all = {
1082 .f = cmd_config_speed_all_parsed,
1084 .help_str = "port config all speed 10|100|1000|10000|40000|100000|auto duplex "
1087 (void *)&cmd_config_speed_all_port,
1088 (void *)&cmd_config_speed_all_keyword,
1089 (void *)&cmd_config_speed_all_all,
1090 (void *)&cmd_config_speed_all_item1,
1091 (void *)&cmd_config_speed_all_value1,
1092 (void *)&cmd_config_speed_all_item2,
1093 (void *)&cmd_config_speed_all_value2,
1098 /* *** configure speed for specific port *** */
1099 struct cmd_config_speed_specific {
1100 cmdline_fixed_string_t port;
1101 cmdline_fixed_string_t keyword;
1103 cmdline_fixed_string_t item1;
1104 cmdline_fixed_string_t item2;
1105 cmdline_fixed_string_t value1;
1106 cmdline_fixed_string_t value2;
1110 cmd_config_speed_specific_parsed(void *parsed_result,
1111 __attribute__((unused)) struct cmdline *cl,
1112 __attribute__((unused)) void *data)
1114 struct cmd_config_speed_specific *res = parsed_result;
1115 uint32_t link_speed;
1117 if (!all_ports_stopped()) {
1118 printf("Please stop all ports first\n");
1122 if (port_id_is_invalid(res->id, ENABLED_WARN))
1125 if (parse_and_check_speed_duplex(res->value1, res->value2,
1129 ports[res->id].dev_conf.link_speeds = link_speed;
1131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1135 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1138 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1141 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1142 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1143 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1146 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1148 "10#100#1000#10000#40000#100000#auto");
1149 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1152 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1156 cmdline_parse_inst_t cmd_config_speed_specific = {
1157 .f = cmd_config_speed_specific_parsed,
1159 .help_str = "port config X speed 10|100|1000|10000|40000|100000|auto duplex "
1162 (void *)&cmd_config_speed_specific_port,
1163 (void *)&cmd_config_speed_specific_keyword,
1164 (void *)&cmd_config_speed_specific_id,
1165 (void *)&cmd_config_speed_specific_item1,
1166 (void *)&cmd_config_speed_specific_value1,
1167 (void *)&cmd_config_speed_specific_item2,
1168 (void *)&cmd_config_speed_specific_value2,
1173 /* *** configure txq/rxq, txd/rxd *** */
1174 struct cmd_config_rx_tx {
1175 cmdline_fixed_string_t port;
1176 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t all;
1178 cmdline_fixed_string_t name;
1183 cmd_config_rx_tx_parsed(void *parsed_result,
1184 __attribute__((unused)) struct cmdline *cl,
1185 __attribute__((unused)) void *data)
1187 struct cmd_config_rx_tx *res = parsed_result;
1189 if (!all_ports_stopped()) {
1190 printf("Please stop all ports first\n");
1193 if (!strcmp(res->name, "rxq")) {
1194 if (!res->value && !nb_txq) {
1195 printf("Warning: Either rx or tx queues should be non zero\n");
1198 nb_rxq = res->value;
1200 else if (!strcmp(res->name, "txq")) {
1201 if (!res->value && !nb_rxq) {
1202 printf("Warning: Either rx or tx queues should be non zero\n");
1205 nb_txq = res->value;
1207 else if (!strcmp(res->name, "rxd")) {
1208 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1209 printf("rxd %d invalid - must be > 0 && <= %d\n",
1210 res->value, RTE_TEST_RX_DESC_MAX);
1213 nb_rxd = res->value;
1214 } else if (!strcmp(res->name, "txd")) {
1215 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1216 printf("txd %d invalid - must be > 0 && <= %d\n",
1217 res->value, RTE_TEST_TX_DESC_MAX);
1220 nb_txd = res->value;
1222 printf("Unknown parameter\n");
1230 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1233 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1235 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1236 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1237 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1239 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1242 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1243 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1245 cmdline_parse_inst_t cmd_config_rx_tx = {
1246 .f = cmd_config_rx_tx_parsed,
1248 .help_str = "port config all rxq|txq|rxd|txd value",
1250 (void *)&cmd_config_rx_tx_port,
1251 (void *)&cmd_config_rx_tx_keyword,
1252 (void *)&cmd_config_rx_tx_all,
1253 (void *)&cmd_config_rx_tx_name,
1254 (void *)&cmd_config_rx_tx_value,
1259 /* *** config max packet length *** */
1260 struct cmd_config_max_pkt_len_result {
1261 cmdline_fixed_string_t port;
1262 cmdline_fixed_string_t keyword;
1263 cmdline_fixed_string_t all;
1264 cmdline_fixed_string_t name;
1269 cmd_config_max_pkt_len_parsed(void *parsed_result,
1270 __attribute__((unused)) struct cmdline *cl,
1271 __attribute__((unused)) void *data)
1273 struct cmd_config_max_pkt_len_result *res = parsed_result;
1275 if (!all_ports_stopped()) {
1276 printf("Please stop all ports first\n");
1280 if (!strcmp(res->name, "max-pkt-len")) {
1281 if (res->value < ETHER_MIN_LEN) {
1282 printf("max-pkt-len can not be less than %d\n",
1286 if (res->value == rx_mode.max_rx_pkt_len)
1289 rx_mode.max_rx_pkt_len = res->value;
1290 if (res->value > ETHER_MAX_LEN)
1291 rx_mode.jumbo_frame = 1;
1293 rx_mode.jumbo_frame = 0;
1295 printf("Unknown parameter\n");
1301 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1304 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1305 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1307 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1308 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1310 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1313 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1314 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1316 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1317 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1320 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1321 .f = cmd_config_max_pkt_len_parsed,
1323 .help_str = "port config all max-pkt-len value",
1325 (void *)&cmd_config_max_pkt_len_port,
1326 (void *)&cmd_config_max_pkt_len_keyword,
1327 (void *)&cmd_config_max_pkt_len_all,
1328 (void *)&cmd_config_max_pkt_len_name,
1329 (void *)&cmd_config_max_pkt_len_value,
1334 /* *** configure port MTU *** */
1335 struct cmd_config_mtu_result {
1336 cmdline_fixed_string_t port;
1337 cmdline_fixed_string_t keyword;
1338 cmdline_fixed_string_t mtu;
1344 cmd_config_mtu_parsed(void *parsed_result,
1345 __attribute__((unused)) struct cmdline *cl,
1346 __attribute__((unused)) void *data)
1348 struct cmd_config_mtu_result *res = parsed_result;
1350 if (res->value < ETHER_MIN_LEN) {
1351 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1354 port_mtu_set(res->port_id, res->value);
1357 cmdline_parse_token_string_t cmd_config_mtu_port =
1358 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1360 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1363 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1364 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1366 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1367 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1368 cmdline_parse_token_num_t cmd_config_mtu_value =
1369 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1371 cmdline_parse_inst_t cmd_config_mtu = {
1372 .f = cmd_config_mtu_parsed,
1374 .help_str = "port config mtu value",
1376 (void *)&cmd_config_mtu_port,
1377 (void *)&cmd_config_mtu_keyword,
1378 (void *)&cmd_config_mtu_mtu,
1379 (void *)&cmd_config_mtu_port_id,
1380 (void *)&cmd_config_mtu_value,
1385 /* *** configure rx mode *** */
1386 struct cmd_config_rx_mode_flag {
1387 cmdline_fixed_string_t port;
1388 cmdline_fixed_string_t keyword;
1389 cmdline_fixed_string_t all;
1390 cmdline_fixed_string_t name;
1391 cmdline_fixed_string_t value;
1395 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1396 __attribute__((unused)) struct cmdline *cl,
1397 __attribute__((unused)) void *data)
1399 struct cmd_config_rx_mode_flag *res = parsed_result;
1401 if (!all_ports_stopped()) {
1402 printf("Please stop all ports first\n");
1406 if (!strcmp(res->name, "crc-strip")) {
1407 if (!strcmp(res->value, "on"))
1408 rx_mode.hw_strip_crc = 1;
1409 else if (!strcmp(res->value, "off"))
1410 rx_mode.hw_strip_crc = 0;
1412 printf("Unknown parameter\n");
1415 } else if (!strcmp(res->name, "scatter")) {
1416 if (!strcmp(res->value, "on"))
1417 rx_mode.enable_scatter = 1;
1418 else if (!strcmp(res->value, "off"))
1419 rx_mode.enable_scatter = 0;
1421 printf("Unknown parameter\n");
1424 } else if (!strcmp(res->name, "rx-cksum")) {
1425 if (!strcmp(res->value, "on"))
1426 rx_mode.hw_ip_checksum = 1;
1427 else if (!strcmp(res->value, "off"))
1428 rx_mode.hw_ip_checksum = 0;
1430 printf("Unknown parameter\n");
1433 } else if (!strcmp(res->name, "hw-vlan")) {
1434 if (!strcmp(res->value, "on")) {
1435 rx_mode.hw_vlan_filter = 1;
1436 rx_mode.hw_vlan_strip = 1;
1438 else if (!strcmp(res->value, "off")) {
1439 rx_mode.hw_vlan_filter = 0;
1440 rx_mode.hw_vlan_strip = 0;
1443 printf("Unknown parameter\n");
1446 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1447 if (!strcmp(res->value, "on"))
1448 rx_mode.hw_vlan_filter = 1;
1449 else if (!strcmp(res->value, "off"))
1450 rx_mode.hw_vlan_filter = 0;
1452 printf("Unknown parameter\n");
1455 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1456 if (!strcmp(res->value, "on"))
1457 rx_mode.hw_vlan_strip = 1;
1458 else if (!strcmp(res->value, "off"))
1459 rx_mode.hw_vlan_strip = 0;
1461 printf("Unknown parameter\n");
1464 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1465 if (!strcmp(res->value, "on"))
1466 rx_mode.hw_vlan_extend = 1;
1467 else if (!strcmp(res->value, "off"))
1468 rx_mode.hw_vlan_extend = 0;
1470 printf("Unknown parameter\n");
1473 } else if (!strcmp(res->name, "drop-en")) {
1474 if (!strcmp(res->value, "on"))
1476 else if (!strcmp(res->value, "off"))
1479 printf("Unknown parameter\n");
1483 printf("Unknown parameter\n");
1489 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1492 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1494 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1497 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1499 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1501 "crc-strip#scatter#rx-cksum#hw-vlan#"
1502 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1503 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1504 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1507 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1508 .f = cmd_config_rx_mode_flag_parsed,
1510 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1511 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1513 (void *)&cmd_config_rx_mode_flag_port,
1514 (void *)&cmd_config_rx_mode_flag_keyword,
1515 (void *)&cmd_config_rx_mode_flag_all,
1516 (void *)&cmd_config_rx_mode_flag_name,
1517 (void *)&cmd_config_rx_mode_flag_value,
1522 /* *** configure rss *** */
1523 struct cmd_config_rss {
1524 cmdline_fixed_string_t port;
1525 cmdline_fixed_string_t keyword;
1526 cmdline_fixed_string_t all;
1527 cmdline_fixed_string_t name;
1528 cmdline_fixed_string_t value;
1532 cmd_config_rss_parsed(void *parsed_result,
1533 __attribute__((unused)) struct cmdline *cl,
1534 __attribute__((unused)) void *data)
1536 struct cmd_config_rss *res = parsed_result;
1537 struct rte_eth_rss_conf rss_conf;
1541 if (!strcmp(res->value, "all"))
1542 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1543 ETH_RSS_UDP | ETH_RSS_SCTP |
1545 else if (!strcmp(res->value, "ip"))
1546 rss_conf.rss_hf = ETH_RSS_IP;
1547 else if (!strcmp(res->value, "udp"))
1548 rss_conf.rss_hf = ETH_RSS_UDP;
1549 else if (!strcmp(res->value, "tcp"))
1550 rss_conf.rss_hf = ETH_RSS_TCP;
1551 else if (!strcmp(res->value, "sctp"))
1552 rss_conf.rss_hf = ETH_RSS_SCTP;
1553 else if (!strcmp(res->value, "ether"))
1554 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1555 else if (!strcmp(res->value, "port"))
1556 rss_conf.rss_hf = ETH_RSS_PORT;
1557 else if (!strcmp(res->value, "vxlan"))
1558 rss_conf.rss_hf = ETH_RSS_VXLAN;
1559 else if (!strcmp(res->value, "geneve"))
1560 rss_conf.rss_hf = ETH_RSS_GENEVE;
1561 else if (!strcmp(res->value, "nvgre"))
1562 rss_conf.rss_hf = ETH_RSS_NVGRE;
1563 else if (!strcmp(res->value, "none"))
1564 rss_conf.rss_hf = 0;
1566 printf("Unknown parameter\n");
1569 rss_conf.rss_key = NULL;
1570 for (i = 0; i < rte_eth_dev_count(); i++) {
1571 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1573 printf("Configuration of RSS hash at ethernet port %d "
1574 "failed with error (%d): %s.\n",
1575 i, -diag, strerror(-diag));
1579 cmdline_parse_token_string_t cmd_config_rss_port =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1581 cmdline_parse_token_string_t cmd_config_rss_keyword =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1583 cmdline_parse_token_string_t cmd_config_rss_all =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1585 cmdline_parse_token_string_t cmd_config_rss_name =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1587 cmdline_parse_token_string_t cmd_config_rss_value =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1589 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1591 cmdline_parse_inst_t cmd_config_rss = {
1592 .f = cmd_config_rss_parsed,
1594 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1596 (void *)&cmd_config_rss_port,
1597 (void *)&cmd_config_rss_keyword,
1598 (void *)&cmd_config_rss_all,
1599 (void *)&cmd_config_rss_name,
1600 (void *)&cmd_config_rss_value,
1605 /* *** configure rss hash key *** */
1606 struct cmd_config_rss_hash_key {
1607 cmdline_fixed_string_t port;
1608 cmdline_fixed_string_t config;
1610 cmdline_fixed_string_t rss_hash_key;
1611 cmdline_fixed_string_t rss_type;
1612 cmdline_fixed_string_t key;
1615 #define RSS_HASH_KEY_LENGTH 40
1617 hexa_digit_to_value(char hexa_digit)
1619 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1620 return (uint8_t) (hexa_digit - '0');
1621 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1622 return (uint8_t) ((hexa_digit - 'a') + 10);
1623 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1624 return (uint8_t) ((hexa_digit - 'A') + 10);
1625 /* Invalid hexa digit */
1630 parse_and_check_key_hexa_digit(char *key, int idx)
1634 hexa_v = hexa_digit_to_value(key[idx]);
1636 printf("invalid key: character %c at position %d is not a "
1637 "valid hexa digit\n", key[idx], idx);
1642 cmd_config_rss_hash_key_parsed(void *parsed_result,
1643 __attribute__((unused)) struct cmdline *cl,
1644 __attribute__((unused)) void *data)
1646 struct cmd_config_rss_hash_key *res = parsed_result;
1647 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1652 /* Check the length of the RSS hash key */
1653 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1654 printf("key length: %d invalid - key must be a string of %d"
1655 "hexa-decimal numbers\n", (int) strlen(res->key),
1656 RSS_HASH_KEY_LENGTH * 2);
1659 /* Translate RSS hash key into binary representation */
1660 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1661 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1664 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1667 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1669 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1670 RSS_HASH_KEY_LENGTH);
1673 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1675 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1678 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1679 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1680 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1682 rss_hash_key, "rss-hash-key");
1683 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1685 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1686 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1687 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1688 "ipv6-tcp-ex#ipv6-udp-ex");
1689 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1692 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1693 .f = cmd_config_rss_hash_key_parsed,
1696 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1697 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1698 "ipv6-sctp|ipv6-other|l2-payload|"
1699 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1701 (void *)&cmd_config_rss_hash_key_port,
1702 (void *)&cmd_config_rss_hash_key_config,
1703 (void *)&cmd_config_rss_hash_key_port_id,
1704 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1705 (void *)&cmd_config_rss_hash_key_rss_type,
1706 (void *)&cmd_config_rss_hash_key_value,
1711 /* *** configure port rxq/txq start/stop *** */
1712 struct cmd_config_rxtx_queue {
1713 cmdline_fixed_string_t port;
1715 cmdline_fixed_string_t rxtxq;
1717 cmdline_fixed_string_t opname;
1721 cmd_config_rxtx_queue_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rxtx_queue *res = parsed_result;
1730 if (test_done == 0) {
1731 printf("Please stop forwarding first\n");
1735 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1738 if (port_is_started(res->portid) != 1) {
1739 printf("Please start port %u first\n", res->portid);
1743 if (!strcmp(res->rxtxq, "rxq"))
1745 else if (!strcmp(res->rxtxq, "txq"))
1748 printf("Unknown parameter\n");
1752 if (isrx && rx_queue_id_is_invalid(res->qid))
1754 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1757 if (!strcmp(res->opname, "start"))
1759 else if (!strcmp(res->opname, "stop"))
1762 printf("Unknown parameter\n");
1766 if (isstart && isrx)
1767 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1768 else if (!isstart && isrx)
1769 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1770 else if (isstart && !isrx)
1771 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1773 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1775 if (ret == -ENOTSUP)
1776 printf("Function not supported in PMD driver\n");
1779 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1781 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1782 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1783 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1785 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1786 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1787 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1791 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1792 .f = cmd_config_rxtx_queue_parsed,
1794 .help_str = "port X rxq|txq ID start|stop",
1796 (void *)&cmd_config_speed_all_port,
1797 (void *)&cmd_config_rxtx_queue_portid,
1798 (void *)&cmd_config_rxtx_queue_rxtxq,
1799 (void *)&cmd_config_rxtx_queue_qid,
1800 (void *)&cmd_config_rxtx_queue_opname,
1805 /* *** Configure RSS RETA *** */
1806 struct cmd_config_rss_reta {
1807 cmdline_fixed_string_t port;
1808 cmdline_fixed_string_t keyword;
1810 cmdline_fixed_string_t name;
1811 cmdline_fixed_string_t list_name;
1812 cmdline_fixed_string_t list_of_items;
1816 parse_reta_config(const char *str,
1817 struct rte_eth_rss_reta_entry64 *reta_conf,
1818 uint16_t nb_entries)
1822 uint16_t hash_index, idx, shift;
1825 const char *p, *p0 = str;
1832 unsigned long int_fld[_NUM_FLD];
1833 char *str_fld[_NUM_FLD];
1835 while ((p = strchr(p0,'(')) != NULL) {
1837 if((p0 = strchr(p,')')) == NULL)
1841 if(size >= sizeof(s))
1844 snprintf(s, sizeof(s), "%.*s", size, p);
1845 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1847 for (i = 0; i < _NUM_FLD; i++) {
1849 int_fld[i] = strtoul(str_fld[i], &end, 0);
1850 if (errno != 0 || end == str_fld[i] ||
1855 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1856 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1858 if (hash_index >= nb_entries) {
1859 printf("Invalid RETA hash index=%d\n", hash_index);
1863 idx = hash_index / RTE_RETA_GROUP_SIZE;
1864 shift = hash_index % RTE_RETA_GROUP_SIZE;
1865 reta_conf[idx].mask |= (1ULL << shift);
1866 reta_conf[idx].reta[shift] = nb_queue;
1873 cmd_set_rss_reta_parsed(void *parsed_result,
1874 __attribute__((unused)) struct cmdline *cl,
1875 __attribute__((unused)) void *data)
1878 struct rte_eth_dev_info dev_info;
1879 struct rte_eth_rss_reta_entry64 reta_conf[8];
1880 struct cmd_config_rss_reta *res = parsed_result;
1882 memset(&dev_info, 0, sizeof(dev_info));
1883 rte_eth_dev_info_get(res->port_id, &dev_info);
1884 if (dev_info.reta_size == 0) {
1885 printf("Redirection table size is 0 which is "
1886 "invalid for RSS\n");
1889 printf("The reta size of port %d is %u\n",
1890 res->port_id, dev_info.reta_size);
1891 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1892 printf("Currently do not support more than %u entries of "
1893 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1897 memset(reta_conf, 0, sizeof(reta_conf));
1898 if (!strcmp(res->list_name, "reta")) {
1899 if (parse_reta_config(res->list_of_items, reta_conf,
1900 dev_info.reta_size)) {
1901 printf("Invalid RSS Redirection Table "
1902 "config entered\n");
1905 ret = rte_eth_dev_rss_reta_update(res->port_id,
1906 reta_conf, dev_info.reta_size);
1908 printf("Bad redirection table parameter, "
1909 "return code = %d \n", ret);
1913 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1914 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1915 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1916 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1917 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1918 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1919 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1921 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1923 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1926 cmdline_parse_inst_t cmd_config_rss_reta = {
1927 .f = cmd_set_rss_reta_parsed,
1929 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1931 (void *)&cmd_config_rss_reta_port,
1932 (void *)&cmd_config_rss_reta_keyword,
1933 (void *)&cmd_config_rss_reta_port_id,
1934 (void *)&cmd_config_rss_reta_name,
1935 (void *)&cmd_config_rss_reta_list_name,
1936 (void *)&cmd_config_rss_reta_list_of_items,
1941 /* *** SHOW PORT RETA INFO *** */
1942 struct cmd_showport_reta {
1943 cmdline_fixed_string_t show;
1944 cmdline_fixed_string_t port;
1946 cmdline_fixed_string_t rss;
1947 cmdline_fixed_string_t reta;
1949 cmdline_fixed_string_t list_of_items;
1953 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1954 uint16_t nb_entries,
1958 const char *p, *p0 = str;
1962 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1965 p = strchr(p0, '(');
1969 p0 = strchr(p, ')');
1973 if (size >= sizeof(s)) {
1974 printf("The string size exceeds the internal buffer size\n");
1977 snprintf(s, sizeof(s), "%.*s", size, p);
1978 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1979 if (ret <= 0 || ret != num) {
1980 printf("The bits of masks do not match the number of "
1981 "reta entries: %u\n", num);
1984 for (i = 0; i < ret; i++)
1985 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1991 cmd_showport_reta_parsed(void *parsed_result,
1992 __attribute__((unused)) struct cmdline *cl,
1993 __attribute__((unused)) void *data)
1995 struct cmd_showport_reta *res = parsed_result;
1996 struct rte_eth_rss_reta_entry64 reta_conf[8];
1997 struct rte_eth_dev_info dev_info;
1999 memset(&dev_info, 0, sizeof(dev_info));
2000 rte_eth_dev_info_get(res->port_id, &dev_info);
2001 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2002 res->size > ETH_RSS_RETA_SIZE_512) {
2003 printf("Invalid redirection table size: %u\n", res->size);
2007 memset(reta_conf, 0, sizeof(reta_conf));
2008 if (showport_parse_reta_config(reta_conf, res->size,
2009 res->list_of_items) < 0) {
2010 printf("Invalid string: %s for reta masks\n",
2011 res->list_of_items);
2014 port_rss_reta_info(res->port_id, reta_conf, res->size);
2017 cmdline_parse_token_string_t cmd_showport_reta_show =
2018 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2019 cmdline_parse_token_string_t cmd_showport_reta_port =
2020 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2021 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2022 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2023 cmdline_parse_token_string_t cmd_showport_reta_rss =
2024 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2025 cmdline_parse_token_string_t cmd_showport_reta_reta =
2026 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2027 cmdline_parse_token_num_t cmd_showport_reta_size =
2028 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2029 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2030 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2031 list_of_items, NULL);
2033 cmdline_parse_inst_t cmd_showport_reta = {
2034 .f = cmd_showport_reta_parsed,
2036 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2038 (void *)&cmd_showport_reta_show,
2039 (void *)&cmd_showport_reta_port,
2040 (void *)&cmd_showport_reta_port_id,
2041 (void *)&cmd_showport_reta_rss,
2042 (void *)&cmd_showport_reta_reta,
2043 (void *)&cmd_showport_reta_size,
2044 (void *)&cmd_showport_reta_list_of_items,
2049 /* *** Show RSS hash configuration *** */
2050 struct cmd_showport_rss_hash {
2051 cmdline_fixed_string_t show;
2052 cmdline_fixed_string_t port;
2054 cmdline_fixed_string_t rss_hash;
2055 cmdline_fixed_string_t rss_type;
2056 cmdline_fixed_string_t key; /* optional argument */
2059 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2060 __attribute__((unused)) struct cmdline *cl,
2063 struct cmd_showport_rss_hash *res = parsed_result;
2065 port_rss_hash_conf_show(res->port_id, res->rss_type,
2066 show_rss_key != NULL);
2069 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2070 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2071 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2072 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2073 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2074 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2075 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2076 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2078 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2079 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2080 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2081 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2082 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2083 "ipv6-tcp-ex#ipv6-udp-ex");
2084 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2085 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2087 cmdline_parse_inst_t cmd_showport_rss_hash = {
2088 .f = cmd_showport_rss_hash_parsed,
2091 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2092 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2093 "ipv6-sctp|ipv6-other|l2-payload|"
2094 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2096 (void *)&cmd_showport_rss_hash_show,
2097 (void *)&cmd_showport_rss_hash_port,
2098 (void *)&cmd_showport_rss_hash_port_id,
2099 (void *)&cmd_showport_rss_hash_rss_hash,
2100 (void *)&cmd_showport_rss_hash_rss_hash_info,
2105 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2106 .f = cmd_showport_rss_hash_parsed,
2109 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2110 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2111 "ipv6-sctp|ipv6-other|l2-payload|"
2112 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2114 (void *)&cmd_showport_rss_hash_show,
2115 (void *)&cmd_showport_rss_hash_port,
2116 (void *)&cmd_showport_rss_hash_port_id,
2117 (void *)&cmd_showport_rss_hash_rss_hash,
2118 (void *)&cmd_showport_rss_hash_rss_hash_info,
2119 (void *)&cmd_showport_rss_hash_rss_key,
2124 /* *** Configure DCB *** */
2125 struct cmd_config_dcb {
2126 cmdline_fixed_string_t port;
2127 cmdline_fixed_string_t config;
2129 cmdline_fixed_string_t dcb;
2130 cmdline_fixed_string_t vt;
2131 cmdline_fixed_string_t vt_en;
2133 cmdline_fixed_string_t pfc;
2134 cmdline_fixed_string_t pfc_en;
2138 cmd_config_dcb_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_config_dcb *res = parsed_result;
2143 portid_t port_id = res->port_id;
2144 struct rte_port *port;
2148 port = &ports[port_id];
2149 /** Check if the port is not started **/
2150 if (port->port_status != RTE_PORT_STOPPED) {
2151 printf("Please stop port %d first\n", port_id);
2155 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2156 printf("The invalid number of traffic class,"
2157 " only 4 or 8 allowed.\n");
2161 if (nb_fwd_lcores < res->num_tcs) {
2162 printf("nb_cores shouldn't be less than number of TCs.\n");
2165 if (!strncmp(res->pfc_en, "on", 2))
2170 /* DCB in VT mode */
2171 if (!strncmp(res->vt_en, "on", 2))
2172 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2173 (enum rte_eth_nb_tcs)res->num_tcs,
2176 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2177 (enum rte_eth_nb_tcs)res->num_tcs,
2182 printf("Cannot initialize network ports.\n");
2186 cmd_reconfig_device_queue(port_id, 1, 1);
2189 cmdline_parse_token_string_t cmd_config_dcb_port =
2190 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2191 cmdline_parse_token_string_t cmd_config_dcb_config =
2192 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2193 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2194 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2195 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2196 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2197 cmdline_parse_token_string_t cmd_config_dcb_vt =
2198 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2199 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2200 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2201 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2202 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2203 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2204 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2205 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2206 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2208 cmdline_parse_inst_t cmd_config_dcb = {
2209 .f = cmd_config_dcb_parsed,
2211 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2213 (void *)&cmd_config_dcb_port,
2214 (void *)&cmd_config_dcb_config,
2215 (void *)&cmd_config_dcb_port_id,
2216 (void *)&cmd_config_dcb_dcb,
2217 (void *)&cmd_config_dcb_vt,
2218 (void *)&cmd_config_dcb_vt_en,
2219 (void *)&cmd_config_dcb_num_tcs,
2220 (void *)&cmd_config_dcb_pfc,
2221 (void *)&cmd_config_dcb_pfc_en,
2226 /* *** configure number of packets per burst *** */
2227 struct cmd_config_burst {
2228 cmdline_fixed_string_t port;
2229 cmdline_fixed_string_t keyword;
2230 cmdline_fixed_string_t all;
2231 cmdline_fixed_string_t name;
2236 cmd_config_burst_parsed(void *parsed_result,
2237 __attribute__((unused)) struct cmdline *cl,
2238 __attribute__((unused)) void *data)
2240 struct cmd_config_burst *res = parsed_result;
2242 if (!all_ports_stopped()) {
2243 printf("Please stop all ports first\n");
2247 if (!strcmp(res->name, "burst")) {
2248 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2249 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2252 nb_pkt_per_burst = res->value;
2254 printf("Unknown parameter\n");
2260 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2263 cmdline_parse_token_string_t cmd_config_burst_port =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2265 cmdline_parse_token_string_t cmd_config_burst_keyword =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2267 cmdline_parse_token_string_t cmd_config_burst_all =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2269 cmdline_parse_token_string_t cmd_config_burst_name =
2270 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2271 cmdline_parse_token_num_t cmd_config_burst_value =
2272 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2274 cmdline_parse_inst_t cmd_config_burst = {
2275 .f = cmd_config_burst_parsed,
2277 .help_str = "port config all burst value",
2279 (void *)&cmd_config_burst_port,
2280 (void *)&cmd_config_burst_keyword,
2281 (void *)&cmd_config_burst_all,
2282 (void *)&cmd_config_burst_name,
2283 (void *)&cmd_config_burst_value,
2288 /* *** configure rx/tx queues *** */
2289 struct cmd_config_thresh {
2290 cmdline_fixed_string_t port;
2291 cmdline_fixed_string_t keyword;
2292 cmdline_fixed_string_t all;
2293 cmdline_fixed_string_t name;
2298 cmd_config_thresh_parsed(void *parsed_result,
2299 __attribute__((unused)) struct cmdline *cl,
2300 __attribute__((unused)) void *data)
2302 struct cmd_config_thresh *res = parsed_result;
2304 if (!all_ports_stopped()) {
2305 printf("Please stop all ports first\n");
2309 if (!strcmp(res->name, "txpt"))
2310 tx_pthresh = res->value;
2311 else if(!strcmp(res->name, "txht"))
2312 tx_hthresh = res->value;
2313 else if(!strcmp(res->name, "txwt"))
2314 tx_wthresh = res->value;
2315 else if(!strcmp(res->name, "rxpt"))
2316 rx_pthresh = res->value;
2317 else if(!strcmp(res->name, "rxht"))
2318 rx_hthresh = res->value;
2319 else if(!strcmp(res->name, "rxwt"))
2320 rx_wthresh = res->value;
2322 printf("Unknown parameter\n");
2328 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2331 cmdline_parse_token_string_t cmd_config_thresh_port =
2332 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2333 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2334 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2335 cmdline_parse_token_string_t cmd_config_thresh_all =
2336 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2337 cmdline_parse_token_string_t cmd_config_thresh_name =
2338 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2339 "txpt#txht#txwt#rxpt#rxht#rxwt");
2340 cmdline_parse_token_num_t cmd_config_thresh_value =
2341 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2343 cmdline_parse_inst_t cmd_config_thresh = {
2344 .f = cmd_config_thresh_parsed,
2346 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2348 (void *)&cmd_config_thresh_port,
2349 (void *)&cmd_config_thresh_keyword,
2350 (void *)&cmd_config_thresh_all,
2351 (void *)&cmd_config_thresh_name,
2352 (void *)&cmd_config_thresh_value,
2357 /* *** configure free/rs threshold *** */
2358 struct cmd_config_threshold {
2359 cmdline_fixed_string_t port;
2360 cmdline_fixed_string_t keyword;
2361 cmdline_fixed_string_t all;
2362 cmdline_fixed_string_t name;
2367 cmd_config_threshold_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2369 __attribute__((unused)) void *data)
2371 struct cmd_config_threshold *res = parsed_result;
2373 if (!all_ports_stopped()) {
2374 printf("Please stop all ports first\n");
2378 if (!strcmp(res->name, "txfreet"))
2379 tx_free_thresh = res->value;
2380 else if (!strcmp(res->name, "txrst"))
2381 tx_rs_thresh = res->value;
2382 else if (!strcmp(res->name, "rxfreet"))
2383 rx_free_thresh = res->value;
2385 printf("Unknown parameter\n");
2391 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2394 cmdline_parse_token_string_t cmd_config_threshold_port =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2396 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2399 cmdline_parse_token_string_t cmd_config_threshold_all =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2401 cmdline_parse_token_string_t cmd_config_threshold_name =
2402 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2403 "txfreet#txrst#rxfreet");
2404 cmdline_parse_token_num_t cmd_config_threshold_value =
2405 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2407 cmdline_parse_inst_t cmd_config_threshold = {
2408 .f = cmd_config_threshold_parsed,
2410 .help_str = "port config all txfreet|txrst|rxfreet value",
2412 (void *)&cmd_config_threshold_port,
2413 (void *)&cmd_config_threshold_keyword,
2414 (void *)&cmd_config_threshold_all,
2415 (void *)&cmd_config_threshold_name,
2416 (void *)&cmd_config_threshold_value,
2422 struct cmd_stop_result {
2423 cmdline_fixed_string_t stop;
2426 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2427 __attribute__((unused)) struct cmdline *cl,
2428 __attribute__((unused)) void *data)
2430 stop_packet_forwarding();
2433 cmdline_parse_token_string_t cmd_stop_stop =
2434 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2436 cmdline_parse_inst_t cmd_stop = {
2437 .f = cmd_stop_parsed,
2439 .help_str = "stop - stop packet forwarding",
2441 (void *)&cmd_stop_stop,
2446 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2449 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2450 unsigned int *parsed_items, int check_unique_values)
2452 unsigned int nb_item;
2460 * First parse all items in the list and store their value.
2465 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2467 if ((c >= '0') && (c <= '9')) {
2468 value = (unsigned int) (value * 10 + (c - '0'));
2473 printf("character %c is not a decimal digit\n", c);
2477 printf("No valid value before comma\n");
2480 if (nb_item < max_items) {
2481 parsed_items[nb_item] = value;
2487 if (nb_item >= max_items) {
2488 printf("Number of %s = %u > %u (maximum items)\n",
2489 item_name, nb_item + 1, max_items);
2492 parsed_items[nb_item++] = value;
2493 if (! check_unique_values)
2497 * Then, check that all values in the list are differents.
2498 * No optimization here...
2500 for (i = 0; i < nb_item; i++) {
2501 for (j = i + 1; j < nb_item; j++) {
2502 if (parsed_items[j] == parsed_items[i]) {
2503 printf("duplicated %s %u at index %u and %u\n",
2504 item_name, parsed_items[i], i, j);
2512 struct cmd_set_list_result {
2513 cmdline_fixed_string_t cmd_keyword;
2514 cmdline_fixed_string_t list_name;
2515 cmdline_fixed_string_t list_of_items;
2518 static void cmd_set_list_parsed(void *parsed_result,
2519 __attribute__((unused)) struct cmdline *cl,
2520 __attribute__((unused)) void *data)
2522 struct cmd_set_list_result *res;
2524 unsigned int lcorelist[RTE_MAX_LCORE];
2525 unsigned int portlist[RTE_MAX_ETHPORTS];
2527 unsigned int nb_item;
2529 if (test_done == 0) {
2530 printf("Please stop forwarding first\n");
2534 res = parsed_result;
2535 if (!strcmp(res->list_name, "corelist")) {
2536 nb_item = parse_item_list(res->list_of_items, "core",
2538 parsed_items.lcorelist, 1);
2540 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2545 if (!strcmp(res->list_name, "portlist")) {
2546 nb_item = parse_item_list(res->list_of_items, "port",
2548 parsed_items.portlist, 1);
2550 set_fwd_ports_list(parsed_items.portlist, nb_item);
2556 cmdline_parse_token_string_t cmd_set_list_keyword =
2557 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2559 cmdline_parse_token_string_t cmd_set_list_name =
2560 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2561 "corelist#portlist");
2562 cmdline_parse_token_string_t cmd_set_list_of_items =
2563 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2566 cmdline_parse_inst_t cmd_set_fwd_list = {
2567 .f = cmd_set_list_parsed,
2569 .help_str = "set corelist|portlist x[,y]*",
2571 (void *)&cmd_set_list_keyword,
2572 (void *)&cmd_set_list_name,
2573 (void *)&cmd_set_list_of_items,
2578 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2580 struct cmd_setmask_result {
2581 cmdline_fixed_string_t set;
2582 cmdline_fixed_string_t mask;
2586 static void cmd_set_mask_parsed(void *parsed_result,
2587 __attribute__((unused)) struct cmdline *cl,
2588 __attribute__((unused)) void *data)
2590 struct cmd_setmask_result *res = parsed_result;
2592 if (test_done == 0) {
2593 printf("Please stop forwarding first\n");
2596 if (!strcmp(res->mask, "coremask")) {
2597 set_fwd_lcores_mask(res->hexavalue);
2599 } else if (!strcmp(res->mask, "portmask")) {
2600 set_fwd_ports_mask(res->hexavalue);
2605 cmdline_parse_token_string_t cmd_setmask_set =
2606 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2607 cmdline_parse_token_string_t cmd_setmask_mask =
2608 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2609 "coremask#portmask");
2610 cmdline_parse_token_num_t cmd_setmask_value =
2611 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2613 cmdline_parse_inst_t cmd_set_fwd_mask = {
2614 .f = cmd_set_mask_parsed,
2616 .help_str = "set coremask|portmask hexadecimal value",
2618 (void *)&cmd_setmask_set,
2619 (void *)&cmd_setmask_mask,
2620 (void *)&cmd_setmask_value,
2626 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2628 struct cmd_set_result {
2629 cmdline_fixed_string_t set;
2630 cmdline_fixed_string_t what;
2634 static void cmd_set_parsed(void *parsed_result,
2635 __attribute__((unused)) struct cmdline *cl,
2636 __attribute__((unused)) void *data)
2638 struct cmd_set_result *res = parsed_result;
2639 if (!strcmp(res->what, "nbport")) {
2640 set_fwd_ports_number(res->value);
2642 } else if (!strcmp(res->what, "nbcore")) {
2643 set_fwd_lcores_number(res->value);
2645 } else if (!strcmp(res->what, "burst"))
2646 set_nb_pkt_per_burst(res->value);
2647 else if (!strcmp(res->what, "verbose"))
2648 set_verbose_level(res->value);
2651 cmdline_parse_token_string_t cmd_set_set =
2652 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2653 cmdline_parse_token_string_t cmd_set_what =
2654 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2655 "nbport#nbcore#burst#verbose");
2656 cmdline_parse_token_num_t cmd_set_value =
2657 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2659 cmdline_parse_inst_t cmd_set_numbers = {
2660 .f = cmd_set_parsed,
2662 .help_str = "set nbport|nbcore|burst|verbose value",
2664 (void *)&cmd_set_set,
2665 (void *)&cmd_set_what,
2666 (void *)&cmd_set_value,
2671 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2673 struct cmd_set_txpkts_result {
2674 cmdline_fixed_string_t cmd_keyword;
2675 cmdline_fixed_string_t txpkts;
2676 cmdline_fixed_string_t seg_lengths;
2680 cmd_set_txpkts_parsed(void *parsed_result,
2681 __attribute__((unused)) struct cmdline *cl,
2682 __attribute__((unused)) void *data)
2684 struct cmd_set_txpkts_result *res;
2685 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2686 unsigned int nb_segs;
2688 res = parsed_result;
2689 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2690 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2692 set_tx_pkt_segments(seg_lengths, nb_segs);
2695 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2696 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2697 cmd_keyword, "set");
2698 cmdline_parse_token_string_t cmd_set_txpkts_name =
2699 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2701 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2702 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2705 cmdline_parse_inst_t cmd_set_txpkts = {
2706 .f = cmd_set_txpkts_parsed,
2708 .help_str = "set txpkts x[,y]*",
2710 (void *)&cmd_set_txpkts_keyword,
2711 (void *)&cmd_set_txpkts_name,
2712 (void *)&cmd_set_txpkts_lengths,
2717 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2719 struct cmd_set_txsplit_result {
2720 cmdline_fixed_string_t cmd_keyword;
2721 cmdline_fixed_string_t txsplit;
2722 cmdline_fixed_string_t mode;
2726 cmd_set_txsplit_parsed(void *parsed_result,
2727 __attribute__((unused)) struct cmdline *cl,
2728 __attribute__((unused)) void *data)
2730 struct cmd_set_txsplit_result *res;
2732 res = parsed_result;
2733 set_tx_pkt_split(res->mode);
2736 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2737 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2738 cmd_keyword, "set");
2739 cmdline_parse_token_string_t cmd_set_txsplit_name =
2740 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2741 txsplit, "txsplit");
2742 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2743 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2746 cmdline_parse_inst_t cmd_set_txsplit = {
2747 .f = cmd_set_txsplit_parsed,
2749 .help_str = "set txsplit on|off|rand",
2751 (void *)&cmd_set_txsplit_keyword,
2752 (void *)&cmd_set_txsplit_name,
2753 (void *)&cmd_set_txsplit_mode,
2758 /* *** CONFIG TX QUEUE FLAGS *** */
2760 struct cmd_config_txqflags_result {
2761 cmdline_fixed_string_t port;
2762 cmdline_fixed_string_t config;
2763 cmdline_fixed_string_t all;
2764 cmdline_fixed_string_t what;
2768 static void cmd_config_txqflags_parsed(void *parsed_result,
2769 __attribute__((unused)) struct cmdline *cl,
2770 __attribute__((unused)) void *data)
2772 struct cmd_config_txqflags_result *res = parsed_result;
2774 if (!all_ports_stopped()) {
2775 printf("Please stop all ports first\n");
2779 if (strcmp(res->what, "txqflags")) {
2780 printf("Unknown parameter\n");
2784 if (res->hexvalue >= 0) {
2785 txq_flags = res->hexvalue;
2787 printf("txqflags must be >= 0\n");
2793 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2796 cmdline_parse_token_string_t cmd_config_txqflags_port =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2799 cmdline_parse_token_string_t cmd_config_txqflags_config =
2800 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2802 cmdline_parse_token_string_t cmd_config_txqflags_all =
2803 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2805 cmdline_parse_token_string_t cmd_config_txqflags_what =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2808 cmdline_parse_token_num_t cmd_config_txqflags_value =
2809 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2812 cmdline_parse_inst_t cmd_config_txqflags = {
2813 .f = cmd_config_txqflags_parsed,
2815 .help_str = "port config all txqflags value",
2817 (void *)&cmd_config_txqflags_port,
2818 (void *)&cmd_config_txqflags_config,
2819 (void *)&cmd_config_txqflags_all,
2820 (void *)&cmd_config_txqflags_what,
2821 (void *)&cmd_config_txqflags_value,
2826 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2827 struct cmd_rx_vlan_filter_all_result {
2828 cmdline_fixed_string_t rx_vlan;
2829 cmdline_fixed_string_t what;
2830 cmdline_fixed_string_t all;
2835 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2836 __attribute__((unused)) struct cmdline *cl,
2837 __attribute__((unused)) void *data)
2839 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2841 if (!strcmp(res->what, "add"))
2842 rx_vlan_all_filter_set(res->port_id, 1);
2844 rx_vlan_all_filter_set(res->port_id, 0);
2847 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2848 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2849 rx_vlan, "rx_vlan");
2850 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2851 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2853 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2854 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2856 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2857 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2860 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2861 .f = cmd_rx_vlan_filter_all_parsed,
2863 .help_str = "add/remove all identifiers to/from the set of VLAN "
2864 "Identifiers filtered by a port",
2866 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2867 (void *)&cmd_rx_vlan_filter_all_what,
2868 (void *)&cmd_rx_vlan_filter_all_all,
2869 (void *)&cmd_rx_vlan_filter_all_portid,
2874 /* *** VLAN OFFLOAD SET ON A PORT *** */
2875 struct cmd_vlan_offload_result {
2876 cmdline_fixed_string_t vlan;
2877 cmdline_fixed_string_t set;
2878 cmdline_fixed_string_t vlan_type;
2879 cmdline_fixed_string_t what;
2880 cmdline_fixed_string_t on;
2881 cmdline_fixed_string_t port_id;
2885 cmd_vlan_offload_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2890 struct cmd_vlan_offload_result *res = parsed_result;
2893 portid_t port_id = 0;
2897 len = strnlen(str, STR_TOKEN_SIZE);
2899 /* Get port_id first */
2907 tmp = strtoul(str, NULL, 0);
2908 /* If port_id greater that what portid_t can represent, return */
2909 if(tmp >= RTE_MAX_ETHPORTS)
2911 port_id = (portid_t)tmp;
2913 if (!strcmp(res->on, "on"))
2918 if (!strcmp(res->what, "strip"))
2919 rx_vlan_strip_set(port_id, on);
2920 else if(!strcmp(res->what, "stripq")){
2921 uint16_t queue_id = 0;
2923 /* No queue_id, return */
2925 printf("must specify (port,queue_id)\n");
2928 tmp = strtoul(str + i + 1, NULL, 0);
2929 /* If queue_id greater that what 16-bits can represent, return */
2933 queue_id = (uint16_t)tmp;
2934 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2936 else if (!strcmp(res->what, "filter"))
2937 rx_vlan_filter_set(port_id, on);
2939 vlan_extend_set(port_id, on);
2944 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2947 cmdline_parse_token_string_t cmd_vlan_offload_set =
2948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2950 cmdline_parse_token_string_t cmd_vlan_offload_what =
2951 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2952 what, "strip#filter#qinq#stripq");
2953 cmdline_parse_token_string_t cmd_vlan_offload_on =
2954 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2956 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2957 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2960 cmdline_parse_inst_t cmd_vlan_offload = {
2961 .f = cmd_vlan_offload_parsed,
2963 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2964 " qinq(extended) for both rx/tx sides ",
2966 (void *)&cmd_vlan_offload_vlan,
2967 (void *)&cmd_vlan_offload_set,
2968 (void *)&cmd_vlan_offload_what,
2969 (void *)&cmd_vlan_offload_on,
2970 (void *)&cmd_vlan_offload_portid,
2975 /* *** VLAN TPID SET ON A PORT *** */
2976 struct cmd_vlan_tpid_result {
2977 cmdline_fixed_string_t vlan;
2978 cmdline_fixed_string_t set;
2979 cmdline_fixed_string_t vlan_type;
2980 cmdline_fixed_string_t what;
2986 cmd_vlan_tpid_parsed(void *parsed_result,
2987 __attribute__((unused)) struct cmdline *cl,
2988 __attribute__((unused)) void *data)
2990 struct cmd_vlan_tpid_result *res = parsed_result;
2991 enum rte_vlan_type vlan_type;
2993 if (!strcmp(res->vlan_type, "inner"))
2994 vlan_type = ETH_VLAN_TYPE_INNER;
2995 else if (!strcmp(res->vlan_type, "outer"))
2996 vlan_type = ETH_VLAN_TYPE_OUTER;
2998 printf("Unknown vlan type\n");
3001 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3004 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3005 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3007 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3008 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3010 cmdline_parse_token_string_t cmd_vlan_type =
3011 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3012 vlan_type, "inner#outer");
3013 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3014 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3016 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3017 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3019 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3020 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3023 cmdline_parse_inst_t cmd_vlan_tpid = {
3024 .f = cmd_vlan_tpid_parsed,
3026 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3029 (void *)&cmd_vlan_tpid_vlan,
3030 (void *)&cmd_vlan_tpid_set,
3031 (void *)&cmd_vlan_type,
3032 (void *)&cmd_vlan_tpid_what,
3033 (void *)&cmd_vlan_tpid_tpid,
3034 (void *)&cmd_vlan_tpid_portid,
3039 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3040 struct cmd_rx_vlan_filter_result {
3041 cmdline_fixed_string_t rx_vlan;
3042 cmdline_fixed_string_t what;
3048 cmd_rx_vlan_filter_parsed(void *parsed_result,
3049 __attribute__((unused)) struct cmdline *cl,
3050 __attribute__((unused)) void *data)
3052 struct cmd_rx_vlan_filter_result *res = parsed_result;
3054 if (!strcmp(res->what, "add"))
3055 rx_vft_set(res->port_id, res->vlan_id, 1);
3057 rx_vft_set(res->port_id, res->vlan_id, 0);
3060 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3061 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3062 rx_vlan, "rx_vlan");
3063 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3064 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3066 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3067 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3069 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3070 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3073 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3074 .f = cmd_rx_vlan_filter_parsed,
3076 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3077 "Identifiers filtered by a port",
3079 (void *)&cmd_rx_vlan_filter_rx_vlan,
3080 (void *)&cmd_rx_vlan_filter_what,
3081 (void *)&cmd_rx_vlan_filter_vlanid,
3082 (void *)&cmd_rx_vlan_filter_portid,
3087 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3088 struct cmd_tx_vlan_set_result {
3089 cmdline_fixed_string_t tx_vlan;
3090 cmdline_fixed_string_t set;
3096 cmd_tx_vlan_set_parsed(void *parsed_result,
3097 __attribute__((unused)) struct cmdline *cl,
3098 __attribute__((unused)) void *data)
3100 struct cmd_tx_vlan_set_result *res = parsed_result;
3102 tx_vlan_set(res->port_id, res->vlan_id);
3105 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3106 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3107 tx_vlan, "tx_vlan");
3108 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3109 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3111 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3112 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3114 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3115 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3118 cmdline_parse_inst_t cmd_tx_vlan_set = {
3119 .f = cmd_tx_vlan_set_parsed,
3121 .help_str = "enable hardware insertion of a single VLAN header "
3122 "with a given TAG Identifier in packets sent on a port",
3124 (void *)&cmd_tx_vlan_set_tx_vlan,
3125 (void *)&cmd_tx_vlan_set_set,
3126 (void *)&cmd_tx_vlan_set_portid,
3127 (void *)&cmd_tx_vlan_set_vlanid,
3132 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3133 struct cmd_tx_vlan_set_qinq_result {
3134 cmdline_fixed_string_t tx_vlan;
3135 cmdline_fixed_string_t set;
3138 uint16_t vlan_id_outer;
3142 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3143 __attribute__((unused)) struct cmdline *cl,
3144 __attribute__((unused)) void *data)
3146 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3148 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3151 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3152 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3153 tx_vlan, "tx_vlan");
3154 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3155 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3157 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3158 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3160 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3161 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3163 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3164 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3165 vlan_id_outer, UINT16);
3167 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3168 .f = cmd_tx_vlan_set_qinq_parsed,
3170 .help_str = "enable hardware insertion of double VLAN header "
3171 "with given TAG Identifiers in packets sent on a port",
3173 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3174 (void *)&cmd_tx_vlan_set_qinq_set,
3175 (void *)&cmd_tx_vlan_set_qinq_portid,
3176 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3177 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3182 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3183 struct cmd_tx_vlan_set_pvid_result {
3184 cmdline_fixed_string_t tx_vlan;
3185 cmdline_fixed_string_t set;
3186 cmdline_fixed_string_t pvid;
3189 cmdline_fixed_string_t mode;
3193 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3194 __attribute__((unused)) struct cmdline *cl,
3195 __attribute__((unused)) void *data)
3197 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3199 if (strcmp(res->mode, "on") == 0)
3200 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3202 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3205 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3206 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3207 tx_vlan, "tx_vlan");
3208 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3209 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3211 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3212 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3214 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3215 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3217 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3218 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3224 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3225 .f = cmd_tx_vlan_set_pvid_parsed,
3227 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3229 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3230 (void *)&cmd_tx_vlan_set_pvid_set,
3231 (void *)&cmd_tx_vlan_set_pvid_pvid,
3232 (void *)&cmd_tx_vlan_set_pvid_port_id,
3233 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3234 (void *)&cmd_tx_vlan_set_pvid_mode,
3239 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3240 struct cmd_tx_vlan_reset_result {
3241 cmdline_fixed_string_t tx_vlan;
3242 cmdline_fixed_string_t reset;
3247 cmd_tx_vlan_reset_parsed(void *parsed_result,
3248 __attribute__((unused)) struct cmdline *cl,
3249 __attribute__((unused)) void *data)
3251 struct cmd_tx_vlan_reset_result *res = parsed_result;
3253 tx_vlan_reset(res->port_id);
3256 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3257 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3258 tx_vlan, "tx_vlan");
3259 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3260 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3262 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3263 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3266 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3267 .f = cmd_tx_vlan_reset_parsed,
3269 .help_str = "disable hardware insertion of a VLAN header in packets "
3272 (void *)&cmd_tx_vlan_reset_tx_vlan,
3273 (void *)&cmd_tx_vlan_reset_reset,
3274 (void *)&cmd_tx_vlan_reset_portid,
3280 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3281 struct cmd_csum_result {
3282 cmdline_fixed_string_t csum;
3283 cmdline_fixed_string_t mode;
3284 cmdline_fixed_string_t proto;
3285 cmdline_fixed_string_t hwsw;
3290 csum_show(int port_id)
3292 struct rte_eth_dev_info dev_info;
3295 ol_flags = ports[port_id].tx_ol_flags;
3296 printf("Parse tunnel is %s\n",
3297 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3298 printf("IP checksum offload is %s\n",
3299 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3300 printf("UDP checksum offload is %s\n",
3301 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3302 printf("TCP checksum offload is %s\n",
3303 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3304 printf("SCTP checksum offload is %s\n",
3305 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3306 printf("Outer-Ip checksum offload is %s\n",
3307 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3309 /* display warnings if configuration is not supported by the NIC */
3310 rte_eth_dev_info_get(port_id, &dev_info);
3311 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3312 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3313 printf("Warning: hardware IP checksum enabled but not "
3314 "supported by port %d\n", port_id);
3316 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3317 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3318 printf("Warning: hardware UDP checksum enabled but not "
3319 "supported by port %d\n", port_id);
3321 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3322 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3323 printf("Warning: hardware TCP checksum enabled but not "
3324 "supported by port %d\n", port_id);
3326 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3327 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3328 printf("Warning: hardware SCTP checksum enabled but not "
3329 "supported by port %d\n", port_id);
3331 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3332 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3333 printf("Warning: hardware outer IP checksum enabled but not "
3334 "supported by port %d\n", port_id);
3339 cmd_csum_parsed(void *parsed_result,
3340 __attribute__((unused)) struct cmdline *cl,
3341 __attribute__((unused)) void *data)
3343 struct cmd_csum_result *res = parsed_result;
3347 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3348 printf("invalid port %d\n", res->port_id);
3352 if (!strcmp(res->mode, "set")) {
3354 if (!strcmp(res->hwsw, "hw"))
3357 if (!strcmp(res->proto, "ip")) {
3358 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3359 } else if (!strcmp(res->proto, "udp")) {
3360 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3361 } else if (!strcmp(res->proto, "tcp")) {
3362 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3363 } else if (!strcmp(res->proto, "sctp")) {
3364 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3365 } else if (!strcmp(res->proto, "outer-ip")) {
3366 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3370 ports[res->port_id].tx_ol_flags |= mask;
3372 ports[res->port_id].tx_ol_flags &= (~mask);
3374 csum_show(res->port_id);
3377 cmdline_parse_token_string_t cmd_csum_csum =
3378 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3380 cmdline_parse_token_string_t cmd_csum_mode =
3381 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3383 cmdline_parse_token_string_t cmd_csum_proto =
3384 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3385 proto, "ip#tcp#udp#sctp#outer-ip");
3386 cmdline_parse_token_string_t cmd_csum_hwsw =
3387 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3389 cmdline_parse_token_num_t cmd_csum_portid =
3390 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3393 cmdline_parse_inst_t cmd_csum_set = {
3394 .f = cmd_csum_parsed,
3396 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3397 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3399 (void *)&cmd_csum_csum,
3400 (void *)&cmd_csum_mode,
3401 (void *)&cmd_csum_proto,
3402 (void *)&cmd_csum_hwsw,
3403 (void *)&cmd_csum_portid,
3408 cmdline_parse_token_string_t cmd_csum_mode_show =
3409 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3412 cmdline_parse_inst_t cmd_csum_show = {
3413 .f = cmd_csum_parsed,
3415 .help_str = "show checksum offload configuration: csum show <port>",
3417 (void *)&cmd_csum_csum,
3418 (void *)&cmd_csum_mode_show,
3419 (void *)&cmd_csum_portid,
3424 /* Enable/disable tunnel parsing */
3425 struct cmd_csum_tunnel_result {
3426 cmdline_fixed_string_t csum;
3427 cmdline_fixed_string_t parse;
3428 cmdline_fixed_string_t onoff;
3433 cmd_csum_tunnel_parsed(void *parsed_result,
3434 __attribute__((unused)) struct cmdline *cl,
3435 __attribute__((unused)) void *data)
3437 struct cmd_csum_tunnel_result *res = parsed_result;
3439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3442 if (!strcmp(res->onoff, "on"))
3443 ports[res->port_id].tx_ol_flags |=
3444 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3446 ports[res->port_id].tx_ol_flags &=
3447 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3449 csum_show(res->port_id);
3452 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3453 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3455 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3456 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3457 parse, "parse_tunnel");
3458 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3459 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3461 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3462 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3465 cmdline_parse_inst_t cmd_csum_tunnel = {
3466 .f = cmd_csum_tunnel_parsed,
3468 .help_str = "enable/disable parsing of tunnels for csum engine: "
3469 "csum parse_tunnel on|off <tx-port>",
3471 (void *)&cmd_csum_tunnel_csum,
3472 (void *)&cmd_csum_tunnel_parse,
3473 (void *)&cmd_csum_tunnel_onoff,
3474 (void *)&cmd_csum_tunnel_portid,
3479 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3480 struct cmd_tso_set_result {
3481 cmdline_fixed_string_t tso;
3482 cmdline_fixed_string_t mode;
3488 cmd_tso_set_parsed(void *parsed_result,
3489 __attribute__((unused)) struct cmdline *cl,
3490 __attribute__((unused)) void *data)
3492 struct cmd_tso_set_result *res = parsed_result;
3493 struct rte_eth_dev_info dev_info;
3495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3498 if (!strcmp(res->mode, "set"))
3499 ports[res->port_id].tso_segsz = res->tso_segsz;
3501 if (ports[res->port_id].tso_segsz == 0)
3502 printf("TSO is disabled\n");
3504 printf("TSO segment size is %d\n",
3505 ports[res->port_id].tso_segsz);
3507 /* display warnings if configuration is not supported by the NIC */
3508 rte_eth_dev_info_get(res->port_id, &dev_info);
3509 if ((ports[res->port_id].tso_segsz != 0) &&
3510 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3511 printf("Warning: TSO enabled but not "
3512 "supported by port %d\n", res->port_id);
3516 cmdline_parse_token_string_t cmd_tso_set_tso =
3517 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3519 cmdline_parse_token_string_t cmd_tso_set_mode =
3520 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3522 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3523 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3525 cmdline_parse_token_num_t cmd_tso_set_portid =
3526 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3529 cmdline_parse_inst_t cmd_tso_set = {
3530 .f = cmd_tso_set_parsed,
3532 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3533 "tso set <tso_segsz> <port>",
3535 (void *)&cmd_tso_set_tso,
3536 (void *)&cmd_tso_set_mode,
3537 (void *)&cmd_tso_set_tso_segsz,
3538 (void *)&cmd_tso_set_portid,
3543 cmdline_parse_token_string_t cmd_tso_show_mode =
3544 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3548 cmdline_parse_inst_t cmd_tso_show = {
3549 .f = cmd_tso_set_parsed,
3551 .help_str = "Show TSO segment size for csum engine: "
3554 (void *)&cmd_tso_set_tso,
3555 (void *)&cmd_tso_show_mode,
3556 (void *)&cmd_tso_set_portid,
3561 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3562 struct cmd_set_flush_rx {
3563 cmdline_fixed_string_t set;
3564 cmdline_fixed_string_t flush_rx;
3565 cmdline_fixed_string_t mode;
3569 cmd_set_flush_rx_parsed(void *parsed_result,
3570 __attribute__((unused)) struct cmdline *cl,
3571 __attribute__((unused)) void *data)
3573 struct cmd_set_flush_rx *res = parsed_result;
3574 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3577 cmdline_parse_token_string_t cmd_setflushrx_set =
3578 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3580 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3581 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3582 flush_rx, "flush_rx");
3583 cmdline_parse_token_string_t cmd_setflushrx_mode =
3584 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3588 cmdline_parse_inst_t cmd_set_flush_rx = {
3589 .f = cmd_set_flush_rx_parsed,
3590 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3593 (void *)&cmd_setflushrx_set,
3594 (void *)&cmd_setflushrx_flush_rx,
3595 (void *)&cmd_setflushrx_mode,
3600 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3601 struct cmd_set_link_check {
3602 cmdline_fixed_string_t set;
3603 cmdline_fixed_string_t link_check;
3604 cmdline_fixed_string_t mode;
3608 cmd_set_link_check_parsed(void *parsed_result,
3609 __attribute__((unused)) struct cmdline *cl,
3610 __attribute__((unused)) void *data)
3612 struct cmd_set_link_check *res = parsed_result;
3613 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3616 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3617 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3619 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3620 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3621 link_check, "link_check");
3622 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3623 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3627 cmdline_parse_inst_t cmd_set_link_check = {
3628 .f = cmd_set_link_check_parsed,
3629 .help_str = "set link_check on|off: enable/disable link status check "
3630 "when starting/stopping a port",
3633 (void *)&cmd_setlinkcheck_set,
3634 (void *)&cmd_setlinkcheck_link_check,
3635 (void *)&cmd_setlinkcheck_mode,
3640 #ifdef RTE_NIC_BYPASS
3641 /* *** SET NIC BYPASS MODE *** */
3642 struct cmd_set_bypass_mode_result {
3643 cmdline_fixed_string_t set;
3644 cmdline_fixed_string_t bypass;
3645 cmdline_fixed_string_t mode;
3646 cmdline_fixed_string_t value;
3651 cmd_set_bypass_mode_parsed(void *parsed_result,
3652 __attribute__((unused)) struct cmdline *cl,
3653 __attribute__((unused)) void *data)
3655 struct cmd_set_bypass_mode_result *res = parsed_result;
3656 portid_t port_id = res->port_id;
3657 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3659 if (!bypass_is_supported(port_id))
3662 if (!strcmp(res->value, "bypass"))
3663 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3664 else if (!strcmp(res->value, "isolate"))
3665 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3667 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3669 /* Set the bypass mode for the relevant port. */
3670 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3671 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3675 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3676 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3678 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3679 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3681 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3682 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3684 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3685 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3686 value, "normal#bypass#isolate");
3687 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3688 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3691 cmdline_parse_inst_t cmd_set_bypass_mode = {
3692 .f = cmd_set_bypass_mode_parsed,
3693 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3694 "Set the NIC bypass mode for port_id",
3697 (void *)&cmd_setbypass_mode_set,
3698 (void *)&cmd_setbypass_mode_bypass,
3699 (void *)&cmd_setbypass_mode_mode,
3700 (void *)&cmd_setbypass_mode_value,
3701 (void *)&cmd_setbypass_mode_port,
3706 /* *** SET NIC BYPASS EVENT *** */
3707 struct cmd_set_bypass_event_result {
3708 cmdline_fixed_string_t set;
3709 cmdline_fixed_string_t bypass;
3710 cmdline_fixed_string_t event;
3711 cmdline_fixed_string_t event_value;
3712 cmdline_fixed_string_t mode;
3713 cmdline_fixed_string_t mode_value;
3718 cmd_set_bypass_event_parsed(void *parsed_result,
3719 __attribute__((unused)) struct cmdline *cl,
3720 __attribute__((unused)) void *data)
3723 struct cmd_set_bypass_event_result *res = parsed_result;
3724 portid_t port_id = res->port_id;
3725 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3726 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3728 if (!bypass_is_supported(port_id))
3731 if (!strcmp(res->event_value, "timeout"))
3732 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3733 else if (!strcmp(res->event_value, "os_on"))
3734 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3735 else if (!strcmp(res->event_value, "os_off"))
3736 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3737 else if (!strcmp(res->event_value, "power_on"))
3738 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3739 else if (!strcmp(res->event_value, "power_off"))
3740 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3742 bypass_event = RTE_BYPASS_EVENT_NONE;
3744 if (!strcmp(res->mode_value, "bypass"))
3745 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3746 else if (!strcmp(res->mode_value, "isolate"))
3747 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3749 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3751 /* Set the watchdog timeout. */
3752 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3755 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3756 (rc = rte_eth_dev_wd_timeout_store(port_id,
3757 bypass_timeout)) != 0) {
3758 printf("Failed to set timeout value %u "
3759 "for port %d, errto code: %d.\n",
3760 bypass_timeout, port_id, rc);
3764 /* Set the bypass event to transition to bypass mode. */
3765 if (0 != rte_eth_dev_bypass_event_store(port_id,
3766 bypass_event, bypass_mode)) {
3767 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3772 cmdline_parse_token_string_t cmd_setbypass_event_set =
3773 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3775 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3776 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3778 cmdline_parse_token_string_t cmd_setbypass_event_event =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3781 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3783 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3784 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3787 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3789 mode_value, "normal#bypass#isolate");
3790 cmdline_parse_token_num_t cmd_setbypass_event_port =
3791 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3794 cmdline_parse_inst_t cmd_set_bypass_event = {
3795 .f = cmd_set_bypass_event_parsed,
3796 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3797 "mode (normal|bypass|isolate) (port_id): "
3798 "Set the NIC bypass event mode for port_id",
3801 (void *)&cmd_setbypass_event_set,
3802 (void *)&cmd_setbypass_event_bypass,
3803 (void *)&cmd_setbypass_event_event,
3804 (void *)&cmd_setbypass_event_event_value,
3805 (void *)&cmd_setbypass_event_mode,
3806 (void *)&cmd_setbypass_event_mode_value,
3807 (void *)&cmd_setbypass_event_port,
3813 /* *** SET NIC BYPASS TIMEOUT *** */
3814 struct cmd_set_bypass_timeout_result {
3815 cmdline_fixed_string_t set;
3816 cmdline_fixed_string_t bypass;
3817 cmdline_fixed_string_t timeout;
3818 cmdline_fixed_string_t value;
3822 cmd_set_bypass_timeout_parsed(void *parsed_result,
3823 __attribute__((unused)) struct cmdline *cl,
3824 __attribute__((unused)) void *data)
3826 struct cmd_set_bypass_timeout_result *res = parsed_result;
3828 if (!strcmp(res->value, "1.5"))
3829 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3830 else if (!strcmp(res->value, "2"))
3831 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3832 else if (!strcmp(res->value, "3"))
3833 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3834 else if (!strcmp(res->value, "4"))
3835 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3836 else if (!strcmp(res->value, "8"))
3837 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3838 else if (!strcmp(res->value, "16"))
3839 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3840 else if (!strcmp(res->value, "32"))
3841 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3843 bypass_timeout = RTE_BYPASS_TMT_OFF;
3846 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3847 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3849 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3852 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3854 timeout, "timeout");
3855 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3857 value, "0#1.5#2#3#4#8#16#32");
3859 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3860 .f = cmd_set_bypass_timeout_parsed,
3861 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3862 "Set the NIC bypass watchdog timeout",
3865 (void *)&cmd_setbypass_timeout_set,
3866 (void *)&cmd_setbypass_timeout_bypass,
3867 (void *)&cmd_setbypass_timeout_timeout,
3868 (void *)&cmd_setbypass_timeout_value,
3873 /* *** SHOW NIC BYPASS MODE *** */
3874 struct cmd_show_bypass_config_result {
3875 cmdline_fixed_string_t show;
3876 cmdline_fixed_string_t bypass;
3877 cmdline_fixed_string_t config;
3882 cmd_show_bypass_config_parsed(void *parsed_result,
3883 __attribute__((unused)) struct cmdline *cl,
3884 __attribute__((unused)) void *data)
3886 struct cmd_show_bypass_config_result *res = parsed_result;
3887 uint32_t event_mode;
3888 uint32_t bypass_mode;
3889 portid_t port_id = res->port_id;
3890 uint32_t timeout = bypass_timeout;
3893 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3894 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3895 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3896 {"UNKNOWN", "normal", "bypass", "isolate"};
3897 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3904 int num_events = (sizeof events) / (sizeof events[0]);
3906 if (!bypass_is_supported(port_id))
3909 /* Display the bypass mode.*/
3910 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3911 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3915 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3916 bypass_mode = RTE_BYPASS_MODE_NONE;
3918 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3921 /* Display the bypass timeout.*/
3922 if (!RTE_BYPASS_TMT_VALID(timeout))
3923 timeout = RTE_BYPASS_TMT_OFF;
3925 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3927 /* Display the bypass events and associated modes. */
3928 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3930 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3931 printf("\tFailed to get bypass mode for event = %s\n",
3934 if (!RTE_BYPASS_MODE_VALID(event_mode))
3935 event_mode = RTE_BYPASS_MODE_NONE;
3937 printf("\tbypass event: %-16s = %s\n", events[i],
3943 cmdline_parse_token_string_t cmd_showbypass_config_show =
3944 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3946 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3947 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3949 cmdline_parse_token_string_t cmd_showbypass_config_config =
3950 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3952 cmdline_parse_token_num_t cmd_showbypass_config_port =
3953 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3956 cmdline_parse_inst_t cmd_show_bypass_config = {
3957 .f = cmd_show_bypass_config_parsed,
3958 .help_str = "show bypass config (port_id): "
3959 "Show the NIC bypass config for port_id",
3962 (void *)&cmd_showbypass_config_show,
3963 (void *)&cmd_showbypass_config_bypass,
3964 (void *)&cmd_showbypass_config_config,
3965 (void *)&cmd_showbypass_config_port,
3971 #ifdef RTE_LIBRTE_PMD_BOND
3972 /* *** SET BONDING MODE *** */
3973 struct cmd_set_bonding_mode_result {
3974 cmdline_fixed_string_t set;
3975 cmdline_fixed_string_t bonding;
3976 cmdline_fixed_string_t mode;
3981 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3982 __attribute__((unused)) struct cmdline *cl,
3983 __attribute__((unused)) void *data)
3985 struct cmd_set_bonding_mode_result *res = parsed_result;
3986 portid_t port_id = res->port_id;
3988 /* Set the bonding mode for the relevant port. */
3989 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3990 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3993 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3996 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3997 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3998 bonding, "bonding");
3999 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4002 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4003 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4005 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4006 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4009 cmdline_parse_inst_t cmd_set_bonding_mode = {
4010 .f = cmd_set_bonding_mode_parsed,
4011 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4014 (void *) &cmd_setbonding_mode_set,
4015 (void *) &cmd_setbonding_mode_bonding,
4016 (void *) &cmd_setbonding_mode_mode,
4017 (void *) &cmd_setbonding_mode_value,
4018 (void *) &cmd_setbonding_mode_port,
4023 /* *** SET BALANCE XMIT POLICY *** */
4024 struct cmd_set_bonding_balance_xmit_policy_result {
4025 cmdline_fixed_string_t set;
4026 cmdline_fixed_string_t bonding;
4027 cmdline_fixed_string_t balance_xmit_policy;
4029 cmdline_fixed_string_t policy;
4032 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4033 __attribute__((unused)) struct cmdline *cl,
4034 __attribute__((unused)) void *data)
4036 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4037 portid_t port_id = res->port_id;
4040 if (!strcmp(res->policy, "l2")) {
4041 policy = BALANCE_XMIT_POLICY_LAYER2;
4042 } else if (!strcmp(res->policy, "l23")) {
4043 policy = BALANCE_XMIT_POLICY_LAYER23;
4044 } else if (!strcmp(res->policy, "l34")) {
4045 policy = BALANCE_XMIT_POLICY_LAYER34;
4047 printf("\t Invalid xmit policy selection");
4051 /* Set the bonding mode for the relevant port. */
4052 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4053 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4058 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4061 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4062 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4063 bonding, "bonding");
4064 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4065 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4066 balance_xmit_policy, "balance_xmit_policy");
4067 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4068 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4070 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4071 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4072 policy, "l2#l23#l34");
4074 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4075 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4076 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4079 (void *)&cmd_setbonding_balance_xmit_policy_set,
4080 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4081 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4082 (void *)&cmd_setbonding_balance_xmit_policy_port,
4083 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4088 /* *** SHOW NIC BONDING CONFIGURATION *** */
4089 struct cmd_show_bonding_config_result {
4090 cmdline_fixed_string_t show;
4091 cmdline_fixed_string_t bonding;
4092 cmdline_fixed_string_t config;
4096 static void cmd_show_bonding_config_parsed(void *parsed_result,
4097 __attribute__((unused)) struct cmdline *cl,
4098 __attribute__((unused)) void *data)
4100 struct cmd_show_bonding_config_result *res = parsed_result;
4102 uint8_t slaves[RTE_MAX_ETHPORTS];
4103 int num_slaves, num_active_slaves;
4106 portid_t port_id = res->port_id;
4108 /* Display the bonding mode.*/
4109 bonding_mode = rte_eth_bond_mode_get(port_id);
4110 if (bonding_mode < 0) {
4111 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4114 printf("\tBonding mode: %d\n", bonding_mode);
4116 if (bonding_mode == BONDING_MODE_BALANCE) {
4117 int balance_xmit_policy;
4119 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4120 if (balance_xmit_policy < 0) {
4121 printf("\tFailed to get balance xmit policy for port = %d\n",
4125 printf("\tBalance Xmit Policy: ");
4127 switch (balance_xmit_policy) {
4128 case BALANCE_XMIT_POLICY_LAYER2:
4129 printf("BALANCE_XMIT_POLICY_LAYER2");
4131 case BALANCE_XMIT_POLICY_LAYER23:
4132 printf("BALANCE_XMIT_POLICY_LAYER23");
4134 case BALANCE_XMIT_POLICY_LAYER34:
4135 printf("BALANCE_XMIT_POLICY_LAYER34");
4142 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4144 if (num_slaves < 0) {
4145 printf("\tFailed to get slave list for port = %d\n", port_id);
4148 if (num_slaves > 0) {
4149 printf("\tSlaves (%d): [", num_slaves);
4150 for (i = 0; i < num_slaves - 1; i++)
4151 printf("%d ", slaves[i]);
4153 printf("%d]\n", slaves[num_slaves - 1]);
4155 printf("\tSlaves: []\n");
4159 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4162 if (num_active_slaves < 0) {
4163 printf("\tFailed to get active slave list for port = %d\n", port_id);
4166 if (num_active_slaves > 0) {
4167 printf("\tActive Slaves (%d): [", num_active_slaves);
4168 for (i = 0; i < num_active_slaves - 1; i++)
4169 printf("%d ", slaves[i]);
4171 printf("%d]\n", slaves[num_active_slaves - 1]);
4174 printf("\tActive Slaves: []\n");
4178 primary_id = rte_eth_bond_primary_get(port_id);
4179 if (primary_id < 0) {
4180 printf("\tFailed to get primary slave for port = %d\n", port_id);
4183 printf("\tPrimary: [%d]\n", primary_id);
4187 cmdline_parse_token_string_t cmd_showbonding_config_show =
4188 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4190 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4191 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4192 bonding, "bonding");
4193 cmdline_parse_token_string_t cmd_showbonding_config_config =
4194 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4196 cmdline_parse_token_num_t cmd_showbonding_config_port =
4197 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4200 cmdline_parse_inst_t cmd_show_bonding_config = {
4201 .f = cmd_show_bonding_config_parsed,
4202 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4205 (void *)&cmd_showbonding_config_show,
4206 (void *)&cmd_showbonding_config_bonding,
4207 (void *)&cmd_showbonding_config_config,
4208 (void *)&cmd_showbonding_config_port,
4213 /* *** SET BONDING PRIMARY *** */
4214 struct cmd_set_bonding_primary_result {
4215 cmdline_fixed_string_t set;
4216 cmdline_fixed_string_t bonding;
4217 cmdline_fixed_string_t primary;
4222 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4223 __attribute__((unused)) struct cmdline *cl,
4224 __attribute__((unused)) void *data)
4226 struct cmd_set_bonding_primary_result *res = parsed_result;
4227 portid_t master_port_id = res->port_id;
4228 portid_t slave_port_id = res->slave_id;
4230 /* Set the primary slave for a bonded device. */
4231 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4232 printf("\t Failed to set primary slave for port = %d.\n",
4239 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4242 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4243 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4244 bonding, "bonding");
4245 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4246 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4247 primary, "primary");
4248 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4249 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4251 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4252 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4255 cmdline_parse_inst_t cmd_set_bonding_primary = {
4256 .f = cmd_set_bonding_primary_parsed,
4257 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4260 (void *)&cmd_setbonding_primary_set,
4261 (void *)&cmd_setbonding_primary_bonding,
4262 (void *)&cmd_setbonding_primary_primary,
4263 (void *)&cmd_setbonding_primary_slave,
4264 (void *)&cmd_setbonding_primary_port,
4269 /* *** ADD SLAVE *** */
4270 struct cmd_add_bonding_slave_result {
4271 cmdline_fixed_string_t add;
4272 cmdline_fixed_string_t bonding;
4273 cmdline_fixed_string_t slave;
4278 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4279 __attribute__((unused)) struct cmdline *cl,
4280 __attribute__((unused)) void *data)
4282 struct cmd_add_bonding_slave_result *res = parsed_result;
4283 portid_t master_port_id = res->port_id;
4284 portid_t slave_port_id = res->slave_id;
4286 /* Set the primary slave for a bonded device. */
4287 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4288 printf("\t Failed to add slave %d to master port = %d.\n",
4289 slave_port_id, master_port_id);
4293 set_port_slave_flag(slave_port_id);
4296 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4297 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4299 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4300 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4301 bonding, "bonding");
4302 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4303 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4305 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4306 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4308 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4309 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4312 cmdline_parse_inst_t cmd_add_bonding_slave = {
4313 .f = cmd_add_bonding_slave_parsed,
4314 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4317 (void *)&cmd_addbonding_slave_add,
4318 (void *)&cmd_addbonding_slave_bonding,
4319 (void *)&cmd_addbonding_slave_slave,
4320 (void *)&cmd_addbonding_slave_slaveid,
4321 (void *)&cmd_addbonding_slave_port,
4326 /* *** REMOVE SLAVE *** */
4327 struct cmd_remove_bonding_slave_result {
4328 cmdline_fixed_string_t remove;
4329 cmdline_fixed_string_t bonding;
4330 cmdline_fixed_string_t slave;
4335 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4336 __attribute__((unused)) struct cmdline *cl,
4337 __attribute__((unused)) void *data)
4339 struct cmd_remove_bonding_slave_result *res = parsed_result;
4340 portid_t master_port_id = res->port_id;
4341 portid_t slave_port_id = res->slave_id;
4343 /* Set the primary slave for a bonded device. */
4344 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4345 printf("\t Failed to remove slave %d from master port = %d.\n",
4346 slave_port_id, master_port_id);
4350 clear_port_slave_flag(slave_port_id);
4353 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4354 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4356 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4357 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4358 bonding, "bonding");
4359 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4360 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4362 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4363 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4365 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4366 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4369 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4370 .f = cmd_remove_bonding_slave_parsed,
4371 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4374 (void *)&cmd_removebonding_slave_remove,
4375 (void *)&cmd_removebonding_slave_bonding,
4376 (void *)&cmd_removebonding_slave_slave,
4377 (void *)&cmd_removebonding_slave_slaveid,
4378 (void *)&cmd_removebonding_slave_port,
4383 /* *** CREATE BONDED DEVICE *** */
4384 struct cmd_create_bonded_device_result {
4385 cmdline_fixed_string_t create;
4386 cmdline_fixed_string_t bonded;
4387 cmdline_fixed_string_t device;
4392 static int bond_dev_num = 0;
4394 static void cmd_create_bonded_device_parsed(void *parsed_result,
4395 __attribute__((unused)) struct cmdline *cl,
4396 __attribute__((unused)) void *data)
4398 struct cmd_create_bonded_device_result *res = parsed_result;
4399 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4402 if (test_done == 0) {
4403 printf("Please stop forwarding first\n");
4407 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4410 /* Create a new bonded device. */
4411 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4413 printf("\t Failed to create bonded device.\n");
4416 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4419 /* Update number of ports */
4420 nb_ports = rte_eth_dev_count();
4421 reconfig(port_id, res->socket);
4422 rte_eth_promiscuous_enable(port_id);
4423 ports[port_id].enabled = 1;
4428 cmdline_parse_token_string_t cmd_createbonded_device_create =
4429 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4431 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4432 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4434 cmdline_parse_token_string_t cmd_createbonded_device_device =
4435 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4437 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4438 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4440 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4441 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4444 cmdline_parse_inst_t cmd_create_bonded_device = {
4445 .f = cmd_create_bonded_device_parsed,
4446 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4449 (void *)&cmd_createbonded_device_create,
4450 (void *)&cmd_createbonded_device_bonded,
4451 (void *)&cmd_createbonded_device_device,
4452 (void *)&cmd_createbonded_device_mode,
4453 (void *)&cmd_createbonded_device_socket,
4458 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4459 struct cmd_set_bond_mac_addr_result {
4460 cmdline_fixed_string_t set;
4461 cmdline_fixed_string_t bonding;
4462 cmdline_fixed_string_t mac_addr;
4464 struct ether_addr address;
4467 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4468 __attribute__((unused)) struct cmdline *cl,
4469 __attribute__((unused)) void *data)
4471 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4474 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4477 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4479 /* check the return value and print it if is < 0 */
4481 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4484 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4485 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4486 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4487 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4489 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4492 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4493 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4494 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4497 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4498 .f = cmd_set_bond_mac_addr_parsed,
4500 .help_str = "set bonding mac_addr (port_id) (address): ",
4502 (void *)&cmd_set_bond_mac_addr_set,
4503 (void *)&cmd_set_bond_mac_addr_bonding,
4504 (void *)&cmd_set_bond_mac_addr_mac,
4505 (void *)&cmd_set_bond_mac_addr_portnum,
4506 (void *)&cmd_set_bond_mac_addr_addr,
4512 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4513 struct cmd_set_bond_mon_period_result {
4514 cmdline_fixed_string_t set;
4515 cmdline_fixed_string_t bonding;
4516 cmdline_fixed_string_t mon_period;
4521 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4522 __attribute__((unused)) struct cmdline *cl,
4523 __attribute__((unused)) void *data)
4525 struct cmd_set_bond_mon_period_result *res = parsed_result;
4528 if (res->port_num >= nb_ports) {
4529 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4533 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4535 /* check the return value and print it if is < 0 */
4537 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4540 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4541 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4543 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4544 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4545 bonding, "bonding");
4546 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4547 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4548 mon_period, "mon_period");
4549 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4550 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4552 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4553 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4556 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4557 .f = cmd_set_bond_mon_period_parsed,
4559 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4561 (void *)&cmd_set_bond_mon_period_set,
4562 (void *)&cmd_set_bond_mon_period_bonding,
4563 (void *)&cmd_set_bond_mon_period_mon_period,
4564 (void *)&cmd_set_bond_mon_period_portnum,
4565 (void *)&cmd_set_bond_mon_period_period_ms,
4570 #endif /* RTE_LIBRTE_PMD_BOND */
4572 /* *** SET FORWARDING MODE *** */
4573 struct cmd_set_fwd_mode_result {
4574 cmdline_fixed_string_t set;
4575 cmdline_fixed_string_t fwd;
4576 cmdline_fixed_string_t mode;
4579 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4580 __attribute__((unused)) struct cmdline *cl,
4581 __attribute__((unused)) void *data)
4583 struct cmd_set_fwd_mode_result *res = parsed_result;
4586 set_pkt_forwarding_mode(res->mode);
4589 cmdline_parse_token_string_t cmd_setfwd_set =
4590 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4591 cmdline_parse_token_string_t cmd_setfwd_fwd =
4592 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4593 cmdline_parse_token_string_t cmd_setfwd_mode =
4594 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4595 "" /* defined at init */);
4597 cmdline_parse_inst_t cmd_set_fwd_mode = {
4598 .f = cmd_set_fwd_mode_parsed,
4600 .help_str = NULL, /* defined at init */
4602 (void *)&cmd_setfwd_set,
4603 (void *)&cmd_setfwd_fwd,
4604 (void *)&cmd_setfwd_mode,
4609 static void cmd_set_fwd_mode_init(void)
4612 static char token[128];
4613 static char help[256];
4614 cmdline_parse_token_string_t *token_struct;
4616 modes = list_pkt_forwarding_modes();
4617 snprintf(help, sizeof help, "set fwd %s - "
4618 "set packet forwarding mode", modes);
4619 cmd_set_fwd_mode.help_str = help;
4621 /* string token separator is # */
4622 for (c = token; *modes != '\0'; modes++)
4627 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4628 token_struct->string_data.str = token;
4631 /* *** SET RETRY FORWARDING MODE *** */
4632 struct cmd_set_fwd_retry_mode_result {
4633 cmdline_fixed_string_t set;
4634 cmdline_fixed_string_t fwd;
4635 cmdline_fixed_string_t mode;
4636 cmdline_fixed_string_t retry;
4639 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4640 __attribute__((unused)) struct cmdline *cl,
4641 __attribute__((unused)) void *data)
4643 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4646 set_pkt_forwarding_mode(res->mode);
4649 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4650 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4652 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4653 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4655 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4656 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4658 "" /* defined at init */);
4659 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4660 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4663 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4664 .f = cmd_set_fwd_retry_mode_parsed,
4666 .help_str = NULL, /* defined at init */
4668 (void *)&cmd_setfwd_retry_set,
4669 (void *)&cmd_setfwd_retry_fwd,
4670 (void *)&cmd_setfwd_retry_mode,
4671 (void *)&cmd_setfwd_retry_retry,
4676 static void cmd_set_fwd_retry_mode_init(void)
4679 static char token[128];
4680 static char help[256];
4681 cmdline_parse_token_string_t *token_struct;
4683 modes = list_pkt_forwarding_retry_modes();
4684 snprintf(help, sizeof(help), "set fwd %s retry - "
4685 "set packet forwarding mode with retry", modes);
4686 cmd_set_fwd_retry_mode.help_str = help;
4688 /* string token separator is # */
4689 for (c = token; *modes != '\0'; modes++)
4694 token_struct = (cmdline_parse_token_string_t *)
4695 cmd_set_fwd_retry_mode.tokens[2];
4696 token_struct->string_data.str = token;
4699 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4700 struct cmd_set_burst_tx_retry_result {
4701 cmdline_fixed_string_t set;
4702 cmdline_fixed_string_t burst;
4703 cmdline_fixed_string_t tx;
4704 cmdline_fixed_string_t delay;
4706 cmdline_fixed_string_t retry;
4710 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4711 __attribute__((unused)) struct cmdline *cl,
4712 __attribute__((unused)) void *data)
4714 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4716 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4717 && !strcmp(res->tx, "tx")) {
4718 if (!strcmp(res->delay, "delay"))
4719 burst_tx_delay_time = res->time;
4720 if (!strcmp(res->retry, "retry"))
4721 burst_tx_retry_num = res->retry_num;
4726 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4727 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4728 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4729 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4731 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4732 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4733 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4734 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4735 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4736 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4737 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4738 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4739 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4740 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4742 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4743 .f = cmd_set_burst_tx_retry_parsed,
4744 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4746 (void *)&cmd_set_burst_tx_retry_set,
4747 (void *)&cmd_set_burst_tx_retry_burst,
4748 (void *)&cmd_set_burst_tx_retry_tx,
4749 (void *)&cmd_set_burst_tx_retry_delay,
4750 (void *)&cmd_set_burst_tx_retry_time,
4751 (void *)&cmd_set_burst_tx_retry_retry,
4752 (void *)&cmd_set_burst_tx_retry_retry_num,
4757 /* *** SET PROMISC MODE *** */
4758 struct cmd_set_promisc_mode_result {
4759 cmdline_fixed_string_t set;
4760 cmdline_fixed_string_t promisc;
4761 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4762 uint8_t port_num; /* valid if "allports" argument == 0 */
4763 cmdline_fixed_string_t mode;
4766 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4767 __attribute__((unused)) struct cmdline *cl,
4770 struct cmd_set_promisc_mode_result *res = parsed_result;
4774 if (!strcmp(res->mode, "on"))
4781 FOREACH_PORT(i, ports) {
4783 rte_eth_promiscuous_enable(i);
4785 rte_eth_promiscuous_disable(i);
4790 rte_eth_promiscuous_enable(res->port_num);
4792 rte_eth_promiscuous_disable(res->port_num);
4796 cmdline_parse_token_string_t cmd_setpromisc_set =
4797 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4798 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4799 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4801 cmdline_parse_token_string_t cmd_setpromisc_portall =
4802 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4804 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4805 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4807 cmdline_parse_token_string_t cmd_setpromisc_mode =
4808 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4811 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4812 .f = cmd_set_promisc_mode_parsed,
4814 .help_str = "set promisc all on|off: set promisc mode for all ports",
4816 (void *)&cmd_setpromisc_set,
4817 (void *)&cmd_setpromisc_promisc,
4818 (void *)&cmd_setpromisc_portall,
4819 (void *)&cmd_setpromisc_mode,
4824 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4825 .f = cmd_set_promisc_mode_parsed,
4827 .help_str = "set promisc X on|off: set promisc mode on port X",
4829 (void *)&cmd_setpromisc_set,
4830 (void *)&cmd_setpromisc_promisc,
4831 (void *)&cmd_setpromisc_portnum,
4832 (void *)&cmd_setpromisc_mode,
4837 /* *** SET ALLMULTI MODE *** */
4838 struct cmd_set_allmulti_mode_result {
4839 cmdline_fixed_string_t set;
4840 cmdline_fixed_string_t allmulti;
4841 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4842 uint8_t port_num; /* valid if "allports" argument == 0 */
4843 cmdline_fixed_string_t mode;
4846 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4847 __attribute__((unused)) struct cmdline *cl,
4850 struct cmd_set_allmulti_mode_result *res = parsed_result;
4854 if (!strcmp(res->mode, "on"))
4861 FOREACH_PORT(i, ports) {
4863 rte_eth_allmulticast_enable(i);
4865 rte_eth_allmulticast_disable(i);
4870 rte_eth_allmulticast_enable(res->port_num);
4872 rte_eth_allmulticast_disable(res->port_num);
4876 cmdline_parse_token_string_t cmd_setallmulti_set =
4877 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4878 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4879 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4881 cmdline_parse_token_string_t cmd_setallmulti_portall =
4882 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4884 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4885 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4887 cmdline_parse_token_string_t cmd_setallmulti_mode =
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4891 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4892 .f = cmd_set_allmulti_mode_parsed,
4894 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4896 (void *)&cmd_setallmulti_set,
4897 (void *)&cmd_setallmulti_allmulti,
4898 (void *)&cmd_setallmulti_portall,
4899 (void *)&cmd_setallmulti_mode,
4904 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4905 .f = cmd_set_allmulti_mode_parsed,
4907 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4909 (void *)&cmd_setallmulti_set,
4910 (void *)&cmd_setallmulti_allmulti,
4911 (void *)&cmd_setallmulti_portnum,
4912 (void *)&cmd_setallmulti_mode,
4917 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4918 struct cmd_link_flow_ctrl_set_result {
4919 cmdline_fixed_string_t set;
4920 cmdline_fixed_string_t flow_ctrl;
4921 cmdline_fixed_string_t rx;
4922 cmdline_fixed_string_t rx_lfc_mode;
4923 cmdline_fixed_string_t tx;
4924 cmdline_fixed_string_t tx_lfc_mode;
4925 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4926 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4927 cmdline_fixed_string_t autoneg_str;
4928 cmdline_fixed_string_t autoneg;
4929 cmdline_fixed_string_t hw_str;
4930 uint32_t high_water;
4931 cmdline_fixed_string_t lw_str;
4933 cmdline_fixed_string_t pt_str;
4934 uint16_t pause_time;
4935 cmdline_fixed_string_t xon_str;
4940 cmdline_parse_token_string_t cmd_lfc_set_set =
4941 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4943 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4944 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4945 flow_ctrl, "flow_ctrl");
4946 cmdline_parse_token_string_t cmd_lfc_set_rx =
4947 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4949 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4950 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4951 rx_lfc_mode, "on#off");
4952 cmdline_parse_token_string_t cmd_lfc_set_tx =
4953 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4955 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4956 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4957 tx_lfc_mode, "on#off");
4958 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4959 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4960 hw_str, "high_water");
4961 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4962 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4963 high_water, UINT32);
4964 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4965 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4966 lw_str, "low_water");
4967 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4968 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4970 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4971 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4972 pt_str, "pause_time");
4973 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4974 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4975 pause_time, UINT16);
4976 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4977 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4978 xon_str, "send_xon");
4979 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4980 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4982 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4984 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4985 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4986 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4987 mac_ctrl_frame_fwd_mode, "on#off");
4988 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4990 autoneg_str, "autoneg");
4991 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4992 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4994 cmdline_parse_token_num_t cmd_lfc_set_portid =
4995 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4998 /* forward declaration */
5000 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5003 cmdline_parse_inst_t cmd_link_flow_control_set = {
5004 .f = cmd_link_flow_ctrl_set_parsed,
5006 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
5007 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
5008 autoneg on|off port_id",
5010 (void *)&cmd_lfc_set_set,
5011 (void *)&cmd_lfc_set_flow_ctrl,
5012 (void *)&cmd_lfc_set_rx,
5013 (void *)&cmd_lfc_set_rx_mode,
5014 (void *)&cmd_lfc_set_tx,
5015 (void *)&cmd_lfc_set_tx_mode,
5016 (void *)&cmd_lfc_set_high_water,
5017 (void *)&cmd_lfc_set_low_water,
5018 (void *)&cmd_lfc_set_pause_time,
5019 (void *)&cmd_lfc_set_send_xon,
5020 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5021 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5022 (void *)&cmd_lfc_set_autoneg_str,
5023 (void *)&cmd_lfc_set_autoneg,
5024 (void *)&cmd_lfc_set_portid,
5029 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5030 .f = cmd_link_flow_ctrl_set_parsed,
5031 .data = (void *)&cmd_link_flow_control_set_rx,
5032 .help_str = "Change rx flow control parameter: set flow_ctrl "
5033 "rx on|off port_id",
5035 (void *)&cmd_lfc_set_set,
5036 (void *)&cmd_lfc_set_flow_ctrl,
5037 (void *)&cmd_lfc_set_rx,
5038 (void *)&cmd_lfc_set_rx_mode,
5039 (void *)&cmd_lfc_set_portid,
5044 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5045 .f = cmd_link_flow_ctrl_set_parsed,
5046 .data = (void *)&cmd_link_flow_control_set_tx,
5047 .help_str = "Change tx flow control parameter: set flow_ctrl "
5048 "tx on|off port_id",
5050 (void *)&cmd_lfc_set_set,
5051 (void *)&cmd_lfc_set_flow_ctrl,
5052 (void *)&cmd_lfc_set_tx,
5053 (void *)&cmd_lfc_set_tx_mode,
5054 (void *)&cmd_lfc_set_portid,
5059 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5060 .f = cmd_link_flow_ctrl_set_parsed,
5061 .data = (void *)&cmd_link_flow_control_set_hw,
5062 .help_str = "Change high water flow control parameter: set flow_ctrl "
5063 "high_water value port_id",
5065 (void *)&cmd_lfc_set_set,
5066 (void *)&cmd_lfc_set_flow_ctrl,
5067 (void *)&cmd_lfc_set_high_water_str,
5068 (void *)&cmd_lfc_set_high_water,
5069 (void *)&cmd_lfc_set_portid,
5074 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5075 .f = cmd_link_flow_ctrl_set_parsed,
5076 .data = (void *)&cmd_link_flow_control_set_lw,
5077 .help_str = "Change low water flow control parameter: set flow_ctrl "
5078 "low_water value port_id",
5080 (void *)&cmd_lfc_set_set,
5081 (void *)&cmd_lfc_set_flow_ctrl,
5082 (void *)&cmd_lfc_set_low_water_str,
5083 (void *)&cmd_lfc_set_low_water,
5084 (void *)&cmd_lfc_set_portid,
5089 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5090 .f = cmd_link_flow_ctrl_set_parsed,
5091 .data = (void *)&cmd_link_flow_control_set_pt,
5092 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5093 "pause_time value port_id",
5095 (void *)&cmd_lfc_set_set,
5096 (void *)&cmd_lfc_set_flow_ctrl,
5097 (void *)&cmd_lfc_set_pause_time_str,
5098 (void *)&cmd_lfc_set_pause_time,
5099 (void *)&cmd_lfc_set_portid,
5104 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5105 .f = cmd_link_flow_ctrl_set_parsed,
5106 .data = (void *)&cmd_link_flow_control_set_xon,
5107 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5108 "send_xon value port_id",
5110 (void *)&cmd_lfc_set_set,
5111 (void *)&cmd_lfc_set_flow_ctrl,
5112 (void *)&cmd_lfc_set_send_xon_str,
5113 (void *)&cmd_lfc_set_send_xon,
5114 (void *)&cmd_lfc_set_portid,
5119 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5120 .f = cmd_link_flow_ctrl_set_parsed,
5121 .data = (void *)&cmd_link_flow_control_set_macfwd,
5122 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5123 "mac_ctrl_frame_fwd on|off port_id",
5125 (void *)&cmd_lfc_set_set,
5126 (void *)&cmd_lfc_set_flow_ctrl,
5127 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5128 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5129 (void *)&cmd_lfc_set_portid,
5134 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5135 .f = cmd_link_flow_ctrl_set_parsed,
5136 .data = (void *)&cmd_link_flow_control_set_autoneg,
5137 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5138 "autoneg on|off port_id",
5140 (void *)&cmd_lfc_set_set,
5141 (void *)&cmd_lfc_set_flow_ctrl,
5142 (void *)&cmd_lfc_set_autoneg_str,
5143 (void *)&cmd_lfc_set_autoneg,
5144 (void *)&cmd_lfc_set_portid,
5150 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5151 __attribute__((unused)) struct cmdline *cl,
5154 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5155 cmdline_parse_inst_t *cmd = data;
5156 struct rte_eth_fc_conf fc_conf;
5162 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5163 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5164 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5165 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5167 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5168 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5171 /* Partial command line, retrieve current configuration */
5173 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5175 printf("cannot get current flow ctrl parameters, return"
5176 "code = %d\n", ret);
5180 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5181 (fc_conf.mode == RTE_FC_FULL))
5183 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5184 (fc_conf.mode == RTE_FC_FULL))
5188 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5189 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5191 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5192 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5194 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5196 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5197 fc_conf.high_water = res->high_water;
5199 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5200 fc_conf.low_water = res->low_water;
5202 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5203 fc_conf.pause_time = res->pause_time;
5205 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5206 fc_conf.send_xon = res->send_xon;
5208 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5209 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5210 fc_conf.mac_ctrl_frame_fwd = 1;
5212 fc_conf.mac_ctrl_frame_fwd = 0;
5215 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5216 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5218 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5220 printf("bad flow contrl parameter, return code = %d \n", ret);
5223 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5224 struct cmd_priority_flow_ctrl_set_result {
5225 cmdline_fixed_string_t set;
5226 cmdline_fixed_string_t pfc_ctrl;
5227 cmdline_fixed_string_t rx;
5228 cmdline_fixed_string_t rx_pfc_mode;
5229 cmdline_fixed_string_t tx;
5230 cmdline_fixed_string_t tx_pfc_mode;
5231 uint32_t high_water;
5233 uint16_t pause_time;
5239 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5240 __attribute__((unused)) struct cmdline *cl,
5241 __attribute__((unused)) void *data)
5243 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5244 struct rte_eth_pfc_conf pfc_conf;
5245 int rx_fc_enable, tx_fc_enable;
5249 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5250 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5251 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5252 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5254 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5255 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5258 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5259 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5260 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5261 pfc_conf.fc.high_water = res->high_water;
5262 pfc_conf.fc.low_water = res->low_water;
5263 pfc_conf.fc.pause_time = res->pause_time;
5264 pfc_conf.priority = res->priority;
5266 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5268 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5271 cmdline_parse_token_string_t cmd_pfc_set_set =
5272 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5274 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5275 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5276 pfc_ctrl, "pfc_ctrl");
5277 cmdline_parse_token_string_t cmd_pfc_set_rx =
5278 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5280 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5281 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5282 rx_pfc_mode, "on#off");
5283 cmdline_parse_token_string_t cmd_pfc_set_tx =
5284 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5286 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5287 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5288 tx_pfc_mode, "on#off");
5289 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5290 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5291 high_water, UINT32);
5292 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5293 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5295 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5296 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5297 pause_time, UINT16);
5298 cmdline_parse_token_num_t cmd_pfc_set_priority =
5299 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5301 cmdline_parse_token_num_t cmd_pfc_set_portid =
5302 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5305 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5306 .f = cmd_priority_flow_ctrl_set_parsed,
5308 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5309 tx on|off high_water low_water pause_time priority port_id",
5311 (void *)&cmd_pfc_set_set,
5312 (void *)&cmd_pfc_set_flow_ctrl,
5313 (void *)&cmd_pfc_set_rx,
5314 (void *)&cmd_pfc_set_rx_mode,
5315 (void *)&cmd_pfc_set_tx,
5316 (void *)&cmd_pfc_set_tx_mode,
5317 (void *)&cmd_pfc_set_high_water,
5318 (void *)&cmd_pfc_set_low_water,
5319 (void *)&cmd_pfc_set_pause_time,
5320 (void *)&cmd_pfc_set_priority,
5321 (void *)&cmd_pfc_set_portid,
5326 /* *** RESET CONFIGURATION *** */
5327 struct cmd_reset_result {
5328 cmdline_fixed_string_t reset;
5329 cmdline_fixed_string_t def;
5332 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5334 __attribute__((unused)) void *data)
5336 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5337 set_def_fwd_config();
5340 cmdline_parse_token_string_t cmd_reset_set =
5341 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5342 cmdline_parse_token_string_t cmd_reset_def =
5343 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5346 cmdline_parse_inst_t cmd_reset = {
5347 .f = cmd_reset_parsed,
5349 .help_str = "set default: reset default forwarding configuration",
5351 (void *)&cmd_reset_set,
5352 (void *)&cmd_reset_def,
5357 /* *** START FORWARDING *** */
5358 struct cmd_start_result {
5359 cmdline_fixed_string_t start;
5362 cmdline_parse_token_string_t cmd_start_start =
5363 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5365 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5366 __attribute__((unused)) struct cmdline *cl,
5367 __attribute__((unused)) void *data)
5369 start_packet_forwarding(0);
5372 cmdline_parse_inst_t cmd_start = {
5373 .f = cmd_start_parsed,
5375 .help_str = "start packet forwarding",
5377 (void *)&cmd_start_start,
5382 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5383 struct cmd_start_tx_first_result {
5384 cmdline_fixed_string_t start;
5385 cmdline_fixed_string_t tx_first;
5389 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5390 __attribute__((unused)) struct cmdline *cl,
5391 __attribute__((unused)) void *data)
5393 start_packet_forwarding(1);
5396 cmdline_parse_token_string_t cmd_start_tx_first_start =
5397 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5399 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5400 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5401 tx_first, "tx_first");
5403 cmdline_parse_inst_t cmd_start_tx_first = {
5404 .f = cmd_start_tx_first_parsed,
5406 .help_str = "start packet forwarding, after sending 1 burst of packets",
5408 (void *)&cmd_start_tx_first_start,
5409 (void *)&cmd_start_tx_first_tx_first,
5414 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5415 struct cmd_start_tx_first_n_result {
5416 cmdline_fixed_string_t start;
5417 cmdline_fixed_string_t tx_first;
5422 cmd_start_tx_first_n_parsed(void *parsed_result,
5423 __attribute__((unused)) struct cmdline *cl,
5424 __attribute__((unused)) void *data)
5426 struct cmd_start_tx_first_n_result *res = parsed_result;
5428 start_packet_forwarding(res->tx_num);
5431 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5432 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5434 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5435 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5436 tx_first, "tx_first");
5437 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5438 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5441 cmdline_parse_inst_t cmd_start_tx_first_n = {
5442 .f = cmd_start_tx_first_n_parsed,
5444 .help_str = "start packet forwarding, after sending <num> "
5445 "bursts of packets",
5447 (void *)&cmd_start_tx_first_n_start,
5448 (void *)&cmd_start_tx_first_n_tx_first,
5449 (void *)&cmd_start_tx_first_n_tx_num,
5454 /* *** SET LINK UP *** */
5455 struct cmd_set_link_up_result {
5456 cmdline_fixed_string_t set;
5457 cmdline_fixed_string_t link_up;
5458 cmdline_fixed_string_t port;
5462 cmdline_parse_token_string_t cmd_set_link_up_set =
5463 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5464 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5467 cmdline_parse_token_string_t cmd_set_link_up_port =
5468 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5469 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5470 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5472 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5473 __attribute__((unused)) struct cmdline *cl,
5474 __attribute__((unused)) void *data)
5476 struct cmd_set_link_up_result *res = parsed_result;
5477 dev_set_link_up(res->port_id);
5480 cmdline_parse_inst_t cmd_set_link_up = {
5481 .f = cmd_set_link_up_parsed,
5483 .help_str = "set link-up port (port id)",
5485 (void *)&cmd_set_link_up_set,
5486 (void *)&cmd_set_link_up_link_up,
5487 (void *)&cmd_set_link_up_port,
5488 (void *)&cmd_set_link_up_port_id,
5493 /* *** SET LINK DOWN *** */
5494 struct cmd_set_link_down_result {
5495 cmdline_fixed_string_t set;
5496 cmdline_fixed_string_t link_down;
5497 cmdline_fixed_string_t port;
5501 cmdline_parse_token_string_t cmd_set_link_down_set =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5503 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5506 cmdline_parse_token_string_t cmd_set_link_down_port =
5507 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5508 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5509 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5511 static void cmd_set_link_down_parsed(
5512 __attribute__((unused)) void *parsed_result,
5513 __attribute__((unused)) struct cmdline *cl,
5514 __attribute__((unused)) void *data)
5516 struct cmd_set_link_down_result *res = parsed_result;
5517 dev_set_link_down(res->port_id);
5520 cmdline_parse_inst_t cmd_set_link_down = {
5521 .f = cmd_set_link_down_parsed,
5523 .help_str = "set link-down port (port id)",
5525 (void *)&cmd_set_link_down_set,
5526 (void *)&cmd_set_link_down_link_down,
5527 (void *)&cmd_set_link_down_port,
5528 (void *)&cmd_set_link_down_port_id,
5533 /* *** SHOW CFG *** */
5534 struct cmd_showcfg_result {
5535 cmdline_fixed_string_t show;
5536 cmdline_fixed_string_t cfg;
5537 cmdline_fixed_string_t what;
5540 static void cmd_showcfg_parsed(void *parsed_result,
5541 __attribute__((unused)) struct cmdline *cl,
5542 __attribute__((unused)) void *data)
5544 struct cmd_showcfg_result *res = parsed_result;
5545 if (!strcmp(res->what, "rxtx"))
5546 rxtx_config_display();
5547 else if (!strcmp(res->what, "cores"))
5548 fwd_lcores_config_display();
5549 else if (!strcmp(res->what, "fwd"))
5550 pkt_fwd_config_display(&cur_fwd_config);
5551 else if (!strcmp(res->what, "txpkts"))
5552 show_tx_pkt_segments();
5555 cmdline_parse_token_string_t cmd_showcfg_show =
5556 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5557 cmdline_parse_token_string_t cmd_showcfg_port =
5558 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5559 cmdline_parse_token_string_t cmd_showcfg_what =
5560 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5561 "rxtx#cores#fwd#txpkts");
5563 cmdline_parse_inst_t cmd_showcfg = {
5564 .f = cmd_showcfg_parsed,
5566 .help_str = "show config rxtx|cores|fwd|txpkts",
5568 (void *)&cmd_showcfg_show,
5569 (void *)&cmd_showcfg_port,
5570 (void *)&cmd_showcfg_what,
5575 /* *** SHOW ALL PORT INFO *** */
5576 struct cmd_showportall_result {
5577 cmdline_fixed_string_t show;
5578 cmdline_fixed_string_t port;
5579 cmdline_fixed_string_t what;
5580 cmdline_fixed_string_t all;
5583 static void cmd_showportall_parsed(void *parsed_result,
5584 __attribute__((unused)) struct cmdline *cl,
5585 __attribute__((unused)) void *data)
5589 struct cmd_showportall_result *res = parsed_result;
5590 if (!strcmp(res->show, "clear")) {
5591 if (!strcmp(res->what, "stats"))
5592 FOREACH_PORT(i, ports)
5594 else if (!strcmp(res->what, "xstats"))
5595 FOREACH_PORT(i, ports)
5596 nic_xstats_clear(i);
5597 } else if (!strcmp(res->what, "info"))
5598 FOREACH_PORT(i, ports)
5599 port_infos_display(i);
5600 else if (!strcmp(res->what, "stats"))
5601 FOREACH_PORT(i, ports)
5602 nic_stats_display(i);
5603 else if (!strcmp(res->what, "xstats"))
5604 FOREACH_PORT(i, ports)
5605 nic_xstats_display(i);
5606 else if (!strcmp(res->what, "fdir"))
5607 FOREACH_PORT(i, ports)
5609 else if (!strcmp(res->what, "stat_qmap"))
5610 FOREACH_PORT(i, ports)
5611 nic_stats_mapping_display(i);
5612 else if (!strcmp(res->what, "dcb_tc"))
5613 FOREACH_PORT(i, ports)
5614 port_dcb_info_display(i);
5617 cmdline_parse_token_string_t cmd_showportall_show =
5618 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5620 cmdline_parse_token_string_t cmd_showportall_port =
5621 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5622 cmdline_parse_token_string_t cmd_showportall_what =
5623 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5624 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5625 cmdline_parse_token_string_t cmd_showportall_all =
5626 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5627 cmdline_parse_inst_t cmd_showportall = {
5628 .f = cmd_showportall_parsed,
5630 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5632 (void *)&cmd_showportall_show,
5633 (void *)&cmd_showportall_port,
5634 (void *)&cmd_showportall_what,
5635 (void *)&cmd_showportall_all,
5640 /* *** SHOW PORT INFO *** */
5641 struct cmd_showport_result {
5642 cmdline_fixed_string_t show;
5643 cmdline_fixed_string_t port;
5644 cmdline_fixed_string_t what;
5648 static void cmd_showport_parsed(void *parsed_result,
5649 __attribute__((unused)) struct cmdline *cl,
5650 __attribute__((unused)) void *data)
5652 struct cmd_showport_result *res = parsed_result;
5653 if (!strcmp(res->show, "clear")) {
5654 if (!strcmp(res->what, "stats"))
5655 nic_stats_clear(res->portnum);
5656 else if (!strcmp(res->what, "xstats"))
5657 nic_xstats_clear(res->portnum);
5658 } else if (!strcmp(res->what, "info"))
5659 port_infos_display(res->portnum);
5660 else if (!strcmp(res->what, "stats"))
5661 nic_stats_display(res->portnum);
5662 else if (!strcmp(res->what, "xstats"))
5663 nic_xstats_display(res->portnum);
5664 else if (!strcmp(res->what, "fdir"))
5665 fdir_get_infos(res->portnum);
5666 else if (!strcmp(res->what, "stat_qmap"))
5667 nic_stats_mapping_display(res->portnum);
5668 else if (!strcmp(res->what, "dcb_tc"))
5669 port_dcb_info_display(res->portnum);
5672 cmdline_parse_token_string_t cmd_showport_show =
5673 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5675 cmdline_parse_token_string_t cmd_showport_port =
5676 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5677 cmdline_parse_token_string_t cmd_showport_what =
5678 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5679 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5680 cmdline_parse_token_num_t cmd_showport_portnum =
5681 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5683 cmdline_parse_inst_t cmd_showport = {
5684 .f = cmd_showport_parsed,
5686 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5688 (void *)&cmd_showport_show,
5689 (void *)&cmd_showport_port,
5690 (void *)&cmd_showport_what,
5691 (void *)&cmd_showport_portnum,
5696 /* *** SHOW QUEUE INFO *** */
5697 struct cmd_showqueue_result {
5698 cmdline_fixed_string_t show;
5699 cmdline_fixed_string_t type;
5700 cmdline_fixed_string_t what;
5706 cmd_showqueue_parsed(void *parsed_result,
5707 __attribute__((unused)) struct cmdline *cl,
5708 __attribute__((unused)) void *data)
5710 struct cmd_showqueue_result *res = parsed_result;
5712 if (!strcmp(res->type, "rxq"))
5713 rx_queue_infos_display(res->portnum, res->queuenum);
5714 else if (!strcmp(res->type, "txq"))
5715 tx_queue_infos_display(res->portnum, res->queuenum);
5718 cmdline_parse_token_string_t cmd_showqueue_show =
5719 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5720 cmdline_parse_token_string_t cmd_showqueue_type =
5721 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5722 cmdline_parse_token_string_t cmd_showqueue_what =
5723 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5724 cmdline_parse_token_num_t cmd_showqueue_portnum =
5725 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5726 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5727 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5729 cmdline_parse_inst_t cmd_showqueue = {
5730 .f = cmd_showqueue_parsed,
5732 .help_str = "show rxq|txq info <port number> <queue_number>",
5734 (void *)&cmd_showqueue_show,
5735 (void *)&cmd_showqueue_type,
5736 (void *)&cmd_showqueue_what,
5737 (void *)&cmd_showqueue_portnum,
5738 (void *)&cmd_showqueue_queuenum,
5743 /* *** READ PORT REGISTER *** */
5744 struct cmd_read_reg_result {
5745 cmdline_fixed_string_t read;
5746 cmdline_fixed_string_t reg;
5752 cmd_read_reg_parsed(void *parsed_result,
5753 __attribute__((unused)) struct cmdline *cl,
5754 __attribute__((unused)) void *data)
5756 struct cmd_read_reg_result *res = parsed_result;
5757 port_reg_display(res->port_id, res->reg_off);
5760 cmdline_parse_token_string_t cmd_read_reg_read =
5761 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5762 cmdline_parse_token_string_t cmd_read_reg_reg =
5763 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5764 cmdline_parse_token_num_t cmd_read_reg_port_id =
5765 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5766 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5767 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5769 cmdline_parse_inst_t cmd_read_reg = {
5770 .f = cmd_read_reg_parsed,
5772 .help_str = "read reg port_id reg_off",
5774 (void *)&cmd_read_reg_read,
5775 (void *)&cmd_read_reg_reg,
5776 (void *)&cmd_read_reg_port_id,
5777 (void *)&cmd_read_reg_reg_off,
5782 /* *** READ PORT REGISTER BIT FIELD *** */
5783 struct cmd_read_reg_bit_field_result {
5784 cmdline_fixed_string_t read;
5785 cmdline_fixed_string_t regfield;
5793 cmd_read_reg_bit_field_parsed(void *parsed_result,
5794 __attribute__((unused)) struct cmdline *cl,
5795 __attribute__((unused)) void *data)
5797 struct cmd_read_reg_bit_field_result *res = parsed_result;
5798 port_reg_bit_field_display(res->port_id, res->reg_off,
5799 res->bit1_pos, res->bit2_pos);
5802 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5803 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5805 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5806 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5807 regfield, "regfield");
5808 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5809 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5811 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5812 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5814 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5815 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5817 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5818 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5821 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5822 .f = cmd_read_reg_bit_field_parsed,
5824 .help_str = "read regfield port_id reg_off bit_x bit_y "
5825 "(read register bit field between bit_x and bit_y included)",
5827 (void *)&cmd_read_reg_bit_field_read,
5828 (void *)&cmd_read_reg_bit_field_regfield,
5829 (void *)&cmd_read_reg_bit_field_port_id,
5830 (void *)&cmd_read_reg_bit_field_reg_off,
5831 (void *)&cmd_read_reg_bit_field_bit1_pos,
5832 (void *)&cmd_read_reg_bit_field_bit2_pos,
5837 /* *** READ PORT REGISTER BIT *** */
5838 struct cmd_read_reg_bit_result {
5839 cmdline_fixed_string_t read;
5840 cmdline_fixed_string_t regbit;
5847 cmd_read_reg_bit_parsed(void *parsed_result,
5848 __attribute__((unused)) struct cmdline *cl,
5849 __attribute__((unused)) void *data)
5851 struct cmd_read_reg_bit_result *res = parsed_result;
5852 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5855 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5856 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5857 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5858 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5860 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5861 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5862 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5863 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5864 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5865 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5867 cmdline_parse_inst_t cmd_read_reg_bit = {
5868 .f = cmd_read_reg_bit_parsed,
5870 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5872 (void *)&cmd_read_reg_bit_read,
5873 (void *)&cmd_read_reg_bit_regbit,
5874 (void *)&cmd_read_reg_bit_port_id,
5875 (void *)&cmd_read_reg_bit_reg_off,
5876 (void *)&cmd_read_reg_bit_bit_pos,
5881 /* *** WRITE PORT REGISTER *** */
5882 struct cmd_write_reg_result {
5883 cmdline_fixed_string_t write;
5884 cmdline_fixed_string_t reg;
5891 cmd_write_reg_parsed(void *parsed_result,
5892 __attribute__((unused)) struct cmdline *cl,
5893 __attribute__((unused)) void *data)
5895 struct cmd_write_reg_result *res = parsed_result;
5896 port_reg_set(res->port_id, res->reg_off, res->value);
5899 cmdline_parse_token_string_t cmd_write_reg_write =
5900 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5901 cmdline_parse_token_string_t cmd_write_reg_reg =
5902 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5903 cmdline_parse_token_num_t cmd_write_reg_port_id =
5904 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5905 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5906 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5907 cmdline_parse_token_num_t cmd_write_reg_value =
5908 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5910 cmdline_parse_inst_t cmd_write_reg = {
5911 .f = cmd_write_reg_parsed,
5913 .help_str = "write reg port_id reg_off reg_value",
5915 (void *)&cmd_write_reg_write,
5916 (void *)&cmd_write_reg_reg,
5917 (void *)&cmd_write_reg_port_id,
5918 (void *)&cmd_write_reg_reg_off,
5919 (void *)&cmd_write_reg_value,
5924 /* *** WRITE PORT REGISTER BIT FIELD *** */
5925 struct cmd_write_reg_bit_field_result {
5926 cmdline_fixed_string_t write;
5927 cmdline_fixed_string_t regfield;
5936 cmd_write_reg_bit_field_parsed(void *parsed_result,
5937 __attribute__((unused)) struct cmdline *cl,
5938 __attribute__((unused)) void *data)
5940 struct cmd_write_reg_bit_field_result *res = parsed_result;
5941 port_reg_bit_field_set(res->port_id, res->reg_off,
5942 res->bit1_pos, res->bit2_pos, res->value);
5945 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5946 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5948 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5949 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5950 regfield, "regfield");
5951 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5952 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5954 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5955 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5957 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5958 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5960 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5961 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5963 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5964 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5967 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5968 .f = cmd_write_reg_bit_field_parsed,
5970 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5971 "(set register bit field between bit_x and bit_y included)",
5973 (void *)&cmd_write_reg_bit_field_write,
5974 (void *)&cmd_write_reg_bit_field_regfield,
5975 (void *)&cmd_write_reg_bit_field_port_id,
5976 (void *)&cmd_write_reg_bit_field_reg_off,
5977 (void *)&cmd_write_reg_bit_field_bit1_pos,
5978 (void *)&cmd_write_reg_bit_field_bit2_pos,
5979 (void *)&cmd_write_reg_bit_field_value,
5984 /* *** WRITE PORT REGISTER BIT *** */
5985 struct cmd_write_reg_bit_result {
5986 cmdline_fixed_string_t write;
5987 cmdline_fixed_string_t regbit;
5995 cmd_write_reg_bit_parsed(void *parsed_result,
5996 __attribute__((unused)) struct cmdline *cl,
5997 __attribute__((unused)) void *data)
5999 struct cmd_write_reg_bit_result *res = parsed_result;
6000 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6003 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6004 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6006 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6007 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6009 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6010 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6011 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6012 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6013 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6014 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6015 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6016 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6018 cmdline_parse_inst_t cmd_write_reg_bit = {
6019 .f = cmd_write_reg_bit_parsed,
6021 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6023 (void *)&cmd_write_reg_bit_write,
6024 (void *)&cmd_write_reg_bit_regbit,
6025 (void *)&cmd_write_reg_bit_port_id,
6026 (void *)&cmd_write_reg_bit_reg_off,
6027 (void *)&cmd_write_reg_bit_bit_pos,
6028 (void *)&cmd_write_reg_bit_value,
6033 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6034 struct cmd_read_rxd_txd_result {
6035 cmdline_fixed_string_t read;
6036 cmdline_fixed_string_t rxd_txd;
6043 cmd_read_rxd_txd_parsed(void *parsed_result,
6044 __attribute__((unused)) struct cmdline *cl,
6045 __attribute__((unused)) void *data)
6047 struct cmd_read_rxd_txd_result *res = parsed_result;
6049 if (!strcmp(res->rxd_txd, "rxd"))
6050 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6051 else if (!strcmp(res->rxd_txd, "txd"))
6052 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6055 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6056 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6057 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6058 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6060 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6061 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6062 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6063 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6064 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6065 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6067 cmdline_parse_inst_t cmd_read_rxd_txd = {
6068 .f = cmd_read_rxd_txd_parsed,
6070 .help_str = "read rxd|txd port_id queue_id rxd_id",
6072 (void *)&cmd_read_rxd_txd_read,
6073 (void *)&cmd_read_rxd_txd_rxd_txd,
6074 (void *)&cmd_read_rxd_txd_port_id,
6075 (void *)&cmd_read_rxd_txd_queue_id,
6076 (void *)&cmd_read_rxd_txd_desc_id,
6082 struct cmd_quit_result {
6083 cmdline_fixed_string_t quit;
6086 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6088 __attribute__((unused)) void *data)
6094 cmdline_parse_token_string_t cmd_quit_quit =
6095 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6097 cmdline_parse_inst_t cmd_quit = {
6098 .f = cmd_quit_parsed,
6100 .help_str = "exit application",
6102 (void *)&cmd_quit_quit,
6107 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6108 struct cmd_mac_addr_result {
6109 cmdline_fixed_string_t mac_addr_cmd;
6110 cmdline_fixed_string_t what;
6112 struct ether_addr address;
6115 static void cmd_mac_addr_parsed(void *parsed_result,
6116 __attribute__((unused)) struct cmdline *cl,
6117 __attribute__((unused)) void *data)
6119 struct cmd_mac_addr_result *res = parsed_result;
6122 if (strcmp(res->what, "add") == 0)
6123 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6125 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6127 /* check the return value and print it if is < 0 */
6129 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6133 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6134 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6136 cmdline_parse_token_string_t cmd_mac_addr_what =
6137 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6139 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6140 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6141 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6142 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6144 cmdline_parse_inst_t cmd_mac_addr = {
6145 .f = cmd_mac_addr_parsed,
6147 .help_str = "mac_addr add|remove X <address>: "
6148 "add/remove MAC address on port X",
6150 (void *)&cmd_mac_addr_cmd,
6151 (void *)&cmd_mac_addr_what,
6152 (void *)&cmd_mac_addr_portnum,
6153 (void *)&cmd_mac_addr_addr,
6159 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6160 struct cmd_set_qmap_result {
6161 cmdline_fixed_string_t set;
6162 cmdline_fixed_string_t qmap;
6163 cmdline_fixed_string_t what;
6170 cmd_set_qmap_parsed(void *parsed_result,
6171 __attribute__((unused)) struct cmdline *cl,
6172 __attribute__((unused)) void *data)
6174 struct cmd_set_qmap_result *res = parsed_result;
6175 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6177 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6180 cmdline_parse_token_string_t cmd_setqmap_set =
6181 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6183 cmdline_parse_token_string_t cmd_setqmap_qmap =
6184 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6186 cmdline_parse_token_string_t cmd_setqmap_what =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6189 cmdline_parse_token_num_t cmd_setqmap_portid =
6190 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6192 cmdline_parse_token_num_t cmd_setqmap_queueid =
6193 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6195 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6196 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6199 cmdline_parse_inst_t cmd_set_qmap = {
6200 .f = cmd_set_qmap_parsed,
6202 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6204 (void *)&cmd_setqmap_set,
6205 (void *)&cmd_setqmap_qmap,
6206 (void *)&cmd_setqmap_what,
6207 (void *)&cmd_setqmap_portid,
6208 (void *)&cmd_setqmap_queueid,
6209 (void *)&cmd_setqmap_mapvalue,
6214 /* *** CONFIGURE UNICAST HASH TABLE *** */
6215 struct cmd_set_uc_hash_table {
6216 cmdline_fixed_string_t set;
6217 cmdline_fixed_string_t port;
6219 cmdline_fixed_string_t what;
6220 struct ether_addr address;
6221 cmdline_fixed_string_t mode;
6225 cmd_set_uc_hash_parsed(void *parsed_result,
6226 __attribute__((unused)) struct cmdline *cl,
6227 __attribute__((unused)) void *data)
6230 struct cmd_set_uc_hash_table *res = parsed_result;
6232 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6234 if (strcmp(res->what, "uta") == 0)
6235 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6236 &res->address,(uint8_t)is_on);
6238 printf("bad unicast hash table parameter, return code = %d \n", ret);
6242 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6245 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6246 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6248 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6249 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6251 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6254 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6255 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6257 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6261 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6262 .f = cmd_set_uc_hash_parsed,
6264 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6266 (void *)&cmd_set_uc_hash_set,
6267 (void *)&cmd_set_uc_hash_port,
6268 (void *)&cmd_set_uc_hash_portid,
6269 (void *)&cmd_set_uc_hash_what,
6270 (void *)&cmd_set_uc_hash_mac,
6271 (void *)&cmd_set_uc_hash_mode,
6276 struct cmd_set_uc_all_hash_table {
6277 cmdline_fixed_string_t set;
6278 cmdline_fixed_string_t port;
6280 cmdline_fixed_string_t what;
6281 cmdline_fixed_string_t value;
6282 cmdline_fixed_string_t mode;
6286 cmd_set_uc_all_hash_parsed(void *parsed_result,
6287 __attribute__((unused)) struct cmdline *cl,
6288 __attribute__((unused)) void *data)
6291 struct cmd_set_uc_all_hash_table *res = parsed_result;
6293 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6295 if ((strcmp(res->what, "uta") == 0) &&
6296 (strcmp(res->value, "all") == 0))
6297 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6299 printf("bad unicast hash table parameter,"
6300 "return code = %d \n", ret);
6303 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6304 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6306 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6307 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6309 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6310 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6312 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6315 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6316 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6318 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6319 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6322 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6323 .f = cmd_set_uc_all_hash_parsed,
6325 .help_str = "set port X uta all on|off (X = port number)",
6327 (void *)&cmd_set_uc_all_hash_set,
6328 (void *)&cmd_set_uc_all_hash_port,
6329 (void *)&cmd_set_uc_all_hash_portid,
6330 (void *)&cmd_set_uc_all_hash_what,
6331 (void *)&cmd_set_uc_all_hash_value,
6332 (void *)&cmd_set_uc_all_hash_mode,
6337 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6338 struct cmd_set_vf_macvlan_filter {
6339 cmdline_fixed_string_t set;
6340 cmdline_fixed_string_t port;
6342 cmdline_fixed_string_t vf;
6344 struct ether_addr address;
6345 cmdline_fixed_string_t filter_type;
6346 cmdline_fixed_string_t mode;
6350 cmd_set_vf_macvlan_parsed(void *parsed_result,
6351 __attribute__((unused)) struct cmdline *cl,
6352 __attribute__((unused)) void *data)
6355 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6356 struct rte_eth_mac_filter filter;
6358 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6360 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6362 /* set VF MAC filter */
6366 filter.dst_id = res->vf_id;
6368 if (!strcmp(res->filter_type, "exact-mac"))
6369 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6370 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6371 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6372 else if (!strcmp(res->filter_type, "hashmac"))
6373 filter.filter_type = RTE_MAC_HASH_MATCH;
6374 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6375 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6377 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6380 ret = rte_eth_dev_filter_ctrl(res->port_id,
6381 RTE_ETH_FILTER_MACVLAN,
6385 ret = rte_eth_dev_filter_ctrl(res->port_id,
6386 RTE_ETH_FILTER_MACVLAN,
6387 RTE_ETH_FILTER_DELETE,
6391 printf("bad set MAC hash parameter, return code = %d\n", ret);
6395 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6396 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6398 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6399 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6401 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6402 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6404 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6407 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6408 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6410 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6411 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6413 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6415 filter_type, "exact-mac#exact-mac-vlan"
6416 "#hashmac#hashmac-vlan");
6417 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6418 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6421 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6422 .f = cmd_set_vf_macvlan_parsed,
6424 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6425 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6427 "exact match rule:exact match of MAC or MAC and VLAN; "
6428 "hash match rule: hash match of MAC and exact match "
6431 (void *)&cmd_set_vf_macvlan_set,
6432 (void *)&cmd_set_vf_macvlan_port,
6433 (void *)&cmd_set_vf_macvlan_portid,
6434 (void *)&cmd_set_vf_macvlan_vf,
6435 (void *)&cmd_set_vf_macvlan_vf_id,
6436 (void *)&cmd_set_vf_macvlan_mac,
6437 (void *)&cmd_set_vf_macvlan_filter_type,
6438 (void *)&cmd_set_vf_macvlan_mode,
6443 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6444 struct cmd_set_vf_traffic {
6445 cmdline_fixed_string_t set;
6446 cmdline_fixed_string_t port;
6448 cmdline_fixed_string_t vf;
6450 cmdline_fixed_string_t what;
6451 cmdline_fixed_string_t mode;
6455 cmd_set_vf_traffic_parsed(void *parsed_result,
6456 __attribute__((unused)) struct cmdline *cl,
6457 __attribute__((unused)) void *data)
6459 struct cmd_set_vf_traffic *res = parsed_result;
6460 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6461 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6463 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6466 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6469 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6472 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6473 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6475 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6478 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6479 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6481 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6484 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6488 cmdline_parse_inst_t cmd_set_vf_traffic = {
6489 .f = cmd_set_vf_traffic_parsed,
6491 .help_str = "set port X vf Y rx|tx on|off"
6492 "(X = port number,Y = vf id)",
6494 (void *)&cmd_setvf_traffic_set,
6495 (void *)&cmd_setvf_traffic_port,
6496 (void *)&cmd_setvf_traffic_portid,
6497 (void *)&cmd_setvf_traffic_vf,
6498 (void *)&cmd_setvf_traffic_vfid,
6499 (void *)&cmd_setvf_traffic_what,
6500 (void *)&cmd_setvf_traffic_mode,
6505 /* *** CONFIGURE VF RECEIVE MODE *** */
6506 struct cmd_set_vf_rxmode {
6507 cmdline_fixed_string_t set;
6508 cmdline_fixed_string_t port;
6510 cmdline_fixed_string_t vf;
6512 cmdline_fixed_string_t what;
6513 cmdline_fixed_string_t mode;
6514 cmdline_fixed_string_t on;
6518 cmd_set_vf_rxmode_parsed(void *parsed_result,
6519 __attribute__((unused)) struct cmdline *cl,
6520 __attribute__((unused)) void *data)
6523 uint16_t rx_mode = 0;
6524 struct cmd_set_vf_rxmode *res = parsed_result;
6526 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6527 if (!strcmp(res->what,"rxmode")) {
6528 if (!strcmp(res->mode, "AUPE"))
6529 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6530 else if (!strcmp(res->mode, "ROPE"))
6531 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6532 else if (!strcmp(res->mode, "BAM"))
6533 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6534 else if (!strncmp(res->mode, "MPE",3))
6535 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6538 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6540 printf("bad VF receive mode parameter, return code = %d \n",
6544 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6547 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6548 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6550 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6551 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6553 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6554 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6556 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6557 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6559 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6560 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6562 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6563 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6564 mode, "AUPE#ROPE#BAM#MPE");
6565 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6566 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6569 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6570 .f = cmd_set_vf_rxmode_parsed,
6572 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6574 (void *)&cmd_set_vf_rxmode_set,
6575 (void *)&cmd_set_vf_rxmode_port,
6576 (void *)&cmd_set_vf_rxmode_portid,
6577 (void *)&cmd_set_vf_rxmode_vf,
6578 (void *)&cmd_set_vf_rxmode_vfid,
6579 (void *)&cmd_set_vf_rxmode_what,
6580 (void *)&cmd_set_vf_rxmode_mode,
6581 (void *)&cmd_set_vf_rxmode_on,
6586 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6587 struct cmd_vf_mac_addr_result {
6588 cmdline_fixed_string_t mac_addr_cmd;
6589 cmdline_fixed_string_t what;
6590 cmdline_fixed_string_t port;
6592 cmdline_fixed_string_t vf;
6594 struct ether_addr address;
6597 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6598 __attribute__((unused)) struct cmdline *cl,
6599 __attribute__((unused)) void *data)
6601 struct cmd_vf_mac_addr_result *res = parsed_result;
6604 if (strcmp(res->what, "add") == 0)
6605 ret = rte_eth_dev_mac_addr_add(res->port_num,
6606 &res->address, res->vf_num);
6608 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6612 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6613 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6614 mac_addr_cmd,"mac_addr");
6615 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6616 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6618 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6619 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6621 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6622 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6624 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6625 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6627 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6628 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6630 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6631 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6634 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6635 .f = cmd_vf_mac_addr_parsed,
6637 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6638 "Y = VF number)add MAC address filtering for a VF on port X",
6640 (void *)&cmd_vf_mac_addr_cmd,
6641 (void *)&cmd_vf_mac_addr_what,
6642 (void *)&cmd_vf_mac_addr_port,
6643 (void *)&cmd_vf_mac_addr_portnum,
6644 (void *)&cmd_vf_mac_addr_vf,
6645 (void *)&cmd_vf_mac_addr_vfnum,
6646 (void *)&cmd_vf_mac_addr_addr,
6651 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6652 struct cmd_vf_rx_vlan_filter {
6653 cmdline_fixed_string_t rx_vlan;
6654 cmdline_fixed_string_t what;
6656 cmdline_fixed_string_t port;
6658 cmdline_fixed_string_t vf;
6663 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6664 __attribute__((unused)) struct cmdline *cl,
6665 __attribute__((unused)) void *data)
6667 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6669 if (!strcmp(res->what, "add"))
6670 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6672 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6675 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6676 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6677 rx_vlan, "rx_vlan");
6678 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6679 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6681 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6682 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6684 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6685 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6687 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6688 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6690 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6691 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6693 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6694 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6697 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6698 .f = cmd_vf_rx_vlan_filter_parsed,
6700 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6701 "Y = port number,Z = hexadecimal VF mask)",
6703 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6704 (void *)&cmd_vf_rx_vlan_filter_what,
6705 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6706 (void *)&cmd_vf_rx_vlan_filter_port,
6707 (void *)&cmd_vf_rx_vlan_filter_portid,
6708 (void *)&cmd_vf_rx_vlan_filter_vf,
6709 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6714 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6715 struct cmd_queue_rate_limit_result {
6716 cmdline_fixed_string_t set;
6717 cmdline_fixed_string_t port;
6719 cmdline_fixed_string_t queue;
6721 cmdline_fixed_string_t rate;
6725 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6726 __attribute__((unused)) struct cmdline *cl,
6727 __attribute__((unused)) void *data)
6729 struct cmd_queue_rate_limit_result *res = parsed_result;
6732 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6733 && (strcmp(res->queue, "queue") == 0)
6734 && (strcmp(res->rate, "rate") == 0))
6735 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6738 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6742 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6743 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6745 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6746 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6748 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6749 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6751 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6752 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6754 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6755 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6757 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6758 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6760 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6761 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6764 cmdline_parse_inst_t cmd_queue_rate_limit = {
6765 .f = cmd_queue_rate_limit_parsed,
6767 .help_str = "set port X queue Y rate Z:(X = port number,"
6768 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6770 (void *)&cmd_queue_rate_limit_set,
6771 (void *)&cmd_queue_rate_limit_port,
6772 (void *)&cmd_queue_rate_limit_portnum,
6773 (void *)&cmd_queue_rate_limit_queue,
6774 (void *)&cmd_queue_rate_limit_queuenum,
6775 (void *)&cmd_queue_rate_limit_rate,
6776 (void *)&cmd_queue_rate_limit_ratenum,
6781 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6782 struct cmd_vf_rate_limit_result {
6783 cmdline_fixed_string_t set;
6784 cmdline_fixed_string_t port;
6786 cmdline_fixed_string_t vf;
6788 cmdline_fixed_string_t rate;
6790 cmdline_fixed_string_t q_msk;
6794 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6795 __attribute__((unused)) struct cmdline *cl,
6796 __attribute__((unused)) void *data)
6798 struct cmd_vf_rate_limit_result *res = parsed_result;
6801 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6802 && (strcmp(res->vf, "vf") == 0)
6803 && (strcmp(res->rate, "rate") == 0)
6804 && (strcmp(res->q_msk, "queue_mask") == 0))
6805 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6806 res->rate_num, res->q_msk_val);
6808 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6812 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6813 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6815 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6816 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6818 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6819 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6821 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6822 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6824 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6825 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6827 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6828 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6830 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6831 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6833 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6834 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6835 q_msk, "queue_mask");
6836 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6837 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6840 cmdline_parse_inst_t cmd_vf_rate_limit = {
6841 .f = cmd_vf_rate_limit_parsed,
6843 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6844 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6845 "for queues of VF on port X",
6847 (void *)&cmd_vf_rate_limit_set,
6848 (void *)&cmd_vf_rate_limit_port,
6849 (void *)&cmd_vf_rate_limit_portnum,
6850 (void *)&cmd_vf_rate_limit_vf,
6851 (void *)&cmd_vf_rate_limit_vfnum,
6852 (void *)&cmd_vf_rate_limit_rate,
6853 (void *)&cmd_vf_rate_limit_ratenum,
6854 (void *)&cmd_vf_rate_limit_q_msk,
6855 (void *)&cmd_vf_rate_limit_q_msk_val,
6860 /* *** ADD TUNNEL FILTER OF A PORT *** */
6861 struct cmd_tunnel_filter_result {
6862 cmdline_fixed_string_t cmd;
6863 cmdline_fixed_string_t what;
6865 struct ether_addr outer_mac;
6866 struct ether_addr inner_mac;
6867 cmdline_ipaddr_t ip_value;
6868 uint16_t inner_vlan;
6869 cmdline_fixed_string_t tunnel_type;
6870 cmdline_fixed_string_t filter_type;
6876 cmd_tunnel_filter_parsed(void *parsed_result,
6877 __attribute__((unused)) struct cmdline *cl,
6878 __attribute__((unused)) void *data)
6880 struct cmd_tunnel_filter_result *res = parsed_result;
6881 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6884 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6886 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6887 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6888 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6890 if (res->ip_value.family == AF_INET) {
6891 tunnel_filter_conf.ip_addr.ipv4_addr =
6892 res->ip_value.addr.ipv4.s_addr;
6893 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6895 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6896 &(res->ip_value.addr.ipv6),
6897 sizeof(struct in6_addr));
6898 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6901 if (!strcmp(res->filter_type, "imac-ivlan"))
6902 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6903 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6904 tunnel_filter_conf.filter_type =
6905 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6906 else if (!strcmp(res->filter_type, "imac-tenid"))
6907 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6908 else if (!strcmp(res->filter_type, "imac"))
6909 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6910 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6911 tunnel_filter_conf.filter_type =
6912 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6913 else if (!strcmp(res->filter_type, "oip"))
6914 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6915 else if (!strcmp(res->filter_type, "iip"))
6916 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6918 printf("The filter type is not supported");
6922 if (!strcmp(res->tunnel_type, "vxlan"))
6923 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6924 else if (!strcmp(res->tunnel_type, "nvgre"))
6925 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6926 else if (!strcmp(res->tunnel_type, "ipingre"))
6927 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6929 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6933 tunnel_filter_conf.tenant_id = res->tenant_id;
6934 tunnel_filter_conf.queue_id = res->queue_num;
6935 if (!strcmp(res->what, "add"))
6936 ret = rte_eth_dev_filter_ctrl(res->port_id,
6937 RTE_ETH_FILTER_TUNNEL,
6939 &tunnel_filter_conf);
6941 ret = rte_eth_dev_filter_ctrl(res->port_id,
6942 RTE_ETH_FILTER_TUNNEL,
6943 RTE_ETH_FILTER_DELETE,
6944 &tunnel_filter_conf);
6946 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6950 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6951 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6952 cmd, "tunnel_filter");
6953 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6954 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6956 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6957 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6959 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6960 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6962 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6963 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6965 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6966 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6967 inner_vlan, UINT16);
6968 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6969 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6971 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6972 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6973 tunnel_type, "vxlan#nvgre#ipingre");
6975 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6976 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6977 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6978 "imac#omac-imac-tenid");
6979 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6980 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6982 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6983 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6986 cmdline_parse_inst_t cmd_tunnel_filter = {
6987 .f = cmd_tunnel_filter_parsed,
6989 .help_str = "add/rm tunnel filter of a port: "
6990 "tunnel_filter add port_id outer_mac inner_mac ip "
6991 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6992 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6993 "imac|omac-imac-tenid) "
6994 "tenant_id queue_num",
6996 (void *)&cmd_tunnel_filter_cmd,
6997 (void *)&cmd_tunnel_filter_what,
6998 (void *)&cmd_tunnel_filter_port_id,
6999 (void *)&cmd_tunnel_filter_outer_mac,
7000 (void *)&cmd_tunnel_filter_inner_mac,
7001 (void *)&cmd_tunnel_filter_ip_value,
7002 (void *)&cmd_tunnel_filter_innner_vlan,
7003 (void *)&cmd_tunnel_filter_tunnel_type,
7004 (void *)&cmd_tunnel_filter_filter_type,
7005 (void *)&cmd_tunnel_filter_tenant_id,
7006 (void *)&cmd_tunnel_filter_queue_num,
7011 /* *** CONFIGURE TUNNEL UDP PORT *** */
7012 struct cmd_tunnel_udp_config {
7013 cmdline_fixed_string_t cmd;
7014 cmdline_fixed_string_t what;
7020 cmd_tunnel_udp_config_parsed(void *parsed_result,
7021 __attribute__((unused)) struct cmdline *cl,
7022 __attribute__((unused)) void *data)
7024 struct cmd_tunnel_udp_config *res = parsed_result;
7025 struct rte_eth_udp_tunnel tunnel_udp;
7028 tunnel_udp.udp_port = res->udp_port;
7030 if (!strcmp(res->cmd, "rx_vxlan_port"))
7031 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7033 if (!strcmp(res->what, "add"))
7034 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7037 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7041 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7044 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7045 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7046 cmd, "rx_vxlan_port");
7047 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7050 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7051 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7053 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7054 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7057 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7058 .f = cmd_tunnel_udp_config_parsed,
7060 .help_str = "add/rm an tunneling UDP port filter: "
7061 "rx_vxlan_port add udp_port port_id",
7063 (void *)&cmd_tunnel_udp_config_cmd,
7064 (void *)&cmd_tunnel_udp_config_what,
7065 (void *)&cmd_tunnel_udp_config_udp_port,
7066 (void *)&cmd_tunnel_udp_config_port_id,
7071 /* *** GLOBAL CONFIG *** */
7072 struct cmd_global_config_result {
7073 cmdline_fixed_string_t cmd;
7075 cmdline_fixed_string_t cfg_type;
7080 cmd_global_config_parsed(void *parsed_result,
7081 __attribute__((unused)) struct cmdline *cl,
7082 __attribute__((unused)) void *data)
7084 struct cmd_global_config_result *res = parsed_result;
7085 struct rte_eth_global_cfg conf;
7088 memset(&conf, 0, sizeof(conf));
7089 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7090 conf.cfg.gre_key_len = res->len;
7091 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7092 RTE_ETH_FILTER_SET, &conf);
7094 printf("Global config error\n");
7097 cmdline_parse_token_string_t cmd_global_config_cmd =
7098 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7100 cmdline_parse_token_num_t cmd_global_config_port_id =
7101 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7102 cmdline_parse_token_string_t cmd_global_config_type =
7103 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7104 cfg_type, "gre-key-len");
7105 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7106 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7109 cmdline_parse_inst_t cmd_global_config = {
7110 .f = cmd_global_config_parsed,
7111 .data = (void *)NULL,
7112 .help_str = "global_config <port_id> gre-key-len <number>",
7114 (void *)&cmd_global_config_cmd,
7115 (void *)&cmd_global_config_port_id,
7116 (void *)&cmd_global_config_type,
7117 (void *)&cmd_global_config_gre_key_len,
7122 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7123 struct cmd_set_mirror_mask_result {
7124 cmdline_fixed_string_t set;
7125 cmdline_fixed_string_t port;
7127 cmdline_fixed_string_t mirror;
7129 cmdline_fixed_string_t what;
7130 cmdline_fixed_string_t value;
7131 cmdline_fixed_string_t dstpool;
7133 cmdline_fixed_string_t on;
7136 cmdline_parse_token_string_t cmd_mirror_mask_set =
7137 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7139 cmdline_parse_token_string_t cmd_mirror_mask_port =
7140 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7142 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7143 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7145 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7146 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7147 mirror, "mirror-rule");
7148 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7149 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7151 cmdline_parse_token_string_t cmd_mirror_mask_what =
7152 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7153 what, "pool-mirror-up#pool-mirror-down"
7155 cmdline_parse_token_string_t cmd_mirror_mask_value =
7156 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7158 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7159 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7160 dstpool, "dst-pool");
7161 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7162 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7164 cmdline_parse_token_string_t cmd_mirror_mask_on =
7165 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7169 cmd_set_mirror_mask_parsed(void *parsed_result,
7170 __attribute__((unused)) struct cmdline *cl,
7171 __attribute__((unused)) void *data)
7174 struct cmd_set_mirror_mask_result *res = parsed_result;
7175 struct rte_eth_mirror_conf mr_conf;
7177 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7179 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7181 mr_conf.dst_pool = res->dstpool_id;
7183 if (!strcmp(res->what, "pool-mirror-up")) {
7184 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7185 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7186 } else if (!strcmp(res->what, "pool-mirror-down")) {
7187 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7188 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7189 } else if (!strcmp(res->what, "vlan-mirror")) {
7190 mr_conf.rule_type = ETH_MIRROR_VLAN;
7191 nb_item = parse_item_list(res->value, "vlan",
7192 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7196 for (i = 0; i < nb_item; i++) {
7197 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7198 printf("Invalid vlan_id: must be < 4096\n");
7202 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7203 mr_conf.vlan.vlan_mask |= 1ULL << i;
7207 if (!strcmp(res->on, "on"))
7208 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7211 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7214 printf("mirror rule add error: (%s)\n", strerror(-ret));
7217 cmdline_parse_inst_t cmd_set_mirror_mask = {
7218 .f = cmd_set_mirror_mask_parsed,
7220 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7221 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7223 (void *)&cmd_mirror_mask_set,
7224 (void *)&cmd_mirror_mask_port,
7225 (void *)&cmd_mirror_mask_portid,
7226 (void *)&cmd_mirror_mask_mirror,
7227 (void *)&cmd_mirror_mask_ruleid,
7228 (void *)&cmd_mirror_mask_what,
7229 (void *)&cmd_mirror_mask_value,
7230 (void *)&cmd_mirror_mask_dstpool,
7231 (void *)&cmd_mirror_mask_poolid,
7232 (void *)&cmd_mirror_mask_on,
7237 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7238 struct cmd_set_mirror_link_result {
7239 cmdline_fixed_string_t set;
7240 cmdline_fixed_string_t port;
7242 cmdline_fixed_string_t mirror;
7244 cmdline_fixed_string_t what;
7245 cmdline_fixed_string_t dstpool;
7247 cmdline_fixed_string_t on;
7250 cmdline_parse_token_string_t cmd_mirror_link_set =
7251 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7253 cmdline_parse_token_string_t cmd_mirror_link_port =
7254 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7256 cmdline_parse_token_num_t cmd_mirror_link_portid =
7257 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7259 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7261 mirror, "mirror-rule");
7262 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7263 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7265 cmdline_parse_token_string_t cmd_mirror_link_what =
7266 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7267 what, "uplink-mirror#downlink-mirror");
7268 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7269 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7270 dstpool, "dst-pool");
7271 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7272 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7274 cmdline_parse_token_string_t cmd_mirror_link_on =
7275 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7279 cmd_set_mirror_link_parsed(void *parsed_result,
7280 __attribute__((unused)) struct cmdline *cl,
7281 __attribute__((unused)) void *data)
7284 struct cmd_set_mirror_link_result *res = parsed_result;
7285 struct rte_eth_mirror_conf mr_conf;
7287 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7288 if (!strcmp(res->what, "uplink-mirror"))
7289 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7291 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7293 mr_conf.dst_pool = res->dstpool_id;
7295 if (!strcmp(res->on, "on"))
7296 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7299 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7302 /* check the return value and print it if is < 0 */
7304 printf("mirror rule add error: (%s)\n", strerror(-ret));
7308 cmdline_parse_inst_t cmd_set_mirror_link = {
7309 .f = cmd_set_mirror_link_parsed,
7311 .help_str = "set port X mirror-rule Y uplink-mirror|"
7312 "downlink-mirror dst-pool Z on|off",
7314 (void *)&cmd_mirror_link_set,
7315 (void *)&cmd_mirror_link_port,
7316 (void *)&cmd_mirror_link_portid,
7317 (void *)&cmd_mirror_link_mirror,
7318 (void *)&cmd_mirror_link_ruleid,
7319 (void *)&cmd_mirror_link_what,
7320 (void *)&cmd_mirror_link_dstpool,
7321 (void *)&cmd_mirror_link_poolid,
7322 (void *)&cmd_mirror_link_on,
7327 /* *** RESET VM MIRROR RULE *** */
7328 struct cmd_rm_mirror_rule_result {
7329 cmdline_fixed_string_t reset;
7330 cmdline_fixed_string_t port;
7332 cmdline_fixed_string_t mirror;
7336 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7337 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7339 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7340 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7342 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7343 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7345 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7346 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7347 mirror, "mirror-rule");
7348 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7349 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7353 cmd_reset_mirror_rule_parsed(void *parsed_result,
7354 __attribute__((unused)) struct cmdline *cl,
7355 __attribute__((unused)) void *data)
7358 struct cmd_set_mirror_link_result *res = parsed_result;
7360 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7362 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7365 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7366 .f = cmd_reset_mirror_rule_parsed,
7368 .help_str = "reset port X mirror-rule Y",
7370 (void *)&cmd_rm_mirror_rule_reset,
7371 (void *)&cmd_rm_mirror_rule_port,
7372 (void *)&cmd_rm_mirror_rule_portid,
7373 (void *)&cmd_rm_mirror_rule_mirror,
7374 (void *)&cmd_rm_mirror_rule_ruleid,
7379 /* ******************************************************************************** */
7381 struct cmd_dump_result {
7382 cmdline_fixed_string_t dump;
7386 dump_struct_sizes(void)
7388 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7389 DUMP_SIZE(struct rte_mbuf);
7390 DUMP_SIZE(struct rte_mempool);
7391 DUMP_SIZE(struct rte_ring);
7395 static void cmd_dump_parsed(void *parsed_result,
7396 __attribute__((unused)) struct cmdline *cl,
7397 __attribute__((unused)) void *data)
7399 struct cmd_dump_result *res = parsed_result;
7401 if (!strcmp(res->dump, "dump_physmem"))
7402 rte_dump_physmem_layout(stdout);
7403 else if (!strcmp(res->dump, "dump_memzone"))
7404 rte_memzone_dump(stdout);
7405 else if (!strcmp(res->dump, "dump_struct_sizes"))
7406 dump_struct_sizes();
7407 else if (!strcmp(res->dump, "dump_ring"))
7408 rte_ring_list_dump(stdout);
7409 else if (!strcmp(res->dump, "dump_mempool"))
7410 rte_mempool_list_dump(stdout);
7411 else if (!strcmp(res->dump, "dump_devargs"))
7412 rte_eal_devargs_dump(stdout);
7415 cmdline_parse_token_string_t cmd_dump_dump =
7416 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7419 "dump_struct_sizes#"
7424 cmdline_parse_inst_t cmd_dump = {
7425 .f = cmd_dump_parsed, /* function to call */
7426 .data = NULL, /* 2nd arg of func */
7427 .help_str = "dump status",
7428 .tokens = { /* token list, NULL terminated */
7429 (void *)&cmd_dump_dump,
7434 /* ******************************************************************************** */
7436 struct cmd_dump_one_result {
7437 cmdline_fixed_string_t dump;
7438 cmdline_fixed_string_t name;
7441 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7442 __attribute__((unused)) void *data)
7444 struct cmd_dump_one_result *res = parsed_result;
7446 if (!strcmp(res->dump, "dump_ring")) {
7448 r = rte_ring_lookup(res->name);
7450 cmdline_printf(cl, "Cannot find ring\n");
7453 rte_ring_dump(stdout, r);
7454 } else if (!strcmp(res->dump, "dump_mempool")) {
7455 struct rte_mempool *mp;
7456 mp = rte_mempool_lookup(res->name);
7458 cmdline_printf(cl, "Cannot find mempool\n");
7461 rte_mempool_dump(stdout, mp);
7465 cmdline_parse_token_string_t cmd_dump_one_dump =
7466 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7467 "dump_ring#dump_mempool");
7469 cmdline_parse_token_string_t cmd_dump_one_name =
7470 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7472 cmdline_parse_inst_t cmd_dump_one = {
7473 .f = cmd_dump_one_parsed, /* function to call */
7474 .data = NULL, /* 2nd arg of func */
7475 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7476 .tokens = { /* token list, NULL terminated */
7477 (void *)&cmd_dump_one_dump,
7478 (void *)&cmd_dump_one_name,
7483 /* *** Add/Del syn filter *** */
7484 struct cmd_syn_filter_result {
7485 cmdline_fixed_string_t filter;
7487 cmdline_fixed_string_t ops;
7488 cmdline_fixed_string_t priority;
7489 cmdline_fixed_string_t high;
7490 cmdline_fixed_string_t queue;
7495 cmd_syn_filter_parsed(void *parsed_result,
7496 __attribute__((unused)) struct cmdline *cl,
7497 __attribute__((unused)) void *data)
7499 struct cmd_syn_filter_result *res = parsed_result;
7500 struct rte_eth_syn_filter syn_filter;
7503 ret = rte_eth_dev_filter_supported(res->port_id,
7504 RTE_ETH_FILTER_SYN);
7506 printf("syn filter is not supported on port %u.\n",
7511 memset(&syn_filter, 0, sizeof(syn_filter));
7513 if (!strcmp(res->ops, "add")) {
7514 if (!strcmp(res->high, "high"))
7515 syn_filter.hig_pri = 1;
7517 syn_filter.hig_pri = 0;
7519 syn_filter.queue = res->queue_id;
7520 ret = rte_eth_dev_filter_ctrl(res->port_id,
7525 ret = rte_eth_dev_filter_ctrl(res->port_id,
7527 RTE_ETH_FILTER_DELETE,
7531 printf("syn filter programming error: (%s)\n",
7535 cmdline_parse_token_string_t cmd_syn_filter_filter =
7536 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7537 filter, "syn_filter");
7538 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7539 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7541 cmdline_parse_token_string_t cmd_syn_filter_ops =
7542 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7544 cmdline_parse_token_string_t cmd_syn_filter_priority =
7545 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7546 priority, "priority");
7547 cmdline_parse_token_string_t cmd_syn_filter_high =
7548 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7550 cmdline_parse_token_string_t cmd_syn_filter_queue =
7551 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7553 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7554 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7557 cmdline_parse_inst_t cmd_syn_filter = {
7558 .f = cmd_syn_filter_parsed,
7560 .help_str = "add/delete syn filter",
7562 (void *)&cmd_syn_filter_filter,
7563 (void *)&cmd_syn_filter_port_id,
7564 (void *)&cmd_syn_filter_ops,
7565 (void *)&cmd_syn_filter_priority,
7566 (void *)&cmd_syn_filter_high,
7567 (void *)&cmd_syn_filter_queue,
7568 (void *)&cmd_syn_filter_queue_id,
7573 /* *** ADD/REMOVE A 2tuple FILTER *** */
7574 struct cmd_2tuple_filter_result {
7575 cmdline_fixed_string_t filter;
7577 cmdline_fixed_string_t ops;
7578 cmdline_fixed_string_t dst_port;
7579 uint16_t dst_port_value;
7580 cmdline_fixed_string_t protocol;
7581 uint8_t protocol_value;
7582 cmdline_fixed_string_t mask;
7584 cmdline_fixed_string_t tcp_flags;
7585 uint8_t tcp_flags_value;
7586 cmdline_fixed_string_t priority;
7587 uint8_t priority_value;
7588 cmdline_fixed_string_t queue;
7593 cmd_2tuple_filter_parsed(void *parsed_result,
7594 __attribute__((unused)) struct cmdline *cl,
7595 __attribute__((unused)) void *data)
7597 struct rte_eth_ntuple_filter filter;
7598 struct cmd_2tuple_filter_result *res = parsed_result;
7601 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7603 printf("ntuple filter is not supported on port %u.\n",
7608 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7610 filter.flags = RTE_2TUPLE_FLAGS;
7611 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7612 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7613 filter.proto = res->protocol_value;
7614 filter.priority = res->priority_value;
7615 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7616 printf("nonzero tcp_flags is only meaningful"
7617 " when protocol is TCP.\n");
7620 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7621 printf("invalid TCP flags.\n");
7625 if (res->tcp_flags_value != 0) {
7626 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7627 filter.tcp_flags = res->tcp_flags_value;
7630 /* need convert to big endian. */
7631 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7632 filter.queue = res->queue_id;
7634 if (!strcmp(res->ops, "add"))
7635 ret = rte_eth_dev_filter_ctrl(res->port_id,
7636 RTE_ETH_FILTER_NTUPLE,
7640 ret = rte_eth_dev_filter_ctrl(res->port_id,
7641 RTE_ETH_FILTER_NTUPLE,
7642 RTE_ETH_FILTER_DELETE,
7645 printf("2tuple filter programming error: (%s)\n",
7650 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7651 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7652 filter, "2tuple_filter");
7653 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7654 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7656 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7657 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7659 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7660 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7661 dst_port, "dst_port");
7662 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7663 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7664 dst_port_value, UINT16);
7665 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7666 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7667 protocol, "protocol");
7668 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7669 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7670 protocol_value, UINT8);
7671 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7672 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7674 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7675 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7677 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7678 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7679 tcp_flags, "tcp_flags");
7680 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7681 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7682 tcp_flags_value, UINT8);
7683 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7684 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7685 priority, "priority");
7686 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7687 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7688 priority_value, UINT8);
7689 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7690 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7692 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7693 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7696 cmdline_parse_inst_t cmd_2tuple_filter = {
7697 .f = cmd_2tuple_filter_parsed,
7699 .help_str = "add a 2tuple filter",
7701 (void *)&cmd_2tuple_filter_filter,
7702 (void *)&cmd_2tuple_filter_port_id,
7703 (void *)&cmd_2tuple_filter_ops,
7704 (void *)&cmd_2tuple_filter_dst_port,
7705 (void *)&cmd_2tuple_filter_dst_port_value,
7706 (void *)&cmd_2tuple_filter_protocol,
7707 (void *)&cmd_2tuple_filter_protocol_value,
7708 (void *)&cmd_2tuple_filter_mask,
7709 (void *)&cmd_2tuple_filter_mask_value,
7710 (void *)&cmd_2tuple_filter_tcp_flags,
7711 (void *)&cmd_2tuple_filter_tcp_flags_value,
7712 (void *)&cmd_2tuple_filter_priority,
7713 (void *)&cmd_2tuple_filter_priority_value,
7714 (void *)&cmd_2tuple_filter_queue,
7715 (void *)&cmd_2tuple_filter_queue_id,
7720 /* *** ADD/REMOVE A 5tuple FILTER *** */
7721 struct cmd_5tuple_filter_result {
7722 cmdline_fixed_string_t filter;
7724 cmdline_fixed_string_t ops;
7725 cmdline_fixed_string_t dst_ip;
7726 cmdline_ipaddr_t dst_ip_value;
7727 cmdline_fixed_string_t src_ip;
7728 cmdline_ipaddr_t src_ip_value;
7729 cmdline_fixed_string_t dst_port;
7730 uint16_t dst_port_value;
7731 cmdline_fixed_string_t src_port;
7732 uint16_t src_port_value;
7733 cmdline_fixed_string_t protocol;
7734 uint8_t protocol_value;
7735 cmdline_fixed_string_t mask;
7737 cmdline_fixed_string_t tcp_flags;
7738 uint8_t tcp_flags_value;
7739 cmdline_fixed_string_t priority;
7740 uint8_t priority_value;
7741 cmdline_fixed_string_t queue;
7746 cmd_5tuple_filter_parsed(void *parsed_result,
7747 __attribute__((unused)) struct cmdline *cl,
7748 __attribute__((unused)) void *data)
7750 struct rte_eth_ntuple_filter filter;
7751 struct cmd_5tuple_filter_result *res = parsed_result;
7754 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7756 printf("ntuple filter is not supported on port %u.\n",
7761 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7763 filter.flags = RTE_5TUPLE_FLAGS;
7764 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7765 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7766 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7767 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7768 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7769 filter.proto = res->protocol_value;
7770 filter.priority = res->priority_value;
7771 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7772 printf("nonzero tcp_flags is only meaningful"
7773 " when protocol is TCP.\n");
7776 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7777 printf("invalid TCP flags.\n");
7781 if (res->tcp_flags_value != 0) {
7782 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7783 filter.tcp_flags = res->tcp_flags_value;
7786 if (res->dst_ip_value.family == AF_INET)
7787 /* no need to convert, already big endian. */
7788 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7790 if (filter.dst_ip_mask == 0) {
7791 printf("can not support ipv6 involved compare.\n");
7797 if (res->src_ip_value.family == AF_INET)
7798 /* no need to convert, already big endian. */
7799 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7801 if (filter.src_ip_mask == 0) {
7802 printf("can not support ipv6 involved compare.\n");
7807 /* need convert to big endian. */
7808 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7809 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7810 filter.queue = res->queue_id;
7812 if (!strcmp(res->ops, "add"))
7813 ret = rte_eth_dev_filter_ctrl(res->port_id,
7814 RTE_ETH_FILTER_NTUPLE,
7818 ret = rte_eth_dev_filter_ctrl(res->port_id,
7819 RTE_ETH_FILTER_NTUPLE,
7820 RTE_ETH_FILTER_DELETE,
7823 printf("5tuple filter programming error: (%s)\n",
7827 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7828 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7829 filter, "5tuple_filter");
7830 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7831 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7833 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7834 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7836 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7837 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7839 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7840 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7842 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7843 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7845 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7846 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7848 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7849 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7850 dst_port, "dst_port");
7851 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7852 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7853 dst_port_value, UINT16);
7854 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7855 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7856 src_port, "src_port");
7857 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7858 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7859 src_port_value, UINT16);
7860 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7861 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7862 protocol, "protocol");
7863 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7864 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7865 protocol_value, UINT8);
7866 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7867 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7869 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7870 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7872 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7873 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7874 tcp_flags, "tcp_flags");
7875 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7876 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7877 tcp_flags_value, UINT8);
7878 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7879 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7880 priority, "priority");
7881 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7882 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7883 priority_value, UINT8);
7884 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7885 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7887 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7888 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7891 cmdline_parse_inst_t cmd_5tuple_filter = {
7892 .f = cmd_5tuple_filter_parsed,
7894 .help_str = "add/del a 5tuple filter",
7896 (void *)&cmd_5tuple_filter_filter,
7897 (void *)&cmd_5tuple_filter_port_id,
7898 (void *)&cmd_5tuple_filter_ops,
7899 (void *)&cmd_5tuple_filter_dst_ip,
7900 (void *)&cmd_5tuple_filter_dst_ip_value,
7901 (void *)&cmd_5tuple_filter_src_ip,
7902 (void *)&cmd_5tuple_filter_src_ip_value,
7903 (void *)&cmd_5tuple_filter_dst_port,
7904 (void *)&cmd_5tuple_filter_dst_port_value,
7905 (void *)&cmd_5tuple_filter_src_port,
7906 (void *)&cmd_5tuple_filter_src_port_value,
7907 (void *)&cmd_5tuple_filter_protocol,
7908 (void *)&cmd_5tuple_filter_protocol_value,
7909 (void *)&cmd_5tuple_filter_mask,
7910 (void *)&cmd_5tuple_filter_mask_value,
7911 (void *)&cmd_5tuple_filter_tcp_flags,
7912 (void *)&cmd_5tuple_filter_tcp_flags_value,
7913 (void *)&cmd_5tuple_filter_priority,
7914 (void *)&cmd_5tuple_filter_priority_value,
7915 (void *)&cmd_5tuple_filter_queue,
7916 (void *)&cmd_5tuple_filter_queue_id,
7921 /* *** ADD/REMOVE A flex FILTER *** */
7922 struct cmd_flex_filter_result {
7923 cmdline_fixed_string_t filter;
7924 cmdline_fixed_string_t ops;
7926 cmdline_fixed_string_t len;
7928 cmdline_fixed_string_t bytes;
7929 cmdline_fixed_string_t bytes_value;
7930 cmdline_fixed_string_t mask;
7931 cmdline_fixed_string_t mask_value;
7932 cmdline_fixed_string_t priority;
7933 uint8_t priority_value;
7934 cmdline_fixed_string_t queue;
7938 static int xdigit2val(unsigned char c)
7943 else if (isupper(c))
7951 cmd_flex_filter_parsed(void *parsed_result,
7952 __attribute__((unused)) struct cmdline *cl,
7953 __attribute__((unused)) void *data)
7956 struct rte_eth_flex_filter filter;
7957 struct cmd_flex_filter_result *res = parsed_result;
7958 char *bytes_ptr, *mask_ptr;
7959 uint16_t len, i, j = 0;
7964 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7965 printf("the len exceed the max length 128\n");
7968 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7969 filter.len = res->len_value;
7970 filter.priority = res->priority_value;
7971 filter.queue = res->queue_id;
7972 bytes_ptr = res->bytes_value;
7973 mask_ptr = res->mask_value;
7975 /* translate bytes string to array. */
7976 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7977 (bytes_ptr[1] == 'X')))
7979 len = strnlen(bytes_ptr, res->len_value * 2);
7980 if (len == 0 || (len % 8 != 0)) {
7981 printf("please check len and bytes input\n");
7984 for (i = 0; i < len; i++) {
7986 if (isxdigit(c) == 0) {
7987 /* invalid characters. */
7988 printf("invalid input\n");
7991 val = xdigit2val(c);
7994 filter.bytes[j] = byte;
7995 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8002 /* translate mask string to uint8_t array. */
8003 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8004 (mask_ptr[1] == 'X')))
8006 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8008 printf("invalid input\n");
8013 for (i = 0; i < len; i++) {
8015 if (isxdigit(c) == 0) {
8016 /* invalid characters. */
8017 printf("invalid input\n");
8020 val = xdigit2val(c);
8023 filter.mask[j] = byte;
8024 printf("mask[%d]:%02x ", j, filter.mask[j]);
8032 if (!strcmp(res->ops, "add"))
8033 ret = rte_eth_dev_filter_ctrl(res->port_id,
8034 RTE_ETH_FILTER_FLEXIBLE,
8038 ret = rte_eth_dev_filter_ctrl(res->port_id,
8039 RTE_ETH_FILTER_FLEXIBLE,
8040 RTE_ETH_FILTER_DELETE,
8044 printf("flex filter setting error: (%s)\n", strerror(-ret));
8047 cmdline_parse_token_string_t cmd_flex_filter_filter =
8048 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8049 filter, "flex_filter");
8050 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8051 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8053 cmdline_parse_token_string_t cmd_flex_filter_ops =
8054 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8056 cmdline_parse_token_string_t cmd_flex_filter_len =
8057 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8059 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8060 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8062 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8063 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8065 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8066 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8068 cmdline_parse_token_string_t cmd_flex_filter_mask =
8069 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8071 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8072 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8074 cmdline_parse_token_string_t cmd_flex_filter_priority =
8075 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8076 priority, "priority");
8077 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8078 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8079 priority_value, UINT8);
8080 cmdline_parse_token_string_t cmd_flex_filter_queue =
8081 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8083 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8084 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8086 cmdline_parse_inst_t cmd_flex_filter = {
8087 .f = cmd_flex_filter_parsed,
8089 .help_str = "add/del a flex filter",
8091 (void *)&cmd_flex_filter_filter,
8092 (void *)&cmd_flex_filter_port_id,
8093 (void *)&cmd_flex_filter_ops,
8094 (void *)&cmd_flex_filter_len,
8095 (void *)&cmd_flex_filter_len_value,
8096 (void *)&cmd_flex_filter_bytes,
8097 (void *)&cmd_flex_filter_bytes_value,
8098 (void *)&cmd_flex_filter_mask,
8099 (void *)&cmd_flex_filter_mask_value,
8100 (void *)&cmd_flex_filter_priority,
8101 (void *)&cmd_flex_filter_priority_value,
8102 (void *)&cmd_flex_filter_queue,
8103 (void *)&cmd_flex_filter_queue_id,
8108 /* *** Filters Control *** */
8110 /* *** deal with ethertype filter *** */
8111 struct cmd_ethertype_filter_result {
8112 cmdline_fixed_string_t filter;
8114 cmdline_fixed_string_t ops;
8115 cmdline_fixed_string_t mac;
8116 struct ether_addr mac_addr;
8117 cmdline_fixed_string_t ethertype;
8118 uint16_t ethertype_value;
8119 cmdline_fixed_string_t drop;
8120 cmdline_fixed_string_t queue;
8124 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8125 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8126 filter, "ethertype_filter");
8127 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8128 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8130 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8131 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8133 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8134 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8135 mac, "mac_addr#mac_ignr");
8136 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8137 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8139 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8140 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8141 ethertype, "ethertype");
8142 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8143 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8144 ethertype_value, UINT16);
8145 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8146 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8148 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8149 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8151 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8152 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8156 cmd_ethertype_filter_parsed(void *parsed_result,
8157 __attribute__((unused)) struct cmdline *cl,
8158 __attribute__((unused)) void *data)
8160 struct cmd_ethertype_filter_result *res = parsed_result;
8161 struct rte_eth_ethertype_filter filter;
8164 ret = rte_eth_dev_filter_supported(res->port_id,
8165 RTE_ETH_FILTER_ETHERTYPE);
8167 printf("ethertype filter is not supported on port %u.\n",
8172 memset(&filter, 0, sizeof(filter));
8173 if (!strcmp(res->mac, "mac_addr")) {
8174 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8175 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8176 sizeof(struct ether_addr));
8178 if (!strcmp(res->drop, "drop"))
8179 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8180 filter.ether_type = res->ethertype_value;
8181 filter.queue = res->queue_id;
8183 if (!strcmp(res->ops, "add"))
8184 ret = rte_eth_dev_filter_ctrl(res->port_id,
8185 RTE_ETH_FILTER_ETHERTYPE,
8189 ret = rte_eth_dev_filter_ctrl(res->port_id,
8190 RTE_ETH_FILTER_ETHERTYPE,
8191 RTE_ETH_FILTER_DELETE,
8194 printf("ethertype filter programming error: (%s)\n",
8198 cmdline_parse_inst_t cmd_ethertype_filter = {
8199 .f = cmd_ethertype_filter_parsed,
8201 .help_str = "add or delete an ethertype filter entry",
8203 (void *)&cmd_ethertype_filter_filter,
8204 (void *)&cmd_ethertype_filter_port_id,
8205 (void *)&cmd_ethertype_filter_ops,
8206 (void *)&cmd_ethertype_filter_mac,
8207 (void *)&cmd_ethertype_filter_mac_addr,
8208 (void *)&cmd_ethertype_filter_ethertype,
8209 (void *)&cmd_ethertype_filter_ethertype_value,
8210 (void *)&cmd_ethertype_filter_drop,
8211 (void *)&cmd_ethertype_filter_queue,
8212 (void *)&cmd_ethertype_filter_queue_id,
8217 /* *** deal with flow director filter *** */
8218 struct cmd_flow_director_result {
8219 cmdline_fixed_string_t flow_director_filter;
8221 cmdline_fixed_string_t mode;
8222 cmdline_fixed_string_t mode_value;
8223 cmdline_fixed_string_t ops;
8224 cmdline_fixed_string_t flow;
8225 cmdline_fixed_string_t flow_type;
8226 cmdline_fixed_string_t ether;
8227 uint16_t ether_type;
8228 cmdline_fixed_string_t src;
8229 cmdline_ipaddr_t ip_src;
8231 cmdline_fixed_string_t dst;
8232 cmdline_ipaddr_t ip_dst;
8234 cmdline_fixed_string_t verify_tag;
8235 uint32_t verify_tag_value;
8236 cmdline_ipaddr_t tos;
8238 cmdline_ipaddr_t proto;
8239 uint8_t proto_value;
8240 cmdline_ipaddr_t ttl;
8242 cmdline_fixed_string_t vlan;
8243 uint16_t vlan_value;
8244 cmdline_fixed_string_t flexbytes;
8245 cmdline_fixed_string_t flexbytes_value;
8246 cmdline_fixed_string_t pf_vf;
8247 cmdline_fixed_string_t drop;
8248 cmdline_fixed_string_t queue;
8250 cmdline_fixed_string_t fd_id;
8251 uint32_t fd_id_value;
8252 cmdline_fixed_string_t mac;
8253 struct ether_addr mac_addr;
8254 cmdline_fixed_string_t tunnel;
8255 cmdline_fixed_string_t tunnel_type;
8256 cmdline_fixed_string_t tunnel_id;
8257 uint32_t tunnel_id_value;
8261 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8264 const char *p, *p0 = q_arg;
8266 unsigned long int_fld;
8267 char *str_fld[max_num];
8272 p = strchr(p0, '(');
8276 p0 = strchr(p, ')');
8281 if (size >= sizeof(s))
8284 snprintf(s, sizeof(s), "%.*s", size, p);
8285 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8286 if (ret < 0 || ret > max_num)
8288 for (i = 0; i < ret; i++) {
8290 int_fld = strtoul(str_fld[i], &end, 0);
8291 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8293 flexbytes[i] = (uint8_t)int_fld;
8299 str2flowtype(char *string)
8302 static const struct {
8305 } flowtype_str[] = {
8306 {"raw", RTE_ETH_FLOW_RAW},
8307 {"ipv4", RTE_ETH_FLOW_IPV4},
8308 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8309 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8310 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8311 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8312 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8313 {"ipv6", RTE_ETH_FLOW_IPV6},
8314 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8315 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8316 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8317 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8318 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8319 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8322 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8323 if (!strcmp(flowtype_str[i].str, string))
8324 return flowtype_str[i].type;
8326 return RTE_ETH_FLOW_UNKNOWN;
8329 static enum rte_eth_fdir_tunnel_type
8330 str2fdir_tunneltype(char *string)
8334 static const struct {
8336 enum rte_eth_fdir_tunnel_type type;
8337 } tunneltype_str[] = {
8338 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8339 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8342 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8343 if (!strcmp(tunneltype_str[i].str, string))
8344 return tunneltype_str[i].type;
8346 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8349 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8351 if ((ip_addr).family == AF_INET) \
8352 (ip) = (ip_addr).addr.ipv4.s_addr; \
8354 printf("invalid parameter.\n"); \
8359 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8361 if ((ip_addr).family == AF_INET6) \
8362 (void)rte_memcpy(&(ip), \
8363 &((ip_addr).addr.ipv6), \
8364 sizeof(struct in6_addr)); \
8366 printf("invalid parameter.\n"); \
8372 cmd_flow_director_filter_parsed(void *parsed_result,
8373 __attribute__((unused)) struct cmdline *cl,
8374 __attribute__((unused)) void *data)
8376 struct cmd_flow_director_result *res = parsed_result;
8377 struct rte_eth_fdir_filter entry;
8378 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8380 unsigned long vf_id;
8383 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8385 printf("flow director is not supported on port %u.\n",
8389 memset(flexbytes, 0, sizeof(flexbytes));
8390 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8392 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8393 if (strcmp(res->mode_value, "MAC-VLAN")) {
8394 printf("Please set mode to MAC-VLAN.\n");
8397 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8398 if (strcmp(res->mode_value, "Tunnel")) {
8399 printf("Please set mode to Tunnel.\n");
8403 if (strcmp(res->mode_value, "IP")) {
8404 printf("Please set mode to IP.\n");
8407 entry.input.flow_type = str2flowtype(res->flow_type);
8410 ret = parse_flexbytes(res->flexbytes_value,
8412 RTE_ETH_FDIR_MAX_FLEXLEN);
8414 printf("error: Cannot parse flexbytes input.\n");
8418 switch (entry.input.flow_type) {
8419 case RTE_ETH_FLOW_FRAG_IPV4:
8420 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8421 entry.input.flow.ip4_flow.proto = res->proto_value;
8422 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8423 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8424 IPV4_ADDR_TO_UINT(res->ip_dst,
8425 entry.input.flow.ip4_flow.dst_ip);
8426 IPV4_ADDR_TO_UINT(res->ip_src,
8427 entry.input.flow.ip4_flow.src_ip);
8428 entry.input.flow.ip4_flow.tos = res->tos_value;
8429 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8430 /* need convert to big endian. */
8431 entry.input.flow.udp4_flow.dst_port =
8432 rte_cpu_to_be_16(res->port_dst);
8433 entry.input.flow.udp4_flow.src_port =
8434 rte_cpu_to_be_16(res->port_src);
8436 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8437 IPV4_ADDR_TO_UINT(res->ip_dst,
8438 entry.input.flow.sctp4_flow.ip.dst_ip);
8439 IPV4_ADDR_TO_UINT(res->ip_src,
8440 entry.input.flow.sctp4_flow.ip.src_ip);
8441 entry.input.flow.ip4_flow.tos = res->tos_value;
8442 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8443 /* need convert to big endian. */
8444 entry.input.flow.sctp4_flow.dst_port =
8445 rte_cpu_to_be_16(res->port_dst);
8446 entry.input.flow.sctp4_flow.src_port =
8447 rte_cpu_to_be_16(res->port_src);
8448 entry.input.flow.sctp4_flow.verify_tag =
8449 rte_cpu_to_be_32(res->verify_tag_value);
8451 case RTE_ETH_FLOW_FRAG_IPV6:
8452 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8453 entry.input.flow.ipv6_flow.proto = res->proto_value;
8454 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8455 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8456 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8457 entry.input.flow.ipv6_flow.dst_ip);
8458 IPV6_ADDR_TO_ARRAY(res->ip_src,
8459 entry.input.flow.ipv6_flow.src_ip);
8460 entry.input.flow.ipv6_flow.tc = res->tos_value;
8461 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8462 /* need convert to big endian. */
8463 entry.input.flow.udp6_flow.dst_port =
8464 rte_cpu_to_be_16(res->port_dst);
8465 entry.input.flow.udp6_flow.src_port =
8466 rte_cpu_to_be_16(res->port_src);
8468 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8469 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8470 entry.input.flow.sctp6_flow.ip.dst_ip);
8471 IPV6_ADDR_TO_ARRAY(res->ip_src,
8472 entry.input.flow.sctp6_flow.ip.src_ip);
8473 entry.input.flow.ipv6_flow.tc = res->tos_value;
8474 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8475 /* need convert to big endian. */
8476 entry.input.flow.sctp6_flow.dst_port =
8477 rte_cpu_to_be_16(res->port_dst);
8478 entry.input.flow.sctp6_flow.src_port =
8479 rte_cpu_to_be_16(res->port_src);
8480 entry.input.flow.sctp6_flow.verify_tag =
8481 rte_cpu_to_be_32(res->verify_tag_value);
8483 case RTE_ETH_FLOW_L2_PAYLOAD:
8484 entry.input.flow.l2_flow.ether_type =
8485 rte_cpu_to_be_16(res->ether_type);
8491 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8492 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8494 sizeof(struct ether_addr));
8496 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8497 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8499 sizeof(struct ether_addr));
8500 entry.input.flow.tunnel_flow.tunnel_type =
8501 str2fdir_tunneltype(res->tunnel_type);
8502 entry.input.flow.tunnel_flow.tunnel_id =
8503 rte_cpu_to_be_32(res->tunnel_id_value);
8506 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8508 RTE_ETH_FDIR_MAX_FLEXLEN);
8510 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8512 entry.action.flex_off = 0; /*use 0 by default */
8513 if (!strcmp(res->drop, "drop"))
8514 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8516 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8518 if (!strcmp(res->pf_vf, "pf"))
8519 entry.input.flow_ext.is_vf = 0;
8520 else if (!strncmp(res->pf_vf, "vf", 2)) {
8521 struct rte_eth_dev_info dev_info;
8523 memset(&dev_info, 0, sizeof(dev_info));
8524 rte_eth_dev_info_get(res->port_id, &dev_info);
8526 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8527 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8528 printf("invalid parameter %s.\n", res->pf_vf);
8531 entry.input.flow_ext.is_vf = 1;
8532 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8534 printf("invalid parameter %s.\n", res->pf_vf);
8538 /* set to report FD ID by default */
8539 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8540 entry.action.rx_queue = res->queue_id;
8541 entry.soft_id = res->fd_id_value;
8542 if (!strcmp(res->ops, "add"))
8543 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8544 RTE_ETH_FILTER_ADD, &entry);
8545 else if (!strcmp(res->ops, "del"))
8546 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8547 RTE_ETH_FILTER_DELETE, &entry);
8549 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8550 RTE_ETH_FILTER_UPDATE, &entry);
8552 printf("flow director programming error: (%s)\n",
8556 cmdline_parse_token_string_t cmd_flow_director_filter =
8557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8558 flow_director_filter, "flow_director_filter");
8559 cmdline_parse_token_num_t cmd_flow_director_port_id =
8560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8562 cmdline_parse_token_string_t cmd_flow_director_ops =
8563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8564 ops, "add#del#update");
8565 cmdline_parse_token_string_t cmd_flow_director_flow =
8566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8568 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8570 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8571 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8572 cmdline_parse_token_string_t cmd_flow_director_ether =
8573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8575 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8576 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8577 ether_type, UINT16);
8578 cmdline_parse_token_string_t cmd_flow_director_src =
8579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8581 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8582 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8584 cmdline_parse_token_num_t cmd_flow_director_port_src =
8585 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8587 cmdline_parse_token_string_t cmd_flow_director_dst =
8588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8590 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8591 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8593 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8594 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8596 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8597 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8598 verify_tag, "verify_tag");
8599 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8601 verify_tag_value, UINT32);
8602 cmdline_parse_token_string_t cmd_flow_director_tos =
8603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8605 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8606 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8608 cmdline_parse_token_string_t cmd_flow_director_proto =
8609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8611 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8612 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8613 proto_value, UINT8);
8614 cmdline_parse_token_string_t cmd_flow_director_ttl =
8615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8617 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8620 cmdline_parse_token_string_t cmd_flow_director_vlan =
8621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8623 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8624 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8625 vlan_value, UINT16);
8626 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8627 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8628 flexbytes, "flexbytes");
8629 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8630 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8631 flexbytes_value, NULL);
8632 cmdline_parse_token_string_t cmd_flow_director_drop =
8633 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8635 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8638 cmdline_parse_token_string_t cmd_flow_director_queue =
8639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8641 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8644 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8647 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8649 fd_id_value, UINT32);
8651 cmdline_parse_token_string_t cmd_flow_director_mode =
8652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8654 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8655 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8657 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8658 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8659 mode_value, "MAC-VLAN");
8660 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8662 mode_value, "Tunnel");
8663 cmdline_parse_token_string_t cmd_flow_director_mac =
8664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8666 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8667 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8669 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8672 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8674 tunnel_type, "NVGRE#VxLAN");
8675 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8677 tunnel_id, "tunnel-id");
8678 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8679 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8680 tunnel_id_value, UINT32);
8682 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8683 .f = cmd_flow_director_filter_parsed,
8685 .help_str = "add or delete an ip flow director entry on NIC",
8687 (void *)&cmd_flow_director_filter,
8688 (void *)&cmd_flow_director_port_id,
8689 (void *)&cmd_flow_director_mode,
8690 (void *)&cmd_flow_director_mode_ip,
8691 (void *)&cmd_flow_director_ops,
8692 (void *)&cmd_flow_director_flow,
8693 (void *)&cmd_flow_director_flow_type,
8694 (void *)&cmd_flow_director_src,
8695 (void *)&cmd_flow_director_ip_src,
8696 (void *)&cmd_flow_director_dst,
8697 (void *)&cmd_flow_director_ip_dst,
8698 (void *)&cmd_flow_director_tos,
8699 (void *)&cmd_flow_director_tos_value,
8700 (void *)&cmd_flow_director_proto,
8701 (void *)&cmd_flow_director_proto_value,
8702 (void *)&cmd_flow_director_ttl,
8703 (void *)&cmd_flow_director_ttl_value,
8704 (void *)&cmd_flow_director_vlan,
8705 (void *)&cmd_flow_director_vlan_value,
8706 (void *)&cmd_flow_director_flexbytes,
8707 (void *)&cmd_flow_director_flexbytes_value,
8708 (void *)&cmd_flow_director_drop,
8709 (void *)&cmd_flow_director_pf_vf,
8710 (void *)&cmd_flow_director_queue,
8711 (void *)&cmd_flow_director_queue_id,
8712 (void *)&cmd_flow_director_fd_id,
8713 (void *)&cmd_flow_director_fd_id_value,
8718 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8719 .f = cmd_flow_director_filter_parsed,
8721 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8723 (void *)&cmd_flow_director_filter,
8724 (void *)&cmd_flow_director_port_id,
8725 (void *)&cmd_flow_director_mode,
8726 (void *)&cmd_flow_director_mode_ip,
8727 (void *)&cmd_flow_director_ops,
8728 (void *)&cmd_flow_director_flow,
8729 (void *)&cmd_flow_director_flow_type,
8730 (void *)&cmd_flow_director_src,
8731 (void *)&cmd_flow_director_ip_src,
8732 (void *)&cmd_flow_director_port_src,
8733 (void *)&cmd_flow_director_dst,
8734 (void *)&cmd_flow_director_ip_dst,
8735 (void *)&cmd_flow_director_port_dst,
8736 (void *)&cmd_flow_director_tos,
8737 (void *)&cmd_flow_director_tos_value,
8738 (void *)&cmd_flow_director_ttl,
8739 (void *)&cmd_flow_director_ttl_value,
8740 (void *)&cmd_flow_director_vlan,
8741 (void *)&cmd_flow_director_vlan_value,
8742 (void *)&cmd_flow_director_flexbytes,
8743 (void *)&cmd_flow_director_flexbytes_value,
8744 (void *)&cmd_flow_director_drop,
8745 (void *)&cmd_flow_director_pf_vf,
8746 (void *)&cmd_flow_director_queue,
8747 (void *)&cmd_flow_director_queue_id,
8748 (void *)&cmd_flow_director_fd_id,
8749 (void *)&cmd_flow_director_fd_id_value,
8754 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8755 .f = cmd_flow_director_filter_parsed,
8757 .help_str = "add or delete a sctp flow director entry on NIC",
8759 (void *)&cmd_flow_director_filter,
8760 (void *)&cmd_flow_director_port_id,
8761 (void *)&cmd_flow_director_mode,
8762 (void *)&cmd_flow_director_mode_ip,
8763 (void *)&cmd_flow_director_ops,
8764 (void *)&cmd_flow_director_flow,
8765 (void *)&cmd_flow_director_flow_type,
8766 (void *)&cmd_flow_director_src,
8767 (void *)&cmd_flow_director_ip_src,
8768 (void *)&cmd_flow_director_port_dst,
8769 (void *)&cmd_flow_director_dst,
8770 (void *)&cmd_flow_director_ip_dst,
8771 (void *)&cmd_flow_director_port_dst,
8772 (void *)&cmd_flow_director_verify_tag,
8773 (void *)&cmd_flow_director_verify_tag_value,
8774 (void *)&cmd_flow_director_tos,
8775 (void *)&cmd_flow_director_tos_value,
8776 (void *)&cmd_flow_director_ttl,
8777 (void *)&cmd_flow_director_ttl_value,
8778 (void *)&cmd_flow_director_vlan,
8779 (void *)&cmd_flow_director_vlan_value,
8780 (void *)&cmd_flow_director_flexbytes,
8781 (void *)&cmd_flow_director_flexbytes_value,
8782 (void *)&cmd_flow_director_drop,
8783 (void *)&cmd_flow_director_pf_vf,
8784 (void *)&cmd_flow_director_queue,
8785 (void *)&cmd_flow_director_queue_id,
8786 (void *)&cmd_flow_director_fd_id,
8787 (void *)&cmd_flow_director_fd_id_value,
8792 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8793 .f = cmd_flow_director_filter_parsed,
8795 .help_str = "add or delete a L2 flow director entry on NIC",
8797 (void *)&cmd_flow_director_filter,
8798 (void *)&cmd_flow_director_port_id,
8799 (void *)&cmd_flow_director_mode,
8800 (void *)&cmd_flow_director_mode_ip,
8801 (void *)&cmd_flow_director_ops,
8802 (void *)&cmd_flow_director_flow,
8803 (void *)&cmd_flow_director_flow_type,
8804 (void *)&cmd_flow_director_ether,
8805 (void *)&cmd_flow_director_ether_type,
8806 (void *)&cmd_flow_director_flexbytes,
8807 (void *)&cmd_flow_director_flexbytes_value,
8808 (void *)&cmd_flow_director_drop,
8809 (void *)&cmd_flow_director_pf_vf,
8810 (void *)&cmd_flow_director_queue,
8811 (void *)&cmd_flow_director_queue_id,
8812 (void *)&cmd_flow_director_fd_id,
8813 (void *)&cmd_flow_director_fd_id_value,
8818 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8819 .f = cmd_flow_director_filter_parsed,
8821 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8823 (void *)&cmd_flow_director_filter,
8824 (void *)&cmd_flow_director_port_id,
8825 (void *)&cmd_flow_director_mode,
8826 (void *)&cmd_flow_director_mode_mac_vlan,
8827 (void *)&cmd_flow_director_ops,
8828 (void *)&cmd_flow_director_mac,
8829 (void *)&cmd_flow_director_mac_addr,
8830 (void *)&cmd_flow_director_vlan,
8831 (void *)&cmd_flow_director_vlan_value,
8832 (void *)&cmd_flow_director_flexbytes,
8833 (void *)&cmd_flow_director_flexbytes_value,
8834 (void *)&cmd_flow_director_drop,
8835 (void *)&cmd_flow_director_queue,
8836 (void *)&cmd_flow_director_queue_id,
8837 (void *)&cmd_flow_director_fd_id,
8838 (void *)&cmd_flow_director_fd_id_value,
8843 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8844 .f = cmd_flow_director_filter_parsed,
8846 .help_str = "add or delete a tunnel flow director entry on NIC",
8848 (void *)&cmd_flow_director_filter,
8849 (void *)&cmd_flow_director_port_id,
8850 (void *)&cmd_flow_director_mode,
8851 (void *)&cmd_flow_director_mode_tunnel,
8852 (void *)&cmd_flow_director_ops,
8853 (void *)&cmd_flow_director_mac,
8854 (void *)&cmd_flow_director_mac_addr,
8855 (void *)&cmd_flow_director_vlan,
8856 (void *)&cmd_flow_director_vlan_value,
8857 (void *)&cmd_flow_director_tunnel,
8858 (void *)&cmd_flow_director_tunnel_type,
8859 (void *)&cmd_flow_director_tunnel_id,
8860 (void *)&cmd_flow_director_tunnel_id_value,
8861 (void *)&cmd_flow_director_flexbytes,
8862 (void *)&cmd_flow_director_flexbytes_value,
8863 (void *)&cmd_flow_director_drop,
8864 (void *)&cmd_flow_director_queue,
8865 (void *)&cmd_flow_director_queue_id,
8866 (void *)&cmd_flow_director_fd_id,
8867 (void *)&cmd_flow_director_fd_id_value,
8872 struct cmd_flush_flow_director_result {
8873 cmdline_fixed_string_t flush_flow_director;
8877 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8878 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8879 flush_flow_director, "flush_flow_director");
8880 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8881 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8885 cmd_flush_flow_director_parsed(void *parsed_result,
8886 __attribute__((unused)) struct cmdline *cl,
8887 __attribute__((unused)) void *data)
8889 struct cmd_flow_director_result *res = parsed_result;
8892 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8894 printf("flow director is not supported on port %u.\n",
8899 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8900 RTE_ETH_FILTER_FLUSH, NULL);
8902 printf("flow director table flushing error: (%s)\n",
8906 cmdline_parse_inst_t cmd_flush_flow_director = {
8907 .f = cmd_flush_flow_director_parsed,
8909 .help_str = "flush all flow director entries of a device on NIC",
8911 (void *)&cmd_flush_flow_director_flush,
8912 (void *)&cmd_flush_flow_director_port_id,
8917 /* *** deal with flow director mask *** */
8918 struct cmd_flow_director_mask_result {
8919 cmdline_fixed_string_t flow_director_mask;
8921 cmdline_fixed_string_t mode;
8922 cmdline_fixed_string_t mode_value;
8923 cmdline_fixed_string_t vlan;
8925 cmdline_fixed_string_t src_mask;
8926 cmdline_ipaddr_t ipv4_src;
8927 cmdline_ipaddr_t ipv6_src;
8929 cmdline_fixed_string_t dst_mask;
8930 cmdline_ipaddr_t ipv4_dst;
8931 cmdline_ipaddr_t ipv6_dst;
8933 cmdline_fixed_string_t mac;
8934 uint8_t mac_addr_byte_mask;
8935 cmdline_fixed_string_t tunnel_id;
8936 uint32_t tunnel_id_mask;
8937 cmdline_fixed_string_t tunnel_type;
8938 uint8_t tunnel_type_mask;
8942 cmd_flow_director_mask_parsed(void *parsed_result,
8943 __attribute__((unused)) struct cmdline *cl,
8944 __attribute__((unused)) void *data)
8946 struct cmd_flow_director_mask_result *res = parsed_result;
8947 struct rte_eth_fdir_masks *mask;
8948 struct rte_port *port;
8950 if (res->port_id > nb_ports) {
8951 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8955 port = &ports[res->port_id];
8956 /** Check if the port is not started **/
8957 if (port->port_status != RTE_PORT_STOPPED) {
8958 printf("Please stop port %d first\n", res->port_id);
8962 mask = &port->dev_conf.fdir_conf.mask;
8964 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8965 if (strcmp(res->mode_value, "MAC-VLAN")) {
8966 printf("Please set mode to MAC-VLAN.\n");
8970 mask->vlan_tci_mask = res->vlan_mask;
8971 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8972 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8973 if (strcmp(res->mode_value, "Tunnel")) {
8974 printf("Please set mode to Tunnel.\n");
8978 mask->vlan_tci_mask = res->vlan_mask;
8979 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8980 mask->tunnel_id_mask = res->tunnel_id_mask;
8981 mask->tunnel_type_mask = res->tunnel_type_mask;
8983 if (strcmp(res->mode_value, "IP")) {
8984 printf("Please set mode to IP.\n");
8988 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8989 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8990 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8991 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8992 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8993 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8994 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8997 cmd_reconfig_device_queue(res->port_id, 1, 1);
9000 cmdline_parse_token_string_t cmd_flow_director_mask =
9001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9002 flow_director_mask, "flow_director_mask");
9003 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9006 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9009 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9010 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9012 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9014 src_mask, "src_mask");
9015 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9016 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9018 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9019 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9021 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9022 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9024 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9026 dst_mask, "dst_mask");
9027 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9028 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9030 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9031 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9033 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9034 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9037 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9040 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9043 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9045 mode_value, "MAC-VLAN");
9046 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9048 mode_value, "Tunnel");
9049 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9052 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9053 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9054 mac_addr_byte_mask, UINT8);
9055 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9056 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9057 tunnel_type, "tunnel-type");
9058 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9059 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9060 tunnel_type_mask, UINT8);
9061 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9063 tunnel_id, "tunnel-id");
9064 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9065 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9066 tunnel_id_mask, UINT32);
9068 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9069 .f = cmd_flow_director_mask_parsed,
9071 .help_str = "set IP mode flow director's mask on NIC",
9073 (void *)&cmd_flow_director_mask,
9074 (void *)&cmd_flow_director_mask_port_id,
9075 (void *)&cmd_flow_director_mask_mode,
9076 (void *)&cmd_flow_director_mask_mode_ip,
9077 (void *)&cmd_flow_director_mask_vlan,
9078 (void *)&cmd_flow_director_mask_vlan_value,
9079 (void *)&cmd_flow_director_mask_src,
9080 (void *)&cmd_flow_director_mask_ipv4_src,
9081 (void *)&cmd_flow_director_mask_ipv6_src,
9082 (void *)&cmd_flow_director_mask_port_src,
9083 (void *)&cmd_flow_director_mask_dst,
9084 (void *)&cmd_flow_director_mask_ipv4_dst,
9085 (void *)&cmd_flow_director_mask_ipv6_dst,
9086 (void *)&cmd_flow_director_mask_port_dst,
9091 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9092 .f = cmd_flow_director_mask_parsed,
9094 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9096 (void *)&cmd_flow_director_mask,
9097 (void *)&cmd_flow_director_mask_port_id,
9098 (void *)&cmd_flow_director_mask_mode,
9099 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9100 (void *)&cmd_flow_director_mask_vlan,
9101 (void *)&cmd_flow_director_mask_vlan_value,
9102 (void *)&cmd_flow_director_mask_mac,
9103 (void *)&cmd_flow_director_mask_mac_value,
9108 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9109 .f = cmd_flow_director_mask_parsed,
9111 .help_str = "set tunnel mode flow director's mask on NIC",
9113 (void *)&cmd_flow_director_mask,
9114 (void *)&cmd_flow_director_mask_port_id,
9115 (void *)&cmd_flow_director_mask_mode,
9116 (void *)&cmd_flow_director_mask_mode_tunnel,
9117 (void *)&cmd_flow_director_mask_vlan,
9118 (void *)&cmd_flow_director_mask_vlan_value,
9119 (void *)&cmd_flow_director_mask_mac,
9120 (void *)&cmd_flow_director_mask_mac_value,
9121 (void *)&cmd_flow_director_mask_tunnel_type,
9122 (void *)&cmd_flow_director_mask_tunnel_type_value,
9123 (void *)&cmd_flow_director_mask_tunnel_id,
9124 (void *)&cmd_flow_director_mask_tunnel_id_value,
9129 /* *** deal with flow director mask on flexible payload *** */
9130 struct cmd_flow_director_flex_mask_result {
9131 cmdline_fixed_string_t flow_director_flexmask;
9133 cmdline_fixed_string_t flow;
9134 cmdline_fixed_string_t flow_type;
9135 cmdline_fixed_string_t mask;
9139 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9140 __attribute__((unused)) struct cmdline *cl,
9141 __attribute__((unused)) void *data)
9143 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9144 struct rte_eth_fdir_info fdir_info;
9145 struct rte_eth_fdir_flex_mask flex_mask;
9146 struct rte_port *port;
9147 uint32_t flow_type_mask;
9151 if (res->port_id > nb_ports) {
9152 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9156 port = &ports[res->port_id];
9157 /** Check if the port is not started **/
9158 if (port->port_status != RTE_PORT_STOPPED) {
9159 printf("Please stop port %d first\n", res->port_id);
9163 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9164 ret = parse_flexbytes(res->mask,
9166 RTE_ETH_FDIR_MAX_FLEXLEN);
9168 printf("error: Cannot parse mask input.\n");
9172 memset(&fdir_info, 0, sizeof(fdir_info));
9173 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9174 RTE_ETH_FILTER_INFO, &fdir_info);
9176 printf("Cannot get FDir filter info\n");
9180 if (!strcmp(res->flow_type, "none")) {
9181 /* means don't specify the flow type */
9182 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9183 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9184 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9185 0, sizeof(struct rte_eth_fdir_flex_mask));
9186 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9187 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9189 sizeof(struct rte_eth_fdir_flex_mask));
9190 cmd_reconfig_device_queue(res->port_id, 1, 1);
9193 flow_type_mask = fdir_info.flow_types_mask[0];
9194 if (!strcmp(res->flow_type, "all")) {
9195 if (!flow_type_mask) {
9196 printf("No flow type supported\n");
9199 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9200 if (flow_type_mask & (1 << i)) {
9201 flex_mask.flow_type = i;
9202 fdir_set_flex_mask(res->port_id, &flex_mask);
9205 cmd_reconfig_device_queue(res->port_id, 1, 1);
9208 flex_mask.flow_type = str2flowtype(res->flow_type);
9209 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9210 printf("Flow type %s not supported on port %d\n",
9211 res->flow_type, res->port_id);
9214 fdir_set_flex_mask(res->port_id, &flex_mask);
9215 cmd_reconfig_device_queue(res->port_id, 1, 1);
9218 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9220 flow_director_flexmask,
9221 "flow_director_flex_mask");
9222 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9223 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9225 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9226 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9228 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9230 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9231 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9232 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9236 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9237 .f = cmd_flow_director_flex_mask_parsed,
9239 .help_str = "set flow director's flex mask on NIC",
9241 (void *)&cmd_flow_director_flexmask,
9242 (void *)&cmd_flow_director_flexmask_port_id,
9243 (void *)&cmd_flow_director_flexmask_flow,
9244 (void *)&cmd_flow_director_flexmask_flow_type,
9245 (void *)&cmd_flow_director_flexmask_mask,
9250 /* *** deal with flow director flexible payload configuration *** */
9251 struct cmd_flow_director_flexpayload_result {
9252 cmdline_fixed_string_t flow_director_flexpayload;
9254 cmdline_fixed_string_t payload_layer;
9255 cmdline_fixed_string_t payload_cfg;
9259 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9262 const char *p, *p0 = q_arg;
9264 unsigned long int_fld;
9265 char *str_fld[max_num];
9270 p = strchr(p0, '(');
9274 p0 = strchr(p, ')');
9279 if (size >= sizeof(s))
9282 snprintf(s, sizeof(s), "%.*s", size, p);
9283 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9284 if (ret < 0 || ret > max_num)
9286 for (i = 0; i < ret; i++) {
9288 int_fld = strtoul(str_fld[i], &end, 0);
9289 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9291 offsets[i] = (uint16_t)int_fld;
9297 cmd_flow_director_flxpld_parsed(void *parsed_result,
9298 __attribute__((unused)) struct cmdline *cl,
9299 __attribute__((unused)) void *data)
9301 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9302 struct rte_eth_flex_payload_cfg flex_cfg;
9303 struct rte_port *port;
9306 if (res->port_id > nb_ports) {
9307 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9311 port = &ports[res->port_id];
9312 /** Check if the port is not started **/
9313 if (port->port_status != RTE_PORT_STOPPED) {
9314 printf("Please stop port %d first\n", res->port_id);
9318 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9320 if (!strcmp(res->payload_layer, "raw"))
9321 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9322 else if (!strcmp(res->payload_layer, "l2"))
9323 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9324 else if (!strcmp(res->payload_layer, "l3"))
9325 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9326 else if (!strcmp(res->payload_layer, "l4"))
9327 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9329 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9330 RTE_ETH_FDIR_MAX_FLEXLEN);
9332 printf("error: Cannot parse flex payload input.\n");
9336 fdir_set_flex_payload(res->port_id, &flex_cfg);
9337 cmd_reconfig_device_queue(res->port_id, 1, 1);
9340 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9342 flow_director_flexpayload,
9343 "flow_director_flex_payload");
9344 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9345 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9347 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9349 payload_layer, "raw#l2#l3#l4");
9350 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9354 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9355 .f = cmd_flow_director_flxpld_parsed,
9357 .help_str = "set flow director's flex payload on NIC",
9359 (void *)&cmd_flow_director_flexpayload,
9360 (void *)&cmd_flow_director_flexpayload_port_id,
9361 (void *)&cmd_flow_director_flexpayload_payload_layer,
9362 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9367 /* *** Classification Filters Control *** */
9368 /* *** Get symmetric hash enable per port *** */
9369 struct cmd_get_sym_hash_ena_per_port_result {
9370 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9375 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9376 __rte_unused struct cmdline *cl,
9377 __rte_unused void *data)
9379 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9380 struct rte_eth_hash_filter_info info;
9383 if (rte_eth_dev_filter_supported(res->port_id,
9384 RTE_ETH_FILTER_HASH) < 0) {
9385 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9390 memset(&info, 0, sizeof(info));
9391 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9392 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9393 RTE_ETH_FILTER_GET, &info);
9396 printf("Cannot get symmetric hash enable per port "
9397 "on port %u\n", res->port_id);
9401 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9402 "enabled" : "disabled", res->port_id);
9405 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9406 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9407 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9408 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9409 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9412 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9413 .f = cmd_get_sym_hash_per_port_parsed,
9415 .help_str = "get_sym_hash_ena_per_port port_id",
9417 (void *)&cmd_get_sym_hash_ena_per_port_all,
9418 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9423 /* *** Set symmetric hash enable per port *** */
9424 struct cmd_set_sym_hash_ena_per_port_result {
9425 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9426 cmdline_fixed_string_t enable;
9431 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9432 __rte_unused struct cmdline *cl,
9433 __rte_unused void *data)
9435 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9436 struct rte_eth_hash_filter_info info;
9439 if (rte_eth_dev_filter_supported(res->port_id,
9440 RTE_ETH_FILTER_HASH) < 0) {
9441 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9446 memset(&info, 0, sizeof(info));
9447 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9448 if (!strcmp(res->enable, "enable"))
9449 info.info.enable = 1;
9450 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9451 RTE_ETH_FILTER_SET, &info);
9453 printf("Cannot set symmetric hash enable per port on "
9454 "port %u\n", res->port_id);
9457 printf("Symmetric hash has been set to %s on port %u\n",
9458 res->enable, res->port_id);
9461 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9462 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9463 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9464 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9465 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9467 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9468 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9469 enable, "enable#disable");
9471 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9472 .f = cmd_set_sym_hash_per_port_parsed,
9474 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9476 (void *)&cmd_set_sym_hash_ena_per_port_all,
9477 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9478 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9483 /* Get global config of hash function */
9484 struct cmd_get_hash_global_config_result {
9485 cmdline_fixed_string_t get_hash_global_config;
9490 flowtype_to_str(uint16_t ftype)
9497 {"ipv4", RTE_ETH_FLOW_IPV4},
9498 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9499 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9500 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9501 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9502 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9503 {"ipv6", RTE_ETH_FLOW_IPV6},
9504 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9505 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9506 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9507 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9508 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9509 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9510 {"port", RTE_ETH_FLOW_PORT},
9511 {"vxlan", RTE_ETH_FLOW_VXLAN},
9512 {"geneve", RTE_ETH_FLOW_GENEVE},
9513 {"nvgre", RTE_ETH_FLOW_NVGRE},
9516 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9517 if (ftype_table[i].ftype == ftype)
9518 return ftype_table[i].str;
9525 cmd_get_hash_global_config_parsed(void *parsed_result,
9526 __rte_unused struct cmdline *cl,
9527 __rte_unused void *data)
9529 struct cmd_get_hash_global_config_result *res = parsed_result;
9530 struct rte_eth_hash_filter_info info;
9531 uint32_t idx, offset;
9536 if (rte_eth_dev_filter_supported(res->port_id,
9537 RTE_ETH_FILTER_HASH) < 0) {
9538 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9543 memset(&info, 0, sizeof(info));
9544 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9545 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9546 RTE_ETH_FILTER_GET, &info);
9548 printf("Cannot get hash global configurations by port %d\n",
9553 switch (info.info.global_conf.hash_func) {
9554 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9555 printf("Hash function is Toeplitz\n");
9557 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9558 printf("Hash function is Simple XOR\n");
9561 printf("Unknown hash function\n");
9565 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9566 idx = i / UINT32_BIT;
9567 offset = i % UINT32_BIT;
9568 if (!(info.info.global_conf.valid_bit_mask[idx] &
9571 str = flowtype_to_str(i);
9574 printf("Symmetric hash is %s globally for flow type %s "
9576 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9577 (1UL << offset)) ? "enabled" : "disabled"), str,
9582 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9583 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9584 get_hash_global_config, "get_hash_global_config");
9585 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9586 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9589 cmdline_parse_inst_t cmd_get_hash_global_config = {
9590 .f = cmd_get_hash_global_config_parsed,
9592 .help_str = "get_hash_global_config port_id",
9594 (void *)&cmd_get_hash_global_config_all,
9595 (void *)&cmd_get_hash_global_config_port_id,
9600 /* Set global config of hash function */
9601 struct cmd_set_hash_global_config_result {
9602 cmdline_fixed_string_t set_hash_global_config;
9604 cmdline_fixed_string_t hash_func;
9605 cmdline_fixed_string_t flow_type;
9606 cmdline_fixed_string_t enable;
9610 cmd_set_hash_global_config_parsed(void *parsed_result,
9611 __rte_unused struct cmdline *cl,
9612 __rte_unused void *data)
9614 struct cmd_set_hash_global_config_result *res = parsed_result;
9615 struct rte_eth_hash_filter_info info;
9616 uint32_t ftype, idx, offset;
9619 if (rte_eth_dev_filter_supported(res->port_id,
9620 RTE_ETH_FILTER_HASH) < 0) {
9621 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9625 memset(&info, 0, sizeof(info));
9626 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9627 if (!strcmp(res->hash_func, "toeplitz"))
9628 info.info.global_conf.hash_func =
9629 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9630 else if (!strcmp(res->hash_func, "simple_xor"))
9631 info.info.global_conf.hash_func =
9632 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9633 else if (!strcmp(res->hash_func, "default"))
9634 info.info.global_conf.hash_func =
9635 RTE_ETH_HASH_FUNCTION_DEFAULT;
9637 ftype = str2flowtype(res->flow_type);
9638 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9639 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9640 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9641 if (!strcmp(res->enable, "enable"))
9642 info.info.global_conf.sym_hash_enable_mask[idx] |=
9644 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9645 RTE_ETH_FILTER_SET, &info);
9647 printf("Cannot set global hash configurations by port %d\n",
9650 printf("Global hash configurations have been set "
9651 "succcessfully by port %d\n", res->port_id);
9654 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9655 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9656 set_hash_global_config, "set_hash_global_config");
9657 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9658 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9660 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9661 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9662 hash_func, "toeplitz#simple_xor#default");
9663 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9664 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9666 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9667 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9668 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9669 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9670 enable, "enable#disable");
9672 cmdline_parse_inst_t cmd_set_hash_global_config = {
9673 .f = cmd_set_hash_global_config_parsed,
9675 .help_str = "set_hash_global_config port_id "
9676 "toeplitz|simple_xor|default "
9677 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9678 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9681 (void *)&cmd_set_hash_global_config_all,
9682 (void *)&cmd_set_hash_global_config_port_id,
9683 (void *)&cmd_set_hash_global_config_hash_func,
9684 (void *)&cmd_set_hash_global_config_flow_type,
9685 (void *)&cmd_set_hash_global_config_enable,
9690 /* Set hash input set */
9691 struct cmd_set_hash_input_set_result {
9692 cmdline_fixed_string_t set_hash_input_set;
9694 cmdline_fixed_string_t flow_type;
9695 cmdline_fixed_string_t inset_field;
9696 cmdline_fixed_string_t select;
9699 static enum rte_eth_input_set_field
9700 str2inset(char *string)
9704 static const struct {
9706 enum rte_eth_input_set_field inset;
9708 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9709 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9710 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9711 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9712 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9713 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9714 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9715 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9716 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9717 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9718 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9719 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9720 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9721 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9722 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9723 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9724 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9725 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9726 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9727 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9728 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9729 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9730 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9731 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9732 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9733 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9734 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9735 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9736 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9737 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9738 {"none", RTE_ETH_INPUT_SET_NONE},
9741 for (i = 0; i < RTE_DIM(inset_table); i++) {
9742 if (!strcmp(string, inset_table[i].str))
9743 return inset_table[i].inset;
9746 return RTE_ETH_INPUT_SET_UNKNOWN;
9750 cmd_set_hash_input_set_parsed(void *parsed_result,
9751 __rte_unused struct cmdline *cl,
9752 __rte_unused void *data)
9754 struct cmd_set_hash_input_set_result *res = parsed_result;
9755 struct rte_eth_hash_filter_info info;
9757 memset(&info, 0, sizeof(info));
9758 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9759 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9760 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9761 info.info.input_set_conf.inset_size = 1;
9762 if (!strcmp(res->select, "select"))
9763 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9764 else if (!strcmp(res->select, "add"))
9765 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9766 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9767 RTE_ETH_FILTER_SET, &info);
9770 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9771 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9772 set_hash_input_set, "set_hash_input_set");
9773 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9774 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9776 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9777 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9779 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9780 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9781 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9782 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9784 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9785 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9786 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9787 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9788 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9790 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9791 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9792 select, "select#add");
9794 cmdline_parse_inst_t cmd_set_hash_input_set = {
9795 .f = cmd_set_hash_input_set_parsed,
9797 .help_str = "set_hash_input_set <port_id> "
9798 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9799 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9800 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9801 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9802 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9803 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9804 "fld-7th|fld-8th|none select|add",
9806 (void *)&cmd_set_hash_input_set_cmd,
9807 (void *)&cmd_set_hash_input_set_port_id,
9808 (void *)&cmd_set_hash_input_set_flow_type,
9809 (void *)&cmd_set_hash_input_set_field,
9810 (void *)&cmd_set_hash_input_set_select,
9815 /* Set flow director input set */
9816 struct cmd_set_fdir_input_set_result {
9817 cmdline_fixed_string_t set_fdir_input_set;
9819 cmdline_fixed_string_t flow_type;
9820 cmdline_fixed_string_t inset_field;
9821 cmdline_fixed_string_t select;
9825 cmd_set_fdir_input_set_parsed(void *parsed_result,
9826 __rte_unused struct cmdline *cl,
9827 __rte_unused void *data)
9829 struct cmd_set_fdir_input_set_result *res = parsed_result;
9830 struct rte_eth_fdir_filter_info info;
9832 memset(&info, 0, sizeof(info));
9833 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9834 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9835 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9836 info.info.input_set_conf.inset_size = 1;
9837 if (!strcmp(res->select, "select"))
9838 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9839 else if (!strcmp(res->select, "add"))
9840 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9841 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9842 RTE_ETH_FILTER_SET, &info);
9845 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9846 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9847 set_fdir_input_set, "set_fdir_input_set");
9848 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9849 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9851 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9852 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9854 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9855 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9856 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9857 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9859 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9860 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9861 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9862 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9863 "sctp-veri-tag#none");
9864 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9865 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9866 select, "select#add");
9868 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9869 .f = cmd_set_fdir_input_set_parsed,
9871 .help_str = "set_fdir_input_set <port_id> "
9872 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9873 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9874 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9875 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9876 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9877 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9878 "sctp-veri-tag|none select|add",
9880 (void *)&cmd_set_fdir_input_set_cmd,
9881 (void *)&cmd_set_fdir_input_set_port_id,
9882 (void *)&cmd_set_fdir_input_set_flow_type,
9883 (void *)&cmd_set_fdir_input_set_field,
9884 (void *)&cmd_set_fdir_input_set_select,
9889 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9890 struct cmd_mcast_addr_result {
9891 cmdline_fixed_string_t mcast_addr_cmd;
9892 cmdline_fixed_string_t what;
9894 struct ether_addr mc_addr;
9897 static void cmd_mcast_addr_parsed(void *parsed_result,
9898 __attribute__((unused)) struct cmdline *cl,
9899 __attribute__((unused)) void *data)
9901 struct cmd_mcast_addr_result *res = parsed_result;
9903 if (!is_multicast_ether_addr(&res->mc_addr)) {
9904 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9905 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9906 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9907 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9910 if (strcmp(res->what, "add") == 0)
9911 mcast_addr_add(res->port_num, &res->mc_addr);
9913 mcast_addr_remove(res->port_num, &res->mc_addr);
9916 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9917 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9918 mcast_addr_cmd, "mcast_addr");
9919 cmdline_parse_token_string_t cmd_mcast_addr_what =
9920 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9922 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9923 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9924 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9925 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9927 cmdline_parse_inst_t cmd_mcast_addr = {
9928 .f = cmd_mcast_addr_parsed,
9930 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9932 (void *)&cmd_mcast_addr_cmd,
9933 (void *)&cmd_mcast_addr_what,
9934 (void *)&cmd_mcast_addr_portnum,
9935 (void *)&cmd_mcast_addr_addr,
9941 * only support E-tag now.
9944 /* Ether type config */
9945 struct cmd_config_l2_tunnel_eth_type_result {
9946 cmdline_fixed_string_t port;
9947 cmdline_fixed_string_t config;
9948 cmdline_fixed_string_t all;
9950 cmdline_fixed_string_t l2_tunnel;
9951 cmdline_fixed_string_t l2_tunnel_type;
9952 cmdline_fixed_string_t eth_type;
9953 uint16_t eth_type_val;
9956 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9957 TOKEN_STRING_INITIALIZER
9958 (struct cmd_config_l2_tunnel_eth_type_result,
9960 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9961 TOKEN_STRING_INITIALIZER
9962 (struct cmd_config_l2_tunnel_eth_type_result,
9964 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9965 TOKEN_STRING_INITIALIZER
9966 (struct cmd_config_l2_tunnel_eth_type_result,
9968 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9969 TOKEN_NUM_INITIALIZER
9970 (struct cmd_config_l2_tunnel_eth_type_result,
9972 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9973 TOKEN_STRING_INITIALIZER
9974 (struct cmd_config_l2_tunnel_eth_type_result,
9975 l2_tunnel, "l2-tunnel");
9976 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9977 TOKEN_STRING_INITIALIZER
9978 (struct cmd_config_l2_tunnel_eth_type_result,
9979 l2_tunnel_type, "E-tag");
9980 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9981 TOKEN_STRING_INITIALIZER
9982 (struct cmd_config_l2_tunnel_eth_type_result,
9983 eth_type, "ether-type");
9984 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9985 TOKEN_NUM_INITIALIZER
9986 (struct cmd_config_l2_tunnel_eth_type_result,
9987 eth_type_val, UINT16);
9989 static enum rte_eth_tunnel_type
9990 str2fdir_l2_tunnel_type(char *string)
9994 static const struct {
9996 enum rte_eth_tunnel_type type;
9997 } l2_tunnel_type_str[] = {
9998 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10001 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10002 if (!strcmp(l2_tunnel_type_str[i].str, string))
10003 return l2_tunnel_type_str[i].type;
10005 return RTE_TUNNEL_TYPE_NONE;
10008 /* ether type config for all ports */
10010 cmd_config_l2_tunnel_eth_type_all_parsed
10011 (void *parsed_result,
10012 __attribute__((unused)) struct cmdline *cl,
10013 __attribute__((unused)) void *data)
10015 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10016 struct rte_eth_l2_tunnel_conf entry;
10019 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10020 entry.ether_type = res->eth_type_val;
10022 FOREACH_PORT(pid, ports) {
10023 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10027 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10028 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10030 .help_str = "port config all l2-tunnel ether-type",
10032 (void *)&cmd_config_l2_tunnel_eth_type_port,
10033 (void *)&cmd_config_l2_tunnel_eth_type_config,
10034 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10035 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10036 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10037 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10038 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10043 /* ether type config for a specific port */
10045 cmd_config_l2_tunnel_eth_type_specific_parsed(
10046 void *parsed_result,
10047 __attribute__((unused)) struct cmdline *cl,
10048 __attribute__((unused)) void *data)
10050 struct cmd_config_l2_tunnel_eth_type_result *res =
10052 struct rte_eth_l2_tunnel_conf entry;
10054 if (port_id_is_invalid(res->id, ENABLED_WARN))
10057 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10058 entry.ether_type = res->eth_type_val;
10060 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10063 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10064 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10066 .help_str = "port config l2-tunnel ether-type",
10068 (void *)&cmd_config_l2_tunnel_eth_type_port,
10069 (void *)&cmd_config_l2_tunnel_eth_type_config,
10070 (void *)&cmd_config_l2_tunnel_eth_type_id,
10071 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10072 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10073 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10074 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10079 /* Enable/disable l2 tunnel */
10080 struct cmd_config_l2_tunnel_en_dis_result {
10081 cmdline_fixed_string_t port;
10082 cmdline_fixed_string_t config;
10083 cmdline_fixed_string_t all;
10085 cmdline_fixed_string_t l2_tunnel;
10086 cmdline_fixed_string_t l2_tunnel_type;
10087 cmdline_fixed_string_t en_dis;
10090 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10091 TOKEN_STRING_INITIALIZER
10092 (struct cmd_config_l2_tunnel_en_dis_result,
10094 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10095 TOKEN_STRING_INITIALIZER
10096 (struct cmd_config_l2_tunnel_en_dis_result,
10098 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10099 TOKEN_STRING_INITIALIZER
10100 (struct cmd_config_l2_tunnel_en_dis_result,
10102 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10103 TOKEN_NUM_INITIALIZER
10104 (struct cmd_config_l2_tunnel_en_dis_result,
10106 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10107 TOKEN_STRING_INITIALIZER
10108 (struct cmd_config_l2_tunnel_en_dis_result,
10109 l2_tunnel, "l2-tunnel");
10110 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10111 TOKEN_STRING_INITIALIZER
10112 (struct cmd_config_l2_tunnel_en_dis_result,
10113 l2_tunnel_type, "E-tag");
10114 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10115 TOKEN_STRING_INITIALIZER
10116 (struct cmd_config_l2_tunnel_en_dis_result,
10117 en_dis, "enable#disable");
10119 /* enable/disable l2 tunnel for all ports */
10121 cmd_config_l2_tunnel_en_dis_all_parsed(
10122 void *parsed_result,
10123 __attribute__((unused)) struct cmdline *cl,
10124 __attribute__((unused)) void *data)
10126 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10127 struct rte_eth_l2_tunnel_conf entry;
10131 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10133 if (!strcmp("enable", res->en_dis))
10138 FOREACH_PORT(pid, ports) {
10139 rte_eth_dev_l2_tunnel_offload_set(pid,
10141 ETH_L2_TUNNEL_ENABLE_MASK,
10146 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10147 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10149 .help_str = "port config all l2-tunnel enable/disable",
10151 (void *)&cmd_config_l2_tunnel_en_dis_port,
10152 (void *)&cmd_config_l2_tunnel_en_dis_config,
10153 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10154 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10155 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10156 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10161 /* enable/disable l2 tunnel for a port */
10163 cmd_config_l2_tunnel_en_dis_specific_parsed(
10164 void *parsed_result,
10165 __attribute__((unused)) struct cmdline *cl,
10166 __attribute__((unused)) void *data)
10168 struct cmd_config_l2_tunnel_en_dis_result *res =
10170 struct rte_eth_l2_tunnel_conf entry;
10172 if (port_id_is_invalid(res->id, ENABLED_WARN))
10175 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10177 if (!strcmp("enable", res->en_dis))
10178 rte_eth_dev_l2_tunnel_offload_set(res->id,
10180 ETH_L2_TUNNEL_ENABLE_MASK,
10183 rte_eth_dev_l2_tunnel_offload_set(res->id,
10185 ETH_L2_TUNNEL_ENABLE_MASK,
10189 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10190 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10192 .help_str = "port config l2-tunnel enable/disable",
10194 (void *)&cmd_config_l2_tunnel_en_dis_port,
10195 (void *)&cmd_config_l2_tunnel_en_dis_config,
10196 (void *)&cmd_config_l2_tunnel_en_dis_id,
10197 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10198 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10199 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10204 /* E-tag configuration */
10206 /* Common result structure for all E-tag configuration */
10207 struct cmd_config_e_tag_result {
10208 cmdline_fixed_string_t e_tag;
10209 cmdline_fixed_string_t set;
10210 cmdline_fixed_string_t insertion;
10211 cmdline_fixed_string_t stripping;
10212 cmdline_fixed_string_t forwarding;
10213 cmdline_fixed_string_t filter;
10214 cmdline_fixed_string_t add;
10215 cmdline_fixed_string_t del;
10216 cmdline_fixed_string_t on;
10217 cmdline_fixed_string_t off;
10218 cmdline_fixed_string_t on_off;
10219 cmdline_fixed_string_t port_tag_id;
10220 uint32_t port_tag_id_val;
10221 cmdline_fixed_string_t e_tag_id;
10222 uint16_t e_tag_id_val;
10223 cmdline_fixed_string_t dst_pool;
10224 uint8_t dst_pool_val;
10225 cmdline_fixed_string_t port;
10227 cmdline_fixed_string_t vf;
10231 /* Common CLI fields for all E-tag configuration */
10232 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10233 TOKEN_STRING_INITIALIZER
10234 (struct cmd_config_e_tag_result,
10236 cmdline_parse_token_string_t cmd_config_e_tag_set =
10237 TOKEN_STRING_INITIALIZER
10238 (struct cmd_config_e_tag_result,
10240 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10241 TOKEN_STRING_INITIALIZER
10242 (struct cmd_config_e_tag_result,
10243 insertion, "insertion");
10244 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10245 TOKEN_STRING_INITIALIZER
10246 (struct cmd_config_e_tag_result,
10247 stripping, "stripping");
10248 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10249 TOKEN_STRING_INITIALIZER
10250 (struct cmd_config_e_tag_result,
10251 forwarding, "forwarding");
10252 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10253 TOKEN_STRING_INITIALIZER
10254 (struct cmd_config_e_tag_result,
10256 cmdline_parse_token_string_t cmd_config_e_tag_add =
10257 TOKEN_STRING_INITIALIZER
10258 (struct cmd_config_e_tag_result,
10260 cmdline_parse_token_string_t cmd_config_e_tag_del =
10261 TOKEN_STRING_INITIALIZER
10262 (struct cmd_config_e_tag_result,
10264 cmdline_parse_token_string_t cmd_config_e_tag_on =
10265 TOKEN_STRING_INITIALIZER
10266 (struct cmd_config_e_tag_result,
10268 cmdline_parse_token_string_t cmd_config_e_tag_off =
10269 TOKEN_STRING_INITIALIZER
10270 (struct cmd_config_e_tag_result,
10272 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10273 TOKEN_STRING_INITIALIZER
10274 (struct cmd_config_e_tag_result,
10276 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10277 TOKEN_STRING_INITIALIZER
10278 (struct cmd_config_e_tag_result,
10279 port_tag_id, "port-tag-id");
10280 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10281 TOKEN_NUM_INITIALIZER
10282 (struct cmd_config_e_tag_result,
10283 port_tag_id_val, UINT32);
10284 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10285 TOKEN_STRING_INITIALIZER
10286 (struct cmd_config_e_tag_result,
10287 e_tag_id, "e-tag-id");
10288 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10289 TOKEN_NUM_INITIALIZER
10290 (struct cmd_config_e_tag_result,
10291 e_tag_id_val, UINT16);
10292 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10293 TOKEN_STRING_INITIALIZER
10294 (struct cmd_config_e_tag_result,
10295 dst_pool, "dst-pool");
10296 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10297 TOKEN_NUM_INITIALIZER
10298 (struct cmd_config_e_tag_result,
10299 dst_pool_val, UINT8);
10300 cmdline_parse_token_string_t cmd_config_e_tag_port =
10301 TOKEN_STRING_INITIALIZER
10302 (struct cmd_config_e_tag_result,
10304 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10305 TOKEN_NUM_INITIALIZER
10306 (struct cmd_config_e_tag_result,
10308 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10309 TOKEN_STRING_INITIALIZER
10310 (struct cmd_config_e_tag_result,
10312 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10313 TOKEN_NUM_INITIALIZER
10314 (struct cmd_config_e_tag_result,
10317 /* E-tag insertion configuration */
10319 cmd_config_e_tag_insertion_en_parsed(
10320 void *parsed_result,
10321 __attribute__((unused)) struct cmdline *cl,
10322 __attribute__((unused)) void *data)
10324 struct cmd_config_e_tag_result *res =
10326 struct rte_eth_l2_tunnel_conf entry;
10328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10331 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10332 entry.tunnel_id = res->port_tag_id_val;
10333 entry.vf_id = res->vf_id;
10334 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10336 ETH_L2_TUNNEL_INSERTION_MASK,
10341 cmd_config_e_tag_insertion_dis_parsed(
10342 void *parsed_result,
10343 __attribute__((unused)) struct cmdline *cl,
10344 __attribute__((unused)) void *data)
10346 struct cmd_config_e_tag_result *res =
10348 struct rte_eth_l2_tunnel_conf entry;
10350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10353 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10354 entry.vf_id = res->vf_id;
10356 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10358 ETH_L2_TUNNEL_INSERTION_MASK,
10362 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10363 .f = cmd_config_e_tag_insertion_en_parsed,
10365 .help_str = "E-tag insertion enable",
10367 (void *)&cmd_config_e_tag_e_tag,
10368 (void *)&cmd_config_e_tag_set,
10369 (void *)&cmd_config_e_tag_insertion,
10370 (void *)&cmd_config_e_tag_on,
10371 (void *)&cmd_config_e_tag_port_tag_id,
10372 (void *)&cmd_config_e_tag_port_tag_id_val,
10373 (void *)&cmd_config_e_tag_port,
10374 (void *)&cmd_config_e_tag_port_id,
10375 (void *)&cmd_config_e_tag_vf,
10376 (void *)&cmd_config_e_tag_vf_id,
10381 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10382 .f = cmd_config_e_tag_insertion_dis_parsed,
10384 .help_str = "E-tag insertion disable",
10386 (void *)&cmd_config_e_tag_e_tag,
10387 (void *)&cmd_config_e_tag_set,
10388 (void *)&cmd_config_e_tag_insertion,
10389 (void *)&cmd_config_e_tag_off,
10390 (void *)&cmd_config_e_tag_port,
10391 (void *)&cmd_config_e_tag_port_id,
10392 (void *)&cmd_config_e_tag_vf,
10393 (void *)&cmd_config_e_tag_vf_id,
10398 /* E-tag stripping configuration */
10400 cmd_config_e_tag_stripping_parsed(
10401 void *parsed_result,
10402 __attribute__((unused)) struct cmdline *cl,
10403 __attribute__((unused)) void *data)
10405 struct cmd_config_e_tag_result *res =
10407 struct rte_eth_l2_tunnel_conf entry;
10409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10412 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10414 if (!strcmp(res->on_off, "on"))
10415 rte_eth_dev_l2_tunnel_offload_set
10418 ETH_L2_TUNNEL_STRIPPING_MASK,
10421 rte_eth_dev_l2_tunnel_offload_set
10424 ETH_L2_TUNNEL_STRIPPING_MASK,
10428 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10429 .f = cmd_config_e_tag_stripping_parsed,
10431 .help_str = "E-tag stripping enable/disable",
10433 (void *)&cmd_config_e_tag_e_tag,
10434 (void *)&cmd_config_e_tag_set,
10435 (void *)&cmd_config_e_tag_stripping,
10436 (void *)&cmd_config_e_tag_on_off,
10437 (void *)&cmd_config_e_tag_port,
10438 (void *)&cmd_config_e_tag_port_id,
10443 /* E-tag forwarding configuration */
10445 cmd_config_e_tag_forwarding_parsed(
10446 void *parsed_result,
10447 __attribute__((unused)) struct cmdline *cl,
10448 __attribute__((unused)) void *data)
10450 struct cmd_config_e_tag_result *res = parsed_result;
10451 struct rte_eth_l2_tunnel_conf entry;
10453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10456 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10458 if (!strcmp(res->on_off, "on"))
10459 rte_eth_dev_l2_tunnel_offload_set
10462 ETH_L2_TUNNEL_FORWARDING_MASK,
10465 rte_eth_dev_l2_tunnel_offload_set
10468 ETH_L2_TUNNEL_FORWARDING_MASK,
10472 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10473 .f = cmd_config_e_tag_forwarding_parsed,
10475 .help_str = "E-tag forwarding enable/disable",
10477 (void *)&cmd_config_e_tag_e_tag,
10478 (void *)&cmd_config_e_tag_set,
10479 (void *)&cmd_config_e_tag_forwarding,
10480 (void *)&cmd_config_e_tag_on_off,
10481 (void *)&cmd_config_e_tag_port,
10482 (void *)&cmd_config_e_tag_port_id,
10487 /* E-tag filter configuration */
10489 cmd_config_e_tag_filter_add_parsed(
10490 void *parsed_result,
10491 __attribute__((unused)) struct cmdline *cl,
10492 __attribute__((unused)) void *data)
10494 struct cmd_config_e_tag_result *res = parsed_result;
10495 struct rte_eth_l2_tunnel_conf entry;
10498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10501 if (res->e_tag_id_val > 0x3fff) {
10502 printf("e-tag-id must be equal or less than 0x3fff.\n");
10506 ret = rte_eth_dev_filter_supported(res->port_id,
10507 RTE_ETH_FILTER_L2_TUNNEL);
10509 printf("E-tag filter is not supported on port %u.\n",
10514 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10515 entry.tunnel_id = res->e_tag_id_val;
10516 entry.pool = res->dst_pool_val;
10518 ret = rte_eth_dev_filter_ctrl(res->port_id,
10519 RTE_ETH_FILTER_L2_TUNNEL,
10520 RTE_ETH_FILTER_ADD,
10523 printf("E-tag filter programming error: (%s)\n",
10527 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10528 .f = cmd_config_e_tag_filter_add_parsed,
10530 .help_str = "E-tag filter add",
10532 (void *)&cmd_config_e_tag_e_tag,
10533 (void *)&cmd_config_e_tag_set,
10534 (void *)&cmd_config_e_tag_filter,
10535 (void *)&cmd_config_e_tag_add,
10536 (void *)&cmd_config_e_tag_e_tag_id,
10537 (void *)&cmd_config_e_tag_e_tag_id_val,
10538 (void *)&cmd_config_e_tag_dst_pool,
10539 (void *)&cmd_config_e_tag_dst_pool_val,
10540 (void *)&cmd_config_e_tag_port,
10541 (void *)&cmd_config_e_tag_port_id,
10547 cmd_config_e_tag_filter_del_parsed(
10548 void *parsed_result,
10549 __attribute__((unused)) struct cmdline *cl,
10550 __attribute__((unused)) void *data)
10552 struct cmd_config_e_tag_result *res = parsed_result;
10553 struct rte_eth_l2_tunnel_conf entry;
10556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10559 if (res->e_tag_id_val > 0x3fff) {
10560 printf("e-tag-id must be less than 0x3fff.\n");
10564 ret = rte_eth_dev_filter_supported(res->port_id,
10565 RTE_ETH_FILTER_L2_TUNNEL);
10567 printf("E-tag filter is not supported on port %u.\n",
10572 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10573 entry.tunnel_id = res->e_tag_id_val;
10575 ret = rte_eth_dev_filter_ctrl(res->port_id,
10576 RTE_ETH_FILTER_L2_TUNNEL,
10577 RTE_ETH_FILTER_DELETE,
10580 printf("E-tag filter programming error: (%s)\n",
10584 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10585 .f = cmd_config_e_tag_filter_del_parsed,
10587 .help_str = "E-tag filter delete",
10589 (void *)&cmd_config_e_tag_e_tag,
10590 (void *)&cmd_config_e_tag_set,
10591 (void *)&cmd_config_e_tag_filter,
10592 (void *)&cmd_config_e_tag_del,
10593 (void *)&cmd_config_e_tag_e_tag_id,
10594 (void *)&cmd_config_e_tag_e_tag_id_val,
10595 (void *)&cmd_config_e_tag_port,
10596 (void *)&cmd_config_e_tag_port_id,
10601 /* ******************************************************************************** */
10603 /* list of instructions */
10604 cmdline_parse_ctx_t main_ctx[] = {
10605 (cmdline_parse_inst_t *)&cmd_help_brief,
10606 (cmdline_parse_inst_t *)&cmd_help_long,
10607 (cmdline_parse_inst_t *)&cmd_quit,
10608 (cmdline_parse_inst_t *)&cmd_showport,
10609 (cmdline_parse_inst_t *)&cmd_showqueue,
10610 (cmdline_parse_inst_t *)&cmd_showportall,
10611 (cmdline_parse_inst_t *)&cmd_showcfg,
10612 (cmdline_parse_inst_t *)&cmd_start,
10613 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10614 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
10615 (cmdline_parse_inst_t *)&cmd_set_link_up,
10616 (cmdline_parse_inst_t *)&cmd_set_link_down,
10617 (cmdline_parse_inst_t *)&cmd_reset,
10618 (cmdline_parse_inst_t *)&cmd_set_numbers,
10619 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10620 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10621 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10622 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10623 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10624 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
10625 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10626 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10627 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10628 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10629 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10630 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10631 (cmdline_parse_inst_t *)&cmd_set_link_check,
10632 #ifdef RTE_NIC_BYPASS
10633 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10634 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10635 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10636 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10638 #ifdef RTE_LIBRTE_PMD_BOND
10639 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10640 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10641 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10642 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10643 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10644 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10645 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10646 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10647 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10649 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10650 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10651 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10652 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10653 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10654 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10655 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10656 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10657 (cmdline_parse_inst_t *)&cmd_csum_set,
10658 (cmdline_parse_inst_t *)&cmd_csum_show,
10659 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10660 (cmdline_parse_inst_t *)&cmd_tso_set,
10661 (cmdline_parse_inst_t *)&cmd_tso_show,
10662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10667 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10668 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10669 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10671 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10672 (cmdline_parse_inst_t *)&cmd_config_dcb,
10673 (cmdline_parse_inst_t *)&cmd_read_reg,
10674 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10675 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10676 (cmdline_parse_inst_t *)&cmd_write_reg,
10677 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10678 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10679 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10680 (cmdline_parse_inst_t *)&cmd_stop,
10681 (cmdline_parse_inst_t *)&cmd_mac_addr,
10682 (cmdline_parse_inst_t *)&cmd_set_qmap,
10683 (cmdline_parse_inst_t *)&cmd_operate_port,
10684 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10685 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10686 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10687 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10688 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10689 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10690 (cmdline_parse_inst_t *)&cmd_config_mtu,
10691 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10692 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10693 (cmdline_parse_inst_t *)&cmd_config_rss,
10694 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10695 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10696 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10697 (cmdline_parse_inst_t *)&cmd_showport_reta,
10698 (cmdline_parse_inst_t *)&cmd_config_burst,
10699 (cmdline_parse_inst_t *)&cmd_config_thresh,
10700 (cmdline_parse_inst_t *)&cmd_config_threshold,
10701 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10702 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10703 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10704 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10705 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10706 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10707 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10708 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10709 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10710 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10711 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10712 (cmdline_parse_inst_t *)&cmd_global_config,
10713 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10714 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10715 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10716 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10717 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10718 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10719 (cmdline_parse_inst_t *)&cmd_dump,
10720 (cmdline_parse_inst_t *)&cmd_dump_one,
10721 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10722 (cmdline_parse_inst_t *)&cmd_syn_filter,
10723 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10724 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10725 (cmdline_parse_inst_t *)&cmd_flex_filter,
10726 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10727 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10728 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10729 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10730 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10731 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10732 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10733 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10734 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10735 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10736 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10737 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10738 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10739 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10740 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10741 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10742 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10743 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10744 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10745 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10746 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10747 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10748 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10749 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10750 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10751 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10752 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10753 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10754 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10758 /* prompt function, called from main on MASTER lcore */
10762 /* initialize non-constant commands */
10763 cmd_set_fwd_mode_init();
10764 cmd_set_fwd_retry_mode_init();
10766 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10767 if (testpmd_cl == NULL)
10769 cmdline_interact(testpmd_cl);
10770 cmdline_stdin_exit(testpmd_cl);
10776 if (testpmd_cl != NULL)
10777 cmdline_quit(testpmd_cl);
10781 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10783 if (id == (portid_t)RTE_PORT_ALL) {
10786 FOREACH_PORT(pid, ports) {
10787 /* check if need_reconfig has been set to 1 */
10788 if (ports[pid].need_reconfig == 0)
10789 ports[pid].need_reconfig = dev;
10790 /* check if need_reconfig_queues has been set to 1 */
10791 if (ports[pid].need_reconfig_queues == 0)
10792 ports[pid].need_reconfig_queues = queue;
10794 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10795 /* check if need_reconfig has been set to 1 */
10796 if (ports[id].need_reconfig == 0)
10797 ports[id].need_reconfig = dev;
10798 /* check if need_reconfig_queues has been set to 1 */
10799 if (ports[id].need_reconfig_queues == 0)
10800 ports[id].need_reconfig_queues = queue;
10804 #ifdef RTE_NIC_BYPASS
10805 #include <rte_pci_dev_ids.h>
10807 bypass_is_supported(portid_t port_id)
10809 struct rte_port *port;
10810 struct rte_pci_id *pci_id;
10812 if (port_id_is_invalid(port_id, ENABLED_WARN))
10815 /* Get the device id. */
10816 port = &ports[port_id];
10817 pci_id = &port->dev_info.pci_dev->id;
10819 /* Check if NIC supports bypass. */
10820 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10824 printf("\tBypass not supported for port_id = %d.\n", port_id);