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|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;
1540 if (!strcmp(res->value, "all"))
1541 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1542 ETH_RSS_UDP | ETH_RSS_SCTP |
1544 else if (!strcmp(res->value, "ip"))
1545 rss_conf.rss_hf = ETH_RSS_IP;
1546 else if (!strcmp(res->value, "udp"))
1547 rss_conf.rss_hf = ETH_RSS_UDP;
1548 else if (!strcmp(res->value, "tcp"))
1549 rss_conf.rss_hf = ETH_RSS_TCP;
1550 else if (!strcmp(res->value, "sctp"))
1551 rss_conf.rss_hf = ETH_RSS_SCTP;
1552 else if (!strcmp(res->value, "ether"))
1553 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1554 else if (!strcmp(res->value, "none"))
1555 rss_conf.rss_hf = 0;
1557 printf("Unknown parameter\n");
1560 rss_conf.rss_key = NULL;
1561 for (i = 0; i < rte_eth_dev_count(); i++)
1562 rte_eth_dev_rss_hash_update(i, &rss_conf);
1565 cmdline_parse_token_string_t cmd_config_rss_port =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1567 cmdline_parse_token_string_t cmd_config_rss_keyword =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1569 cmdline_parse_token_string_t cmd_config_rss_all =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1571 cmdline_parse_token_string_t cmd_config_rss_name =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1573 cmdline_parse_token_string_t cmd_config_rss_value =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1575 "all#ip#tcp#udp#sctp#ether#none");
1577 cmdline_parse_inst_t cmd_config_rss = {
1578 .f = cmd_config_rss_parsed,
1580 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1582 (void *)&cmd_config_rss_port,
1583 (void *)&cmd_config_rss_keyword,
1584 (void *)&cmd_config_rss_all,
1585 (void *)&cmd_config_rss_name,
1586 (void *)&cmd_config_rss_value,
1591 /* *** configure rss hash key *** */
1592 struct cmd_config_rss_hash_key {
1593 cmdline_fixed_string_t port;
1594 cmdline_fixed_string_t config;
1596 cmdline_fixed_string_t rss_hash_key;
1597 cmdline_fixed_string_t rss_type;
1598 cmdline_fixed_string_t key;
1601 #define RSS_HASH_KEY_LENGTH 40
1603 hexa_digit_to_value(char hexa_digit)
1605 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1606 return (uint8_t) (hexa_digit - '0');
1607 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1608 return (uint8_t) ((hexa_digit - 'a') + 10);
1609 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1610 return (uint8_t) ((hexa_digit - 'A') + 10);
1611 /* Invalid hexa digit */
1616 parse_and_check_key_hexa_digit(char *key, int idx)
1620 hexa_v = hexa_digit_to_value(key[idx]);
1622 printf("invalid key: character %c at position %d is not a "
1623 "valid hexa digit\n", key[idx], idx);
1628 cmd_config_rss_hash_key_parsed(void *parsed_result,
1629 __attribute__((unused)) struct cmdline *cl,
1630 __attribute__((unused)) void *data)
1632 struct cmd_config_rss_hash_key *res = parsed_result;
1633 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1638 /* Check the length of the RSS hash key */
1639 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1640 printf("key length: %d invalid - key must be a string of %d"
1641 "hexa-decimal numbers\n", (int) strlen(res->key),
1642 RSS_HASH_KEY_LENGTH * 2);
1645 /* Translate RSS hash key into binary representation */
1646 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1647 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1650 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1653 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1655 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1656 RSS_HASH_KEY_LENGTH);
1659 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1661 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1664 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1665 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1666 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1668 rss_hash_key, "rss-hash-key");
1669 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1671 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1672 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1673 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1674 "ipv6-tcp-ex#ipv6-udp-ex");
1675 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1678 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1679 .f = cmd_config_rss_hash_key_parsed,
1682 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1683 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1684 "ipv6-sctp|ipv6-other|l2-payload|"
1685 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1687 (void *)&cmd_config_rss_hash_key_port,
1688 (void *)&cmd_config_rss_hash_key_config,
1689 (void *)&cmd_config_rss_hash_key_port_id,
1690 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1691 (void *)&cmd_config_rss_hash_key_rss_type,
1692 (void *)&cmd_config_rss_hash_key_value,
1697 /* *** configure port rxq/txq start/stop *** */
1698 struct cmd_config_rxtx_queue {
1699 cmdline_fixed_string_t port;
1701 cmdline_fixed_string_t rxtxq;
1703 cmdline_fixed_string_t opname;
1707 cmd_config_rxtx_queue_parsed(void *parsed_result,
1708 __attribute__((unused)) struct cmdline *cl,
1709 __attribute__((unused)) void *data)
1711 struct cmd_config_rxtx_queue *res = parsed_result;
1716 if (test_done == 0) {
1717 printf("Please stop forwarding first\n");
1721 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1724 if (port_is_started(res->portid) != 1) {
1725 printf("Please start port %u first\n", res->portid);
1729 if (!strcmp(res->rxtxq, "rxq"))
1731 else if (!strcmp(res->rxtxq, "txq"))
1734 printf("Unknown parameter\n");
1738 if (isrx && rx_queue_id_is_invalid(res->qid))
1740 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1743 if (!strcmp(res->opname, "start"))
1745 else if (!strcmp(res->opname, "stop"))
1748 printf("Unknown parameter\n");
1752 if (isstart && isrx)
1753 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1754 else if (!isstart && isrx)
1755 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1756 else if (isstart && !isrx)
1757 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1759 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1761 if (ret == -ENOTSUP)
1762 printf("Function not supported in PMD driver\n");
1765 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1767 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1768 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1769 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1771 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1772 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1773 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1777 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1778 .f = cmd_config_rxtx_queue_parsed,
1780 .help_str = "port X rxq|txq ID start|stop",
1782 (void *)&cmd_config_speed_all_port,
1783 (void *)&cmd_config_rxtx_queue_portid,
1784 (void *)&cmd_config_rxtx_queue_rxtxq,
1785 (void *)&cmd_config_rxtx_queue_qid,
1786 (void *)&cmd_config_rxtx_queue_opname,
1791 /* *** Configure RSS RETA *** */
1792 struct cmd_config_rss_reta {
1793 cmdline_fixed_string_t port;
1794 cmdline_fixed_string_t keyword;
1796 cmdline_fixed_string_t name;
1797 cmdline_fixed_string_t list_name;
1798 cmdline_fixed_string_t list_of_items;
1802 parse_reta_config(const char *str,
1803 struct rte_eth_rss_reta_entry64 *reta_conf,
1804 uint16_t nb_entries)
1808 uint16_t hash_index, idx, shift;
1811 const char *p, *p0 = str;
1818 unsigned long int_fld[_NUM_FLD];
1819 char *str_fld[_NUM_FLD];
1821 while ((p = strchr(p0,'(')) != NULL) {
1823 if((p0 = strchr(p,')')) == NULL)
1827 if(size >= sizeof(s))
1830 snprintf(s, sizeof(s), "%.*s", size, p);
1831 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1833 for (i = 0; i < _NUM_FLD; i++) {
1835 int_fld[i] = strtoul(str_fld[i], &end, 0);
1836 if (errno != 0 || end == str_fld[i] ||
1841 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1842 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1844 if (hash_index >= nb_entries) {
1845 printf("Invalid RETA hash index=%d\n", hash_index);
1849 idx = hash_index / RTE_RETA_GROUP_SIZE;
1850 shift = hash_index % RTE_RETA_GROUP_SIZE;
1851 reta_conf[idx].mask |= (1ULL << shift);
1852 reta_conf[idx].reta[shift] = nb_queue;
1859 cmd_set_rss_reta_parsed(void *parsed_result,
1860 __attribute__((unused)) struct cmdline *cl,
1861 __attribute__((unused)) void *data)
1864 struct rte_eth_dev_info dev_info;
1865 struct rte_eth_rss_reta_entry64 reta_conf[8];
1866 struct cmd_config_rss_reta *res = parsed_result;
1868 memset(&dev_info, 0, sizeof(dev_info));
1869 rte_eth_dev_info_get(res->port_id, &dev_info);
1870 if (dev_info.reta_size == 0) {
1871 printf("Redirection table size is 0 which is "
1872 "invalid for RSS\n");
1875 printf("The reta size of port %d is %u\n",
1876 res->port_id, dev_info.reta_size);
1877 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1878 printf("Currently do not support more than %u entries of "
1879 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1883 memset(reta_conf, 0, sizeof(reta_conf));
1884 if (!strcmp(res->list_name, "reta")) {
1885 if (parse_reta_config(res->list_of_items, reta_conf,
1886 dev_info.reta_size)) {
1887 printf("Invalid RSS Redirection Table "
1888 "config entered\n");
1891 ret = rte_eth_dev_rss_reta_update(res->port_id,
1892 reta_conf, dev_info.reta_size);
1894 printf("Bad redirection table parameter, "
1895 "return code = %d \n", ret);
1899 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1901 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1903 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1904 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1905 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1907 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1909 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1910 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1912 cmdline_parse_inst_t cmd_config_rss_reta = {
1913 .f = cmd_set_rss_reta_parsed,
1915 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1917 (void *)&cmd_config_rss_reta_port,
1918 (void *)&cmd_config_rss_reta_keyword,
1919 (void *)&cmd_config_rss_reta_port_id,
1920 (void *)&cmd_config_rss_reta_name,
1921 (void *)&cmd_config_rss_reta_list_name,
1922 (void *)&cmd_config_rss_reta_list_of_items,
1927 /* *** SHOW PORT RETA INFO *** */
1928 struct cmd_showport_reta {
1929 cmdline_fixed_string_t show;
1930 cmdline_fixed_string_t port;
1932 cmdline_fixed_string_t rss;
1933 cmdline_fixed_string_t reta;
1935 cmdline_fixed_string_t list_of_items;
1939 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1940 uint16_t nb_entries,
1944 const char *p, *p0 = str;
1948 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1951 p = strchr(p0, '(');
1955 p0 = strchr(p, ')');
1959 if (size >= sizeof(s)) {
1960 printf("The string size exceeds the internal buffer size\n");
1963 snprintf(s, sizeof(s), "%.*s", size, p);
1964 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1965 if (ret <= 0 || ret != num) {
1966 printf("The bits of masks do not match the number of "
1967 "reta entries: %u\n", num);
1970 for (i = 0; i < ret; i++)
1971 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1977 cmd_showport_reta_parsed(void *parsed_result,
1978 __attribute__((unused)) struct cmdline *cl,
1979 __attribute__((unused)) void *data)
1981 struct cmd_showport_reta *res = parsed_result;
1982 struct rte_eth_rss_reta_entry64 reta_conf[8];
1983 struct rte_eth_dev_info dev_info;
1985 memset(&dev_info, 0, sizeof(dev_info));
1986 rte_eth_dev_info_get(res->port_id, &dev_info);
1987 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1988 res->size > ETH_RSS_RETA_SIZE_512) {
1989 printf("Invalid redirection table size: %u\n", res->size);
1993 memset(reta_conf, 0, sizeof(reta_conf));
1994 if (showport_parse_reta_config(reta_conf, res->size,
1995 res->list_of_items) < 0) {
1996 printf("Invalid string: %s for reta masks\n",
1997 res->list_of_items);
2000 port_rss_reta_info(res->port_id, reta_conf, res->size);
2003 cmdline_parse_token_string_t cmd_showport_reta_show =
2004 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2005 cmdline_parse_token_string_t cmd_showport_reta_port =
2006 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2007 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2008 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2009 cmdline_parse_token_string_t cmd_showport_reta_rss =
2010 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2011 cmdline_parse_token_string_t cmd_showport_reta_reta =
2012 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2013 cmdline_parse_token_num_t cmd_showport_reta_size =
2014 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2015 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2016 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2017 list_of_items, NULL);
2019 cmdline_parse_inst_t cmd_showport_reta = {
2020 .f = cmd_showport_reta_parsed,
2022 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2024 (void *)&cmd_showport_reta_show,
2025 (void *)&cmd_showport_reta_port,
2026 (void *)&cmd_showport_reta_port_id,
2027 (void *)&cmd_showport_reta_rss,
2028 (void *)&cmd_showport_reta_reta,
2029 (void *)&cmd_showport_reta_size,
2030 (void *)&cmd_showport_reta_list_of_items,
2035 /* *** Show RSS hash configuration *** */
2036 struct cmd_showport_rss_hash {
2037 cmdline_fixed_string_t show;
2038 cmdline_fixed_string_t port;
2040 cmdline_fixed_string_t rss_hash;
2041 cmdline_fixed_string_t rss_type;
2042 cmdline_fixed_string_t key; /* optional argument */
2045 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2046 __attribute__((unused)) struct cmdline *cl,
2049 struct cmd_showport_rss_hash *res = parsed_result;
2051 port_rss_hash_conf_show(res->port_id, res->rss_type,
2052 show_rss_key != NULL);
2055 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2056 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2057 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2058 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2059 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2060 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2061 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2062 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2064 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2065 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2066 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2067 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2068 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2069 "ipv6-tcp-ex#ipv6-udp-ex");
2070 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2071 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2073 cmdline_parse_inst_t cmd_showport_rss_hash = {
2074 .f = cmd_showport_rss_hash_parsed,
2077 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2078 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2079 "ipv6-sctp|ipv6-other|l2-payload|"
2080 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2082 (void *)&cmd_showport_rss_hash_show,
2083 (void *)&cmd_showport_rss_hash_port,
2084 (void *)&cmd_showport_rss_hash_port_id,
2085 (void *)&cmd_showport_rss_hash_rss_hash,
2086 (void *)&cmd_showport_rss_hash_rss_hash_info,
2091 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2092 .f = cmd_showport_rss_hash_parsed,
2095 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2096 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2097 "ipv6-sctp|ipv6-other|l2-payload|"
2098 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2100 (void *)&cmd_showport_rss_hash_show,
2101 (void *)&cmd_showport_rss_hash_port,
2102 (void *)&cmd_showport_rss_hash_port_id,
2103 (void *)&cmd_showport_rss_hash_rss_hash,
2104 (void *)&cmd_showport_rss_hash_rss_hash_info,
2105 (void *)&cmd_showport_rss_hash_rss_key,
2110 /* *** Configure DCB *** */
2111 struct cmd_config_dcb {
2112 cmdline_fixed_string_t port;
2113 cmdline_fixed_string_t config;
2115 cmdline_fixed_string_t dcb;
2116 cmdline_fixed_string_t vt;
2117 cmdline_fixed_string_t vt_en;
2119 cmdline_fixed_string_t pfc;
2120 cmdline_fixed_string_t pfc_en;
2124 cmd_config_dcb_parsed(void *parsed_result,
2125 __attribute__((unused)) struct cmdline *cl,
2126 __attribute__((unused)) void *data)
2128 struct cmd_config_dcb *res = parsed_result;
2129 portid_t port_id = res->port_id;
2130 struct rte_port *port;
2134 port = &ports[port_id];
2135 /** Check if the port is not started **/
2136 if (port->port_status != RTE_PORT_STOPPED) {
2137 printf("Please stop port %d first\n", port_id);
2141 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2142 printf("The invalid number of traffic class,"
2143 " only 4 or 8 allowed.\n");
2147 if (nb_fwd_lcores < res->num_tcs) {
2148 printf("nb_cores shouldn't be less than number of TCs.\n");
2151 if (!strncmp(res->pfc_en, "on", 2))
2156 /* DCB in VT mode */
2157 if (!strncmp(res->vt_en, "on", 2))
2158 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2159 (enum rte_eth_nb_tcs)res->num_tcs,
2162 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2163 (enum rte_eth_nb_tcs)res->num_tcs,
2168 printf("Cannot initialize network ports.\n");
2172 cmd_reconfig_device_queue(port_id, 1, 1);
2175 cmdline_parse_token_string_t cmd_config_dcb_port =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2177 cmdline_parse_token_string_t cmd_config_dcb_config =
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2179 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2180 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2181 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2183 cmdline_parse_token_string_t cmd_config_dcb_vt =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2185 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2187 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2188 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2189 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2190 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2191 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2192 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2194 cmdline_parse_inst_t cmd_config_dcb = {
2195 .f = cmd_config_dcb_parsed,
2197 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2199 (void *)&cmd_config_dcb_port,
2200 (void *)&cmd_config_dcb_config,
2201 (void *)&cmd_config_dcb_port_id,
2202 (void *)&cmd_config_dcb_dcb,
2203 (void *)&cmd_config_dcb_vt,
2204 (void *)&cmd_config_dcb_vt_en,
2205 (void *)&cmd_config_dcb_num_tcs,
2206 (void *)&cmd_config_dcb_pfc,
2207 (void *)&cmd_config_dcb_pfc_en,
2212 /* *** configure number of packets per burst *** */
2213 struct cmd_config_burst {
2214 cmdline_fixed_string_t port;
2215 cmdline_fixed_string_t keyword;
2216 cmdline_fixed_string_t all;
2217 cmdline_fixed_string_t name;
2222 cmd_config_burst_parsed(void *parsed_result,
2223 __attribute__((unused)) struct cmdline *cl,
2224 __attribute__((unused)) void *data)
2226 struct cmd_config_burst *res = parsed_result;
2228 if (!all_ports_stopped()) {
2229 printf("Please stop all ports first\n");
2233 if (!strcmp(res->name, "burst")) {
2234 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2235 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2238 nb_pkt_per_burst = res->value;
2240 printf("Unknown parameter\n");
2246 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2249 cmdline_parse_token_string_t cmd_config_burst_port =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2251 cmdline_parse_token_string_t cmd_config_burst_keyword =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2253 cmdline_parse_token_string_t cmd_config_burst_all =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2255 cmdline_parse_token_string_t cmd_config_burst_name =
2256 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2257 cmdline_parse_token_num_t cmd_config_burst_value =
2258 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2260 cmdline_parse_inst_t cmd_config_burst = {
2261 .f = cmd_config_burst_parsed,
2263 .help_str = "port config all burst value",
2265 (void *)&cmd_config_burst_port,
2266 (void *)&cmd_config_burst_keyword,
2267 (void *)&cmd_config_burst_all,
2268 (void *)&cmd_config_burst_name,
2269 (void *)&cmd_config_burst_value,
2274 /* *** configure rx/tx queues *** */
2275 struct cmd_config_thresh {
2276 cmdline_fixed_string_t port;
2277 cmdline_fixed_string_t keyword;
2278 cmdline_fixed_string_t all;
2279 cmdline_fixed_string_t name;
2284 cmd_config_thresh_parsed(void *parsed_result,
2285 __attribute__((unused)) struct cmdline *cl,
2286 __attribute__((unused)) void *data)
2288 struct cmd_config_thresh *res = parsed_result;
2290 if (!all_ports_stopped()) {
2291 printf("Please stop all ports first\n");
2295 if (!strcmp(res->name, "txpt"))
2296 tx_pthresh = res->value;
2297 else if(!strcmp(res->name, "txht"))
2298 tx_hthresh = res->value;
2299 else if(!strcmp(res->name, "txwt"))
2300 tx_wthresh = res->value;
2301 else if(!strcmp(res->name, "rxpt"))
2302 rx_pthresh = res->value;
2303 else if(!strcmp(res->name, "rxht"))
2304 rx_hthresh = res->value;
2305 else if(!strcmp(res->name, "rxwt"))
2306 rx_wthresh = res->value;
2308 printf("Unknown parameter\n");
2314 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2317 cmdline_parse_token_string_t cmd_config_thresh_port =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2319 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2321 cmdline_parse_token_string_t cmd_config_thresh_all =
2322 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2323 cmdline_parse_token_string_t cmd_config_thresh_name =
2324 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2325 "txpt#txht#txwt#rxpt#rxht#rxwt");
2326 cmdline_parse_token_num_t cmd_config_thresh_value =
2327 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2329 cmdline_parse_inst_t cmd_config_thresh = {
2330 .f = cmd_config_thresh_parsed,
2332 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2334 (void *)&cmd_config_thresh_port,
2335 (void *)&cmd_config_thresh_keyword,
2336 (void *)&cmd_config_thresh_all,
2337 (void *)&cmd_config_thresh_name,
2338 (void *)&cmd_config_thresh_value,
2343 /* *** configure free/rs threshold *** */
2344 struct cmd_config_threshold {
2345 cmdline_fixed_string_t port;
2346 cmdline_fixed_string_t keyword;
2347 cmdline_fixed_string_t all;
2348 cmdline_fixed_string_t name;
2353 cmd_config_threshold_parsed(void *parsed_result,
2354 __attribute__((unused)) struct cmdline *cl,
2355 __attribute__((unused)) void *data)
2357 struct cmd_config_threshold *res = parsed_result;
2359 if (!all_ports_stopped()) {
2360 printf("Please stop all ports first\n");
2364 if (!strcmp(res->name, "txfreet"))
2365 tx_free_thresh = res->value;
2366 else if (!strcmp(res->name, "txrst"))
2367 tx_rs_thresh = res->value;
2368 else if (!strcmp(res->name, "rxfreet"))
2369 rx_free_thresh = res->value;
2371 printf("Unknown parameter\n");
2377 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2380 cmdline_parse_token_string_t cmd_config_threshold_port =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2382 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2385 cmdline_parse_token_string_t cmd_config_threshold_all =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2387 cmdline_parse_token_string_t cmd_config_threshold_name =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2389 "txfreet#txrst#rxfreet");
2390 cmdline_parse_token_num_t cmd_config_threshold_value =
2391 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2393 cmdline_parse_inst_t cmd_config_threshold = {
2394 .f = cmd_config_threshold_parsed,
2396 .help_str = "port config all txfreet|txrst|rxfreet value",
2398 (void *)&cmd_config_threshold_port,
2399 (void *)&cmd_config_threshold_keyword,
2400 (void *)&cmd_config_threshold_all,
2401 (void *)&cmd_config_threshold_name,
2402 (void *)&cmd_config_threshold_value,
2408 struct cmd_stop_result {
2409 cmdline_fixed_string_t stop;
2412 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2413 __attribute__((unused)) struct cmdline *cl,
2414 __attribute__((unused)) void *data)
2416 stop_packet_forwarding();
2419 cmdline_parse_token_string_t cmd_stop_stop =
2420 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2422 cmdline_parse_inst_t cmd_stop = {
2423 .f = cmd_stop_parsed,
2425 .help_str = "stop - stop packet forwarding",
2427 (void *)&cmd_stop_stop,
2432 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2435 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2436 unsigned int *parsed_items, int check_unique_values)
2438 unsigned int nb_item;
2446 * First parse all items in the list and store their value.
2451 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2453 if ((c >= '0') && (c <= '9')) {
2454 value = (unsigned int) (value * 10 + (c - '0'));
2459 printf("character %c is not a decimal digit\n", c);
2463 printf("No valid value before comma\n");
2466 if (nb_item < max_items) {
2467 parsed_items[nb_item] = value;
2473 if (nb_item >= max_items) {
2474 printf("Number of %s = %u > %u (maximum items)\n",
2475 item_name, nb_item + 1, max_items);
2478 parsed_items[nb_item++] = value;
2479 if (! check_unique_values)
2483 * Then, check that all values in the list are differents.
2484 * No optimization here...
2486 for (i = 0; i < nb_item; i++) {
2487 for (j = i + 1; j < nb_item; j++) {
2488 if (parsed_items[j] == parsed_items[i]) {
2489 printf("duplicated %s %u at index %u and %u\n",
2490 item_name, parsed_items[i], i, j);
2498 struct cmd_set_list_result {
2499 cmdline_fixed_string_t cmd_keyword;
2500 cmdline_fixed_string_t list_name;
2501 cmdline_fixed_string_t list_of_items;
2504 static void cmd_set_list_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_set_list_result *res;
2510 unsigned int lcorelist[RTE_MAX_LCORE];
2511 unsigned int portlist[RTE_MAX_ETHPORTS];
2513 unsigned int nb_item;
2515 if (test_done == 0) {
2516 printf("Please stop forwarding first\n");
2520 res = parsed_result;
2521 if (!strcmp(res->list_name, "corelist")) {
2522 nb_item = parse_item_list(res->list_of_items, "core",
2524 parsed_items.lcorelist, 1);
2526 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2531 if (!strcmp(res->list_name, "portlist")) {
2532 nb_item = parse_item_list(res->list_of_items, "port",
2534 parsed_items.portlist, 1);
2536 set_fwd_ports_list(parsed_items.portlist, nb_item);
2542 cmdline_parse_token_string_t cmd_set_list_keyword =
2543 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2545 cmdline_parse_token_string_t cmd_set_list_name =
2546 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2547 "corelist#portlist");
2548 cmdline_parse_token_string_t cmd_set_list_of_items =
2549 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2552 cmdline_parse_inst_t cmd_set_fwd_list = {
2553 .f = cmd_set_list_parsed,
2555 .help_str = "set corelist|portlist x[,y]*",
2557 (void *)&cmd_set_list_keyword,
2558 (void *)&cmd_set_list_name,
2559 (void *)&cmd_set_list_of_items,
2564 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2566 struct cmd_setmask_result {
2567 cmdline_fixed_string_t set;
2568 cmdline_fixed_string_t mask;
2572 static void cmd_set_mask_parsed(void *parsed_result,
2573 __attribute__((unused)) struct cmdline *cl,
2574 __attribute__((unused)) void *data)
2576 struct cmd_setmask_result *res = parsed_result;
2578 if (test_done == 0) {
2579 printf("Please stop forwarding first\n");
2582 if (!strcmp(res->mask, "coremask")) {
2583 set_fwd_lcores_mask(res->hexavalue);
2585 } else if (!strcmp(res->mask, "portmask")) {
2586 set_fwd_ports_mask(res->hexavalue);
2591 cmdline_parse_token_string_t cmd_setmask_set =
2592 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2593 cmdline_parse_token_string_t cmd_setmask_mask =
2594 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2595 "coremask#portmask");
2596 cmdline_parse_token_num_t cmd_setmask_value =
2597 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2599 cmdline_parse_inst_t cmd_set_fwd_mask = {
2600 .f = cmd_set_mask_parsed,
2602 .help_str = "set coremask|portmask hexadecimal value",
2604 (void *)&cmd_setmask_set,
2605 (void *)&cmd_setmask_mask,
2606 (void *)&cmd_setmask_value,
2612 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2614 struct cmd_set_result {
2615 cmdline_fixed_string_t set;
2616 cmdline_fixed_string_t what;
2620 static void cmd_set_parsed(void *parsed_result,
2621 __attribute__((unused)) struct cmdline *cl,
2622 __attribute__((unused)) void *data)
2624 struct cmd_set_result *res = parsed_result;
2625 if (!strcmp(res->what, "nbport")) {
2626 set_fwd_ports_number(res->value);
2628 } else if (!strcmp(res->what, "nbcore")) {
2629 set_fwd_lcores_number(res->value);
2631 } else if (!strcmp(res->what, "burst"))
2632 set_nb_pkt_per_burst(res->value);
2633 else if (!strcmp(res->what, "verbose"))
2634 set_verbose_level(res->value);
2637 cmdline_parse_token_string_t cmd_set_set =
2638 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2639 cmdline_parse_token_string_t cmd_set_what =
2640 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2641 "nbport#nbcore#burst#verbose");
2642 cmdline_parse_token_num_t cmd_set_value =
2643 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2645 cmdline_parse_inst_t cmd_set_numbers = {
2646 .f = cmd_set_parsed,
2648 .help_str = "set nbport|nbcore|burst|verbose value",
2650 (void *)&cmd_set_set,
2651 (void *)&cmd_set_what,
2652 (void *)&cmd_set_value,
2657 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2659 struct cmd_set_txpkts_result {
2660 cmdline_fixed_string_t cmd_keyword;
2661 cmdline_fixed_string_t txpkts;
2662 cmdline_fixed_string_t seg_lengths;
2666 cmd_set_txpkts_parsed(void *parsed_result,
2667 __attribute__((unused)) struct cmdline *cl,
2668 __attribute__((unused)) void *data)
2670 struct cmd_set_txpkts_result *res;
2671 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2672 unsigned int nb_segs;
2674 res = parsed_result;
2675 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2676 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2678 set_tx_pkt_segments(seg_lengths, nb_segs);
2681 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2682 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2683 cmd_keyword, "set");
2684 cmdline_parse_token_string_t cmd_set_txpkts_name =
2685 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2687 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2691 cmdline_parse_inst_t cmd_set_txpkts = {
2692 .f = cmd_set_txpkts_parsed,
2694 .help_str = "set txpkts x[,y]*",
2696 (void *)&cmd_set_txpkts_keyword,
2697 (void *)&cmd_set_txpkts_name,
2698 (void *)&cmd_set_txpkts_lengths,
2703 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2705 struct cmd_set_txsplit_result {
2706 cmdline_fixed_string_t cmd_keyword;
2707 cmdline_fixed_string_t txsplit;
2708 cmdline_fixed_string_t mode;
2712 cmd_set_txsplit_parsed(void *parsed_result,
2713 __attribute__((unused)) struct cmdline *cl,
2714 __attribute__((unused)) void *data)
2716 struct cmd_set_txsplit_result *res;
2718 res = parsed_result;
2719 set_tx_pkt_split(res->mode);
2722 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2723 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2724 cmd_keyword, "set");
2725 cmdline_parse_token_string_t cmd_set_txsplit_name =
2726 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2727 txsplit, "txsplit");
2728 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2729 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2732 cmdline_parse_inst_t cmd_set_txsplit = {
2733 .f = cmd_set_txsplit_parsed,
2735 .help_str = "set txsplit on|off|rand",
2737 (void *)&cmd_set_txsplit_keyword,
2738 (void *)&cmd_set_txsplit_name,
2739 (void *)&cmd_set_txsplit_mode,
2744 /* *** CONFIG TX QUEUE FLAGS *** */
2746 struct cmd_config_txqflags_result {
2747 cmdline_fixed_string_t port;
2748 cmdline_fixed_string_t config;
2749 cmdline_fixed_string_t all;
2750 cmdline_fixed_string_t what;
2754 static void cmd_config_txqflags_parsed(void *parsed_result,
2755 __attribute__((unused)) struct cmdline *cl,
2756 __attribute__((unused)) void *data)
2758 struct cmd_config_txqflags_result *res = parsed_result;
2760 if (!all_ports_stopped()) {
2761 printf("Please stop all ports first\n");
2765 if (strcmp(res->what, "txqflags")) {
2766 printf("Unknown parameter\n");
2770 if (res->hexvalue >= 0) {
2771 txq_flags = res->hexvalue;
2773 printf("txqflags must be >= 0\n");
2779 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2782 cmdline_parse_token_string_t cmd_config_txqflags_port =
2783 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2785 cmdline_parse_token_string_t cmd_config_txqflags_config =
2786 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2788 cmdline_parse_token_string_t cmd_config_txqflags_all =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2791 cmdline_parse_token_string_t cmd_config_txqflags_what =
2792 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2794 cmdline_parse_token_num_t cmd_config_txqflags_value =
2795 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2798 cmdline_parse_inst_t cmd_config_txqflags = {
2799 .f = cmd_config_txqflags_parsed,
2801 .help_str = "port config all txqflags value",
2803 (void *)&cmd_config_txqflags_port,
2804 (void *)&cmd_config_txqflags_config,
2805 (void *)&cmd_config_txqflags_all,
2806 (void *)&cmd_config_txqflags_what,
2807 (void *)&cmd_config_txqflags_value,
2812 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2813 struct cmd_rx_vlan_filter_all_result {
2814 cmdline_fixed_string_t rx_vlan;
2815 cmdline_fixed_string_t what;
2816 cmdline_fixed_string_t all;
2821 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2822 __attribute__((unused)) struct cmdline *cl,
2823 __attribute__((unused)) void *data)
2825 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2827 if (!strcmp(res->what, "add"))
2828 rx_vlan_all_filter_set(res->port_id, 1);
2830 rx_vlan_all_filter_set(res->port_id, 0);
2833 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2834 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2835 rx_vlan, "rx_vlan");
2836 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2837 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2839 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2840 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2842 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2843 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2846 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2847 .f = cmd_rx_vlan_filter_all_parsed,
2849 .help_str = "add/remove all identifiers to/from the set of VLAN "
2850 "Identifiers filtered by a port",
2852 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2853 (void *)&cmd_rx_vlan_filter_all_what,
2854 (void *)&cmd_rx_vlan_filter_all_all,
2855 (void *)&cmd_rx_vlan_filter_all_portid,
2860 /* *** VLAN OFFLOAD SET ON A PORT *** */
2861 struct cmd_vlan_offload_result {
2862 cmdline_fixed_string_t vlan;
2863 cmdline_fixed_string_t set;
2864 cmdline_fixed_string_t vlan_type;
2865 cmdline_fixed_string_t what;
2866 cmdline_fixed_string_t on;
2867 cmdline_fixed_string_t port_id;
2871 cmd_vlan_offload_parsed(void *parsed_result,
2872 __attribute__((unused)) struct cmdline *cl,
2873 __attribute__((unused)) void *data)
2876 struct cmd_vlan_offload_result *res = parsed_result;
2879 portid_t port_id = 0;
2883 len = strnlen(str, STR_TOKEN_SIZE);
2885 /* Get port_id first */
2893 tmp = strtoul(str, NULL, 0);
2894 /* If port_id greater that what portid_t can represent, return */
2895 if(tmp >= RTE_MAX_ETHPORTS)
2897 port_id = (portid_t)tmp;
2899 if (!strcmp(res->on, "on"))
2904 if (!strcmp(res->what, "strip"))
2905 rx_vlan_strip_set(port_id, on);
2906 else if(!strcmp(res->what, "stripq")){
2907 uint16_t queue_id = 0;
2909 /* No queue_id, return */
2911 printf("must specify (port,queue_id)\n");
2914 tmp = strtoul(str + i + 1, NULL, 0);
2915 /* If queue_id greater that what 16-bits can represent, return */
2919 queue_id = (uint16_t)tmp;
2920 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2922 else if (!strcmp(res->what, "filter"))
2923 rx_vlan_filter_set(port_id, on);
2925 vlan_extend_set(port_id, on);
2930 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2931 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2933 cmdline_parse_token_string_t cmd_vlan_offload_set =
2934 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2936 cmdline_parse_token_string_t cmd_vlan_offload_what =
2937 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2938 what, "strip#filter#qinq#stripq");
2939 cmdline_parse_token_string_t cmd_vlan_offload_on =
2940 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2942 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2943 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2946 cmdline_parse_inst_t cmd_vlan_offload = {
2947 .f = cmd_vlan_offload_parsed,
2949 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2950 " qinq(extended) for both rx/tx sides ",
2952 (void *)&cmd_vlan_offload_vlan,
2953 (void *)&cmd_vlan_offload_set,
2954 (void *)&cmd_vlan_offload_what,
2955 (void *)&cmd_vlan_offload_on,
2956 (void *)&cmd_vlan_offload_portid,
2961 /* *** VLAN TPID SET ON A PORT *** */
2962 struct cmd_vlan_tpid_result {
2963 cmdline_fixed_string_t vlan;
2964 cmdline_fixed_string_t set;
2965 cmdline_fixed_string_t vlan_type;
2966 cmdline_fixed_string_t what;
2972 cmd_vlan_tpid_parsed(void *parsed_result,
2973 __attribute__((unused)) struct cmdline *cl,
2974 __attribute__((unused)) void *data)
2976 struct cmd_vlan_tpid_result *res = parsed_result;
2977 enum rte_vlan_type vlan_type;
2979 if (!strcmp(res->vlan_type, "inner"))
2980 vlan_type = ETH_VLAN_TYPE_INNER;
2981 else if (!strcmp(res->vlan_type, "outer"))
2982 vlan_type = ETH_VLAN_TYPE_OUTER;
2984 printf("Unknown vlan type\n");
2987 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
2990 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2991 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2993 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2994 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2996 cmdline_parse_token_string_t cmd_vlan_type =
2997 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2998 vlan_type, "inner#outer");
2999 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3000 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3002 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3003 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3005 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3006 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3009 cmdline_parse_inst_t cmd_vlan_tpid = {
3010 .f = cmd_vlan_tpid_parsed,
3012 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3015 (void *)&cmd_vlan_tpid_vlan,
3016 (void *)&cmd_vlan_tpid_set,
3017 (void *)&cmd_vlan_type,
3018 (void *)&cmd_vlan_tpid_what,
3019 (void *)&cmd_vlan_tpid_tpid,
3020 (void *)&cmd_vlan_tpid_portid,
3025 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3026 struct cmd_rx_vlan_filter_result {
3027 cmdline_fixed_string_t rx_vlan;
3028 cmdline_fixed_string_t what;
3034 cmd_rx_vlan_filter_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_rx_vlan_filter_result *res = parsed_result;
3040 if (!strcmp(res->what, "add"))
3041 rx_vft_set(res->port_id, res->vlan_id, 1);
3043 rx_vft_set(res->port_id, res->vlan_id, 0);
3046 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3047 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3048 rx_vlan, "rx_vlan");
3049 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3050 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3052 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3053 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3055 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3056 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3059 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3060 .f = cmd_rx_vlan_filter_parsed,
3062 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3063 "Identifiers filtered by a port",
3065 (void *)&cmd_rx_vlan_filter_rx_vlan,
3066 (void *)&cmd_rx_vlan_filter_what,
3067 (void *)&cmd_rx_vlan_filter_vlanid,
3068 (void *)&cmd_rx_vlan_filter_portid,
3073 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3074 struct cmd_tx_vlan_set_result {
3075 cmdline_fixed_string_t tx_vlan;
3076 cmdline_fixed_string_t set;
3082 cmd_tx_vlan_set_parsed(void *parsed_result,
3083 __attribute__((unused)) struct cmdline *cl,
3084 __attribute__((unused)) void *data)
3086 struct cmd_tx_vlan_set_result *res = parsed_result;
3088 tx_vlan_set(res->port_id, res->vlan_id);
3091 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3092 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3093 tx_vlan, "tx_vlan");
3094 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3095 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3097 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3098 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3100 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3101 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3104 cmdline_parse_inst_t cmd_tx_vlan_set = {
3105 .f = cmd_tx_vlan_set_parsed,
3107 .help_str = "enable hardware insertion of a single VLAN header "
3108 "with a given TAG Identifier in packets sent on a port",
3110 (void *)&cmd_tx_vlan_set_tx_vlan,
3111 (void *)&cmd_tx_vlan_set_set,
3112 (void *)&cmd_tx_vlan_set_portid,
3113 (void *)&cmd_tx_vlan_set_vlanid,
3118 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3119 struct cmd_tx_vlan_set_qinq_result {
3120 cmdline_fixed_string_t tx_vlan;
3121 cmdline_fixed_string_t set;
3124 uint16_t vlan_id_outer;
3128 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3129 __attribute__((unused)) struct cmdline *cl,
3130 __attribute__((unused)) void *data)
3132 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3134 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3137 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3138 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3139 tx_vlan, "tx_vlan");
3140 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3141 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3143 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3144 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3146 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3147 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3149 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3150 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3151 vlan_id_outer, UINT16);
3153 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3154 .f = cmd_tx_vlan_set_qinq_parsed,
3156 .help_str = "enable hardware insertion of double VLAN header "
3157 "with given TAG Identifiers in packets sent on a port",
3159 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3160 (void *)&cmd_tx_vlan_set_qinq_set,
3161 (void *)&cmd_tx_vlan_set_qinq_portid,
3162 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3163 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3168 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3169 struct cmd_tx_vlan_set_pvid_result {
3170 cmdline_fixed_string_t tx_vlan;
3171 cmdline_fixed_string_t set;
3172 cmdline_fixed_string_t pvid;
3175 cmdline_fixed_string_t mode;
3179 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3180 __attribute__((unused)) struct cmdline *cl,
3181 __attribute__((unused)) void *data)
3183 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3185 if (strcmp(res->mode, "on") == 0)
3186 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3188 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3191 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3192 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3193 tx_vlan, "tx_vlan");
3194 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3195 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3197 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3198 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3200 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3201 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3203 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3204 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3206 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3207 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3210 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3211 .f = cmd_tx_vlan_set_pvid_parsed,
3213 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3215 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3216 (void *)&cmd_tx_vlan_set_pvid_set,
3217 (void *)&cmd_tx_vlan_set_pvid_pvid,
3218 (void *)&cmd_tx_vlan_set_pvid_port_id,
3219 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3220 (void *)&cmd_tx_vlan_set_pvid_mode,
3225 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3226 struct cmd_tx_vlan_reset_result {
3227 cmdline_fixed_string_t tx_vlan;
3228 cmdline_fixed_string_t reset;
3233 cmd_tx_vlan_reset_parsed(void *parsed_result,
3234 __attribute__((unused)) struct cmdline *cl,
3235 __attribute__((unused)) void *data)
3237 struct cmd_tx_vlan_reset_result *res = parsed_result;
3239 tx_vlan_reset(res->port_id);
3242 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3243 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3244 tx_vlan, "tx_vlan");
3245 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3246 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3248 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3249 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3252 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3253 .f = cmd_tx_vlan_reset_parsed,
3255 .help_str = "disable hardware insertion of a VLAN header in packets "
3258 (void *)&cmd_tx_vlan_reset_tx_vlan,
3259 (void *)&cmd_tx_vlan_reset_reset,
3260 (void *)&cmd_tx_vlan_reset_portid,
3266 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3267 struct cmd_csum_result {
3268 cmdline_fixed_string_t csum;
3269 cmdline_fixed_string_t mode;
3270 cmdline_fixed_string_t proto;
3271 cmdline_fixed_string_t hwsw;
3276 csum_show(int port_id)
3278 struct rte_eth_dev_info dev_info;
3281 ol_flags = ports[port_id].tx_ol_flags;
3282 printf("Parse tunnel is %s\n",
3283 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3284 printf("IP checksum offload is %s\n",
3285 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3286 printf("UDP checksum offload is %s\n",
3287 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3288 printf("TCP checksum offload is %s\n",
3289 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3290 printf("SCTP checksum offload is %s\n",
3291 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3292 printf("Outer-Ip checksum offload is %s\n",
3293 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3295 /* display warnings if configuration is not supported by the NIC */
3296 rte_eth_dev_info_get(port_id, &dev_info);
3297 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3298 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3299 printf("Warning: hardware IP checksum enabled but not "
3300 "supported by port %d\n", port_id);
3302 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3303 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3304 printf("Warning: hardware UDP checksum enabled but not "
3305 "supported by port %d\n", port_id);
3307 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3308 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3309 printf("Warning: hardware TCP checksum enabled but not "
3310 "supported by port %d\n", port_id);
3312 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3313 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3314 printf("Warning: hardware SCTP checksum enabled but not "
3315 "supported by port %d\n", port_id);
3317 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3318 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3319 printf("Warning: hardware outer IP checksum enabled but not "
3320 "supported by port %d\n", port_id);
3325 cmd_csum_parsed(void *parsed_result,
3326 __attribute__((unused)) struct cmdline *cl,
3327 __attribute__((unused)) void *data)
3329 struct cmd_csum_result *res = parsed_result;
3333 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3334 printf("invalid port %d\n", res->port_id);
3338 if (!strcmp(res->mode, "set")) {
3340 if (!strcmp(res->hwsw, "hw"))
3343 if (!strcmp(res->proto, "ip")) {
3344 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3345 } else if (!strcmp(res->proto, "udp")) {
3346 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3347 } else if (!strcmp(res->proto, "tcp")) {
3348 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3349 } else if (!strcmp(res->proto, "sctp")) {
3350 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3351 } else if (!strcmp(res->proto, "outer-ip")) {
3352 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3356 ports[res->port_id].tx_ol_flags |= mask;
3358 ports[res->port_id].tx_ol_flags &= (~mask);
3360 csum_show(res->port_id);
3363 cmdline_parse_token_string_t cmd_csum_csum =
3364 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3366 cmdline_parse_token_string_t cmd_csum_mode =
3367 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3369 cmdline_parse_token_string_t cmd_csum_proto =
3370 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3371 proto, "ip#tcp#udp#sctp#outer-ip");
3372 cmdline_parse_token_string_t cmd_csum_hwsw =
3373 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3375 cmdline_parse_token_num_t cmd_csum_portid =
3376 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3379 cmdline_parse_inst_t cmd_csum_set = {
3380 .f = cmd_csum_parsed,
3382 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3383 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3385 (void *)&cmd_csum_csum,
3386 (void *)&cmd_csum_mode,
3387 (void *)&cmd_csum_proto,
3388 (void *)&cmd_csum_hwsw,
3389 (void *)&cmd_csum_portid,
3394 cmdline_parse_token_string_t cmd_csum_mode_show =
3395 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3398 cmdline_parse_inst_t cmd_csum_show = {
3399 .f = cmd_csum_parsed,
3401 .help_str = "show checksum offload configuration: csum show <port>",
3403 (void *)&cmd_csum_csum,
3404 (void *)&cmd_csum_mode_show,
3405 (void *)&cmd_csum_portid,
3410 /* Enable/disable tunnel parsing */
3411 struct cmd_csum_tunnel_result {
3412 cmdline_fixed_string_t csum;
3413 cmdline_fixed_string_t parse;
3414 cmdline_fixed_string_t onoff;
3419 cmd_csum_tunnel_parsed(void *parsed_result,
3420 __attribute__((unused)) struct cmdline *cl,
3421 __attribute__((unused)) void *data)
3423 struct cmd_csum_tunnel_result *res = parsed_result;
3425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3428 if (!strcmp(res->onoff, "on"))
3429 ports[res->port_id].tx_ol_flags |=
3430 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3432 ports[res->port_id].tx_ol_flags &=
3433 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3435 csum_show(res->port_id);
3438 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3439 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3441 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3442 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3443 parse, "parse_tunnel");
3444 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3445 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3447 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3448 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3451 cmdline_parse_inst_t cmd_csum_tunnel = {
3452 .f = cmd_csum_tunnel_parsed,
3454 .help_str = "enable/disable parsing of tunnels for csum engine: "
3455 "csum parse_tunnel on|off <tx-port>",
3457 (void *)&cmd_csum_tunnel_csum,
3458 (void *)&cmd_csum_tunnel_parse,
3459 (void *)&cmd_csum_tunnel_onoff,
3460 (void *)&cmd_csum_tunnel_portid,
3465 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3466 struct cmd_tso_set_result {
3467 cmdline_fixed_string_t tso;
3468 cmdline_fixed_string_t mode;
3474 cmd_tso_set_parsed(void *parsed_result,
3475 __attribute__((unused)) struct cmdline *cl,
3476 __attribute__((unused)) void *data)
3478 struct cmd_tso_set_result *res = parsed_result;
3479 struct rte_eth_dev_info dev_info;
3481 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3484 if (!strcmp(res->mode, "set"))
3485 ports[res->port_id].tso_segsz = res->tso_segsz;
3487 if (ports[res->port_id].tso_segsz == 0)
3488 printf("TSO is disabled\n");
3490 printf("TSO segment size is %d\n",
3491 ports[res->port_id].tso_segsz);
3493 /* display warnings if configuration is not supported by the NIC */
3494 rte_eth_dev_info_get(res->port_id, &dev_info);
3495 if ((ports[res->port_id].tso_segsz != 0) &&
3496 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3497 printf("Warning: TSO enabled but not "
3498 "supported by port %d\n", res->port_id);
3502 cmdline_parse_token_string_t cmd_tso_set_tso =
3503 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3505 cmdline_parse_token_string_t cmd_tso_set_mode =
3506 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3508 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3509 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3511 cmdline_parse_token_num_t cmd_tso_set_portid =
3512 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3515 cmdline_parse_inst_t cmd_tso_set = {
3516 .f = cmd_tso_set_parsed,
3518 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3519 "tso set <tso_segsz> <port>",
3521 (void *)&cmd_tso_set_tso,
3522 (void *)&cmd_tso_set_mode,
3523 (void *)&cmd_tso_set_tso_segsz,
3524 (void *)&cmd_tso_set_portid,
3529 cmdline_parse_token_string_t cmd_tso_show_mode =
3530 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3534 cmdline_parse_inst_t cmd_tso_show = {
3535 .f = cmd_tso_set_parsed,
3537 .help_str = "Show TSO segment size for csum engine: "
3540 (void *)&cmd_tso_set_tso,
3541 (void *)&cmd_tso_show_mode,
3542 (void *)&cmd_tso_set_portid,
3547 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3548 struct cmd_set_flush_rx {
3549 cmdline_fixed_string_t set;
3550 cmdline_fixed_string_t flush_rx;
3551 cmdline_fixed_string_t mode;
3555 cmd_set_flush_rx_parsed(void *parsed_result,
3556 __attribute__((unused)) struct cmdline *cl,
3557 __attribute__((unused)) void *data)
3559 struct cmd_set_flush_rx *res = parsed_result;
3560 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3563 cmdline_parse_token_string_t cmd_setflushrx_set =
3564 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3566 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3568 flush_rx, "flush_rx");
3569 cmdline_parse_token_string_t cmd_setflushrx_mode =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3574 cmdline_parse_inst_t cmd_set_flush_rx = {
3575 .f = cmd_set_flush_rx_parsed,
3576 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3579 (void *)&cmd_setflushrx_set,
3580 (void *)&cmd_setflushrx_flush_rx,
3581 (void *)&cmd_setflushrx_mode,
3586 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3587 struct cmd_set_link_check {
3588 cmdline_fixed_string_t set;
3589 cmdline_fixed_string_t link_check;
3590 cmdline_fixed_string_t mode;
3594 cmd_set_link_check_parsed(void *parsed_result,
3595 __attribute__((unused)) struct cmdline *cl,
3596 __attribute__((unused)) void *data)
3598 struct cmd_set_link_check *res = parsed_result;
3599 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3602 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3603 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3605 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3606 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3607 link_check, "link_check");
3608 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3609 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3613 cmdline_parse_inst_t cmd_set_link_check = {
3614 .f = cmd_set_link_check_parsed,
3615 .help_str = "set link_check on|off: enable/disable link status check "
3616 "when starting/stopping a port",
3619 (void *)&cmd_setlinkcheck_set,
3620 (void *)&cmd_setlinkcheck_link_check,
3621 (void *)&cmd_setlinkcheck_mode,
3626 #ifdef RTE_NIC_BYPASS
3627 /* *** SET NIC BYPASS MODE *** */
3628 struct cmd_set_bypass_mode_result {
3629 cmdline_fixed_string_t set;
3630 cmdline_fixed_string_t bypass;
3631 cmdline_fixed_string_t mode;
3632 cmdline_fixed_string_t value;
3637 cmd_set_bypass_mode_parsed(void *parsed_result,
3638 __attribute__((unused)) struct cmdline *cl,
3639 __attribute__((unused)) void *data)
3641 struct cmd_set_bypass_mode_result *res = parsed_result;
3642 portid_t port_id = res->port_id;
3643 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3645 if (!bypass_is_supported(port_id))
3648 if (!strcmp(res->value, "bypass"))
3649 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3650 else if (!strcmp(res->value, "isolate"))
3651 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3653 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3655 /* Set the bypass mode for the relevant port. */
3656 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3657 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3661 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3662 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3664 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3665 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3667 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3668 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3670 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3671 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3672 value, "normal#bypass#isolate");
3673 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3674 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3677 cmdline_parse_inst_t cmd_set_bypass_mode = {
3678 .f = cmd_set_bypass_mode_parsed,
3679 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3680 "Set the NIC bypass mode for port_id",
3683 (void *)&cmd_setbypass_mode_set,
3684 (void *)&cmd_setbypass_mode_bypass,
3685 (void *)&cmd_setbypass_mode_mode,
3686 (void *)&cmd_setbypass_mode_value,
3687 (void *)&cmd_setbypass_mode_port,
3692 /* *** SET NIC BYPASS EVENT *** */
3693 struct cmd_set_bypass_event_result {
3694 cmdline_fixed_string_t set;
3695 cmdline_fixed_string_t bypass;
3696 cmdline_fixed_string_t event;
3697 cmdline_fixed_string_t event_value;
3698 cmdline_fixed_string_t mode;
3699 cmdline_fixed_string_t mode_value;
3704 cmd_set_bypass_event_parsed(void *parsed_result,
3705 __attribute__((unused)) struct cmdline *cl,
3706 __attribute__((unused)) void *data)
3709 struct cmd_set_bypass_event_result *res = parsed_result;
3710 portid_t port_id = res->port_id;
3711 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3712 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3714 if (!bypass_is_supported(port_id))
3717 if (!strcmp(res->event_value, "timeout"))
3718 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3719 else if (!strcmp(res->event_value, "os_on"))
3720 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3721 else if (!strcmp(res->event_value, "os_off"))
3722 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3723 else if (!strcmp(res->event_value, "power_on"))
3724 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3725 else if (!strcmp(res->event_value, "power_off"))
3726 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3728 bypass_event = RTE_BYPASS_EVENT_NONE;
3730 if (!strcmp(res->mode_value, "bypass"))
3731 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3732 else if (!strcmp(res->mode_value, "isolate"))
3733 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3735 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3737 /* Set the watchdog timeout. */
3738 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3741 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3742 (rc = rte_eth_dev_wd_timeout_store(port_id,
3743 bypass_timeout)) != 0) {
3744 printf("Failed to set timeout value %u "
3745 "for port %d, errto code: %d.\n",
3746 bypass_timeout, port_id, rc);
3750 /* Set the bypass event to transition to bypass mode. */
3751 if (0 != rte_eth_dev_bypass_event_store(port_id,
3752 bypass_event, bypass_mode)) {
3753 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3758 cmdline_parse_token_string_t cmd_setbypass_event_set =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3761 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3764 cmdline_parse_token_string_t cmd_setbypass_event_event =
3765 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3767 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3768 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3769 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3770 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3771 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3773 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3774 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3775 mode_value, "normal#bypass#isolate");
3776 cmdline_parse_token_num_t cmd_setbypass_event_port =
3777 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3780 cmdline_parse_inst_t cmd_set_bypass_event = {
3781 .f = cmd_set_bypass_event_parsed,
3782 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3783 "mode (normal|bypass|isolate) (port_id): "
3784 "Set the NIC bypass event mode for port_id",
3787 (void *)&cmd_setbypass_event_set,
3788 (void *)&cmd_setbypass_event_bypass,
3789 (void *)&cmd_setbypass_event_event,
3790 (void *)&cmd_setbypass_event_event_value,
3791 (void *)&cmd_setbypass_event_mode,
3792 (void *)&cmd_setbypass_event_mode_value,
3793 (void *)&cmd_setbypass_event_port,
3799 /* *** SET NIC BYPASS TIMEOUT *** */
3800 struct cmd_set_bypass_timeout_result {
3801 cmdline_fixed_string_t set;
3802 cmdline_fixed_string_t bypass;
3803 cmdline_fixed_string_t timeout;
3804 cmdline_fixed_string_t value;
3808 cmd_set_bypass_timeout_parsed(void *parsed_result,
3809 __attribute__((unused)) struct cmdline *cl,
3810 __attribute__((unused)) void *data)
3812 struct cmd_set_bypass_timeout_result *res = parsed_result;
3814 if (!strcmp(res->value, "1.5"))
3815 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3816 else if (!strcmp(res->value, "2"))
3817 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3818 else if (!strcmp(res->value, "3"))
3819 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3820 else if (!strcmp(res->value, "4"))
3821 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3822 else if (!strcmp(res->value, "8"))
3823 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3824 else if (!strcmp(res->value, "16"))
3825 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3826 else if (!strcmp(res->value, "32"))
3827 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3829 bypass_timeout = RTE_BYPASS_TMT_OFF;
3832 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3835 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3838 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3840 timeout, "timeout");
3841 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3842 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3843 value, "0#1.5#2#3#4#8#16#32");
3845 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3846 .f = cmd_set_bypass_timeout_parsed,
3847 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3848 "Set the NIC bypass watchdog timeout",
3851 (void *)&cmd_setbypass_timeout_set,
3852 (void *)&cmd_setbypass_timeout_bypass,
3853 (void *)&cmd_setbypass_timeout_timeout,
3854 (void *)&cmd_setbypass_timeout_value,
3859 /* *** SHOW NIC BYPASS MODE *** */
3860 struct cmd_show_bypass_config_result {
3861 cmdline_fixed_string_t show;
3862 cmdline_fixed_string_t bypass;
3863 cmdline_fixed_string_t config;
3868 cmd_show_bypass_config_parsed(void *parsed_result,
3869 __attribute__((unused)) struct cmdline *cl,
3870 __attribute__((unused)) void *data)
3872 struct cmd_show_bypass_config_result *res = parsed_result;
3873 uint32_t event_mode;
3874 uint32_t bypass_mode;
3875 portid_t port_id = res->port_id;
3876 uint32_t timeout = bypass_timeout;
3879 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3880 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3881 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3882 {"UNKNOWN", "normal", "bypass", "isolate"};
3883 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3890 int num_events = (sizeof events) / (sizeof events[0]);
3892 if (!bypass_is_supported(port_id))
3895 /* Display the bypass mode.*/
3896 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3897 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3901 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3902 bypass_mode = RTE_BYPASS_MODE_NONE;
3904 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3907 /* Display the bypass timeout.*/
3908 if (!RTE_BYPASS_TMT_VALID(timeout))
3909 timeout = RTE_BYPASS_TMT_OFF;
3911 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3913 /* Display the bypass events and associated modes. */
3914 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3916 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3917 printf("\tFailed to get bypass mode for event = %s\n",
3920 if (!RTE_BYPASS_MODE_VALID(event_mode))
3921 event_mode = RTE_BYPASS_MODE_NONE;
3923 printf("\tbypass event: %-16s = %s\n", events[i],
3929 cmdline_parse_token_string_t cmd_showbypass_config_show =
3930 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3932 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3933 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3935 cmdline_parse_token_string_t cmd_showbypass_config_config =
3936 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3938 cmdline_parse_token_num_t cmd_showbypass_config_port =
3939 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3942 cmdline_parse_inst_t cmd_show_bypass_config = {
3943 .f = cmd_show_bypass_config_parsed,
3944 .help_str = "show bypass config (port_id): "
3945 "Show the NIC bypass config for port_id",
3948 (void *)&cmd_showbypass_config_show,
3949 (void *)&cmd_showbypass_config_bypass,
3950 (void *)&cmd_showbypass_config_config,
3951 (void *)&cmd_showbypass_config_port,
3957 #ifdef RTE_LIBRTE_PMD_BOND
3958 /* *** SET BONDING MODE *** */
3959 struct cmd_set_bonding_mode_result {
3960 cmdline_fixed_string_t set;
3961 cmdline_fixed_string_t bonding;
3962 cmdline_fixed_string_t mode;
3967 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3968 __attribute__((unused)) struct cmdline *cl,
3969 __attribute__((unused)) void *data)
3971 struct cmd_set_bonding_mode_result *res = parsed_result;
3972 portid_t port_id = res->port_id;
3974 /* Set the bonding mode for the relevant port. */
3975 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3976 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3979 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3980 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3982 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3983 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3984 bonding, "bonding");
3985 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3988 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3989 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3991 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3992 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3995 cmdline_parse_inst_t cmd_set_bonding_mode = {
3996 .f = cmd_set_bonding_mode_parsed,
3997 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
4000 (void *) &cmd_setbonding_mode_set,
4001 (void *) &cmd_setbonding_mode_bonding,
4002 (void *) &cmd_setbonding_mode_mode,
4003 (void *) &cmd_setbonding_mode_value,
4004 (void *) &cmd_setbonding_mode_port,
4009 /* *** SET BALANCE XMIT POLICY *** */
4010 struct cmd_set_bonding_balance_xmit_policy_result {
4011 cmdline_fixed_string_t set;
4012 cmdline_fixed_string_t bonding;
4013 cmdline_fixed_string_t balance_xmit_policy;
4015 cmdline_fixed_string_t policy;
4018 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4019 __attribute__((unused)) struct cmdline *cl,
4020 __attribute__((unused)) void *data)
4022 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4023 portid_t port_id = res->port_id;
4026 if (!strcmp(res->policy, "l2")) {
4027 policy = BALANCE_XMIT_POLICY_LAYER2;
4028 } else if (!strcmp(res->policy, "l23")) {
4029 policy = BALANCE_XMIT_POLICY_LAYER23;
4030 } else if (!strcmp(res->policy, "l34")) {
4031 policy = BALANCE_XMIT_POLICY_LAYER34;
4033 printf("\t Invalid xmit policy selection");
4037 /* Set the bonding mode for the relevant port. */
4038 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4039 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4044 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4047 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4049 bonding, "bonding");
4050 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4052 balance_xmit_policy, "balance_xmit_policy");
4053 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4054 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4056 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4057 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4058 policy, "l2#l23#l34");
4060 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4061 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4062 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4065 (void *)&cmd_setbonding_balance_xmit_policy_set,
4066 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4067 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4068 (void *)&cmd_setbonding_balance_xmit_policy_port,
4069 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4074 /* *** SHOW NIC BONDING CONFIGURATION *** */
4075 struct cmd_show_bonding_config_result {
4076 cmdline_fixed_string_t show;
4077 cmdline_fixed_string_t bonding;
4078 cmdline_fixed_string_t config;
4082 static void cmd_show_bonding_config_parsed(void *parsed_result,
4083 __attribute__((unused)) struct cmdline *cl,
4084 __attribute__((unused)) void *data)
4086 struct cmd_show_bonding_config_result *res = parsed_result;
4088 uint8_t slaves[RTE_MAX_ETHPORTS];
4089 int num_slaves, num_active_slaves;
4092 portid_t port_id = res->port_id;
4094 /* Display the bonding mode.*/
4095 bonding_mode = rte_eth_bond_mode_get(port_id);
4096 if (bonding_mode < 0) {
4097 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4100 printf("\tBonding mode: %d\n", bonding_mode);
4102 if (bonding_mode == BONDING_MODE_BALANCE) {
4103 int balance_xmit_policy;
4105 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4106 if (balance_xmit_policy < 0) {
4107 printf("\tFailed to get balance xmit policy for port = %d\n",
4111 printf("\tBalance Xmit Policy: ");
4113 switch (balance_xmit_policy) {
4114 case BALANCE_XMIT_POLICY_LAYER2:
4115 printf("BALANCE_XMIT_POLICY_LAYER2");
4117 case BALANCE_XMIT_POLICY_LAYER23:
4118 printf("BALANCE_XMIT_POLICY_LAYER23");
4120 case BALANCE_XMIT_POLICY_LAYER34:
4121 printf("BALANCE_XMIT_POLICY_LAYER34");
4128 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4130 if (num_slaves < 0) {
4131 printf("\tFailed to get slave list for port = %d\n", port_id);
4134 if (num_slaves > 0) {
4135 printf("\tSlaves (%d): [", num_slaves);
4136 for (i = 0; i < num_slaves - 1; i++)
4137 printf("%d ", slaves[i]);
4139 printf("%d]\n", slaves[num_slaves - 1]);
4141 printf("\tSlaves: []\n");
4145 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4148 if (num_active_slaves < 0) {
4149 printf("\tFailed to get active slave list for port = %d\n", port_id);
4152 if (num_active_slaves > 0) {
4153 printf("\tActive Slaves (%d): [", num_active_slaves);
4154 for (i = 0; i < num_active_slaves - 1; i++)
4155 printf("%d ", slaves[i]);
4157 printf("%d]\n", slaves[num_active_slaves - 1]);
4160 printf("\tActive Slaves: []\n");
4164 primary_id = rte_eth_bond_primary_get(port_id);
4165 if (primary_id < 0) {
4166 printf("\tFailed to get primary slave for port = %d\n", port_id);
4169 printf("\tPrimary: [%d]\n", primary_id);
4173 cmdline_parse_token_string_t cmd_showbonding_config_show =
4174 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4176 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4177 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4178 bonding, "bonding");
4179 cmdline_parse_token_string_t cmd_showbonding_config_config =
4180 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4182 cmdline_parse_token_num_t cmd_showbonding_config_port =
4183 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4186 cmdline_parse_inst_t cmd_show_bonding_config = {
4187 .f = cmd_show_bonding_config_parsed,
4188 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4191 (void *)&cmd_showbonding_config_show,
4192 (void *)&cmd_showbonding_config_bonding,
4193 (void *)&cmd_showbonding_config_config,
4194 (void *)&cmd_showbonding_config_port,
4199 /* *** SET BONDING PRIMARY *** */
4200 struct cmd_set_bonding_primary_result {
4201 cmdline_fixed_string_t set;
4202 cmdline_fixed_string_t bonding;
4203 cmdline_fixed_string_t primary;
4208 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4209 __attribute__((unused)) struct cmdline *cl,
4210 __attribute__((unused)) void *data)
4212 struct cmd_set_bonding_primary_result *res = parsed_result;
4213 portid_t master_port_id = res->port_id;
4214 portid_t slave_port_id = res->slave_id;
4216 /* Set the primary slave for a bonded device. */
4217 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4218 printf("\t Failed to set primary slave for port = %d.\n",
4225 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4226 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4228 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4230 bonding, "bonding");
4231 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4233 primary, "primary");
4234 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4235 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4237 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4238 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4241 cmdline_parse_inst_t cmd_set_bonding_primary = {
4242 .f = cmd_set_bonding_primary_parsed,
4243 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4246 (void *)&cmd_setbonding_primary_set,
4247 (void *)&cmd_setbonding_primary_bonding,
4248 (void *)&cmd_setbonding_primary_primary,
4249 (void *)&cmd_setbonding_primary_slave,
4250 (void *)&cmd_setbonding_primary_port,
4255 /* *** ADD SLAVE *** */
4256 struct cmd_add_bonding_slave_result {
4257 cmdline_fixed_string_t add;
4258 cmdline_fixed_string_t bonding;
4259 cmdline_fixed_string_t slave;
4264 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4265 __attribute__((unused)) struct cmdline *cl,
4266 __attribute__((unused)) void *data)
4268 struct cmd_add_bonding_slave_result *res = parsed_result;
4269 portid_t master_port_id = res->port_id;
4270 portid_t slave_port_id = res->slave_id;
4272 /* Set the primary slave for a bonded device. */
4273 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4274 printf("\t Failed to add slave %d to master port = %d.\n",
4275 slave_port_id, master_port_id);
4279 set_port_slave_flag(slave_port_id);
4282 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4283 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4285 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4287 bonding, "bonding");
4288 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4289 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4291 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4292 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4294 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4295 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4298 cmdline_parse_inst_t cmd_add_bonding_slave = {
4299 .f = cmd_add_bonding_slave_parsed,
4300 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4303 (void *)&cmd_addbonding_slave_add,
4304 (void *)&cmd_addbonding_slave_bonding,
4305 (void *)&cmd_addbonding_slave_slave,
4306 (void *)&cmd_addbonding_slave_slaveid,
4307 (void *)&cmd_addbonding_slave_port,
4312 /* *** REMOVE SLAVE *** */
4313 struct cmd_remove_bonding_slave_result {
4314 cmdline_fixed_string_t remove;
4315 cmdline_fixed_string_t bonding;
4316 cmdline_fixed_string_t slave;
4321 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4322 __attribute__((unused)) struct cmdline *cl,
4323 __attribute__((unused)) void *data)
4325 struct cmd_remove_bonding_slave_result *res = parsed_result;
4326 portid_t master_port_id = res->port_id;
4327 portid_t slave_port_id = res->slave_id;
4329 /* Set the primary slave for a bonded device. */
4330 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4331 printf("\t Failed to remove slave %d from master port = %d.\n",
4332 slave_port_id, master_port_id);
4336 clear_port_slave_flag(slave_port_id);
4339 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4340 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4342 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4343 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4344 bonding, "bonding");
4345 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4346 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4348 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4349 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4351 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4352 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4355 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4356 .f = cmd_remove_bonding_slave_parsed,
4357 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4360 (void *)&cmd_removebonding_slave_remove,
4361 (void *)&cmd_removebonding_slave_bonding,
4362 (void *)&cmd_removebonding_slave_slave,
4363 (void *)&cmd_removebonding_slave_slaveid,
4364 (void *)&cmd_removebonding_slave_port,
4369 /* *** CREATE BONDED DEVICE *** */
4370 struct cmd_create_bonded_device_result {
4371 cmdline_fixed_string_t create;
4372 cmdline_fixed_string_t bonded;
4373 cmdline_fixed_string_t device;
4378 static int bond_dev_num = 0;
4380 static void cmd_create_bonded_device_parsed(void *parsed_result,
4381 __attribute__((unused)) struct cmdline *cl,
4382 __attribute__((unused)) void *data)
4384 struct cmd_create_bonded_device_result *res = parsed_result;
4385 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4388 if (test_done == 0) {
4389 printf("Please stop forwarding first\n");
4393 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4396 /* Create a new bonded device. */
4397 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4399 printf("\t Failed to create bonded device.\n");
4402 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4405 /* Update number of ports */
4406 nb_ports = rte_eth_dev_count();
4407 reconfig(port_id, res->socket);
4408 rte_eth_promiscuous_enable(port_id);
4409 ports[port_id].enabled = 1;
4414 cmdline_parse_token_string_t cmd_createbonded_device_create =
4415 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4417 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4418 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4420 cmdline_parse_token_string_t cmd_createbonded_device_device =
4421 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4423 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4424 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4426 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4427 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4430 cmdline_parse_inst_t cmd_create_bonded_device = {
4431 .f = cmd_create_bonded_device_parsed,
4432 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4435 (void *)&cmd_createbonded_device_create,
4436 (void *)&cmd_createbonded_device_bonded,
4437 (void *)&cmd_createbonded_device_device,
4438 (void *)&cmd_createbonded_device_mode,
4439 (void *)&cmd_createbonded_device_socket,
4444 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4445 struct cmd_set_bond_mac_addr_result {
4446 cmdline_fixed_string_t set;
4447 cmdline_fixed_string_t bonding;
4448 cmdline_fixed_string_t mac_addr;
4450 struct ether_addr address;
4453 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4454 __attribute__((unused)) struct cmdline *cl,
4455 __attribute__((unused)) void *data)
4457 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4460 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4463 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4465 /* check the return value and print it if is < 0 */
4467 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4470 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4471 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4472 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4475 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4476 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4478 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4479 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4480 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4481 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4483 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4484 .f = cmd_set_bond_mac_addr_parsed,
4486 .help_str = "set bonding mac_addr (port_id) (address): ",
4488 (void *)&cmd_set_bond_mac_addr_set,
4489 (void *)&cmd_set_bond_mac_addr_bonding,
4490 (void *)&cmd_set_bond_mac_addr_mac,
4491 (void *)&cmd_set_bond_mac_addr_portnum,
4492 (void *)&cmd_set_bond_mac_addr_addr,
4498 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4499 struct cmd_set_bond_mon_period_result {
4500 cmdline_fixed_string_t set;
4501 cmdline_fixed_string_t bonding;
4502 cmdline_fixed_string_t mon_period;
4507 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4508 __attribute__((unused)) struct cmdline *cl,
4509 __attribute__((unused)) void *data)
4511 struct cmd_set_bond_mon_period_result *res = parsed_result;
4514 if (res->port_num >= nb_ports) {
4515 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4519 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4521 /* check the return value and print it if is < 0 */
4523 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4526 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4529 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4530 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4531 bonding, "bonding");
4532 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4533 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4534 mon_period, "mon_period");
4535 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4536 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4538 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4539 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4542 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4543 .f = cmd_set_bond_mon_period_parsed,
4545 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4547 (void *)&cmd_set_bond_mon_period_set,
4548 (void *)&cmd_set_bond_mon_period_bonding,
4549 (void *)&cmd_set_bond_mon_period_mon_period,
4550 (void *)&cmd_set_bond_mon_period_portnum,
4551 (void *)&cmd_set_bond_mon_period_period_ms,
4556 #endif /* RTE_LIBRTE_PMD_BOND */
4558 /* *** SET FORWARDING MODE *** */
4559 struct cmd_set_fwd_mode_result {
4560 cmdline_fixed_string_t set;
4561 cmdline_fixed_string_t fwd;
4562 cmdline_fixed_string_t mode;
4565 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4566 __attribute__((unused)) struct cmdline *cl,
4567 __attribute__((unused)) void *data)
4569 struct cmd_set_fwd_mode_result *res = parsed_result;
4572 set_pkt_forwarding_mode(res->mode);
4575 cmdline_parse_token_string_t cmd_setfwd_set =
4576 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4577 cmdline_parse_token_string_t cmd_setfwd_fwd =
4578 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4579 cmdline_parse_token_string_t cmd_setfwd_mode =
4580 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4581 "" /* defined at init */);
4583 cmdline_parse_inst_t cmd_set_fwd_mode = {
4584 .f = cmd_set_fwd_mode_parsed,
4586 .help_str = NULL, /* defined at init */
4588 (void *)&cmd_setfwd_set,
4589 (void *)&cmd_setfwd_fwd,
4590 (void *)&cmd_setfwd_mode,
4595 static void cmd_set_fwd_mode_init(void)
4598 static char token[128];
4599 static char help[256];
4600 cmdline_parse_token_string_t *token_struct;
4602 modes = list_pkt_forwarding_modes();
4603 snprintf(help, sizeof help, "set fwd %s - "
4604 "set packet forwarding mode", modes);
4605 cmd_set_fwd_mode.help_str = help;
4607 /* string token separator is # */
4608 for (c = token; *modes != '\0'; modes++)
4613 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4614 token_struct->string_data.str = token;
4617 /* *** SET RETRY FORWARDING MODE *** */
4618 struct cmd_set_fwd_retry_mode_result {
4619 cmdline_fixed_string_t set;
4620 cmdline_fixed_string_t fwd;
4621 cmdline_fixed_string_t mode;
4622 cmdline_fixed_string_t retry;
4625 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4626 __attribute__((unused)) struct cmdline *cl,
4627 __attribute__((unused)) void *data)
4629 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4632 set_pkt_forwarding_mode(res->mode);
4635 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4638 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4641 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4644 "" /* defined at init */);
4645 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4646 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4649 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4650 .f = cmd_set_fwd_retry_mode_parsed,
4652 .help_str = NULL, /* defined at init */
4654 (void *)&cmd_setfwd_retry_set,
4655 (void *)&cmd_setfwd_retry_fwd,
4656 (void *)&cmd_setfwd_retry_mode,
4657 (void *)&cmd_setfwd_retry_retry,
4662 static void cmd_set_fwd_retry_mode_init(void)
4665 static char token[128];
4666 static char help[256];
4667 cmdline_parse_token_string_t *token_struct;
4669 modes = list_pkt_forwarding_retry_modes();
4670 snprintf(help, sizeof(help), "set fwd %s retry - "
4671 "set packet forwarding mode with retry", modes);
4672 cmd_set_fwd_retry_mode.help_str = help;
4674 /* string token separator is # */
4675 for (c = token; *modes != '\0'; modes++)
4680 token_struct = (cmdline_parse_token_string_t *)
4681 cmd_set_fwd_retry_mode.tokens[2];
4682 token_struct->string_data.str = token;
4685 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4686 struct cmd_set_burst_tx_retry_result {
4687 cmdline_fixed_string_t set;
4688 cmdline_fixed_string_t burst;
4689 cmdline_fixed_string_t tx;
4690 cmdline_fixed_string_t delay;
4692 cmdline_fixed_string_t retry;
4696 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4697 __attribute__((unused)) struct cmdline *cl,
4698 __attribute__((unused)) void *data)
4700 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4702 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4703 && !strcmp(res->tx, "tx")) {
4704 if (!strcmp(res->delay, "delay"))
4705 burst_tx_delay_time = res->time;
4706 if (!strcmp(res->retry, "retry"))
4707 burst_tx_retry_num = res->retry_num;
4712 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4714 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4717 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4719 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4720 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4721 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4722 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4723 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4724 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4725 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4726 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4728 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4729 .f = cmd_set_burst_tx_retry_parsed,
4730 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4732 (void *)&cmd_set_burst_tx_retry_set,
4733 (void *)&cmd_set_burst_tx_retry_burst,
4734 (void *)&cmd_set_burst_tx_retry_tx,
4735 (void *)&cmd_set_burst_tx_retry_delay,
4736 (void *)&cmd_set_burst_tx_retry_time,
4737 (void *)&cmd_set_burst_tx_retry_retry,
4738 (void *)&cmd_set_burst_tx_retry_retry_num,
4743 /* *** SET PROMISC MODE *** */
4744 struct cmd_set_promisc_mode_result {
4745 cmdline_fixed_string_t set;
4746 cmdline_fixed_string_t promisc;
4747 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4748 uint8_t port_num; /* valid if "allports" argument == 0 */
4749 cmdline_fixed_string_t mode;
4752 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4753 __attribute__((unused)) struct cmdline *cl,
4756 struct cmd_set_promisc_mode_result *res = parsed_result;
4760 if (!strcmp(res->mode, "on"))
4767 FOREACH_PORT(i, ports) {
4769 rte_eth_promiscuous_enable(i);
4771 rte_eth_promiscuous_disable(i);
4776 rte_eth_promiscuous_enable(res->port_num);
4778 rte_eth_promiscuous_disable(res->port_num);
4782 cmdline_parse_token_string_t cmd_setpromisc_set =
4783 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4784 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4785 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4787 cmdline_parse_token_string_t cmd_setpromisc_portall =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4790 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4791 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4793 cmdline_parse_token_string_t cmd_setpromisc_mode =
4794 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4797 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4798 .f = cmd_set_promisc_mode_parsed,
4800 .help_str = "set promisc all on|off: set promisc mode for all ports",
4802 (void *)&cmd_setpromisc_set,
4803 (void *)&cmd_setpromisc_promisc,
4804 (void *)&cmd_setpromisc_portall,
4805 (void *)&cmd_setpromisc_mode,
4810 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4811 .f = cmd_set_promisc_mode_parsed,
4813 .help_str = "set promisc X on|off: set promisc mode on port X",
4815 (void *)&cmd_setpromisc_set,
4816 (void *)&cmd_setpromisc_promisc,
4817 (void *)&cmd_setpromisc_portnum,
4818 (void *)&cmd_setpromisc_mode,
4823 /* *** SET ALLMULTI MODE *** */
4824 struct cmd_set_allmulti_mode_result {
4825 cmdline_fixed_string_t set;
4826 cmdline_fixed_string_t allmulti;
4827 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4828 uint8_t port_num; /* valid if "allports" argument == 0 */
4829 cmdline_fixed_string_t mode;
4832 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4833 __attribute__((unused)) struct cmdline *cl,
4836 struct cmd_set_allmulti_mode_result *res = parsed_result;
4840 if (!strcmp(res->mode, "on"))
4847 FOREACH_PORT(i, ports) {
4849 rte_eth_allmulticast_enable(i);
4851 rte_eth_allmulticast_disable(i);
4856 rte_eth_allmulticast_enable(res->port_num);
4858 rte_eth_allmulticast_disable(res->port_num);
4862 cmdline_parse_token_string_t cmd_setallmulti_set =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4864 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4865 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4867 cmdline_parse_token_string_t cmd_setallmulti_portall =
4868 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4870 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4871 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4873 cmdline_parse_token_string_t cmd_setallmulti_mode =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4877 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4878 .f = cmd_set_allmulti_mode_parsed,
4880 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4882 (void *)&cmd_setallmulti_set,
4883 (void *)&cmd_setallmulti_allmulti,
4884 (void *)&cmd_setallmulti_portall,
4885 (void *)&cmd_setallmulti_mode,
4890 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4891 .f = cmd_set_allmulti_mode_parsed,
4893 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4895 (void *)&cmd_setallmulti_set,
4896 (void *)&cmd_setallmulti_allmulti,
4897 (void *)&cmd_setallmulti_portnum,
4898 (void *)&cmd_setallmulti_mode,
4903 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4904 struct cmd_link_flow_ctrl_set_result {
4905 cmdline_fixed_string_t set;
4906 cmdline_fixed_string_t flow_ctrl;
4907 cmdline_fixed_string_t rx;
4908 cmdline_fixed_string_t rx_lfc_mode;
4909 cmdline_fixed_string_t tx;
4910 cmdline_fixed_string_t tx_lfc_mode;
4911 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4912 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4913 cmdline_fixed_string_t autoneg_str;
4914 cmdline_fixed_string_t autoneg;
4915 cmdline_fixed_string_t hw_str;
4916 uint32_t high_water;
4917 cmdline_fixed_string_t lw_str;
4919 cmdline_fixed_string_t pt_str;
4920 uint16_t pause_time;
4921 cmdline_fixed_string_t xon_str;
4926 cmdline_parse_token_string_t cmd_lfc_set_set =
4927 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4929 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4930 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4931 flow_ctrl, "flow_ctrl");
4932 cmdline_parse_token_string_t cmd_lfc_set_rx =
4933 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4935 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4936 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4937 rx_lfc_mode, "on#off");
4938 cmdline_parse_token_string_t cmd_lfc_set_tx =
4939 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4941 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4942 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4943 tx_lfc_mode, "on#off");
4944 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4945 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4946 hw_str, "high_water");
4947 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4948 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4949 high_water, UINT32);
4950 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4951 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4952 lw_str, "low_water");
4953 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4954 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4956 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4957 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4958 pt_str, "pause_time");
4959 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4960 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4961 pause_time, UINT16);
4962 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4963 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4964 xon_str, "send_xon");
4965 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4966 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4968 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4969 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4970 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4971 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4972 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4973 mac_ctrl_frame_fwd_mode, "on#off");
4974 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4976 autoneg_str, "autoneg");
4977 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4980 cmdline_parse_token_num_t cmd_lfc_set_portid =
4981 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4984 /* forward declaration */
4986 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4989 cmdline_parse_inst_t cmd_link_flow_control_set = {
4990 .f = cmd_link_flow_ctrl_set_parsed,
4992 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4993 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4994 autoneg on|off port_id",
4996 (void *)&cmd_lfc_set_set,
4997 (void *)&cmd_lfc_set_flow_ctrl,
4998 (void *)&cmd_lfc_set_rx,
4999 (void *)&cmd_lfc_set_rx_mode,
5000 (void *)&cmd_lfc_set_tx,
5001 (void *)&cmd_lfc_set_tx_mode,
5002 (void *)&cmd_lfc_set_high_water,
5003 (void *)&cmd_lfc_set_low_water,
5004 (void *)&cmd_lfc_set_pause_time,
5005 (void *)&cmd_lfc_set_send_xon,
5006 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5007 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5008 (void *)&cmd_lfc_set_autoneg_str,
5009 (void *)&cmd_lfc_set_autoneg,
5010 (void *)&cmd_lfc_set_portid,
5015 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5016 .f = cmd_link_flow_ctrl_set_parsed,
5017 .data = (void *)&cmd_link_flow_control_set_rx,
5018 .help_str = "Change rx flow control parameter: set flow_ctrl "
5019 "rx on|off port_id",
5021 (void *)&cmd_lfc_set_set,
5022 (void *)&cmd_lfc_set_flow_ctrl,
5023 (void *)&cmd_lfc_set_rx,
5024 (void *)&cmd_lfc_set_rx_mode,
5025 (void *)&cmd_lfc_set_portid,
5030 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5031 .f = cmd_link_flow_ctrl_set_parsed,
5032 .data = (void *)&cmd_link_flow_control_set_tx,
5033 .help_str = "Change tx flow control parameter: set flow_ctrl "
5034 "tx on|off port_id",
5036 (void *)&cmd_lfc_set_set,
5037 (void *)&cmd_lfc_set_flow_ctrl,
5038 (void *)&cmd_lfc_set_tx,
5039 (void *)&cmd_lfc_set_tx_mode,
5040 (void *)&cmd_lfc_set_portid,
5045 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5046 .f = cmd_link_flow_ctrl_set_parsed,
5047 .data = (void *)&cmd_link_flow_control_set_hw,
5048 .help_str = "Change high water flow control parameter: set flow_ctrl "
5049 "high_water value port_id",
5051 (void *)&cmd_lfc_set_set,
5052 (void *)&cmd_lfc_set_flow_ctrl,
5053 (void *)&cmd_lfc_set_high_water_str,
5054 (void *)&cmd_lfc_set_high_water,
5055 (void *)&cmd_lfc_set_portid,
5060 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5061 .f = cmd_link_flow_ctrl_set_parsed,
5062 .data = (void *)&cmd_link_flow_control_set_lw,
5063 .help_str = "Change low water flow control parameter: set flow_ctrl "
5064 "low_water value port_id",
5066 (void *)&cmd_lfc_set_set,
5067 (void *)&cmd_lfc_set_flow_ctrl,
5068 (void *)&cmd_lfc_set_low_water_str,
5069 (void *)&cmd_lfc_set_low_water,
5070 (void *)&cmd_lfc_set_portid,
5075 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5076 .f = cmd_link_flow_ctrl_set_parsed,
5077 .data = (void *)&cmd_link_flow_control_set_pt,
5078 .help_str = "Change pause time flow control parameter: set flow_ctrl "
5079 "pause_time value port_id",
5081 (void *)&cmd_lfc_set_set,
5082 (void *)&cmd_lfc_set_flow_ctrl,
5083 (void *)&cmd_lfc_set_pause_time_str,
5084 (void *)&cmd_lfc_set_pause_time,
5085 (void *)&cmd_lfc_set_portid,
5090 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5091 .f = cmd_link_flow_ctrl_set_parsed,
5092 .data = (void *)&cmd_link_flow_control_set_xon,
5093 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5094 "send_xon value port_id",
5096 (void *)&cmd_lfc_set_set,
5097 (void *)&cmd_lfc_set_flow_ctrl,
5098 (void *)&cmd_lfc_set_send_xon_str,
5099 (void *)&cmd_lfc_set_send_xon,
5100 (void *)&cmd_lfc_set_portid,
5105 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5106 .f = cmd_link_flow_ctrl_set_parsed,
5107 .data = (void *)&cmd_link_flow_control_set_macfwd,
5108 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5109 "mac_ctrl_frame_fwd on|off port_id",
5111 (void *)&cmd_lfc_set_set,
5112 (void *)&cmd_lfc_set_flow_ctrl,
5113 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5114 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5115 (void *)&cmd_lfc_set_portid,
5120 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5121 .f = cmd_link_flow_ctrl_set_parsed,
5122 .data = (void *)&cmd_link_flow_control_set_autoneg,
5123 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5124 "autoneg on|off port_id",
5126 (void *)&cmd_lfc_set_set,
5127 (void *)&cmd_lfc_set_flow_ctrl,
5128 (void *)&cmd_lfc_set_autoneg_str,
5129 (void *)&cmd_lfc_set_autoneg,
5130 (void *)&cmd_lfc_set_portid,
5136 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5137 __attribute__((unused)) struct cmdline *cl,
5140 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5141 cmdline_parse_inst_t *cmd = data;
5142 struct rte_eth_fc_conf fc_conf;
5148 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5149 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5150 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5151 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5153 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5154 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5157 /* Partial command line, retrieve current configuration */
5159 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5161 printf("cannot get current flow ctrl parameters, return"
5162 "code = %d\n", ret);
5166 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5167 (fc_conf.mode == RTE_FC_FULL))
5169 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5170 (fc_conf.mode == RTE_FC_FULL))
5174 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5175 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5177 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5178 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5180 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5182 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5183 fc_conf.high_water = res->high_water;
5185 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5186 fc_conf.low_water = res->low_water;
5188 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5189 fc_conf.pause_time = res->pause_time;
5191 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5192 fc_conf.send_xon = res->send_xon;
5194 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5195 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5196 fc_conf.mac_ctrl_frame_fwd = 1;
5198 fc_conf.mac_ctrl_frame_fwd = 0;
5201 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5202 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5204 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5206 printf("bad flow contrl parameter, return code = %d \n", ret);
5209 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5210 struct cmd_priority_flow_ctrl_set_result {
5211 cmdline_fixed_string_t set;
5212 cmdline_fixed_string_t pfc_ctrl;
5213 cmdline_fixed_string_t rx;
5214 cmdline_fixed_string_t rx_pfc_mode;
5215 cmdline_fixed_string_t tx;
5216 cmdline_fixed_string_t tx_pfc_mode;
5217 uint32_t high_water;
5219 uint16_t pause_time;
5225 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5226 __attribute__((unused)) struct cmdline *cl,
5227 __attribute__((unused)) void *data)
5229 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5230 struct rte_eth_pfc_conf pfc_conf;
5231 int rx_fc_enable, tx_fc_enable;
5235 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5236 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5237 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5238 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5240 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5241 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5244 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5245 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5246 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5247 pfc_conf.fc.high_water = res->high_water;
5248 pfc_conf.fc.low_water = res->low_water;
5249 pfc_conf.fc.pause_time = res->pause_time;
5250 pfc_conf.priority = res->priority;
5252 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5254 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5257 cmdline_parse_token_string_t cmd_pfc_set_set =
5258 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5260 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5261 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5262 pfc_ctrl, "pfc_ctrl");
5263 cmdline_parse_token_string_t cmd_pfc_set_rx =
5264 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5266 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5267 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5268 rx_pfc_mode, "on#off");
5269 cmdline_parse_token_string_t cmd_pfc_set_tx =
5270 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5272 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5273 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5274 tx_pfc_mode, "on#off");
5275 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5276 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5277 high_water, UINT32);
5278 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5279 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5281 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5282 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5283 pause_time, UINT16);
5284 cmdline_parse_token_num_t cmd_pfc_set_priority =
5285 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5287 cmdline_parse_token_num_t cmd_pfc_set_portid =
5288 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5291 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5292 .f = cmd_priority_flow_ctrl_set_parsed,
5294 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5295 tx on|off high_water low_water pause_time priority port_id",
5297 (void *)&cmd_pfc_set_set,
5298 (void *)&cmd_pfc_set_flow_ctrl,
5299 (void *)&cmd_pfc_set_rx,
5300 (void *)&cmd_pfc_set_rx_mode,
5301 (void *)&cmd_pfc_set_tx,
5302 (void *)&cmd_pfc_set_tx_mode,
5303 (void *)&cmd_pfc_set_high_water,
5304 (void *)&cmd_pfc_set_low_water,
5305 (void *)&cmd_pfc_set_pause_time,
5306 (void *)&cmd_pfc_set_priority,
5307 (void *)&cmd_pfc_set_portid,
5312 /* *** RESET CONFIGURATION *** */
5313 struct cmd_reset_result {
5314 cmdline_fixed_string_t reset;
5315 cmdline_fixed_string_t def;
5318 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5320 __attribute__((unused)) void *data)
5322 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5323 set_def_fwd_config();
5326 cmdline_parse_token_string_t cmd_reset_set =
5327 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5328 cmdline_parse_token_string_t cmd_reset_def =
5329 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5332 cmdline_parse_inst_t cmd_reset = {
5333 .f = cmd_reset_parsed,
5335 .help_str = "set default: reset default forwarding configuration",
5337 (void *)&cmd_reset_set,
5338 (void *)&cmd_reset_def,
5343 /* *** START FORWARDING *** */
5344 struct cmd_start_result {
5345 cmdline_fixed_string_t start;
5348 cmdline_parse_token_string_t cmd_start_start =
5349 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5351 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5352 __attribute__((unused)) struct cmdline *cl,
5353 __attribute__((unused)) void *data)
5355 start_packet_forwarding(0);
5358 cmdline_parse_inst_t cmd_start = {
5359 .f = cmd_start_parsed,
5361 .help_str = "start packet forwarding",
5363 (void *)&cmd_start_start,
5368 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5369 struct cmd_start_tx_first_result {
5370 cmdline_fixed_string_t start;
5371 cmdline_fixed_string_t tx_first;
5375 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5376 __attribute__((unused)) struct cmdline *cl,
5377 __attribute__((unused)) void *data)
5379 start_packet_forwarding(1);
5382 cmdline_parse_token_string_t cmd_start_tx_first_start =
5383 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5385 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5386 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5387 tx_first, "tx_first");
5389 cmdline_parse_inst_t cmd_start_tx_first = {
5390 .f = cmd_start_tx_first_parsed,
5392 .help_str = "start packet forwarding, after sending 1 burst of packets",
5394 (void *)&cmd_start_tx_first_start,
5395 (void *)&cmd_start_tx_first_tx_first,
5400 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5401 struct cmd_start_tx_first_n_result {
5402 cmdline_fixed_string_t start;
5403 cmdline_fixed_string_t tx_first;
5408 cmd_start_tx_first_n_parsed(void *parsed_result,
5409 __attribute__((unused)) struct cmdline *cl,
5410 __attribute__((unused)) void *data)
5412 struct cmd_start_tx_first_n_result *res = parsed_result;
5414 start_packet_forwarding(res->tx_num);
5417 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5418 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5420 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5421 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5422 tx_first, "tx_first");
5423 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5424 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5427 cmdline_parse_inst_t cmd_start_tx_first_n = {
5428 .f = cmd_start_tx_first_n_parsed,
5430 .help_str = "start packet forwarding, after sending <num> "
5431 "bursts of packets",
5433 (void *)&cmd_start_tx_first_n_start,
5434 (void *)&cmd_start_tx_first_n_tx_first,
5435 (void *)&cmd_start_tx_first_n_tx_num,
5440 /* *** SET LINK UP *** */
5441 struct cmd_set_link_up_result {
5442 cmdline_fixed_string_t set;
5443 cmdline_fixed_string_t link_up;
5444 cmdline_fixed_string_t port;
5448 cmdline_parse_token_string_t cmd_set_link_up_set =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5450 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5451 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5453 cmdline_parse_token_string_t cmd_set_link_up_port =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5455 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5456 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5458 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5459 __attribute__((unused)) struct cmdline *cl,
5460 __attribute__((unused)) void *data)
5462 struct cmd_set_link_up_result *res = parsed_result;
5463 dev_set_link_up(res->port_id);
5466 cmdline_parse_inst_t cmd_set_link_up = {
5467 .f = cmd_set_link_up_parsed,
5469 .help_str = "set link-up port (port id)",
5471 (void *)&cmd_set_link_up_set,
5472 (void *)&cmd_set_link_up_link_up,
5473 (void *)&cmd_set_link_up_port,
5474 (void *)&cmd_set_link_up_port_id,
5479 /* *** SET LINK DOWN *** */
5480 struct cmd_set_link_down_result {
5481 cmdline_fixed_string_t set;
5482 cmdline_fixed_string_t link_down;
5483 cmdline_fixed_string_t port;
5487 cmdline_parse_token_string_t cmd_set_link_down_set =
5488 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5489 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5492 cmdline_parse_token_string_t cmd_set_link_down_port =
5493 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5494 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5495 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5497 static void cmd_set_link_down_parsed(
5498 __attribute__((unused)) void *parsed_result,
5499 __attribute__((unused)) struct cmdline *cl,
5500 __attribute__((unused)) void *data)
5502 struct cmd_set_link_down_result *res = parsed_result;
5503 dev_set_link_down(res->port_id);
5506 cmdline_parse_inst_t cmd_set_link_down = {
5507 .f = cmd_set_link_down_parsed,
5509 .help_str = "set link-down port (port id)",
5511 (void *)&cmd_set_link_down_set,
5512 (void *)&cmd_set_link_down_link_down,
5513 (void *)&cmd_set_link_down_port,
5514 (void *)&cmd_set_link_down_port_id,
5519 /* *** SHOW CFG *** */
5520 struct cmd_showcfg_result {
5521 cmdline_fixed_string_t show;
5522 cmdline_fixed_string_t cfg;
5523 cmdline_fixed_string_t what;
5526 static void cmd_showcfg_parsed(void *parsed_result,
5527 __attribute__((unused)) struct cmdline *cl,
5528 __attribute__((unused)) void *data)
5530 struct cmd_showcfg_result *res = parsed_result;
5531 if (!strcmp(res->what, "rxtx"))
5532 rxtx_config_display();
5533 else if (!strcmp(res->what, "cores"))
5534 fwd_lcores_config_display();
5535 else if (!strcmp(res->what, "fwd"))
5536 pkt_fwd_config_display(&cur_fwd_config);
5537 else if (!strcmp(res->what, "txpkts"))
5538 show_tx_pkt_segments();
5541 cmdline_parse_token_string_t cmd_showcfg_show =
5542 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5543 cmdline_parse_token_string_t cmd_showcfg_port =
5544 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5545 cmdline_parse_token_string_t cmd_showcfg_what =
5546 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5547 "rxtx#cores#fwd#txpkts");
5549 cmdline_parse_inst_t cmd_showcfg = {
5550 .f = cmd_showcfg_parsed,
5552 .help_str = "show config rxtx|cores|fwd|txpkts",
5554 (void *)&cmd_showcfg_show,
5555 (void *)&cmd_showcfg_port,
5556 (void *)&cmd_showcfg_what,
5561 /* *** SHOW ALL PORT INFO *** */
5562 struct cmd_showportall_result {
5563 cmdline_fixed_string_t show;
5564 cmdline_fixed_string_t port;
5565 cmdline_fixed_string_t what;
5566 cmdline_fixed_string_t all;
5569 static void cmd_showportall_parsed(void *parsed_result,
5570 __attribute__((unused)) struct cmdline *cl,
5571 __attribute__((unused)) void *data)
5575 struct cmd_showportall_result *res = parsed_result;
5576 if (!strcmp(res->show, "clear")) {
5577 if (!strcmp(res->what, "stats"))
5578 FOREACH_PORT(i, ports)
5580 else if (!strcmp(res->what, "xstats"))
5581 FOREACH_PORT(i, ports)
5582 nic_xstats_clear(i);
5583 } else if (!strcmp(res->what, "info"))
5584 FOREACH_PORT(i, ports)
5585 port_infos_display(i);
5586 else if (!strcmp(res->what, "stats"))
5587 FOREACH_PORT(i, ports)
5588 nic_stats_display(i);
5589 else if (!strcmp(res->what, "xstats"))
5590 FOREACH_PORT(i, ports)
5591 nic_xstats_display(i);
5592 else if (!strcmp(res->what, "fdir"))
5593 FOREACH_PORT(i, ports)
5595 else if (!strcmp(res->what, "stat_qmap"))
5596 FOREACH_PORT(i, ports)
5597 nic_stats_mapping_display(i);
5598 else if (!strcmp(res->what, "dcb_tc"))
5599 FOREACH_PORT(i, ports)
5600 port_dcb_info_display(i);
5603 cmdline_parse_token_string_t cmd_showportall_show =
5604 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5606 cmdline_parse_token_string_t cmd_showportall_port =
5607 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5608 cmdline_parse_token_string_t cmd_showportall_what =
5609 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5610 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5611 cmdline_parse_token_string_t cmd_showportall_all =
5612 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5613 cmdline_parse_inst_t cmd_showportall = {
5614 .f = cmd_showportall_parsed,
5616 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5618 (void *)&cmd_showportall_show,
5619 (void *)&cmd_showportall_port,
5620 (void *)&cmd_showportall_what,
5621 (void *)&cmd_showportall_all,
5626 /* *** SHOW PORT INFO *** */
5627 struct cmd_showport_result {
5628 cmdline_fixed_string_t show;
5629 cmdline_fixed_string_t port;
5630 cmdline_fixed_string_t what;
5634 static void cmd_showport_parsed(void *parsed_result,
5635 __attribute__((unused)) struct cmdline *cl,
5636 __attribute__((unused)) void *data)
5638 struct cmd_showport_result *res = parsed_result;
5639 if (!strcmp(res->show, "clear")) {
5640 if (!strcmp(res->what, "stats"))
5641 nic_stats_clear(res->portnum);
5642 else if (!strcmp(res->what, "xstats"))
5643 nic_xstats_clear(res->portnum);
5644 } else if (!strcmp(res->what, "info"))
5645 port_infos_display(res->portnum);
5646 else if (!strcmp(res->what, "stats"))
5647 nic_stats_display(res->portnum);
5648 else if (!strcmp(res->what, "xstats"))
5649 nic_xstats_display(res->portnum);
5650 else if (!strcmp(res->what, "fdir"))
5651 fdir_get_infos(res->portnum);
5652 else if (!strcmp(res->what, "stat_qmap"))
5653 nic_stats_mapping_display(res->portnum);
5654 else if (!strcmp(res->what, "dcb_tc"))
5655 port_dcb_info_display(res->portnum);
5658 cmdline_parse_token_string_t cmd_showport_show =
5659 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5661 cmdline_parse_token_string_t cmd_showport_port =
5662 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5663 cmdline_parse_token_string_t cmd_showport_what =
5664 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5665 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5666 cmdline_parse_token_num_t cmd_showport_portnum =
5667 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5669 cmdline_parse_inst_t cmd_showport = {
5670 .f = cmd_showport_parsed,
5672 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5674 (void *)&cmd_showport_show,
5675 (void *)&cmd_showport_port,
5676 (void *)&cmd_showport_what,
5677 (void *)&cmd_showport_portnum,
5682 /* *** SHOW QUEUE INFO *** */
5683 struct cmd_showqueue_result {
5684 cmdline_fixed_string_t show;
5685 cmdline_fixed_string_t type;
5686 cmdline_fixed_string_t what;
5692 cmd_showqueue_parsed(void *parsed_result,
5693 __attribute__((unused)) struct cmdline *cl,
5694 __attribute__((unused)) void *data)
5696 struct cmd_showqueue_result *res = parsed_result;
5698 if (!strcmp(res->type, "rxq"))
5699 rx_queue_infos_display(res->portnum, res->queuenum);
5700 else if (!strcmp(res->type, "txq"))
5701 tx_queue_infos_display(res->portnum, res->queuenum);
5704 cmdline_parse_token_string_t cmd_showqueue_show =
5705 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5706 cmdline_parse_token_string_t cmd_showqueue_type =
5707 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5708 cmdline_parse_token_string_t cmd_showqueue_what =
5709 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5710 cmdline_parse_token_num_t cmd_showqueue_portnum =
5711 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5712 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5713 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5715 cmdline_parse_inst_t cmd_showqueue = {
5716 .f = cmd_showqueue_parsed,
5718 .help_str = "show rxq|txq info <port number> <queue_number>",
5720 (void *)&cmd_showqueue_show,
5721 (void *)&cmd_showqueue_type,
5722 (void *)&cmd_showqueue_what,
5723 (void *)&cmd_showqueue_portnum,
5724 (void *)&cmd_showqueue_queuenum,
5729 /* *** READ PORT REGISTER *** */
5730 struct cmd_read_reg_result {
5731 cmdline_fixed_string_t read;
5732 cmdline_fixed_string_t reg;
5738 cmd_read_reg_parsed(void *parsed_result,
5739 __attribute__((unused)) struct cmdline *cl,
5740 __attribute__((unused)) void *data)
5742 struct cmd_read_reg_result *res = parsed_result;
5743 port_reg_display(res->port_id, res->reg_off);
5746 cmdline_parse_token_string_t cmd_read_reg_read =
5747 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5748 cmdline_parse_token_string_t cmd_read_reg_reg =
5749 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5750 cmdline_parse_token_num_t cmd_read_reg_port_id =
5751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5752 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5755 cmdline_parse_inst_t cmd_read_reg = {
5756 .f = cmd_read_reg_parsed,
5758 .help_str = "read reg port_id reg_off",
5760 (void *)&cmd_read_reg_read,
5761 (void *)&cmd_read_reg_reg,
5762 (void *)&cmd_read_reg_port_id,
5763 (void *)&cmd_read_reg_reg_off,
5768 /* *** READ PORT REGISTER BIT FIELD *** */
5769 struct cmd_read_reg_bit_field_result {
5770 cmdline_fixed_string_t read;
5771 cmdline_fixed_string_t regfield;
5779 cmd_read_reg_bit_field_parsed(void *parsed_result,
5780 __attribute__((unused)) struct cmdline *cl,
5781 __attribute__((unused)) void *data)
5783 struct cmd_read_reg_bit_field_result *res = parsed_result;
5784 port_reg_bit_field_display(res->port_id, res->reg_off,
5785 res->bit1_pos, res->bit2_pos);
5788 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5789 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5791 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5792 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5793 regfield, "regfield");
5794 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5795 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5797 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5798 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5800 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5801 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5803 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5804 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5807 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5808 .f = cmd_read_reg_bit_field_parsed,
5810 .help_str = "read regfield port_id reg_off bit_x bit_y "
5811 "(read register bit field between bit_x and bit_y included)",
5813 (void *)&cmd_read_reg_bit_field_read,
5814 (void *)&cmd_read_reg_bit_field_regfield,
5815 (void *)&cmd_read_reg_bit_field_port_id,
5816 (void *)&cmd_read_reg_bit_field_reg_off,
5817 (void *)&cmd_read_reg_bit_field_bit1_pos,
5818 (void *)&cmd_read_reg_bit_field_bit2_pos,
5823 /* *** READ PORT REGISTER BIT *** */
5824 struct cmd_read_reg_bit_result {
5825 cmdline_fixed_string_t read;
5826 cmdline_fixed_string_t regbit;
5833 cmd_read_reg_bit_parsed(void *parsed_result,
5834 __attribute__((unused)) struct cmdline *cl,
5835 __attribute__((unused)) void *data)
5837 struct cmd_read_reg_bit_result *res = parsed_result;
5838 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5841 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5842 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5843 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5844 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5846 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5848 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5849 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5850 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5851 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5853 cmdline_parse_inst_t cmd_read_reg_bit = {
5854 .f = cmd_read_reg_bit_parsed,
5856 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5858 (void *)&cmd_read_reg_bit_read,
5859 (void *)&cmd_read_reg_bit_regbit,
5860 (void *)&cmd_read_reg_bit_port_id,
5861 (void *)&cmd_read_reg_bit_reg_off,
5862 (void *)&cmd_read_reg_bit_bit_pos,
5867 /* *** WRITE PORT REGISTER *** */
5868 struct cmd_write_reg_result {
5869 cmdline_fixed_string_t write;
5870 cmdline_fixed_string_t reg;
5877 cmd_write_reg_parsed(void *parsed_result,
5878 __attribute__((unused)) struct cmdline *cl,
5879 __attribute__((unused)) void *data)
5881 struct cmd_write_reg_result *res = parsed_result;
5882 port_reg_set(res->port_id, res->reg_off, res->value);
5885 cmdline_parse_token_string_t cmd_write_reg_write =
5886 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5887 cmdline_parse_token_string_t cmd_write_reg_reg =
5888 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5889 cmdline_parse_token_num_t cmd_write_reg_port_id =
5890 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5891 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5892 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5893 cmdline_parse_token_num_t cmd_write_reg_value =
5894 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5896 cmdline_parse_inst_t cmd_write_reg = {
5897 .f = cmd_write_reg_parsed,
5899 .help_str = "write reg port_id reg_off reg_value",
5901 (void *)&cmd_write_reg_write,
5902 (void *)&cmd_write_reg_reg,
5903 (void *)&cmd_write_reg_port_id,
5904 (void *)&cmd_write_reg_reg_off,
5905 (void *)&cmd_write_reg_value,
5910 /* *** WRITE PORT REGISTER BIT FIELD *** */
5911 struct cmd_write_reg_bit_field_result {
5912 cmdline_fixed_string_t write;
5913 cmdline_fixed_string_t regfield;
5922 cmd_write_reg_bit_field_parsed(void *parsed_result,
5923 __attribute__((unused)) struct cmdline *cl,
5924 __attribute__((unused)) void *data)
5926 struct cmd_write_reg_bit_field_result *res = parsed_result;
5927 port_reg_bit_field_set(res->port_id, res->reg_off,
5928 res->bit1_pos, res->bit2_pos, res->value);
5931 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5932 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5934 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5935 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5936 regfield, "regfield");
5937 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5938 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5940 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5941 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5943 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5944 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5946 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5947 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5949 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5953 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5954 .f = cmd_write_reg_bit_field_parsed,
5956 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5957 "(set register bit field between bit_x and bit_y included)",
5959 (void *)&cmd_write_reg_bit_field_write,
5960 (void *)&cmd_write_reg_bit_field_regfield,
5961 (void *)&cmd_write_reg_bit_field_port_id,
5962 (void *)&cmd_write_reg_bit_field_reg_off,
5963 (void *)&cmd_write_reg_bit_field_bit1_pos,
5964 (void *)&cmd_write_reg_bit_field_bit2_pos,
5965 (void *)&cmd_write_reg_bit_field_value,
5970 /* *** WRITE PORT REGISTER BIT *** */
5971 struct cmd_write_reg_bit_result {
5972 cmdline_fixed_string_t write;
5973 cmdline_fixed_string_t regbit;
5981 cmd_write_reg_bit_parsed(void *parsed_result,
5982 __attribute__((unused)) struct cmdline *cl,
5983 __attribute__((unused)) void *data)
5985 struct cmd_write_reg_bit_result *res = parsed_result;
5986 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5989 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5990 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5992 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5993 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5995 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5997 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5998 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5999 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6000 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6001 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6002 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6004 cmdline_parse_inst_t cmd_write_reg_bit = {
6005 .f = cmd_write_reg_bit_parsed,
6007 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
6009 (void *)&cmd_write_reg_bit_write,
6010 (void *)&cmd_write_reg_bit_regbit,
6011 (void *)&cmd_write_reg_bit_port_id,
6012 (void *)&cmd_write_reg_bit_reg_off,
6013 (void *)&cmd_write_reg_bit_bit_pos,
6014 (void *)&cmd_write_reg_bit_value,
6019 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6020 struct cmd_read_rxd_txd_result {
6021 cmdline_fixed_string_t read;
6022 cmdline_fixed_string_t rxd_txd;
6029 cmd_read_rxd_txd_parsed(void *parsed_result,
6030 __attribute__((unused)) struct cmdline *cl,
6031 __attribute__((unused)) void *data)
6033 struct cmd_read_rxd_txd_result *res = parsed_result;
6035 if (!strcmp(res->rxd_txd, "rxd"))
6036 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6037 else if (!strcmp(res->rxd_txd, "txd"))
6038 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6041 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6042 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6043 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6044 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6046 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6047 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6048 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6049 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6050 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6051 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6053 cmdline_parse_inst_t cmd_read_rxd_txd = {
6054 .f = cmd_read_rxd_txd_parsed,
6056 .help_str = "read rxd|txd port_id queue_id rxd_id",
6058 (void *)&cmd_read_rxd_txd_read,
6059 (void *)&cmd_read_rxd_txd_rxd_txd,
6060 (void *)&cmd_read_rxd_txd_port_id,
6061 (void *)&cmd_read_rxd_txd_queue_id,
6062 (void *)&cmd_read_rxd_txd_desc_id,
6068 struct cmd_quit_result {
6069 cmdline_fixed_string_t quit;
6072 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6074 __attribute__((unused)) void *data)
6080 cmdline_parse_token_string_t cmd_quit_quit =
6081 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6083 cmdline_parse_inst_t cmd_quit = {
6084 .f = cmd_quit_parsed,
6086 .help_str = "exit application",
6088 (void *)&cmd_quit_quit,
6093 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6094 struct cmd_mac_addr_result {
6095 cmdline_fixed_string_t mac_addr_cmd;
6096 cmdline_fixed_string_t what;
6098 struct ether_addr address;
6101 static void cmd_mac_addr_parsed(void *parsed_result,
6102 __attribute__((unused)) struct cmdline *cl,
6103 __attribute__((unused)) void *data)
6105 struct cmd_mac_addr_result *res = parsed_result;
6108 if (strcmp(res->what, "add") == 0)
6109 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6111 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6113 /* check the return value and print it if is < 0 */
6115 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6119 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6120 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6122 cmdline_parse_token_string_t cmd_mac_addr_what =
6123 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6125 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6126 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6127 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6128 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6130 cmdline_parse_inst_t cmd_mac_addr = {
6131 .f = cmd_mac_addr_parsed,
6133 .help_str = "mac_addr add|remove X <address>: "
6134 "add/remove MAC address on port X",
6136 (void *)&cmd_mac_addr_cmd,
6137 (void *)&cmd_mac_addr_what,
6138 (void *)&cmd_mac_addr_portnum,
6139 (void *)&cmd_mac_addr_addr,
6145 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6146 struct cmd_set_qmap_result {
6147 cmdline_fixed_string_t set;
6148 cmdline_fixed_string_t qmap;
6149 cmdline_fixed_string_t what;
6156 cmd_set_qmap_parsed(void *parsed_result,
6157 __attribute__((unused)) struct cmdline *cl,
6158 __attribute__((unused)) void *data)
6160 struct cmd_set_qmap_result *res = parsed_result;
6161 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6163 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6166 cmdline_parse_token_string_t cmd_setqmap_set =
6167 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6169 cmdline_parse_token_string_t cmd_setqmap_qmap =
6170 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6172 cmdline_parse_token_string_t cmd_setqmap_what =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6175 cmdline_parse_token_num_t cmd_setqmap_portid =
6176 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6178 cmdline_parse_token_num_t cmd_setqmap_queueid =
6179 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6181 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6182 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6185 cmdline_parse_inst_t cmd_set_qmap = {
6186 .f = cmd_set_qmap_parsed,
6188 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6190 (void *)&cmd_setqmap_set,
6191 (void *)&cmd_setqmap_qmap,
6192 (void *)&cmd_setqmap_what,
6193 (void *)&cmd_setqmap_portid,
6194 (void *)&cmd_setqmap_queueid,
6195 (void *)&cmd_setqmap_mapvalue,
6200 /* *** CONFIGURE UNICAST HASH TABLE *** */
6201 struct cmd_set_uc_hash_table {
6202 cmdline_fixed_string_t set;
6203 cmdline_fixed_string_t port;
6205 cmdline_fixed_string_t what;
6206 struct ether_addr address;
6207 cmdline_fixed_string_t mode;
6211 cmd_set_uc_hash_parsed(void *parsed_result,
6212 __attribute__((unused)) struct cmdline *cl,
6213 __attribute__((unused)) void *data)
6216 struct cmd_set_uc_hash_table *res = parsed_result;
6218 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6220 if (strcmp(res->what, "uta") == 0)
6221 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6222 &res->address,(uint8_t)is_on);
6224 printf("bad unicast hash table parameter, return code = %d \n", ret);
6228 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6231 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6234 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6235 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6237 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6238 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6240 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6241 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6243 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6247 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6248 .f = cmd_set_uc_hash_parsed,
6250 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6252 (void *)&cmd_set_uc_hash_set,
6253 (void *)&cmd_set_uc_hash_port,
6254 (void *)&cmd_set_uc_hash_portid,
6255 (void *)&cmd_set_uc_hash_what,
6256 (void *)&cmd_set_uc_hash_mac,
6257 (void *)&cmd_set_uc_hash_mode,
6262 struct cmd_set_uc_all_hash_table {
6263 cmdline_fixed_string_t set;
6264 cmdline_fixed_string_t port;
6266 cmdline_fixed_string_t what;
6267 cmdline_fixed_string_t value;
6268 cmdline_fixed_string_t mode;
6272 cmd_set_uc_all_hash_parsed(void *parsed_result,
6273 __attribute__((unused)) struct cmdline *cl,
6274 __attribute__((unused)) void *data)
6277 struct cmd_set_uc_all_hash_table *res = parsed_result;
6279 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6281 if ((strcmp(res->what, "uta") == 0) &&
6282 (strcmp(res->value, "all") == 0))
6283 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6285 printf("bad unicast hash table parameter,"
6286 "return code = %d \n", ret);
6289 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6290 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6292 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6293 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6295 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6296 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6298 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6299 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6301 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6304 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6305 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6308 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6309 .f = cmd_set_uc_all_hash_parsed,
6311 .help_str = "set port X uta all on|off (X = port number)",
6313 (void *)&cmd_set_uc_all_hash_set,
6314 (void *)&cmd_set_uc_all_hash_port,
6315 (void *)&cmd_set_uc_all_hash_portid,
6316 (void *)&cmd_set_uc_all_hash_what,
6317 (void *)&cmd_set_uc_all_hash_value,
6318 (void *)&cmd_set_uc_all_hash_mode,
6323 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6324 struct cmd_set_vf_macvlan_filter {
6325 cmdline_fixed_string_t set;
6326 cmdline_fixed_string_t port;
6328 cmdline_fixed_string_t vf;
6330 struct ether_addr address;
6331 cmdline_fixed_string_t filter_type;
6332 cmdline_fixed_string_t mode;
6336 cmd_set_vf_macvlan_parsed(void *parsed_result,
6337 __attribute__((unused)) struct cmdline *cl,
6338 __attribute__((unused)) void *data)
6341 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6342 struct rte_eth_mac_filter filter;
6344 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6346 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6348 /* set VF MAC filter */
6352 filter.dst_id = res->vf_id;
6354 if (!strcmp(res->filter_type, "exact-mac"))
6355 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6356 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6357 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6358 else if (!strcmp(res->filter_type, "hashmac"))
6359 filter.filter_type = RTE_MAC_HASH_MATCH;
6360 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6361 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6363 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6366 ret = rte_eth_dev_filter_ctrl(res->port_id,
6367 RTE_ETH_FILTER_MACVLAN,
6371 ret = rte_eth_dev_filter_ctrl(res->port_id,
6372 RTE_ETH_FILTER_MACVLAN,
6373 RTE_ETH_FILTER_DELETE,
6377 printf("bad set MAC hash parameter, return code = %d\n", ret);
6381 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6382 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6384 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6385 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6387 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6388 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6390 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6391 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6393 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6394 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6396 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6397 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6399 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6401 filter_type, "exact-mac#exact-mac-vlan"
6402 "#hashmac#hashmac-vlan");
6403 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6404 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6407 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6408 .f = cmd_set_vf_macvlan_parsed,
6410 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6411 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6413 "exact match rule:exact match of MAC or MAC and VLAN; "
6414 "hash match rule: hash match of MAC and exact match "
6417 (void *)&cmd_set_vf_macvlan_set,
6418 (void *)&cmd_set_vf_macvlan_port,
6419 (void *)&cmd_set_vf_macvlan_portid,
6420 (void *)&cmd_set_vf_macvlan_vf,
6421 (void *)&cmd_set_vf_macvlan_vf_id,
6422 (void *)&cmd_set_vf_macvlan_mac,
6423 (void *)&cmd_set_vf_macvlan_filter_type,
6424 (void *)&cmd_set_vf_macvlan_mode,
6429 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6430 struct cmd_set_vf_traffic {
6431 cmdline_fixed_string_t set;
6432 cmdline_fixed_string_t port;
6434 cmdline_fixed_string_t vf;
6436 cmdline_fixed_string_t what;
6437 cmdline_fixed_string_t mode;
6441 cmd_set_vf_traffic_parsed(void *parsed_result,
6442 __attribute__((unused)) struct cmdline *cl,
6443 __attribute__((unused)) void *data)
6445 struct cmd_set_vf_traffic *res = parsed_result;
6446 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6447 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6449 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6452 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6453 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6455 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6456 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6458 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6459 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6461 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6464 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6465 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6467 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6468 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6470 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6474 cmdline_parse_inst_t cmd_set_vf_traffic = {
6475 .f = cmd_set_vf_traffic_parsed,
6477 .help_str = "set port X vf Y rx|tx on|off"
6478 "(X = port number,Y = vf id)",
6480 (void *)&cmd_setvf_traffic_set,
6481 (void *)&cmd_setvf_traffic_port,
6482 (void *)&cmd_setvf_traffic_portid,
6483 (void *)&cmd_setvf_traffic_vf,
6484 (void *)&cmd_setvf_traffic_vfid,
6485 (void *)&cmd_setvf_traffic_what,
6486 (void *)&cmd_setvf_traffic_mode,
6491 /* *** CONFIGURE VF RECEIVE MODE *** */
6492 struct cmd_set_vf_rxmode {
6493 cmdline_fixed_string_t set;
6494 cmdline_fixed_string_t port;
6496 cmdline_fixed_string_t vf;
6498 cmdline_fixed_string_t what;
6499 cmdline_fixed_string_t mode;
6500 cmdline_fixed_string_t on;
6504 cmd_set_vf_rxmode_parsed(void *parsed_result,
6505 __attribute__((unused)) struct cmdline *cl,
6506 __attribute__((unused)) void *data)
6509 uint16_t rx_mode = 0;
6510 struct cmd_set_vf_rxmode *res = parsed_result;
6512 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6513 if (!strcmp(res->what,"rxmode")) {
6514 if (!strcmp(res->mode, "AUPE"))
6515 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6516 else if (!strcmp(res->mode, "ROPE"))
6517 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6518 else if (!strcmp(res->mode, "BAM"))
6519 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6520 else if (!strncmp(res->mode, "MPE",3))
6521 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6524 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6526 printf("bad VF receive mode parameter, return code = %d \n",
6530 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6533 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6534 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6536 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6537 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6539 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6542 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6543 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6545 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6548 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6550 mode, "AUPE#ROPE#BAM#MPE");
6551 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6555 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6556 .f = cmd_set_vf_rxmode_parsed,
6558 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6560 (void *)&cmd_set_vf_rxmode_set,
6561 (void *)&cmd_set_vf_rxmode_port,
6562 (void *)&cmd_set_vf_rxmode_portid,
6563 (void *)&cmd_set_vf_rxmode_vf,
6564 (void *)&cmd_set_vf_rxmode_vfid,
6565 (void *)&cmd_set_vf_rxmode_what,
6566 (void *)&cmd_set_vf_rxmode_mode,
6567 (void *)&cmd_set_vf_rxmode_on,
6572 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6573 struct cmd_vf_mac_addr_result {
6574 cmdline_fixed_string_t mac_addr_cmd;
6575 cmdline_fixed_string_t what;
6576 cmdline_fixed_string_t port;
6578 cmdline_fixed_string_t vf;
6580 struct ether_addr address;
6583 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6584 __attribute__((unused)) struct cmdline *cl,
6585 __attribute__((unused)) void *data)
6587 struct cmd_vf_mac_addr_result *res = parsed_result;
6590 if (strcmp(res->what, "add") == 0)
6591 ret = rte_eth_dev_mac_addr_add(res->port_num,
6592 &res->address, res->vf_num);
6594 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6598 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6599 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6600 mac_addr_cmd,"mac_addr");
6601 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6602 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6604 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6605 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6607 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6608 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6610 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6611 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6613 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6614 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6616 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6620 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6621 .f = cmd_vf_mac_addr_parsed,
6623 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6624 "Y = VF number)add MAC address filtering for a VF on port X",
6626 (void *)&cmd_vf_mac_addr_cmd,
6627 (void *)&cmd_vf_mac_addr_what,
6628 (void *)&cmd_vf_mac_addr_port,
6629 (void *)&cmd_vf_mac_addr_portnum,
6630 (void *)&cmd_vf_mac_addr_vf,
6631 (void *)&cmd_vf_mac_addr_vfnum,
6632 (void *)&cmd_vf_mac_addr_addr,
6637 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6638 struct cmd_vf_rx_vlan_filter {
6639 cmdline_fixed_string_t rx_vlan;
6640 cmdline_fixed_string_t what;
6642 cmdline_fixed_string_t port;
6644 cmdline_fixed_string_t vf;
6649 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6650 __attribute__((unused)) struct cmdline *cl,
6651 __attribute__((unused)) void *data)
6653 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6655 if (!strcmp(res->what, "add"))
6656 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6658 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6661 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6662 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6663 rx_vlan, "rx_vlan");
6664 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6665 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6667 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6668 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6670 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6671 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6673 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6674 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6676 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6677 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6679 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6680 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6683 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6684 .f = cmd_vf_rx_vlan_filter_parsed,
6686 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6687 "Y = port number,Z = hexadecimal VF mask)",
6689 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6690 (void *)&cmd_vf_rx_vlan_filter_what,
6691 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6692 (void *)&cmd_vf_rx_vlan_filter_port,
6693 (void *)&cmd_vf_rx_vlan_filter_portid,
6694 (void *)&cmd_vf_rx_vlan_filter_vf,
6695 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6700 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6701 struct cmd_queue_rate_limit_result {
6702 cmdline_fixed_string_t set;
6703 cmdline_fixed_string_t port;
6705 cmdline_fixed_string_t queue;
6707 cmdline_fixed_string_t rate;
6711 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6712 __attribute__((unused)) struct cmdline *cl,
6713 __attribute__((unused)) void *data)
6715 struct cmd_queue_rate_limit_result *res = parsed_result;
6718 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6719 && (strcmp(res->queue, "queue") == 0)
6720 && (strcmp(res->rate, "rate") == 0))
6721 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6724 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6728 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6729 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6731 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6732 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6734 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6735 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6737 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6738 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6740 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6741 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6743 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6744 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6746 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6747 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6750 cmdline_parse_inst_t cmd_queue_rate_limit = {
6751 .f = cmd_queue_rate_limit_parsed,
6753 .help_str = "set port X queue Y rate Z:(X = port number,"
6754 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6756 (void *)&cmd_queue_rate_limit_set,
6757 (void *)&cmd_queue_rate_limit_port,
6758 (void *)&cmd_queue_rate_limit_portnum,
6759 (void *)&cmd_queue_rate_limit_queue,
6760 (void *)&cmd_queue_rate_limit_queuenum,
6761 (void *)&cmd_queue_rate_limit_rate,
6762 (void *)&cmd_queue_rate_limit_ratenum,
6767 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6768 struct cmd_vf_rate_limit_result {
6769 cmdline_fixed_string_t set;
6770 cmdline_fixed_string_t port;
6772 cmdline_fixed_string_t vf;
6774 cmdline_fixed_string_t rate;
6776 cmdline_fixed_string_t q_msk;
6780 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6781 __attribute__((unused)) struct cmdline *cl,
6782 __attribute__((unused)) void *data)
6784 struct cmd_vf_rate_limit_result *res = parsed_result;
6787 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6788 && (strcmp(res->vf, "vf") == 0)
6789 && (strcmp(res->rate, "rate") == 0)
6790 && (strcmp(res->q_msk, "queue_mask") == 0))
6791 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6792 res->rate_num, res->q_msk_val);
6794 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6798 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6799 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6801 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6802 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6804 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6805 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6807 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6808 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6810 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6811 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6813 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6814 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6816 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6817 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6819 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6820 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6821 q_msk, "queue_mask");
6822 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6823 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6826 cmdline_parse_inst_t cmd_vf_rate_limit = {
6827 .f = cmd_vf_rate_limit_parsed,
6829 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6830 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6831 "for queues of VF on port X",
6833 (void *)&cmd_vf_rate_limit_set,
6834 (void *)&cmd_vf_rate_limit_port,
6835 (void *)&cmd_vf_rate_limit_portnum,
6836 (void *)&cmd_vf_rate_limit_vf,
6837 (void *)&cmd_vf_rate_limit_vfnum,
6838 (void *)&cmd_vf_rate_limit_rate,
6839 (void *)&cmd_vf_rate_limit_ratenum,
6840 (void *)&cmd_vf_rate_limit_q_msk,
6841 (void *)&cmd_vf_rate_limit_q_msk_val,
6846 /* *** ADD TUNNEL FILTER OF A PORT *** */
6847 struct cmd_tunnel_filter_result {
6848 cmdline_fixed_string_t cmd;
6849 cmdline_fixed_string_t what;
6851 struct ether_addr outer_mac;
6852 struct ether_addr inner_mac;
6853 cmdline_ipaddr_t ip_value;
6854 uint16_t inner_vlan;
6855 cmdline_fixed_string_t tunnel_type;
6856 cmdline_fixed_string_t filter_type;
6862 cmd_tunnel_filter_parsed(void *parsed_result,
6863 __attribute__((unused)) struct cmdline *cl,
6864 __attribute__((unused)) void *data)
6866 struct cmd_tunnel_filter_result *res = parsed_result;
6867 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6870 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6872 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6873 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6874 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6876 if (res->ip_value.family == AF_INET) {
6877 tunnel_filter_conf.ip_addr.ipv4_addr =
6878 res->ip_value.addr.ipv4.s_addr;
6879 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6881 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6882 &(res->ip_value.addr.ipv6),
6883 sizeof(struct in6_addr));
6884 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6887 if (!strcmp(res->filter_type, "imac-ivlan"))
6888 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6889 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6890 tunnel_filter_conf.filter_type =
6891 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6892 else if (!strcmp(res->filter_type, "imac-tenid"))
6893 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6894 else if (!strcmp(res->filter_type, "imac"))
6895 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6896 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6897 tunnel_filter_conf.filter_type =
6898 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6899 else if (!strcmp(res->filter_type, "oip"))
6900 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6901 else if (!strcmp(res->filter_type, "iip"))
6902 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6904 printf("The filter type is not supported");
6908 if (!strcmp(res->tunnel_type, "vxlan"))
6909 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6910 else if (!strcmp(res->tunnel_type, "nvgre"))
6911 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6912 else if (!strcmp(res->tunnel_type, "ipingre"))
6913 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6915 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6919 tunnel_filter_conf.tenant_id = res->tenant_id;
6920 tunnel_filter_conf.queue_id = res->queue_num;
6921 if (!strcmp(res->what, "add"))
6922 ret = rte_eth_dev_filter_ctrl(res->port_id,
6923 RTE_ETH_FILTER_TUNNEL,
6925 &tunnel_filter_conf);
6927 ret = rte_eth_dev_filter_ctrl(res->port_id,
6928 RTE_ETH_FILTER_TUNNEL,
6929 RTE_ETH_FILTER_DELETE,
6930 &tunnel_filter_conf);
6932 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6936 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6937 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6938 cmd, "tunnel_filter");
6939 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6940 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6942 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6943 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6945 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6946 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6948 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6949 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6951 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6952 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6953 inner_vlan, UINT16);
6954 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6955 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6957 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6958 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6959 tunnel_type, "vxlan#nvgre#ipingre");
6961 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6962 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6963 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6964 "imac#omac-imac-tenid");
6965 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6966 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6968 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6969 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6972 cmdline_parse_inst_t cmd_tunnel_filter = {
6973 .f = cmd_tunnel_filter_parsed,
6975 .help_str = "add/rm tunnel filter of a port: "
6976 "tunnel_filter add port_id outer_mac inner_mac ip "
6977 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6978 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6979 "imac|omac-imac-tenid) "
6980 "tenant_id queue_num",
6982 (void *)&cmd_tunnel_filter_cmd,
6983 (void *)&cmd_tunnel_filter_what,
6984 (void *)&cmd_tunnel_filter_port_id,
6985 (void *)&cmd_tunnel_filter_outer_mac,
6986 (void *)&cmd_tunnel_filter_inner_mac,
6987 (void *)&cmd_tunnel_filter_ip_value,
6988 (void *)&cmd_tunnel_filter_innner_vlan,
6989 (void *)&cmd_tunnel_filter_tunnel_type,
6990 (void *)&cmd_tunnel_filter_filter_type,
6991 (void *)&cmd_tunnel_filter_tenant_id,
6992 (void *)&cmd_tunnel_filter_queue_num,
6997 /* *** CONFIGURE TUNNEL UDP PORT *** */
6998 struct cmd_tunnel_udp_config {
6999 cmdline_fixed_string_t cmd;
7000 cmdline_fixed_string_t what;
7006 cmd_tunnel_udp_config_parsed(void *parsed_result,
7007 __attribute__((unused)) struct cmdline *cl,
7008 __attribute__((unused)) void *data)
7010 struct cmd_tunnel_udp_config *res = parsed_result;
7011 struct rte_eth_udp_tunnel tunnel_udp;
7014 tunnel_udp.udp_port = res->udp_port;
7016 if (!strcmp(res->cmd, "rx_vxlan_port"))
7017 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7019 if (!strcmp(res->what, "add"))
7020 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7023 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7027 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7030 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7031 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7032 cmd, "rx_vxlan_port");
7033 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7034 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7036 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7037 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7039 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7040 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7043 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7044 .f = cmd_tunnel_udp_config_parsed,
7046 .help_str = "add/rm an tunneling UDP port filter: "
7047 "rx_vxlan_port add udp_port port_id",
7049 (void *)&cmd_tunnel_udp_config_cmd,
7050 (void *)&cmd_tunnel_udp_config_what,
7051 (void *)&cmd_tunnel_udp_config_udp_port,
7052 (void *)&cmd_tunnel_udp_config_port_id,
7057 /* *** GLOBAL CONFIG *** */
7058 struct cmd_global_config_result {
7059 cmdline_fixed_string_t cmd;
7061 cmdline_fixed_string_t cfg_type;
7066 cmd_global_config_parsed(void *parsed_result,
7067 __attribute__((unused)) struct cmdline *cl,
7068 __attribute__((unused)) void *data)
7070 struct cmd_global_config_result *res = parsed_result;
7071 struct rte_eth_global_cfg conf;
7074 memset(&conf, 0, sizeof(conf));
7075 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7076 conf.cfg.gre_key_len = res->len;
7077 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7078 RTE_ETH_FILTER_SET, &conf);
7080 printf("Global config error\n");
7083 cmdline_parse_token_string_t cmd_global_config_cmd =
7084 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7086 cmdline_parse_token_num_t cmd_global_config_port_id =
7087 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7088 cmdline_parse_token_string_t cmd_global_config_type =
7089 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7090 cfg_type, "gre-key-len");
7091 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7092 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7095 cmdline_parse_inst_t cmd_global_config = {
7096 .f = cmd_global_config_parsed,
7097 .data = (void *)NULL,
7098 .help_str = "global_config <port_id> gre-key-len <number>",
7100 (void *)&cmd_global_config_cmd,
7101 (void *)&cmd_global_config_port_id,
7102 (void *)&cmd_global_config_type,
7103 (void *)&cmd_global_config_gre_key_len,
7108 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7109 struct cmd_set_mirror_mask_result {
7110 cmdline_fixed_string_t set;
7111 cmdline_fixed_string_t port;
7113 cmdline_fixed_string_t mirror;
7115 cmdline_fixed_string_t what;
7116 cmdline_fixed_string_t value;
7117 cmdline_fixed_string_t dstpool;
7119 cmdline_fixed_string_t on;
7122 cmdline_parse_token_string_t cmd_mirror_mask_set =
7123 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7125 cmdline_parse_token_string_t cmd_mirror_mask_port =
7126 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7128 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7129 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7131 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7133 mirror, "mirror-rule");
7134 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7135 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7137 cmdline_parse_token_string_t cmd_mirror_mask_what =
7138 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7139 what, "pool-mirror-up#pool-mirror-down"
7141 cmdline_parse_token_string_t cmd_mirror_mask_value =
7142 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7144 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7145 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7146 dstpool, "dst-pool");
7147 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7148 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7150 cmdline_parse_token_string_t cmd_mirror_mask_on =
7151 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7155 cmd_set_mirror_mask_parsed(void *parsed_result,
7156 __attribute__((unused)) struct cmdline *cl,
7157 __attribute__((unused)) void *data)
7160 struct cmd_set_mirror_mask_result *res = parsed_result;
7161 struct rte_eth_mirror_conf mr_conf;
7163 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7165 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7167 mr_conf.dst_pool = res->dstpool_id;
7169 if (!strcmp(res->what, "pool-mirror-up")) {
7170 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7171 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7172 } else if (!strcmp(res->what, "pool-mirror-down")) {
7173 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7174 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7175 } else if (!strcmp(res->what, "vlan-mirror")) {
7176 mr_conf.rule_type = ETH_MIRROR_VLAN;
7177 nb_item = parse_item_list(res->value, "vlan",
7178 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7182 for (i = 0; i < nb_item; i++) {
7183 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7184 printf("Invalid vlan_id: must be < 4096\n");
7188 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7189 mr_conf.vlan.vlan_mask |= 1ULL << i;
7193 if (!strcmp(res->on, "on"))
7194 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7197 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7200 printf("mirror rule add error: (%s)\n", strerror(-ret));
7203 cmdline_parse_inst_t cmd_set_mirror_mask = {
7204 .f = cmd_set_mirror_mask_parsed,
7206 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7207 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7209 (void *)&cmd_mirror_mask_set,
7210 (void *)&cmd_mirror_mask_port,
7211 (void *)&cmd_mirror_mask_portid,
7212 (void *)&cmd_mirror_mask_mirror,
7213 (void *)&cmd_mirror_mask_ruleid,
7214 (void *)&cmd_mirror_mask_what,
7215 (void *)&cmd_mirror_mask_value,
7216 (void *)&cmd_mirror_mask_dstpool,
7217 (void *)&cmd_mirror_mask_poolid,
7218 (void *)&cmd_mirror_mask_on,
7223 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7224 struct cmd_set_mirror_link_result {
7225 cmdline_fixed_string_t set;
7226 cmdline_fixed_string_t port;
7228 cmdline_fixed_string_t mirror;
7230 cmdline_fixed_string_t what;
7231 cmdline_fixed_string_t dstpool;
7233 cmdline_fixed_string_t on;
7236 cmdline_parse_token_string_t cmd_mirror_link_set =
7237 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7239 cmdline_parse_token_string_t cmd_mirror_link_port =
7240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7242 cmdline_parse_token_num_t cmd_mirror_link_portid =
7243 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7245 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7246 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7247 mirror, "mirror-rule");
7248 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7249 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7251 cmdline_parse_token_string_t cmd_mirror_link_what =
7252 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7253 what, "uplink-mirror#downlink-mirror");
7254 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7256 dstpool, "dst-pool");
7257 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7258 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7260 cmdline_parse_token_string_t cmd_mirror_link_on =
7261 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7265 cmd_set_mirror_link_parsed(void *parsed_result,
7266 __attribute__((unused)) struct cmdline *cl,
7267 __attribute__((unused)) void *data)
7270 struct cmd_set_mirror_link_result *res = parsed_result;
7271 struct rte_eth_mirror_conf mr_conf;
7273 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7274 if (!strcmp(res->what, "uplink-mirror"))
7275 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7277 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7279 mr_conf.dst_pool = res->dstpool_id;
7281 if (!strcmp(res->on, "on"))
7282 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7285 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7288 /* check the return value and print it if is < 0 */
7290 printf("mirror rule add error: (%s)\n", strerror(-ret));
7294 cmdline_parse_inst_t cmd_set_mirror_link = {
7295 .f = cmd_set_mirror_link_parsed,
7297 .help_str = "set port X mirror-rule Y uplink-mirror|"
7298 "downlink-mirror dst-pool Z on|off",
7300 (void *)&cmd_mirror_link_set,
7301 (void *)&cmd_mirror_link_port,
7302 (void *)&cmd_mirror_link_portid,
7303 (void *)&cmd_mirror_link_mirror,
7304 (void *)&cmd_mirror_link_ruleid,
7305 (void *)&cmd_mirror_link_what,
7306 (void *)&cmd_mirror_link_dstpool,
7307 (void *)&cmd_mirror_link_poolid,
7308 (void *)&cmd_mirror_link_on,
7313 /* *** RESET VM MIRROR RULE *** */
7314 struct cmd_rm_mirror_rule_result {
7315 cmdline_fixed_string_t reset;
7316 cmdline_fixed_string_t port;
7318 cmdline_fixed_string_t mirror;
7322 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7323 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7325 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7326 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7328 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7329 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7331 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7332 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7333 mirror, "mirror-rule");
7334 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7335 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7339 cmd_reset_mirror_rule_parsed(void *parsed_result,
7340 __attribute__((unused)) struct cmdline *cl,
7341 __attribute__((unused)) void *data)
7344 struct cmd_set_mirror_link_result *res = parsed_result;
7346 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7348 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7351 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7352 .f = cmd_reset_mirror_rule_parsed,
7354 .help_str = "reset port X mirror-rule Y",
7356 (void *)&cmd_rm_mirror_rule_reset,
7357 (void *)&cmd_rm_mirror_rule_port,
7358 (void *)&cmd_rm_mirror_rule_portid,
7359 (void *)&cmd_rm_mirror_rule_mirror,
7360 (void *)&cmd_rm_mirror_rule_ruleid,
7365 /* ******************************************************************************** */
7367 struct cmd_dump_result {
7368 cmdline_fixed_string_t dump;
7372 dump_struct_sizes(void)
7374 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7375 DUMP_SIZE(struct rte_mbuf);
7376 DUMP_SIZE(struct rte_mempool);
7377 DUMP_SIZE(struct rte_ring);
7381 static void cmd_dump_parsed(void *parsed_result,
7382 __attribute__((unused)) struct cmdline *cl,
7383 __attribute__((unused)) void *data)
7385 struct cmd_dump_result *res = parsed_result;
7387 if (!strcmp(res->dump, "dump_physmem"))
7388 rte_dump_physmem_layout(stdout);
7389 else if (!strcmp(res->dump, "dump_memzone"))
7390 rte_memzone_dump(stdout);
7391 else if (!strcmp(res->dump, "dump_struct_sizes"))
7392 dump_struct_sizes();
7393 else if (!strcmp(res->dump, "dump_ring"))
7394 rte_ring_list_dump(stdout);
7395 else if (!strcmp(res->dump, "dump_mempool"))
7396 rte_mempool_list_dump(stdout);
7397 else if (!strcmp(res->dump, "dump_devargs"))
7398 rte_eal_devargs_dump(stdout);
7401 cmdline_parse_token_string_t cmd_dump_dump =
7402 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7405 "dump_struct_sizes#"
7410 cmdline_parse_inst_t cmd_dump = {
7411 .f = cmd_dump_parsed, /* function to call */
7412 .data = NULL, /* 2nd arg of func */
7413 .help_str = "dump status",
7414 .tokens = { /* token list, NULL terminated */
7415 (void *)&cmd_dump_dump,
7420 /* ******************************************************************************** */
7422 struct cmd_dump_one_result {
7423 cmdline_fixed_string_t dump;
7424 cmdline_fixed_string_t name;
7427 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7428 __attribute__((unused)) void *data)
7430 struct cmd_dump_one_result *res = parsed_result;
7432 if (!strcmp(res->dump, "dump_ring")) {
7434 r = rte_ring_lookup(res->name);
7436 cmdline_printf(cl, "Cannot find ring\n");
7439 rte_ring_dump(stdout, r);
7440 } else if (!strcmp(res->dump, "dump_mempool")) {
7441 struct rte_mempool *mp;
7442 mp = rte_mempool_lookup(res->name);
7444 cmdline_printf(cl, "Cannot find mempool\n");
7447 rte_mempool_dump(stdout, mp);
7451 cmdline_parse_token_string_t cmd_dump_one_dump =
7452 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7453 "dump_ring#dump_mempool");
7455 cmdline_parse_token_string_t cmd_dump_one_name =
7456 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7458 cmdline_parse_inst_t cmd_dump_one = {
7459 .f = cmd_dump_one_parsed, /* function to call */
7460 .data = NULL, /* 2nd arg of func */
7461 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7462 .tokens = { /* token list, NULL terminated */
7463 (void *)&cmd_dump_one_dump,
7464 (void *)&cmd_dump_one_name,
7469 /* *** Add/Del syn filter *** */
7470 struct cmd_syn_filter_result {
7471 cmdline_fixed_string_t filter;
7473 cmdline_fixed_string_t ops;
7474 cmdline_fixed_string_t priority;
7475 cmdline_fixed_string_t high;
7476 cmdline_fixed_string_t queue;
7481 cmd_syn_filter_parsed(void *parsed_result,
7482 __attribute__((unused)) struct cmdline *cl,
7483 __attribute__((unused)) void *data)
7485 struct cmd_syn_filter_result *res = parsed_result;
7486 struct rte_eth_syn_filter syn_filter;
7489 ret = rte_eth_dev_filter_supported(res->port_id,
7490 RTE_ETH_FILTER_SYN);
7492 printf("syn filter is not supported on port %u.\n",
7497 memset(&syn_filter, 0, sizeof(syn_filter));
7499 if (!strcmp(res->ops, "add")) {
7500 if (!strcmp(res->high, "high"))
7501 syn_filter.hig_pri = 1;
7503 syn_filter.hig_pri = 0;
7505 syn_filter.queue = res->queue_id;
7506 ret = rte_eth_dev_filter_ctrl(res->port_id,
7511 ret = rte_eth_dev_filter_ctrl(res->port_id,
7513 RTE_ETH_FILTER_DELETE,
7517 printf("syn filter programming error: (%s)\n",
7521 cmdline_parse_token_string_t cmd_syn_filter_filter =
7522 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7523 filter, "syn_filter");
7524 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7525 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7527 cmdline_parse_token_string_t cmd_syn_filter_ops =
7528 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7530 cmdline_parse_token_string_t cmd_syn_filter_priority =
7531 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7532 priority, "priority");
7533 cmdline_parse_token_string_t cmd_syn_filter_high =
7534 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7536 cmdline_parse_token_string_t cmd_syn_filter_queue =
7537 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7539 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7540 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7543 cmdline_parse_inst_t cmd_syn_filter = {
7544 .f = cmd_syn_filter_parsed,
7546 .help_str = "add/delete syn filter",
7548 (void *)&cmd_syn_filter_filter,
7549 (void *)&cmd_syn_filter_port_id,
7550 (void *)&cmd_syn_filter_ops,
7551 (void *)&cmd_syn_filter_priority,
7552 (void *)&cmd_syn_filter_high,
7553 (void *)&cmd_syn_filter_queue,
7554 (void *)&cmd_syn_filter_queue_id,
7559 /* *** ADD/REMOVE A 2tuple FILTER *** */
7560 struct cmd_2tuple_filter_result {
7561 cmdline_fixed_string_t filter;
7563 cmdline_fixed_string_t ops;
7564 cmdline_fixed_string_t dst_port;
7565 uint16_t dst_port_value;
7566 cmdline_fixed_string_t protocol;
7567 uint8_t protocol_value;
7568 cmdline_fixed_string_t mask;
7570 cmdline_fixed_string_t tcp_flags;
7571 uint8_t tcp_flags_value;
7572 cmdline_fixed_string_t priority;
7573 uint8_t priority_value;
7574 cmdline_fixed_string_t queue;
7579 cmd_2tuple_filter_parsed(void *parsed_result,
7580 __attribute__((unused)) struct cmdline *cl,
7581 __attribute__((unused)) void *data)
7583 struct rte_eth_ntuple_filter filter;
7584 struct cmd_2tuple_filter_result *res = parsed_result;
7587 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7589 printf("ntuple filter is not supported on port %u.\n",
7594 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7596 filter.flags = RTE_2TUPLE_FLAGS;
7597 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7598 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7599 filter.proto = res->protocol_value;
7600 filter.priority = res->priority_value;
7601 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7602 printf("nonzero tcp_flags is only meaningful"
7603 " when protocol is TCP.\n");
7606 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7607 printf("invalid TCP flags.\n");
7611 if (res->tcp_flags_value != 0) {
7612 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7613 filter.tcp_flags = res->tcp_flags_value;
7616 /* need convert to big endian. */
7617 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7618 filter.queue = res->queue_id;
7620 if (!strcmp(res->ops, "add"))
7621 ret = rte_eth_dev_filter_ctrl(res->port_id,
7622 RTE_ETH_FILTER_NTUPLE,
7626 ret = rte_eth_dev_filter_ctrl(res->port_id,
7627 RTE_ETH_FILTER_NTUPLE,
7628 RTE_ETH_FILTER_DELETE,
7631 printf("2tuple filter programming error: (%s)\n",
7636 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7637 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7638 filter, "2tuple_filter");
7639 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7640 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7642 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7643 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7645 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7646 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7647 dst_port, "dst_port");
7648 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7649 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7650 dst_port_value, UINT16);
7651 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7652 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7653 protocol, "protocol");
7654 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7655 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7656 protocol_value, UINT8);
7657 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7658 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7660 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7661 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7663 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7664 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7665 tcp_flags, "tcp_flags");
7666 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7667 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7668 tcp_flags_value, UINT8);
7669 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7670 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7671 priority, "priority");
7672 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7673 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7674 priority_value, UINT8);
7675 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7676 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7678 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7679 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7682 cmdline_parse_inst_t cmd_2tuple_filter = {
7683 .f = cmd_2tuple_filter_parsed,
7685 .help_str = "add a 2tuple filter",
7687 (void *)&cmd_2tuple_filter_filter,
7688 (void *)&cmd_2tuple_filter_port_id,
7689 (void *)&cmd_2tuple_filter_ops,
7690 (void *)&cmd_2tuple_filter_dst_port,
7691 (void *)&cmd_2tuple_filter_dst_port_value,
7692 (void *)&cmd_2tuple_filter_protocol,
7693 (void *)&cmd_2tuple_filter_protocol_value,
7694 (void *)&cmd_2tuple_filter_mask,
7695 (void *)&cmd_2tuple_filter_mask_value,
7696 (void *)&cmd_2tuple_filter_tcp_flags,
7697 (void *)&cmd_2tuple_filter_tcp_flags_value,
7698 (void *)&cmd_2tuple_filter_priority,
7699 (void *)&cmd_2tuple_filter_priority_value,
7700 (void *)&cmd_2tuple_filter_queue,
7701 (void *)&cmd_2tuple_filter_queue_id,
7706 /* *** ADD/REMOVE A 5tuple FILTER *** */
7707 struct cmd_5tuple_filter_result {
7708 cmdline_fixed_string_t filter;
7710 cmdline_fixed_string_t ops;
7711 cmdline_fixed_string_t dst_ip;
7712 cmdline_ipaddr_t dst_ip_value;
7713 cmdline_fixed_string_t src_ip;
7714 cmdline_ipaddr_t src_ip_value;
7715 cmdline_fixed_string_t dst_port;
7716 uint16_t dst_port_value;
7717 cmdline_fixed_string_t src_port;
7718 uint16_t src_port_value;
7719 cmdline_fixed_string_t protocol;
7720 uint8_t protocol_value;
7721 cmdline_fixed_string_t mask;
7723 cmdline_fixed_string_t tcp_flags;
7724 uint8_t tcp_flags_value;
7725 cmdline_fixed_string_t priority;
7726 uint8_t priority_value;
7727 cmdline_fixed_string_t queue;
7732 cmd_5tuple_filter_parsed(void *parsed_result,
7733 __attribute__((unused)) struct cmdline *cl,
7734 __attribute__((unused)) void *data)
7736 struct rte_eth_ntuple_filter filter;
7737 struct cmd_5tuple_filter_result *res = parsed_result;
7740 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7742 printf("ntuple filter is not supported on port %u.\n",
7747 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7749 filter.flags = RTE_5TUPLE_FLAGS;
7750 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7751 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7752 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7753 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7754 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7755 filter.proto = res->protocol_value;
7756 filter.priority = res->priority_value;
7757 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7758 printf("nonzero tcp_flags is only meaningful"
7759 " when protocol is TCP.\n");
7762 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7763 printf("invalid TCP flags.\n");
7767 if (res->tcp_flags_value != 0) {
7768 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7769 filter.tcp_flags = res->tcp_flags_value;
7772 if (res->dst_ip_value.family == AF_INET)
7773 /* no need to convert, already big endian. */
7774 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7776 if (filter.dst_ip_mask == 0) {
7777 printf("can not support ipv6 involved compare.\n");
7783 if (res->src_ip_value.family == AF_INET)
7784 /* no need to convert, already big endian. */
7785 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7787 if (filter.src_ip_mask == 0) {
7788 printf("can not support ipv6 involved compare.\n");
7793 /* need convert to big endian. */
7794 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7795 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7796 filter.queue = res->queue_id;
7798 if (!strcmp(res->ops, "add"))
7799 ret = rte_eth_dev_filter_ctrl(res->port_id,
7800 RTE_ETH_FILTER_NTUPLE,
7804 ret = rte_eth_dev_filter_ctrl(res->port_id,
7805 RTE_ETH_FILTER_NTUPLE,
7806 RTE_ETH_FILTER_DELETE,
7809 printf("5tuple filter programming error: (%s)\n",
7813 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7814 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7815 filter, "5tuple_filter");
7816 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7817 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7819 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7820 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7822 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7823 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7825 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7826 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7828 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7829 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7831 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7832 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7834 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7835 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7836 dst_port, "dst_port");
7837 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7838 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7839 dst_port_value, UINT16);
7840 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7841 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7842 src_port, "src_port");
7843 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7844 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7845 src_port_value, UINT16);
7846 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7847 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7848 protocol, "protocol");
7849 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7850 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7851 protocol_value, UINT8);
7852 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7853 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7855 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7856 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7858 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7859 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7860 tcp_flags, "tcp_flags");
7861 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7862 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7863 tcp_flags_value, UINT8);
7864 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7865 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7866 priority, "priority");
7867 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7868 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7869 priority_value, UINT8);
7870 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7871 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7873 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7874 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7877 cmdline_parse_inst_t cmd_5tuple_filter = {
7878 .f = cmd_5tuple_filter_parsed,
7880 .help_str = "add/del a 5tuple filter",
7882 (void *)&cmd_5tuple_filter_filter,
7883 (void *)&cmd_5tuple_filter_port_id,
7884 (void *)&cmd_5tuple_filter_ops,
7885 (void *)&cmd_5tuple_filter_dst_ip,
7886 (void *)&cmd_5tuple_filter_dst_ip_value,
7887 (void *)&cmd_5tuple_filter_src_ip,
7888 (void *)&cmd_5tuple_filter_src_ip_value,
7889 (void *)&cmd_5tuple_filter_dst_port,
7890 (void *)&cmd_5tuple_filter_dst_port_value,
7891 (void *)&cmd_5tuple_filter_src_port,
7892 (void *)&cmd_5tuple_filter_src_port_value,
7893 (void *)&cmd_5tuple_filter_protocol,
7894 (void *)&cmd_5tuple_filter_protocol_value,
7895 (void *)&cmd_5tuple_filter_mask,
7896 (void *)&cmd_5tuple_filter_mask_value,
7897 (void *)&cmd_5tuple_filter_tcp_flags,
7898 (void *)&cmd_5tuple_filter_tcp_flags_value,
7899 (void *)&cmd_5tuple_filter_priority,
7900 (void *)&cmd_5tuple_filter_priority_value,
7901 (void *)&cmd_5tuple_filter_queue,
7902 (void *)&cmd_5tuple_filter_queue_id,
7907 /* *** ADD/REMOVE A flex FILTER *** */
7908 struct cmd_flex_filter_result {
7909 cmdline_fixed_string_t filter;
7910 cmdline_fixed_string_t ops;
7912 cmdline_fixed_string_t len;
7914 cmdline_fixed_string_t bytes;
7915 cmdline_fixed_string_t bytes_value;
7916 cmdline_fixed_string_t mask;
7917 cmdline_fixed_string_t mask_value;
7918 cmdline_fixed_string_t priority;
7919 uint8_t priority_value;
7920 cmdline_fixed_string_t queue;
7924 static int xdigit2val(unsigned char c)
7929 else if (isupper(c))
7937 cmd_flex_filter_parsed(void *parsed_result,
7938 __attribute__((unused)) struct cmdline *cl,
7939 __attribute__((unused)) void *data)
7942 struct rte_eth_flex_filter filter;
7943 struct cmd_flex_filter_result *res = parsed_result;
7944 char *bytes_ptr, *mask_ptr;
7945 uint16_t len, i, j = 0;
7950 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7951 printf("the len exceed the max length 128\n");
7954 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7955 filter.len = res->len_value;
7956 filter.priority = res->priority_value;
7957 filter.queue = res->queue_id;
7958 bytes_ptr = res->bytes_value;
7959 mask_ptr = res->mask_value;
7961 /* translate bytes string to array. */
7962 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7963 (bytes_ptr[1] == 'X')))
7965 len = strnlen(bytes_ptr, res->len_value * 2);
7966 if (len == 0 || (len % 8 != 0)) {
7967 printf("please check len and bytes input\n");
7970 for (i = 0; i < len; i++) {
7972 if (isxdigit(c) == 0) {
7973 /* invalid characters. */
7974 printf("invalid input\n");
7977 val = xdigit2val(c);
7980 filter.bytes[j] = byte;
7981 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7988 /* translate mask string to uint8_t array. */
7989 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7990 (mask_ptr[1] == 'X')))
7992 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7994 printf("invalid input\n");
7999 for (i = 0; i < len; i++) {
8001 if (isxdigit(c) == 0) {
8002 /* invalid characters. */
8003 printf("invalid input\n");
8006 val = xdigit2val(c);
8009 filter.mask[j] = byte;
8010 printf("mask[%d]:%02x ", j, filter.mask[j]);
8018 if (!strcmp(res->ops, "add"))
8019 ret = rte_eth_dev_filter_ctrl(res->port_id,
8020 RTE_ETH_FILTER_FLEXIBLE,
8024 ret = rte_eth_dev_filter_ctrl(res->port_id,
8025 RTE_ETH_FILTER_FLEXIBLE,
8026 RTE_ETH_FILTER_DELETE,
8030 printf("flex filter setting error: (%s)\n", strerror(-ret));
8033 cmdline_parse_token_string_t cmd_flex_filter_filter =
8034 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8035 filter, "flex_filter");
8036 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8037 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8039 cmdline_parse_token_string_t cmd_flex_filter_ops =
8040 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8042 cmdline_parse_token_string_t cmd_flex_filter_len =
8043 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8045 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8046 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8048 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8049 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8051 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8052 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8054 cmdline_parse_token_string_t cmd_flex_filter_mask =
8055 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8057 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8058 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8060 cmdline_parse_token_string_t cmd_flex_filter_priority =
8061 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8062 priority, "priority");
8063 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8064 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8065 priority_value, UINT8);
8066 cmdline_parse_token_string_t cmd_flex_filter_queue =
8067 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8069 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8070 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8072 cmdline_parse_inst_t cmd_flex_filter = {
8073 .f = cmd_flex_filter_parsed,
8075 .help_str = "add/del a flex filter",
8077 (void *)&cmd_flex_filter_filter,
8078 (void *)&cmd_flex_filter_port_id,
8079 (void *)&cmd_flex_filter_ops,
8080 (void *)&cmd_flex_filter_len,
8081 (void *)&cmd_flex_filter_len_value,
8082 (void *)&cmd_flex_filter_bytes,
8083 (void *)&cmd_flex_filter_bytes_value,
8084 (void *)&cmd_flex_filter_mask,
8085 (void *)&cmd_flex_filter_mask_value,
8086 (void *)&cmd_flex_filter_priority,
8087 (void *)&cmd_flex_filter_priority_value,
8088 (void *)&cmd_flex_filter_queue,
8089 (void *)&cmd_flex_filter_queue_id,
8094 /* *** Filters Control *** */
8096 /* *** deal with ethertype filter *** */
8097 struct cmd_ethertype_filter_result {
8098 cmdline_fixed_string_t filter;
8100 cmdline_fixed_string_t ops;
8101 cmdline_fixed_string_t mac;
8102 struct ether_addr mac_addr;
8103 cmdline_fixed_string_t ethertype;
8104 uint16_t ethertype_value;
8105 cmdline_fixed_string_t drop;
8106 cmdline_fixed_string_t queue;
8110 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8111 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8112 filter, "ethertype_filter");
8113 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8114 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8116 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8117 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8119 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8120 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8121 mac, "mac_addr#mac_ignr");
8122 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8123 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8125 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8126 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8127 ethertype, "ethertype");
8128 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8129 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8130 ethertype_value, UINT16);
8131 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8132 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8134 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8135 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8137 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8138 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8142 cmd_ethertype_filter_parsed(void *parsed_result,
8143 __attribute__((unused)) struct cmdline *cl,
8144 __attribute__((unused)) void *data)
8146 struct cmd_ethertype_filter_result *res = parsed_result;
8147 struct rte_eth_ethertype_filter filter;
8150 ret = rte_eth_dev_filter_supported(res->port_id,
8151 RTE_ETH_FILTER_ETHERTYPE);
8153 printf("ethertype filter is not supported on port %u.\n",
8158 memset(&filter, 0, sizeof(filter));
8159 if (!strcmp(res->mac, "mac_addr")) {
8160 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8161 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8162 sizeof(struct ether_addr));
8164 if (!strcmp(res->drop, "drop"))
8165 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8166 filter.ether_type = res->ethertype_value;
8167 filter.queue = res->queue_id;
8169 if (!strcmp(res->ops, "add"))
8170 ret = rte_eth_dev_filter_ctrl(res->port_id,
8171 RTE_ETH_FILTER_ETHERTYPE,
8175 ret = rte_eth_dev_filter_ctrl(res->port_id,
8176 RTE_ETH_FILTER_ETHERTYPE,
8177 RTE_ETH_FILTER_DELETE,
8180 printf("ethertype filter programming error: (%s)\n",
8184 cmdline_parse_inst_t cmd_ethertype_filter = {
8185 .f = cmd_ethertype_filter_parsed,
8187 .help_str = "add or delete an ethertype filter entry",
8189 (void *)&cmd_ethertype_filter_filter,
8190 (void *)&cmd_ethertype_filter_port_id,
8191 (void *)&cmd_ethertype_filter_ops,
8192 (void *)&cmd_ethertype_filter_mac,
8193 (void *)&cmd_ethertype_filter_mac_addr,
8194 (void *)&cmd_ethertype_filter_ethertype,
8195 (void *)&cmd_ethertype_filter_ethertype_value,
8196 (void *)&cmd_ethertype_filter_drop,
8197 (void *)&cmd_ethertype_filter_queue,
8198 (void *)&cmd_ethertype_filter_queue_id,
8203 /* *** deal with flow director filter *** */
8204 struct cmd_flow_director_result {
8205 cmdline_fixed_string_t flow_director_filter;
8207 cmdline_fixed_string_t mode;
8208 cmdline_fixed_string_t mode_value;
8209 cmdline_fixed_string_t ops;
8210 cmdline_fixed_string_t flow;
8211 cmdline_fixed_string_t flow_type;
8212 cmdline_fixed_string_t ether;
8213 uint16_t ether_type;
8214 cmdline_fixed_string_t src;
8215 cmdline_ipaddr_t ip_src;
8217 cmdline_fixed_string_t dst;
8218 cmdline_ipaddr_t ip_dst;
8220 cmdline_fixed_string_t verify_tag;
8221 uint32_t verify_tag_value;
8222 cmdline_ipaddr_t tos;
8224 cmdline_ipaddr_t proto;
8225 uint8_t proto_value;
8226 cmdline_ipaddr_t ttl;
8228 cmdline_fixed_string_t vlan;
8229 uint16_t vlan_value;
8230 cmdline_fixed_string_t flexbytes;
8231 cmdline_fixed_string_t flexbytes_value;
8232 cmdline_fixed_string_t pf_vf;
8233 cmdline_fixed_string_t drop;
8234 cmdline_fixed_string_t queue;
8236 cmdline_fixed_string_t fd_id;
8237 uint32_t fd_id_value;
8238 cmdline_fixed_string_t mac;
8239 struct ether_addr mac_addr;
8240 cmdline_fixed_string_t tunnel;
8241 cmdline_fixed_string_t tunnel_type;
8242 cmdline_fixed_string_t tunnel_id;
8243 uint32_t tunnel_id_value;
8247 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8250 const char *p, *p0 = q_arg;
8252 unsigned long int_fld;
8253 char *str_fld[max_num];
8258 p = strchr(p0, '(');
8262 p0 = strchr(p, ')');
8267 if (size >= sizeof(s))
8270 snprintf(s, sizeof(s), "%.*s", size, p);
8271 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8272 if (ret < 0 || ret > max_num)
8274 for (i = 0; i < ret; i++) {
8276 int_fld = strtoul(str_fld[i], &end, 0);
8277 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8279 flexbytes[i] = (uint8_t)int_fld;
8285 str2flowtype(char *string)
8288 static const struct {
8291 } flowtype_str[] = {
8292 {"raw", RTE_ETH_FLOW_RAW},
8293 {"ipv4", RTE_ETH_FLOW_IPV4},
8294 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8295 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8296 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8297 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8298 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8299 {"ipv6", RTE_ETH_FLOW_IPV6},
8300 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8301 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8302 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8303 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8304 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8305 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8308 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8309 if (!strcmp(flowtype_str[i].str, string))
8310 return flowtype_str[i].type;
8312 return RTE_ETH_FLOW_UNKNOWN;
8315 static enum rte_eth_fdir_tunnel_type
8316 str2fdir_tunneltype(char *string)
8320 static const struct {
8322 enum rte_eth_fdir_tunnel_type type;
8323 } tunneltype_str[] = {
8324 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8325 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8328 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8329 if (!strcmp(tunneltype_str[i].str, string))
8330 return tunneltype_str[i].type;
8332 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8335 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8337 if ((ip_addr).family == AF_INET) \
8338 (ip) = (ip_addr).addr.ipv4.s_addr; \
8340 printf("invalid parameter.\n"); \
8345 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8347 if ((ip_addr).family == AF_INET6) \
8348 (void)rte_memcpy(&(ip), \
8349 &((ip_addr).addr.ipv6), \
8350 sizeof(struct in6_addr)); \
8352 printf("invalid parameter.\n"); \
8358 cmd_flow_director_filter_parsed(void *parsed_result,
8359 __attribute__((unused)) struct cmdline *cl,
8360 __attribute__((unused)) void *data)
8362 struct cmd_flow_director_result *res = parsed_result;
8363 struct rte_eth_fdir_filter entry;
8364 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8366 unsigned long vf_id;
8369 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8371 printf("flow director is not supported on port %u.\n",
8375 memset(flexbytes, 0, sizeof(flexbytes));
8376 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8378 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8379 if (strcmp(res->mode_value, "MAC-VLAN")) {
8380 printf("Please set mode to MAC-VLAN.\n");
8383 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8384 if (strcmp(res->mode_value, "Tunnel")) {
8385 printf("Please set mode to Tunnel.\n");
8389 if (strcmp(res->mode_value, "IP")) {
8390 printf("Please set mode to IP.\n");
8393 entry.input.flow_type = str2flowtype(res->flow_type);
8396 ret = parse_flexbytes(res->flexbytes_value,
8398 RTE_ETH_FDIR_MAX_FLEXLEN);
8400 printf("error: Cannot parse flexbytes input.\n");
8404 switch (entry.input.flow_type) {
8405 case RTE_ETH_FLOW_FRAG_IPV4:
8406 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8407 entry.input.flow.ip4_flow.proto = res->proto_value;
8408 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8409 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8410 IPV4_ADDR_TO_UINT(res->ip_dst,
8411 entry.input.flow.ip4_flow.dst_ip);
8412 IPV4_ADDR_TO_UINT(res->ip_src,
8413 entry.input.flow.ip4_flow.src_ip);
8414 entry.input.flow.ip4_flow.tos = res->tos_value;
8415 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8416 /* need convert to big endian. */
8417 entry.input.flow.udp4_flow.dst_port =
8418 rte_cpu_to_be_16(res->port_dst);
8419 entry.input.flow.udp4_flow.src_port =
8420 rte_cpu_to_be_16(res->port_src);
8422 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8423 IPV4_ADDR_TO_UINT(res->ip_dst,
8424 entry.input.flow.sctp4_flow.ip.dst_ip);
8425 IPV4_ADDR_TO_UINT(res->ip_src,
8426 entry.input.flow.sctp4_flow.ip.src_ip);
8427 entry.input.flow.ip4_flow.tos = res->tos_value;
8428 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8429 /* need convert to big endian. */
8430 entry.input.flow.sctp4_flow.dst_port =
8431 rte_cpu_to_be_16(res->port_dst);
8432 entry.input.flow.sctp4_flow.src_port =
8433 rte_cpu_to_be_16(res->port_src);
8434 entry.input.flow.sctp4_flow.verify_tag =
8435 rte_cpu_to_be_32(res->verify_tag_value);
8437 case RTE_ETH_FLOW_FRAG_IPV6:
8438 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8439 entry.input.flow.ipv6_flow.proto = res->proto_value;
8440 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8441 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8442 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8443 entry.input.flow.ipv6_flow.dst_ip);
8444 IPV6_ADDR_TO_ARRAY(res->ip_src,
8445 entry.input.flow.ipv6_flow.src_ip);
8446 entry.input.flow.ipv6_flow.tc = res->tos_value;
8447 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8448 /* need convert to big endian. */
8449 entry.input.flow.udp6_flow.dst_port =
8450 rte_cpu_to_be_16(res->port_dst);
8451 entry.input.flow.udp6_flow.src_port =
8452 rte_cpu_to_be_16(res->port_src);
8454 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8455 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8456 entry.input.flow.sctp6_flow.ip.dst_ip);
8457 IPV6_ADDR_TO_ARRAY(res->ip_src,
8458 entry.input.flow.sctp6_flow.ip.src_ip);
8459 entry.input.flow.ipv6_flow.tc = res->tos_value;
8460 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8461 /* need convert to big endian. */
8462 entry.input.flow.sctp6_flow.dst_port =
8463 rte_cpu_to_be_16(res->port_dst);
8464 entry.input.flow.sctp6_flow.src_port =
8465 rte_cpu_to_be_16(res->port_src);
8466 entry.input.flow.sctp6_flow.verify_tag =
8467 rte_cpu_to_be_32(res->verify_tag_value);
8469 case RTE_ETH_FLOW_L2_PAYLOAD:
8470 entry.input.flow.l2_flow.ether_type =
8471 rte_cpu_to_be_16(res->ether_type);
8477 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8478 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8480 sizeof(struct ether_addr));
8482 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8483 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8485 sizeof(struct ether_addr));
8486 entry.input.flow.tunnel_flow.tunnel_type =
8487 str2fdir_tunneltype(res->tunnel_type);
8488 entry.input.flow.tunnel_flow.tunnel_id =
8489 rte_cpu_to_be_32(res->tunnel_id_value);
8492 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8494 RTE_ETH_FDIR_MAX_FLEXLEN);
8496 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8498 entry.action.flex_off = 0; /*use 0 by default */
8499 if (!strcmp(res->drop, "drop"))
8500 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8502 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8504 if (!strcmp(res->pf_vf, "pf"))
8505 entry.input.flow_ext.is_vf = 0;
8506 else if (!strncmp(res->pf_vf, "vf", 2)) {
8507 struct rte_eth_dev_info dev_info;
8509 memset(&dev_info, 0, sizeof(dev_info));
8510 rte_eth_dev_info_get(res->port_id, &dev_info);
8512 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8513 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8514 printf("invalid parameter %s.\n", res->pf_vf);
8517 entry.input.flow_ext.is_vf = 1;
8518 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8520 printf("invalid parameter %s.\n", res->pf_vf);
8524 /* set to report FD ID by default */
8525 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8526 entry.action.rx_queue = res->queue_id;
8527 entry.soft_id = res->fd_id_value;
8528 if (!strcmp(res->ops, "add"))
8529 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8530 RTE_ETH_FILTER_ADD, &entry);
8531 else if (!strcmp(res->ops, "del"))
8532 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8533 RTE_ETH_FILTER_DELETE, &entry);
8535 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8536 RTE_ETH_FILTER_UPDATE, &entry);
8538 printf("flow director programming error: (%s)\n",
8542 cmdline_parse_token_string_t cmd_flow_director_filter =
8543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8544 flow_director_filter, "flow_director_filter");
8545 cmdline_parse_token_num_t cmd_flow_director_port_id =
8546 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8548 cmdline_parse_token_string_t cmd_flow_director_ops =
8549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8550 ops, "add#del#update");
8551 cmdline_parse_token_string_t cmd_flow_director_flow =
8552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8554 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8556 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8557 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8558 cmdline_parse_token_string_t cmd_flow_director_ether =
8559 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8561 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8562 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8563 ether_type, UINT16);
8564 cmdline_parse_token_string_t cmd_flow_director_src =
8565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8567 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8568 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8570 cmdline_parse_token_num_t cmd_flow_director_port_src =
8571 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8573 cmdline_parse_token_string_t cmd_flow_director_dst =
8574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8576 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8577 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8579 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8580 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8582 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8583 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8584 verify_tag, "verify_tag");
8585 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8586 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8587 verify_tag_value, UINT32);
8588 cmdline_parse_token_string_t cmd_flow_director_tos =
8589 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8591 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8592 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8594 cmdline_parse_token_string_t cmd_flow_director_proto =
8595 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8597 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8598 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8599 proto_value, UINT8);
8600 cmdline_parse_token_string_t cmd_flow_director_ttl =
8601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8603 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8604 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8606 cmdline_parse_token_string_t cmd_flow_director_vlan =
8607 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8609 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8610 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8611 vlan_value, UINT16);
8612 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8614 flexbytes, "flexbytes");
8615 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8616 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8617 flexbytes_value, NULL);
8618 cmdline_parse_token_string_t cmd_flow_director_drop =
8619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8621 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8622 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8624 cmdline_parse_token_string_t cmd_flow_director_queue =
8625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8627 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8628 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8630 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8631 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8633 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8635 fd_id_value, UINT32);
8637 cmdline_parse_token_string_t cmd_flow_director_mode =
8638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8640 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8643 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8645 mode_value, "MAC-VLAN");
8646 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8648 mode_value, "Tunnel");
8649 cmdline_parse_token_string_t cmd_flow_director_mac =
8650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8652 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8653 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8655 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8658 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8660 tunnel_type, "NVGRE#VxLAN");
8661 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8663 tunnel_id, "tunnel-id");
8664 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8665 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8666 tunnel_id_value, UINT32);
8668 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8669 .f = cmd_flow_director_filter_parsed,
8671 .help_str = "add or delete an ip flow director entry on NIC",
8673 (void *)&cmd_flow_director_filter,
8674 (void *)&cmd_flow_director_port_id,
8675 (void *)&cmd_flow_director_mode,
8676 (void *)&cmd_flow_director_mode_ip,
8677 (void *)&cmd_flow_director_ops,
8678 (void *)&cmd_flow_director_flow,
8679 (void *)&cmd_flow_director_flow_type,
8680 (void *)&cmd_flow_director_src,
8681 (void *)&cmd_flow_director_ip_src,
8682 (void *)&cmd_flow_director_dst,
8683 (void *)&cmd_flow_director_ip_dst,
8684 (void *)&cmd_flow_director_tos,
8685 (void *)&cmd_flow_director_tos_value,
8686 (void *)&cmd_flow_director_proto,
8687 (void *)&cmd_flow_director_proto_value,
8688 (void *)&cmd_flow_director_ttl,
8689 (void *)&cmd_flow_director_ttl_value,
8690 (void *)&cmd_flow_director_vlan,
8691 (void *)&cmd_flow_director_vlan_value,
8692 (void *)&cmd_flow_director_flexbytes,
8693 (void *)&cmd_flow_director_flexbytes_value,
8694 (void *)&cmd_flow_director_drop,
8695 (void *)&cmd_flow_director_pf_vf,
8696 (void *)&cmd_flow_director_queue,
8697 (void *)&cmd_flow_director_queue_id,
8698 (void *)&cmd_flow_director_fd_id,
8699 (void *)&cmd_flow_director_fd_id_value,
8704 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8705 .f = cmd_flow_director_filter_parsed,
8707 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8709 (void *)&cmd_flow_director_filter,
8710 (void *)&cmd_flow_director_port_id,
8711 (void *)&cmd_flow_director_mode,
8712 (void *)&cmd_flow_director_mode_ip,
8713 (void *)&cmd_flow_director_ops,
8714 (void *)&cmd_flow_director_flow,
8715 (void *)&cmd_flow_director_flow_type,
8716 (void *)&cmd_flow_director_src,
8717 (void *)&cmd_flow_director_ip_src,
8718 (void *)&cmd_flow_director_port_src,
8719 (void *)&cmd_flow_director_dst,
8720 (void *)&cmd_flow_director_ip_dst,
8721 (void *)&cmd_flow_director_port_dst,
8722 (void *)&cmd_flow_director_tos,
8723 (void *)&cmd_flow_director_tos_value,
8724 (void *)&cmd_flow_director_ttl,
8725 (void *)&cmd_flow_director_ttl_value,
8726 (void *)&cmd_flow_director_vlan,
8727 (void *)&cmd_flow_director_vlan_value,
8728 (void *)&cmd_flow_director_flexbytes,
8729 (void *)&cmd_flow_director_flexbytes_value,
8730 (void *)&cmd_flow_director_drop,
8731 (void *)&cmd_flow_director_pf_vf,
8732 (void *)&cmd_flow_director_queue,
8733 (void *)&cmd_flow_director_queue_id,
8734 (void *)&cmd_flow_director_fd_id,
8735 (void *)&cmd_flow_director_fd_id_value,
8740 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8741 .f = cmd_flow_director_filter_parsed,
8743 .help_str = "add or delete a sctp flow director entry on NIC",
8745 (void *)&cmd_flow_director_filter,
8746 (void *)&cmd_flow_director_port_id,
8747 (void *)&cmd_flow_director_mode,
8748 (void *)&cmd_flow_director_mode_ip,
8749 (void *)&cmd_flow_director_ops,
8750 (void *)&cmd_flow_director_flow,
8751 (void *)&cmd_flow_director_flow_type,
8752 (void *)&cmd_flow_director_src,
8753 (void *)&cmd_flow_director_ip_src,
8754 (void *)&cmd_flow_director_port_dst,
8755 (void *)&cmd_flow_director_dst,
8756 (void *)&cmd_flow_director_ip_dst,
8757 (void *)&cmd_flow_director_port_dst,
8758 (void *)&cmd_flow_director_verify_tag,
8759 (void *)&cmd_flow_director_verify_tag_value,
8760 (void *)&cmd_flow_director_tos,
8761 (void *)&cmd_flow_director_tos_value,
8762 (void *)&cmd_flow_director_ttl,
8763 (void *)&cmd_flow_director_ttl_value,
8764 (void *)&cmd_flow_director_vlan,
8765 (void *)&cmd_flow_director_vlan_value,
8766 (void *)&cmd_flow_director_flexbytes,
8767 (void *)&cmd_flow_director_flexbytes_value,
8768 (void *)&cmd_flow_director_drop,
8769 (void *)&cmd_flow_director_pf_vf,
8770 (void *)&cmd_flow_director_queue,
8771 (void *)&cmd_flow_director_queue_id,
8772 (void *)&cmd_flow_director_fd_id,
8773 (void *)&cmd_flow_director_fd_id_value,
8778 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8779 .f = cmd_flow_director_filter_parsed,
8781 .help_str = "add or delete a L2 flow director entry on NIC",
8783 (void *)&cmd_flow_director_filter,
8784 (void *)&cmd_flow_director_port_id,
8785 (void *)&cmd_flow_director_mode,
8786 (void *)&cmd_flow_director_mode_ip,
8787 (void *)&cmd_flow_director_ops,
8788 (void *)&cmd_flow_director_flow,
8789 (void *)&cmd_flow_director_flow_type,
8790 (void *)&cmd_flow_director_ether,
8791 (void *)&cmd_flow_director_ether_type,
8792 (void *)&cmd_flow_director_flexbytes,
8793 (void *)&cmd_flow_director_flexbytes_value,
8794 (void *)&cmd_flow_director_drop,
8795 (void *)&cmd_flow_director_pf_vf,
8796 (void *)&cmd_flow_director_queue,
8797 (void *)&cmd_flow_director_queue_id,
8798 (void *)&cmd_flow_director_fd_id,
8799 (void *)&cmd_flow_director_fd_id_value,
8804 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8805 .f = cmd_flow_director_filter_parsed,
8807 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8809 (void *)&cmd_flow_director_filter,
8810 (void *)&cmd_flow_director_port_id,
8811 (void *)&cmd_flow_director_mode,
8812 (void *)&cmd_flow_director_mode_mac_vlan,
8813 (void *)&cmd_flow_director_ops,
8814 (void *)&cmd_flow_director_mac,
8815 (void *)&cmd_flow_director_mac_addr,
8816 (void *)&cmd_flow_director_vlan,
8817 (void *)&cmd_flow_director_vlan_value,
8818 (void *)&cmd_flow_director_flexbytes,
8819 (void *)&cmd_flow_director_flexbytes_value,
8820 (void *)&cmd_flow_director_drop,
8821 (void *)&cmd_flow_director_queue,
8822 (void *)&cmd_flow_director_queue_id,
8823 (void *)&cmd_flow_director_fd_id,
8824 (void *)&cmd_flow_director_fd_id_value,
8829 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8830 .f = cmd_flow_director_filter_parsed,
8832 .help_str = "add or delete a tunnel flow director entry on NIC",
8834 (void *)&cmd_flow_director_filter,
8835 (void *)&cmd_flow_director_port_id,
8836 (void *)&cmd_flow_director_mode,
8837 (void *)&cmd_flow_director_mode_tunnel,
8838 (void *)&cmd_flow_director_ops,
8839 (void *)&cmd_flow_director_mac,
8840 (void *)&cmd_flow_director_mac_addr,
8841 (void *)&cmd_flow_director_vlan,
8842 (void *)&cmd_flow_director_vlan_value,
8843 (void *)&cmd_flow_director_tunnel,
8844 (void *)&cmd_flow_director_tunnel_type,
8845 (void *)&cmd_flow_director_tunnel_id,
8846 (void *)&cmd_flow_director_tunnel_id_value,
8847 (void *)&cmd_flow_director_flexbytes,
8848 (void *)&cmd_flow_director_flexbytes_value,
8849 (void *)&cmd_flow_director_drop,
8850 (void *)&cmd_flow_director_queue,
8851 (void *)&cmd_flow_director_queue_id,
8852 (void *)&cmd_flow_director_fd_id,
8853 (void *)&cmd_flow_director_fd_id_value,
8858 struct cmd_flush_flow_director_result {
8859 cmdline_fixed_string_t flush_flow_director;
8863 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8864 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8865 flush_flow_director, "flush_flow_director");
8866 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8867 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8871 cmd_flush_flow_director_parsed(void *parsed_result,
8872 __attribute__((unused)) struct cmdline *cl,
8873 __attribute__((unused)) void *data)
8875 struct cmd_flow_director_result *res = parsed_result;
8878 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8880 printf("flow director is not supported on port %u.\n",
8885 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8886 RTE_ETH_FILTER_FLUSH, NULL);
8888 printf("flow director table flushing error: (%s)\n",
8892 cmdline_parse_inst_t cmd_flush_flow_director = {
8893 .f = cmd_flush_flow_director_parsed,
8895 .help_str = "flush all flow director entries of a device on NIC",
8897 (void *)&cmd_flush_flow_director_flush,
8898 (void *)&cmd_flush_flow_director_port_id,
8903 /* *** deal with flow director mask *** */
8904 struct cmd_flow_director_mask_result {
8905 cmdline_fixed_string_t flow_director_mask;
8907 cmdline_fixed_string_t mode;
8908 cmdline_fixed_string_t mode_value;
8909 cmdline_fixed_string_t vlan;
8911 cmdline_fixed_string_t src_mask;
8912 cmdline_ipaddr_t ipv4_src;
8913 cmdline_ipaddr_t ipv6_src;
8915 cmdline_fixed_string_t dst_mask;
8916 cmdline_ipaddr_t ipv4_dst;
8917 cmdline_ipaddr_t ipv6_dst;
8919 cmdline_fixed_string_t mac;
8920 uint8_t mac_addr_byte_mask;
8921 cmdline_fixed_string_t tunnel_id;
8922 uint32_t tunnel_id_mask;
8923 cmdline_fixed_string_t tunnel_type;
8924 uint8_t tunnel_type_mask;
8928 cmd_flow_director_mask_parsed(void *parsed_result,
8929 __attribute__((unused)) struct cmdline *cl,
8930 __attribute__((unused)) void *data)
8932 struct cmd_flow_director_mask_result *res = parsed_result;
8933 struct rte_eth_fdir_masks *mask;
8934 struct rte_port *port;
8936 if (res->port_id > nb_ports) {
8937 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8941 port = &ports[res->port_id];
8942 /** Check if the port is not started **/
8943 if (port->port_status != RTE_PORT_STOPPED) {
8944 printf("Please stop port %d first\n", res->port_id);
8948 mask = &port->dev_conf.fdir_conf.mask;
8950 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8951 if (strcmp(res->mode_value, "MAC-VLAN")) {
8952 printf("Please set mode to MAC-VLAN.\n");
8956 mask->vlan_tci_mask = res->vlan_mask;
8957 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8958 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8959 if (strcmp(res->mode_value, "Tunnel")) {
8960 printf("Please set mode to Tunnel.\n");
8964 mask->vlan_tci_mask = res->vlan_mask;
8965 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8966 mask->tunnel_id_mask = res->tunnel_id_mask;
8967 mask->tunnel_type_mask = res->tunnel_type_mask;
8969 if (strcmp(res->mode_value, "IP")) {
8970 printf("Please set mode to IP.\n");
8974 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8975 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8976 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8977 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8978 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8979 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8980 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8983 cmd_reconfig_device_queue(res->port_id, 1, 1);
8986 cmdline_parse_token_string_t cmd_flow_director_mask =
8987 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8988 flow_director_mask, "flow_director_mask");
8989 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8990 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8992 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8993 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8995 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8996 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8998 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8999 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9000 src_mask, "src_mask");
9001 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9002 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9004 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9005 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9007 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9008 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9010 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9012 dst_mask, "dst_mask");
9013 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9014 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9016 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9017 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9019 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9020 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9023 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9024 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9026 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9027 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9029 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9030 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9031 mode_value, "MAC-VLAN");
9032 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9034 mode_value, "Tunnel");
9035 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9036 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9038 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9039 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9040 mac_addr_byte_mask, UINT8);
9041 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9042 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9043 tunnel_type, "tunnel-type");
9044 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9045 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9046 tunnel_type_mask, UINT8);
9047 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9048 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9049 tunnel_id, "tunnel-id");
9050 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9051 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9052 tunnel_id_mask, UINT32);
9054 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9055 .f = cmd_flow_director_mask_parsed,
9057 .help_str = "set IP mode flow director's mask on NIC",
9059 (void *)&cmd_flow_director_mask,
9060 (void *)&cmd_flow_director_mask_port_id,
9061 (void *)&cmd_flow_director_mask_mode,
9062 (void *)&cmd_flow_director_mask_mode_ip,
9063 (void *)&cmd_flow_director_mask_vlan,
9064 (void *)&cmd_flow_director_mask_vlan_value,
9065 (void *)&cmd_flow_director_mask_src,
9066 (void *)&cmd_flow_director_mask_ipv4_src,
9067 (void *)&cmd_flow_director_mask_ipv6_src,
9068 (void *)&cmd_flow_director_mask_port_src,
9069 (void *)&cmd_flow_director_mask_dst,
9070 (void *)&cmd_flow_director_mask_ipv4_dst,
9071 (void *)&cmd_flow_director_mask_ipv6_dst,
9072 (void *)&cmd_flow_director_mask_port_dst,
9077 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9078 .f = cmd_flow_director_mask_parsed,
9080 .help_str = "set MAC VLAN mode flow director's mask on NIC",
9082 (void *)&cmd_flow_director_mask,
9083 (void *)&cmd_flow_director_mask_port_id,
9084 (void *)&cmd_flow_director_mask_mode,
9085 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9086 (void *)&cmd_flow_director_mask_vlan,
9087 (void *)&cmd_flow_director_mask_vlan_value,
9088 (void *)&cmd_flow_director_mask_mac,
9089 (void *)&cmd_flow_director_mask_mac_value,
9094 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9095 .f = cmd_flow_director_mask_parsed,
9097 .help_str = "set tunnel mode flow director's mask on NIC",
9099 (void *)&cmd_flow_director_mask,
9100 (void *)&cmd_flow_director_mask_port_id,
9101 (void *)&cmd_flow_director_mask_mode,
9102 (void *)&cmd_flow_director_mask_mode_tunnel,
9103 (void *)&cmd_flow_director_mask_vlan,
9104 (void *)&cmd_flow_director_mask_vlan_value,
9105 (void *)&cmd_flow_director_mask_mac,
9106 (void *)&cmd_flow_director_mask_mac_value,
9107 (void *)&cmd_flow_director_mask_tunnel_type,
9108 (void *)&cmd_flow_director_mask_tunnel_type_value,
9109 (void *)&cmd_flow_director_mask_tunnel_id,
9110 (void *)&cmd_flow_director_mask_tunnel_id_value,
9115 /* *** deal with flow director mask on flexible payload *** */
9116 struct cmd_flow_director_flex_mask_result {
9117 cmdline_fixed_string_t flow_director_flexmask;
9119 cmdline_fixed_string_t flow;
9120 cmdline_fixed_string_t flow_type;
9121 cmdline_fixed_string_t mask;
9125 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9126 __attribute__((unused)) struct cmdline *cl,
9127 __attribute__((unused)) void *data)
9129 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9130 struct rte_eth_fdir_info fdir_info;
9131 struct rte_eth_fdir_flex_mask flex_mask;
9132 struct rte_port *port;
9133 uint32_t flow_type_mask;
9137 if (res->port_id > nb_ports) {
9138 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9142 port = &ports[res->port_id];
9143 /** Check if the port is not started **/
9144 if (port->port_status != RTE_PORT_STOPPED) {
9145 printf("Please stop port %d first\n", res->port_id);
9149 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9150 ret = parse_flexbytes(res->mask,
9152 RTE_ETH_FDIR_MAX_FLEXLEN);
9154 printf("error: Cannot parse mask input.\n");
9158 memset(&fdir_info, 0, sizeof(fdir_info));
9159 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9160 RTE_ETH_FILTER_INFO, &fdir_info);
9162 printf("Cannot get FDir filter info\n");
9166 if (!strcmp(res->flow_type, "none")) {
9167 /* means don't specify the flow type */
9168 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9169 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9170 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9171 0, sizeof(struct rte_eth_fdir_flex_mask));
9172 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9173 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9175 sizeof(struct rte_eth_fdir_flex_mask));
9176 cmd_reconfig_device_queue(res->port_id, 1, 1);
9179 flow_type_mask = fdir_info.flow_types_mask[0];
9180 if (!strcmp(res->flow_type, "all")) {
9181 if (!flow_type_mask) {
9182 printf("No flow type supported\n");
9185 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9186 if (flow_type_mask & (1 << i)) {
9187 flex_mask.flow_type = i;
9188 fdir_set_flex_mask(res->port_id, &flex_mask);
9191 cmd_reconfig_device_queue(res->port_id, 1, 1);
9194 flex_mask.flow_type = str2flowtype(res->flow_type);
9195 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9196 printf("Flow type %s not supported on port %d\n",
9197 res->flow_type, res->port_id);
9200 fdir_set_flex_mask(res->port_id, &flex_mask);
9201 cmd_reconfig_device_queue(res->port_id, 1, 1);
9204 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9206 flow_director_flexmask,
9207 "flow_director_flex_mask");
9208 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9209 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9211 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9212 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9214 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9216 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9217 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9218 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9222 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9223 .f = cmd_flow_director_flex_mask_parsed,
9225 .help_str = "set flow director's flex mask on NIC",
9227 (void *)&cmd_flow_director_flexmask,
9228 (void *)&cmd_flow_director_flexmask_port_id,
9229 (void *)&cmd_flow_director_flexmask_flow,
9230 (void *)&cmd_flow_director_flexmask_flow_type,
9231 (void *)&cmd_flow_director_flexmask_mask,
9236 /* *** deal with flow director flexible payload configuration *** */
9237 struct cmd_flow_director_flexpayload_result {
9238 cmdline_fixed_string_t flow_director_flexpayload;
9240 cmdline_fixed_string_t payload_layer;
9241 cmdline_fixed_string_t payload_cfg;
9245 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9248 const char *p, *p0 = q_arg;
9250 unsigned long int_fld;
9251 char *str_fld[max_num];
9256 p = strchr(p0, '(');
9260 p0 = strchr(p, ')');
9265 if (size >= sizeof(s))
9268 snprintf(s, sizeof(s), "%.*s", size, p);
9269 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9270 if (ret < 0 || ret > max_num)
9272 for (i = 0; i < ret; i++) {
9274 int_fld = strtoul(str_fld[i], &end, 0);
9275 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9277 offsets[i] = (uint16_t)int_fld;
9283 cmd_flow_director_flxpld_parsed(void *parsed_result,
9284 __attribute__((unused)) struct cmdline *cl,
9285 __attribute__((unused)) void *data)
9287 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9288 struct rte_eth_flex_payload_cfg flex_cfg;
9289 struct rte_port *port;
9292 if (res->port_id > nb_ports) {
9293 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9297 port = &ports[res->port_id];
9298 /** Check if the port is not started **/
9299 if (port->port_status != RTE_PORT_STOPPED) {
9300 printf("Please stop port %d first\n", res->port_id);
9304 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9306 if (!strcmp(res->payload_layer, "raw"))
9307 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9308 else if (!strcmp(res->payload_layer, "l2"))
9309 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9310 else if (!strcmp(res->payload_layer, "l3"))
9311 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9312 else if (!strcmp(res->payload_layer, "l4"))
9313 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9315 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9316 RTE_ETH_FDIR_MAX_FLEXLEN);
9318 printf("error: Cannot parse flex payload input.\n");
9322 fdir_set_flex_payload(res->port_id, &flex_cfg);
9323 cmd_reconfig_device_queue(res->port_id, 1, 1);
9326 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9328 flow_director_flexpayload,
9329 "flow_director_flex_payload");
9330 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9333 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9335 payload_layer, "raw#l2#l3#l4");
9336 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9337 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9340 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9341 .f = cmd_flow_director_flxpld_parsed,
9343 .help_str = "set flow director's flex payload on NIC",
9345 (void *)&cmd_flow_director_flexpayload,
9346 (void *)&cmd_flow_director_flexpayload_port_id,
9347 (void *)&cmd_flow_director_flexpayload_payload_layer,
9348 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9353 /* *** Classification Filters Control *** */
9354 /* *** Get symmetric hash enable per port *** */
9355 struct cmd_get_sym_hash_ena_per_port_result {
9356 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9361 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9362 __rte_unused struct cmdline *cl,
9363 __rte_unused void *data)
9365 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9366 struct rte_eth_hash_filter_info info;
9369 if (rte_eth_dev_filter_supported(res->port_id,
9370 RTE_ETH_FILTER_HASH) < 0) {
9371 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9376 memset(&info, 0, sizeof(info));
9377 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9378 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9379 RTE_ETH_FILTER_GET, &info);
9382 printf("Cannot get symmetric hash enable per port "
9383 "on port %u\n", res->port_id);
9387 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9388 "enabled" : "disabled", res->port_id);
9391 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9392 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9393 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9394 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9395 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9398 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9399 .f = cmd_get_sym_hash_per_port_parsed,
9401 .help_str = "get_sym_hash_ena_per_port port_id",
9403 (void *)&cmd_get_sym_hash_ena_per_port_all,
9404 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9409 /* *** Set symmetric hash enable per port *** */
9410 struct cmd_set_sym_hash_ena_per_port_result {
9411 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9412 cmdline_fixed_string_t enable;
9417 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9418 __rte_unused struct cmdline *cl,
9419 __rte_unused void *data)
9421 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9422 struct rte_eth_hash_filter_info info;
9425 if (rte_eth_dev_filter_supported(res->port_id,
9426 RTE_ETH_FILTER_HASH) < 0) {
9427 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9432 memset(&info, 0, sizeof(info));
9433 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9434 if (!strcmp(res->enable, "enable"))
9435 info.info.enable = 1;
9436 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9437 RTE_ETH_FILTER_SET, &info);
9439 printf("Cannot set symmetric hash enable per port on "
9440 "port %u\n", res->port_id);
9443 printf("Symmetric hash has been set to %s on port %u\n",
9444 res->enable, res->port_id);
9447 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9448 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9449 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9450 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9451 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9453 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9454 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9455 enable, "enable#disable");
9457 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9458 .f = cmd_set_sym_hash_per_port_parsed,
9460 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9462 (void *)&cmd_set_sym_hash_ena_per_port_all,
9463 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9464 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9469 /* Get global config of hash function */
9470 struct cmd_get_hash_global_config_result {
9471 cmdline_fixed_string_t get_hash_global_config;
9476 flowtype_to_str(uint16_t ftype)
9483 {"ipv4", RTE_ETH_FLOW_IPV4},
9484 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9485 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9486 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9487 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9488 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9489 {"ipv6", RTE_ETH_FLOW_IPV6},
9490 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9491 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9492 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9493 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9494 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9495 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9498 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9499 if (ftype_table[i].ftype == ftype)
9500 return ftype_table[i].str;
9507 cmd_get_hash_global_config_parsed(void *parsed_result,
9508 __rte_unused struct cmdline *cl,
9509 __rte_unused void *data)
9511 struct cmd_get_hash_global_config_result *res = parsed_result;
9512 struct rte_eth_hash_filter_info info;
9513 uint32_t idx, offset;
9518 if (rte_eth_dev_filter_supported(res->port_id,
9519 RTE_ETH_FILTER_HASH) < 0) {
9520 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9525 memset(&info, 0, sizeof(info));
9526 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9527 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9528 RTE_ETH_FILTER_GET, &info);
9530 printf("Cannot get hash global configurations by port %d\n",
9535 switch (info.info.global_conf.hash_func) {
9536 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9537 printf("Hash function is Toeplitz\n");
9539 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9540 printf("Hash function is Simple XOR\n");
9543 printf("Unknown hash function\n");
9547 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9548 idx = i / UINT32_BIT;
9549 offset = i % UINT32_BIT;
9550 if (!(info.info.global_conf.valid_bit_mask[idx] &
9553 str = flowtype_to_str(i);
9556 printf("Symmetric hash is %s globally for flow type %s "
9558 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9559 (1UL << offset)) ? "enabled" : "disabled"), str,
9564 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9565 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9566 get_hash_global_config, "get_hash_global_config");
9567 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9568 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9571 cmdline_parse_inst_t cmd_get_hash_global_config = {
9572 .f = cmd_get_hash_global_config_parsed,
9574 .help_str = "get_hash_global_config port_id",
9576 (void *)&cmd_get_hash_global_config_all,
9577 (void *)&cmd_get_hash_global_config_port_id,
9582 /* Set global config of hash function */
9583 struct cmd_set_hash_global_config_result {
9584 cmdline_fixed_string_t set_hash_global_config;
9586 cmdline_fixed_string_t hash_func;
9587 cmdline_fixed_string_t flow_type;
9588 cmdline_fixed_string_t enable;
9592 cmd_set_hash_global_config_parsed(void *parsed_result,
9593 __rte_unused struct cmdline *cl,
9594 __rte_unused void *data)
9596 struct cmd_set_hash_global_config_result *res = parsed_result;
9597 struct rte_eth_hash_filter_info info;
9598 uint32_t ftype, idx, offset;
9601 if (rte_eth_dev_filter_supported(res->port_id,
9602 RTE_ETH_FILTER_HASH) < 0) {
9603 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9607 memset(&info, 0, sizeof(info));
9608 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9609 if (!strcmp(res->hash_func, "toeplitz"))
9610 info.info.global_conf.hash_func =
9611 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9612 else if (!strcmp(res->hash_func, "simple_xor"))
9613 info.info.global_conf.hash_func =
9614 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9615 else if (!strcmp(res->hash_func, "default"))
9616 info.info.global_conf.hash_func =
9617 RTE_ETH_HASH_FUNCTION_DEFAULT;
9619 ftype = str2flowtype(res->flow_type);
9620 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9621 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9622 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9623 if (!strcmp(res->enable, "enable"))
9624 info.info.global_conf.sym_hash_enable_mask[idx] |=
9626 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9627 RTE_ETH_FILTER_SET, &info);
9629 printf("Cannot set global hash configurations by port %d\n",
9632 printf("Global hash configurations have been set "
9633 "succcessfully by port %d\n", res->port_id);
9636 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9637 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9638 set_hash_global_config, "set_hash_global_config");
9639 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9640 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9642 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9643 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9644 hash_func, "toeplitz#simple_xor#default");
9645 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9646 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9648 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9649 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9650 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9651 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9652 enable, "enable#disable");
9654 cmdline_parse_inst_t cmd_set_hash_global_config = {
9655 .f = cmd_set_hash_global_config_parsed,
9657 .help_str = "set_hash_global_config port_id "
9658 "toeplitz|simple_xor|default "
9659 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9660 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9663 (void *)&cmd_set_hash_global_config_all,
9664 (void *)&cmd_set_hash_global_config_port_id,
9665 (void *)&cmd_set_hash_global_config_hash_func,
9666 (void *)&cmd_set_hash_global_config_flow_type,
9667 (void *)&cmd_set_hash_global_config_enable,
9672 /* Set hash input set */
9673 struct cmd_set_hash_input_set_result {
9674 cmdline_fixed_string_t set_hash_input_set;
9676 cmdline_fixed_string_t flow_type;
9677 cmdline_fixed_string_t inset_field;
9678 cmdline_fixed_string_t select;
9681 static enum rte_eth_input_set_field
9682 str2inset(char *string)
9686 static const struct {
9688 enum rte_eth_input_set_field inset;
9690 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9691 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9692 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9693 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9694 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9695 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9696 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9697 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9698 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9699 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9700 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9701 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9702 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9703 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9704 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9705 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9706 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9707 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9708 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9709 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9710 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9711 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9712 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9713 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9714 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9715 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9716 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9717 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9718 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9719 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9720 {"none", RTE_ETH_INPUT_SET_NONE},
9723 for (i = 0; i < RTE_DIM(inset_table); i++) {
9724 if (!strcmp(string, inset_table[i].str))
9725 return inset_table[i].inset;
9728 return RTE_ETH_INPUT_SET_UNKNOWN;
9732 cmd_set_hash_input_set_parsed(void *parsed_result,
9733 __rte_unused struct cmdline *cl,
9734 __rte_unused void *data)
9736 struct cmd_set_hash_input_set_result *res = parsed_result;
9737 struct rte_eth_hash_filter_info info;
9739 memset(&info, 0, sizeof(info));
9740 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9741 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9742 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9743 info.info.input_set_conf.inset_size = 1;
9744 if (!strcmp(res->select, "select"))
9745 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9746 else if (!strcmp(res->select, "add"))
9747 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9748 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9749 RTE_ETH_FILTER_SET, &info);
9752 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9753 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9754 set_hash_input_set, "set_hash_input_set");
9755 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9756 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9758 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9759 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9761 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9762 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9763 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9764 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9766 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9767 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9768 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9769 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9770 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9772 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9773 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9774 select, "select#add");
9776 cmdline_parse_inst_t cmd_set_hash_input_set = {
9777 .f = cmd_set_hash_input_set_parsed,
9779 .help_str = "set_hash_input_set <port_id> "
9780 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9781 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9782 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9783 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9784 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9785 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9786 "fld-7th|fld-8th|none select|add",
9788 (void *)&cmd_set_hash_input_set_cmd,
9789 (void *)&cmd_set_hash_input_set_port_id,
9790 (void *)&cmd_set_hash_input_set_flow_type,
9791 (void *)&cmd_set_hash_input_set_field,
9792 (void *)&cmd_set_hash_input_set_select,
9797 /* Set flow director input set */
9798 struct cmd_set_fdir_input_set_result {
9799 cmdline_fixed_string_t set_fdir_input_set;
9801 cmdline_fixed_string_t flow_type;
9802 cmdline_fixed_string_t inset_field;
9803 cmdline_fixed_string_t select;
9807 cmd_set_fdir_input_set_parsed(void *parsed_result,
9808 __rte_unused struct cmdline *cl,
9809 __rte_unused void *data)
9811 struct cmd_set_fdir_input_set_result *res = parsed_result;
9812 struct rte_eth_fdir_filter_info info;
9814 memset(&info, 0, sizeof(info));
9815 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9816 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9817 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9818 info.info.input_set_conf.inset_size = 1;
9819 if (!strcmp(res->select, "select"))
9820 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9821 else if (!strcmp(res->select, "add"))
9822 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9823 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9824 RTE_ETH_FILTER_SET, &info);
9827 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9828 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9829 set_fdir_input_set, "set_fdir_input_set");
9830 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9831 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9833 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9834 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9836 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9837 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9838 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9839 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9841 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9842 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9843 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9844 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9845 "sctp-veri-tag#none");
9846 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9847 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9848 select, "select#add");
9850 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9851 .f = cmd_set_fdir_input_set_parsed,
9853 .help_str = "set_fdir_input_set <port_id> "
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 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9857 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9858 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9859 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9860 "sctp-veri-tag|none select|add",
9862 (void *)&cmd_set_fdir_input_set_cmd,
9863 (void *)&cmd_set_fdir_input_set_port_id,
9864 (void *)&cmd_set_fdir_input_set_flow_type,
9865 (void *)&cmd_set_fdir_input_set_field,
9866 (void *)&cmd_set_fdir_input_set_select,
9871 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9872 struct cmd_mcast_addr_result {
9873 cmdline_fixed_string_t mcast_addr_cmd;
9874 cmdline_fixed_string_t what;
9876 struct ether_addr mc_addr;
9879 static void cmd_mcast_addr_parsed(void *parsed_result,
9880 __attribute__((unused)) struct cmdline *cl,
9881 __attribute__((unused)) void *data)
9883 struct cmd_mcast_addr_result *res = parsed_result;
9885 if (!is_multicast_ether_addr(&res->mc_addr)) {
9886 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9887 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9888 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9889 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9892 if (strcmp(res->what, "add") == 0)
9893 mcast_addr_add(res->port_num, &res->mc_addr);
9895 mcast_addr_remove(res->port_num, &res->mc_addr);
9898 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9899 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9900 mcast_addr_cmd, "mcast_addr");
9901 cmdline_parse_token_string_t cmd_mcast_addr_what =
9902 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9904 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9905 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9906 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9907 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9909 cmdline_parse_inst_t cmd_mcast_addr = {
9910 .f = cmd_mcast_addr_parsed,
9912 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9914 (void *)&cmd_mcast_addr_cmd,
9915 (void *)&cmd_mcast_addr_what,
9916 (void *)&cmd_mcast_addr_portnum,
9917 (void *)&cmd_mcast_addr_addr,
9923 * only support E-tag now.
9926 /* Ether type config */
9927 struct cmd_config_l2_tunnel_eth_type_result {
9928 cmdline_fixed_string_t port;
9929 cmdline_fixed_string_t config;
9930 cmdline_fixed_string_t all;
9932 cmdline_fixed_string_t l2_tunnel;
9933 cmdline_fixed_string_t l2_tunnel_type;
9934 cmdline_fixed_string_t eth_type;
9935 uint16_t eth_type_val;
9938 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9939 TOKEN_STRING_INITIALIZER
9940 (struct cmd_config_l2_tunnel_eth_type_result,
9942 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9943 TOKEN_STRING_INITIALIZER
9944 (struct cmd_config_l2_tunnel_eth_type_result,
9946 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9947 TOKEN_STRING_INITIALIZER
9948 (struct cmd_config_l2_tunnel_eth_type_result,
9950 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9951 TOKEN_NUM_INITIALIZER
9952 (struct cmd_config_l2_tunnel_eth_type_result,
9954 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9955 TOKEN_STRING_INITIALIZER
9956 (struct cmd_config_l2_tunnel_eth_type_result,
9957 l2_tunnel, "l2-tunnel");
9958 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9959 TOKEN_STRING_INITIALIZER
9960 (struct cmd_config_l2_tunnel_eth_type_result,
9961 l2_tunnel_type, "E-tag");
9962 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9963 TOKEN_STRING_INITIALIZER
9964 (struct cmd_config_l2_tunnel_eth_type_result,
9965 eth_type, "ether-type");
9966 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9967 TOKEN_NUM_INITIALIZER
9968 (struct cmd_config_l2_tunnel_eth_type_result,
9969 eth_type_val, UINT16);
9971 static enum rte_eth_tunnel_type
9972 str2fdir_l2_tunnel_type(char *string)
9976 static const struct {
9978 enum rte_eth_tunnel_type type;
9979 } l2_tunnel_type_str[] = {
9980 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9983 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9984 if (!strcmp(l2_tunnel_type_str[i].str, string))
9985 return l2_tunnel_type_str[i].type;
9987 return RTE_TUNNEL_TYPE_NONE;
9990 /* ether type config for all ports */
9992 cmd_config_l2_tunnel_eth_type_all_parsed
9993 (void *parsed_result,
9994 __attribute__((unused)) struct cmdline *cl,
9995 __attribute__((unused)) void *data)
9997 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9998 struct rte_eth_l2_tunnel_conf entry;
10001 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10002 entry.ether_type = res->eth_type_val;
10004 FOREACH_PORT(pid, ports) {
10005 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10009 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10010 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10012 .help_str = "port config all l2-tunnel ether-type",
10014 (void *)&cmd_config_l2_tunnel_eth_type_port,
10015 (void *)&cmd_config_l2_tunnel_eth_type_config,
10016 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10017 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10018 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10019 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10020 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10025 /* ether type config for a specific port */
10027 cmd_config_l2_tunnel_eth_type_specific_parsed(
10028 void *parsed_result,
10029 __attribute__((unused)) struct cmdline *cl,
10030 __attribute__((unused)) void *data)
10032 struct cmd_config_l2_tunnel_eth_type_result *res =
10034 struct rte_eth_l2_tunnel_conf entry;
10036 if (port_id_is_invalid(res->id, ENABLED_WARN))
10039 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10040 entry.ether_type = res->eth_type_val;
10042 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10045 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10046 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10048 .help_str = "port config l2-tunnel ether-type",
10050 (void *)&cmd_config_l2_tunnel_eth_type_port,
10051 (void *)&cmd_config_l2_tunnel_eth_type_config,
10052 (void *)&cmd_config_l2_tunnel_eth_type_id,
10053 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10054 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10055 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10056 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10061 /* Enable/disable l2 tunnel */
10062 struct cmd_config_l2_tunnel_en_dis_result {
10063 cmdline_fixed_string_t port;
10064 cmdline_fixed_string_t config;
10065 cmdline_fixed_string_t all;
10067 cmdline_fixed_string_t l2_tunnel;
10068 cmdline_fixed_string_t l2_tunnel_type;
10069 cmdline_fixed_string_t en_dis;
10072 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10073 TOKEN_STRING_INITIALIZER
10074 (struct cmd_config_l2_tunnel_en_dis_result,
10076 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10077 TOKEN_STRING_INITIALIZER
10078 (struct cmd_config_l2_tunnel_en_dis_result,
10080 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10081 TOKEN_STRING_INITIALIZER
10082 (struct cmd_config_l2_tunnel_en_dis_result,
10084 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10085 TOKEN_NUM_INITIALIZER
10086 (struct cmd_config_l2_tunnel_en_dis_result,
10088 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10089 TOKEN_STRING_INITIALIZER
10090 (struct cmd_config_l2_tunnel_en_dis_result,
10091 l2_tunnel, "l2-tunnel");
10092 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10093 TOKEN_STRING_INITIALIZER
10094 (struct cmd_config_l2_tunnel_en_dis_result,
10095 l2_tunnel_type, "E-tag");
10096 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10097 TOKEN_STRING_INITIALIZER
10098 (struct cmd_config_l2_tunnel_en_dis_result,
10099 en_dis, "enable#disable");
10101 /* enable/disable l2 tunnel for all ports */
10103 cmd_config_l2_tunnel_en_dis_all_parsed(
10104 void *parsed_result,
10105 __attribute__((unused)) struct cmdline *cl,
10106 __attribute__((unused)) void *data)
10108 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10109 struct rte_eth_l2_tunnel_conf entry;
10113 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10115 if (!strcmp("enable", res->en_dis))
10120 FOREACH_PORT(pid, ports) {
10121 rte_eth_dev_l2_tunnel_offload_set(pid,
10123 ETH_L2_TUNNEL_ENABLE_MASK,
10128 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10129 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10131 .help_str = "port config all l2-tunnel enable/disable",
10133 (void *)&cmd_config_l2_tunnel_en_dis_port,
10134 (void *)&cmd_config_l2_tunnel_en_dis_config,
10135 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10136 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10137 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10138 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10143 /* enable/disable l2 tunnel for a port */
10145 cmd_config_l2_tunnel_en_dis_specific_parsed(
10146 void *parsed_result,
10147 __attribute__((unused)) struct cmdline *cl,
10148 __attribute__((unused)) void *data)
10150 struct cmd_config_l2_tunnel_en_dis_result *res =
10152 struct rte_eth_l2_tunnel_conf entry;
10154 if (port_id_is_invalid(res->id, ENABLED_WARN))
10157 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10159 if (!strcmp("enable", res->en_dis))
10160 rte_eth_dev_l2_tunnel_offload_set(res->id,
10162 ETH_L2_TUNNEL_ENABLE_MASK,
10165 rte_eth_dev_l2_tunnel_offload_set(res->id,
10167 ETH_L2_TUNNEL_ENABLE_MASK,
10171 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10172 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10174 .help_str = "port config l2-tunnel enable/disable",
10176 (void *)&cmd_config_l2_tunnel_en_dis_port,
10177 (void *)&cmd_config_l2_tunnel_en_dis_config,
10178 (void *)&cmd_config_l2_tunnel_en_dis_id,
10179 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10180 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10181 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10186 /* E-tag configuration */
10188 /* Common result structure for all E-tag configuration */
10189 struct cmd_config_e_tag_result {
10190 cmdline_fixed_string_t e_tag;
10191 cmdline_fixed_string_t set;
10192 cmdline_fixed_string_t insertion;
10193 cmdline_fixed_string_t stripping;
10194 cmdline_fixed_string_t forwarding;
10195 cmdline_fixed_string_t filter;
10196 cmdline_fixed_string_t add;
10197 cmdline_fixed_string_t del;
10198 cmdline_fixed_string_t on;
10199 cmdline_fixed_string_t off;
10200 cmdline_fixed_string_t on_off;
10201 cmdline_fixed_string_t port_tag_id;
10202 uint32_t port_tag_id_val;
10203 cmdline_fixed_string_t e_tag_id;
10204 uint16_t e_tag_id_val;
10205 cmdline_fixed_string_t dst_pool;
10206 uint8_t dst_pool_val;
10207 cmdline_fixed_string_t port;
10209 cmdline_fixed_string_t vf;
10213 /* Common CLI fields for all E-tag configuration */
10214 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10215 TOKEN_STRING_INITIALIZER
10216 (struct cmd_config_e_tag_result,
10218 cmdline_parse_token_string_t cmd_config_e_tag_set =
10219 TOKEN_STRING_INITIALIZER
10220 (struct cmd_config_e_tag_result,
10222 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10223 TOKEN_STRING_INITIALIZER
10224 (struct cmd_config_e_tag_result,
10225 insertion, "insertion");
10226 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10227 TOKEN_STRING_INITIALIZER
10228 (struct cmd_config_e_tag_result,
10229 stripping, "stripping");
10230 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10231 TOKEN_STRING_INITIALIZER
10232 (struct cmd_config_e_tag_result,
10233 forwarding, "forwarding");
10234 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10235 TOKEN_STRING_INITIALIZER
10236 (struct cmd_config_e_tag_result,
10238 cmdline_parse_token_string_t cmd_config_e_tag_add =
10239 TOKEN_STRING_INITIALIZER
10240 (struct cmd_config_e_tag_result,
10242 cmdline_parse_token_string_t cmd_config_e_tag_del =
10243 TOKEN_STRING_INITIALIZER
10244 (struct cmd_config_e_tag_result,
10246 cmdline_parse_token_string_t cmd_config_e_tag_on =
10247 TOKEN_STRING_INITIALIZER
10248 (struct cmd_config_e_tag_result,
10250 cmdline_parse_token_string_t cmd_config_e_tag_off =
10251 TOKEN_STRING_INITIALIZER
10252 (struct cmd_config_e_tag_result,
10254 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10255 TOKEN_STRING_INITIALIZER
10256 (struct cmd_config_e_tag_result,
10258 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10259 TOKEN_STRING_INITIALIZER
10260 (struct cmd_config_e_tag_result,
10261 port_tag_id, "port-tag-id");
10262 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10263 TOKEN_NUM_INITIALIZER
10264 (struct cmd_config_e_tag_result,
10265 port_tag_id_val, UINT32);
10266 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10267 TOKEN_STRING_INITIALIZER
10268 (struct cmd_config_e_tag_result,
10269 e_tag_id, "e-tag-id");
10270 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10271 TOKEN_NUM_INITIALIZER
10272 (struct cmd_config_e_tag_result,
10273 e_tag_id_val, UINT16);
10274 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10275 TOKEN_STRING_INITIALIZER
10276 (struct cmd_config_e_tag_result,
10277 dst_pool, "dst-pool");
10278 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10279 TOKEN_NUM_INITIALIZER
10280 (struct cmd_config_e_tag_result,
10281 dst_pool_val, UINT8);
10282 cmdline_parse_token_string_t cmd_config_e_tag_port =
10283 TOKEN_STRING_INITIALIZER
10284 (struct cmd_config_e_tag_result,
10286 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10287 TOKEN_NUM_INITIALIZER
10288 (struct cmd_config_e_tag_result,
10290 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10291 TOKEN_STRING_INITIALIZER
10292 (struct cmd_config_e_tag_result,
10294 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10295 TOKEN_NUM_INITIALIZER
10296 (struct cmd_config_e_tag_result,
10299 /* E-tag insertion configuration */
10301 cmd_config_e_tag_insertion_en_parsed(
10302 void *parsed_result,
10303 __attribute__((unused)) struct cmdline *cl,
10304 __attribute__((unused)) void *data)
10306 struct cmd_config_e_tag_result *res =
10308 struct rte_eth_l2_tunnel_conf entry;
10310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10313 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10314 entry.tunnel_id = res->port_tag_id_val;
10315 entry.vf_id = res->vf_id;
10316 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10318 ETH_L2_TUNNEL_INSERTION_MASK,
10323 cmd_config_e_tag_insertion_dis_parsed(
10324 void *parsed_result,
10325 __attribute__((unused)) struct cmdline *cl,
10326 __attribute__((unused)) void *data)
10328 struct cmd_config_e_tag_result *res =
10330 struct rte_eth_l2_tunnel_conf entry;
10332 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10335 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10336 entry.vf_id = res->vf_id;
10338 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10340 ETH_L2_TUNNEL_INSERTION_MASK,
10344 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10345 .f = cmd_config_e_tag_insertion_en_parsed,
10347 .help_str = "E-tag insertion enable",
10349 (void *)&cmd_config_e_tag_e_tag,
10350 (void *)&cmd_config_e_tag_set,
10351 (void *)&cmd_config_e_tag_insertion,
10352 (void *)&cmd_config_e_tag_on,
10353 (void *)&cmd_config_e_tag_port_tag_id,
10354 (void *)&cmd_config_e_tag_port_tag_id_val,
10355 (void *)&cmd_config_e_tag_port,
10356 (void *)&cmd_config_e_tag_port_id,
10357 (void *)&cmd_config_e_tag_vf,
10358 (void *)&cmd_config_e_tag_vf_id,
10363 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10364 .f = cmd_config_e_tag_insertion_dis_parsed,
10366 .help_str = "E-tag insertion disable",
10368 (void *)&cmd_config_e_tag_e_tag,
10369 (void *)&cmd_config_e_tag_set,
10370 (void *)&cmd_config_e_tag_insertion,
10371 (void *)&cmd_config_e_tag_off,
10372 (void *)&cmd_config_e_tag_port,
10373 (void *)&cmd_config_e_tag_port_id,
10374 (void *)&cmd_config_e_tag_vf,
10375 (void *)&cmd_config_e_tag_vf_id,
10380 /* E-tag stripping configuration */
10382 cmd_config_e_tag_stripping_parsed(
10383 void *parsed_result,
10384 __attribute__((unused)) struct cmdline *cl,
10385 __attribute__((unused)) void *data)
10387 struct cmd_config_e_tag_result *res =
10389 struct rte_eth_l2_tunnel_conf entry;
10391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10394 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10396 if (!strcmp(res->on_off, "on"))
10397 rte_eth_dev_l2_tunnel_offload_set
10400 ETH_L2_TUNNEL_STRIPPING_MASK,
10403 rte_eth_dev_l2_tunnel_offload_set
10406 ETH_L2_TUNNEL_STRIPPING_MASK,
10410 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10411 .f = cmd_config_e_tag_stripping_parsed,
10413 .help_str = "E-tag stripping enable/disable",
10415 (void *)&cmd_config_e_tag_e_tag,
10416 (void *)&cmd_config_e_tag_set,
10417 (void *)&cmd_config_e_tag_stripping,
10418 (void *)&cmd_config_e_tag_on_off,
10419 (void *)&cmd_config_e_tag_port,
10420 (void *)&cmd_config_e_tag_port_id,
10425 /* E-tag forwarding configuration */
10427 cmd_config_e_tag_forwarding_parsed(
10428 void *parsed_result,
10429 __attribute__((unused)) struct cmdline *cl,
10430 __attribute__((unused)) void *data)
10432 struct cmd_config_e_tag_result *res = parsed_result;
10433 struct rte_eth_l2_tunnel_conf entry;
10435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10438 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10440 if (!strcmp(res->on_off, "on"))
10441 rte_eth_dev_l2_tunnel_offload_set
10444 ETH_L2_TUNNEL_FORWARDING_MASK,
10447 rte_eth_dev_l2_tunnel_offload_set
10450 ETH_L2_TUNNEL_FORWARDING_MASK,
10454 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10455 .f = cmd_config_e_tag_forwarding_parsed,
10457 .help_str = "E-tag forwarding enable/disable",
10459 (void *)&cmd_config_e_tag_e_tag,
10460 (void *)&cmd_config_e_tag_set,
10461 (void *)&cmd_config_e_tag_forwarding,
10462 (void *)&cmd_config_e_tag_on_off,
10463 (void *)&cmd_config_e_tag_port,
10464 (void *)&cmd_config_e_tag_port_id,
10469 /* E-tag filter configuration */
10471 cmd_config_e_tag_filter_add_parsed(
10472 void *parsed_result,
10473 __attribute__((unused)) struct cmdline *cl,
10474 __attribute__((unused)) void *data)
10476 struct cmd_config_e_tag_result *res = parsed_result;
10477 struct rte_eth_l2_tunnel_conf entry;
10480 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10483 if (res->e_tag_id_val > 0x3fff) {
10484 printf("e-tag-id must be equal or less than 0x3fff.\n");
10488 ret = rte_eth_dev_filter_supported(res->port_id,
10489 RTE_ETH_FILTER_L2_TUNNEL);
10491 printf("E-tag filter is not supported on port %u.\n",
10496 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10497 entry.tunnel_id = res->e_tag_id_val;
10498 entry.pool = res->dst_pool_val;
10500 ret = rte_eth_dev_filter_ctrl(res->port_id,
10501 RTE_ETH_FILTER_L2_TUNNEL,
10502 RTE_ETH_FILTER_ADD,
10505 printf("E-tag filter programming error: (%s)\n",
10509 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10510 .f = cmd_config_e_tag_filter_add_parsed,
10512 .help_str = "E-tag filter add",
10514 (void *)&cmd_config_e_tag_e_tag,
10515 (void *)&cmd_config_e_tag_set,
10516 (void *)&cmd_config_e_tag_filter,
10517 (void *)&cmd_config_e_tag_add,
10518 (void *)&cmd_config_e_tag_e_tag_id,
10519 (void *)&cmd_config_e_tag_e_tag_id_val,
10520 (void *)&cmd_config_e_tag_dst_pool,
10521 (void *)&cmd_config_e_tag_dst_pool_val,
10522 (void *)&cmd_config_e_tag_port,
10523 (void *)&cmd_config_e_tag_port_id,
10529 cmd_config_e_tag_filter_del_parsed(
10530 void *parsed_result,
10531 __attribute__((unused)) struct cmdline *cl,
10532 __attribute__((unused)) void *data)
10534 struct cmd_config_e_tag_result *res = parsed_result;
10535 struct rte_eth_l2_tunnel_conf entry;
10538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10541 if (res->e_tag_id_val > 0x3fff) {
10542 printf("e-tag-id must be less than 0x3fff.\n");
10546 ret = rte_eth_dev_filter_supported(res->port_id,
10547 RTE_ETH_FILTER_L2_TUNNEL);
10549 printf("E-tag filter is not supported on port %u.\n",
10554 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10555 entry.tunnel_id = res->e_tag_id_val;
10557 ret = rte_eth_dev_filter_ctrl(res->port_id,
10558 RTE_ETH_FILTER_L2_TUNNEL,
10559 RTE_ETH_FILTER_DELETE,
10562 printf("E-tag filter programming error: (%s)\n",
10566 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10567 .f = cmd_config_e_tag_filter_del_parsed,
10569 .help_str = "E-tag filter delete",
10571 (void *)&cmd_config_e_tag_e_tag,
10572 (void *)&cmd_config_e_tag_set,
10573 (void *)&cmd_config_e_tag_filter,
10574 (void *)&cmd_config_e_tag_del,
10575 (void *)&cmd_config_e_tag_e_tag_id,
10576 (void *)&cmd_config_e_tag_e_tag_id_val,
10577 (void *)&cmd_config_e_tag_port,
10578 (void *)&cmd_config_e_tag_port_id,
10583 /* ******************************************************************************** */
10585 /* list of instructions */
10586 cmdline_parse_ctx_t main_ctx[] = {
10587 (cmdline_parse_inst_t *)&cmd_help_brief,
10588 (cmdline_parse_inst_t *)&cmd_help_long,
10589 (cmdline_parse_inst_t *)&cmd_quit,
10590 (cmdline_parse_inst_t *)&cmd_showport,
10591 (cmdline_parse_inst_t *)&cmd_showqueue,
10592 (cmdline_parse_inst_t *)&cmd_showportall,
10593 (cmdline_parse_inst_t *)&cmd_showcfg,
10594 (cmdline_parse_inst_t *)&cmd_start,
10595 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10596 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
10597 (cmdline_parse_inst_t *)&cmd_set_link_up,
10598 (cmdline_parse_inst_t *)&cmd_set_link_down,
10599 (cmdline_parse_inst_t *)&cmd_reset,
10600 (cmdline_parse_inst_t *)&cmd_set_numbers,
10601 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10602 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10603 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10604 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10605 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10606 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
10607 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10608 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10609 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10610 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10611 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10612 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10613 (cmdline_parse_inst_t *)&cmd_set_link_check,
10614 #ifdef RTE_NIC_BYPASS
10615 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10616 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10617 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10618 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10620 #ifdef RTE_LIBRTE_PMD_BOND
10621 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10622 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10623 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10624 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10625 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10626 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10627 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10628 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10629 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10631 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10632 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10633 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10634 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10635 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10636 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10637 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10638 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10639 (cmdline_parse_inst_t *)&cmd_csum_set,
10640 (cmdline_parse_inst_t *)&cmd_csum_show,
10641 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10642 (cmdline_parse_inst_t *)&cmd_tso_set,
10643 (cmdline_parse_inst_t *)&cmd_tso_show,
10644 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10645 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10646 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10647 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10648 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10649 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10650 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10651 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10652 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10653 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10654 (cmdline_parse_inst_t *)&cmd_config_dcb,
10655 (cmdline_parse_inst_t *)&cmd_read_reg,
10656 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10657 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10658 (cmdline_parse_inst_t *)&cmd_write_reg,
10659 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10660 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10661 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10662 (cmdline_parse_inst_t *)&cmd_stop,
10663 (cmdline_parse_inst_t *)&cmd_mac_addr,
10664 (cmdline_parse_inst_t *)&cmd_set_qmap,
10665 (cmdline_parse_inst_t *)&cmd_operate_port,
10666 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10667 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10668 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10669 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10670 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10671 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10672 (cmdline_parse_inst_t *)&cmd_config_mtu,
10673 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10674 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10675 (cmdline_parse_inst_t *)&cmd_config_rss,
10676 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10677 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10678 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10679 (cmdline_parse_inst_t *)&cmd_showport_reta,
10680 (cmdline_parse_inst_t *)&cmd_config_burst,
10681 (cmdline_parse_inst_t *)&cmd_config_thresh,
10682 (cmdline_parse_inst_t *)&cmd_config_threshold,
10683 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10684 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10685 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10686 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10687 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10688 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10689 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10690 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10691 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10692 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10693 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10694 (cmdline_parse_inst_t *)&cmd_global_config,
10695 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10696 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10697 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10698 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10699 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10700 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10701 (cmdline_parse_inst_t *)&cmd_dump,
10702 (cmdline_parse_inst_t *)&cmd_dump_one,
10703 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10704 (cmdline_parse_inst_t *)&cmd_syn_filter,
10705 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10706 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10707 (cmdline_parse_inst_t *)&cmd_flex_filter,
10708 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10709 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10710 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10711 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10712 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10713 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10714 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10715 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10716 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10717 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10718 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10719 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10720 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10721 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10722 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10723 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10724 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10725 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10726 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10727 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10728 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10729 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10730 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10731 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10732 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10733 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10734 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10735 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10736 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10740 /* prompt function, called from main on MASTER lcore */
10744 /* initialize non-constant commands */
10745 cmd_set_fwd_mode_init();
10746 cmd_set_fwd_retry_mode_init();
10748 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10749 if (testpmd_cl == NULL)
10751 cmdline_interact(testpmd_cl);
10752 cmdline_stdin_exit(testpmd_cl);
10758 if (testpmd_cl != NULL)
10759 cmdline_quit(testpmd_cl);
10763 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10765 if (id == (portid_t)RTE_PORT_ALL) {
10768 FOREACH_PORT(pid, ports) {
10769 /* check if need_reconfig has been set to 1 */
10770 if (ports[pid].need_reconfig == 0)
10771 ports[pid].need_reconfig = dev;
10772 /* check if need_reconfig_queues has been set to 1 */
10773 if (ports[pid].need_reconfig_queues == 0)
10774 ports[pid].need_reconfig_queues = queue;
10776 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10777 /* check if need_reconfig has been set to 1 */
10778 if (ports[id].need_reconfig == 0)
10779 ports[id].need_reconfig = dev;
10780 /* check if need_reconfig_queues has been set to 1 */
10781 if (ports[id].need_reconfig_queues == 0)
10782 ports[id].need_reconfig_queues = queue;
10786 #ifdef RTE_NIC_BYPASS
10787 #include <rte_pci_dev_ids.h>
10789 bypass_is_supported(portid_t port_id)
10791 struct rte_port *port;
10792 struct rte_pci_id *pci_id;
10794 if (port_id_is_invalid(port_id, ENABLED_WARN))
10797 /* Get the device id. */
10798 port = &ports[port_id];
10799 pci_id = &port->dev_info.pci_dev->id;
10801 /* Check if NIC supports bypass. */
10802 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10806 printf("\tBypass not supported for port_id = %d.\n", port_id);