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 " in mac_retry forwarding mode.\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|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|rx-cksum|hw-vlan|hw-vlan-filter|"
563 "hw-vlan-strip|hw-vlan-extend|drop-en)"
565 " Set crc-strip/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 cmd_config_speed_all_parsed(void *parsed_result,
993 __attribute__((unused)) struct cmdline *cl,
994 __attribute__((unused)) void *data)
996 struct cmd_config_speed_all *res = parsed_result;
997 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
998 uint16_t link_duplex = 0;
1001 if (!all_ports_stopped()) {
1002 printf("Please stop all ports first\n");
1006 if (!strcmp(res->value1, "10"))
1007 link_speed = ETH_LINK_SPEED_10;
1008 else if (!strcmp(res->value1, "100"))
1009 link_speed = ETH_LINK_SPEED_100;
1010 else if (!strcmp(res->value1, "1000"))
1011 link_speed = ETH_LINK_SPEED_1000;
1012 else if (!strcmp(res->value1, "10000"))
1013 link_speed = ETH_LINK_SPEED_10G;
1014 else if (!strcmp(res->value1, "40000"))
1015 link_speed = ETH_LINK_SPEED_40G;
1016 else if (!strcmp(res->value1, "auto"))
1017 link_speed = ETH_LINK_SPEED_AUTONEG;
1019 printf("Unknown parameter\n");
1023 if (!strcmp(res->value2, "half"))
1024 link_duplex = ETH_LINK_HALF_DUPLEX;
1025 else if (!strcmp(res->value2, "full"))
1026 link_duplex = ETH_LINK_FULL_DUPLEX;
1027 else if (!strcmp(res->value2, "auto"))
1028 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1030 printf("Unknown parameter\n");
1034 FOREACH_PORT(pid, ports) {
1035 ports[pid].dev_conf.link_speed = link_speed;
1036 ports[pid].dev_conf.link_duplex = link_duplex;
1039 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1042 cmdline_parse_token_string_t cmd_config_speed_all_port =
1043 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1044 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1045 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1047 cmdline_parse_token_string_t cmd_config_speed_all_all =
1048 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1049 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1051 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1052 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1053 "10#100#1000#10000#40000#auto");
1054 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1055 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1056 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1057 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1060 cmdline_parse_inst_t cmd_config_speed_all = {
1061 .f = cmd_config_speed_all_parsed,
1063 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1066 (void *)&cmd_config_speed_all_port,
1067 (void *)&cmd_config_speed_all_keyword,
1068 (void *)&cmd_config_speed_all_all,
1069 (void *)&cmd_config_speed_all_item1,
1070 (void *)&cmd_config_speed_all_value1,
1071 (void *)&cmd_config_speed_all_item2,
1072 (void *)&cmd_config_speed_all_value2,
1077 /* *** configure speed for specific port *** */
1078 struct cmd_config_speed_specific {
1079 cmdline_fixed_string_t port;
1080 cmdline_fixed_string_t keyword;
1082 cmdline_fixed_string_t item1;
1083 cmdline_fixed_string_t item2;
1084 cmdline_fixed_string_t value1;
1085 cmdline_fixed_string_t value2;
1089 cmd_config_speed_specific_parsed(void *parsed_result,
1090 __attribute__((unused)) struct cmdline *cl,
1091 __attribute__((unused)) void *data)
1093 struct cmd_config_speed_specific *res = parsed_result;
1094 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1095 uint16_t link_duplex = 0;
1097 if (!all_ports_stopped()) {
1098 printf("Please stop all ports first\n");
1102 if (port_id_is_invalid(res->id, ENABLED_WARN))
1105 if (!strcmp(res->value1, "10"))
1106 link_speed = ETH_LINK_SPEED_10;
1107 else if (!strcmp(res->value1, "100"))
1108 link_speed = ETH_LINK_SPEED_100;
1109 else if (!strcmp(res->value1, "1000"))
1110 link_speed = ETH_LINK_SPEED_1000;
1111 else if (!strcmp(res->value1, "10000"))
1112 link_speed = ETH_LINK_SPEED_10000;
1113 else if (!strcmp(res->value1, "40000"))
1114 link_speed = ETH_LINK_SPEED_40G;
1115 else if (!strcmp(res->value1, "auto"))
1116 link_speed = ETH_LINK_SPEED_AUTONEG;
1118 printf("Unknown parameter\n");
1122 if (!strcmp(res->value2, "half"))
1123 link_duplex = ETH_LINK_HALF_DUPLEX;
1124 else if (!strcmp(res->value2, "full"))
1125 link_duplex = ETH_LINK_FULL_DUPLEX;
1126 else if (!strcmp(res->value2, "auto"))
1127 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1129 printf("Unknown parameter\n");
1133 ports[res->id].dev_conf.link_speed = link_speed;
1134 ports[res->id].dev_conf.link_duplex = link_duplex;
1136 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1140 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1141 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1143 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1146 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1147 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1148 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1151 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1153 "10#100#1000#10000#40000#auto");
1154 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1157 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1161 cmdline_parse_inst_t cmd_config_speed_specific = {
1162 .f = cmd_config_speed_specific_parsed,
1164 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1167 (void *)&cmd_config_speed_specific_port,
1168 (void *)&cmd_config_speed_specific_keyword,
1169 (void *)&cmd_config_speed_specific_id,
1170 (void *)&cmd_config_speed_specific_item1,
1171 (void *)&cmd_config_speed_specific_value1,
1172 (void *)&cmd_config_speed_specific_item2,
1173 (void *)&cmd_config_speed_specific_value2,
1178 /* *** configure txq/rxq, txd/rxd *** */
1179 struct cmd_config_rx_tx {
1180 cmdline_fixed_string_t port;
1181 cmdline_fixed_string_t keyword;
1182 cmdline_fixed_string_t all;
1183 cmdline_fixed_string_t name;
1188 cmd_config_rx_tx_parsed(void *parsed_result,
1189 __attribute__((unused)) struct cmdline *cl,
1190 __attribute__((unused)) void *data)
1192 struct cmd_config_rx_tx *res = parsed_result;
1194 if (!all_ports_stopped()) {
1195 printf("Please stop all ports first\n");
1198 if (!strcmp(res->name, "rxq")) {
1199 if (!res->value && !nb_txq) {
1200 printf("Warning: Either rx or tx queues should be non zero\n");
1203 nb_rxq = res->value;
1205 else if (!strcmp(res->name, "txq")) {
1206 if (!res->value && !nb_rxq) {
1207 printf("Warning: Either rx or tx queues should be non zero\n");
1210 nb_txq = res->value;
1212 else if (!strcmp(res->name, "rxd")) {
1213 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1214 printf("rxd %d invalid - must be > 0 && <= %d\n",
1215 res->value, RTE_TEST_RX_DESC_MAX);
1218 nb_rxd = res->value;
1219 } else if (!strcmp(res->name, "txd")) {
1220 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1221 printf("txd %d invalid - must be > 0 && <= %d\n",
1222 res->value, RTE_TEST_TX_DESC_MAX);
1225 nb_txd = res->value;
1227 printf("Unknown parameter\n");
1233 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1236 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1238 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1239 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1240 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1241 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1242 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1245 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1246 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1248 cmdline_parse_inst_t cmd_config_rx_tx = {
1249 .f = cmd_config_rx_tx_parsed,
1251 .help_str = "port config all rxq|txq|rxd|txd value",
1253 (void *)&cmd_config_rx_tx_port,
1254 (void *)&cmd_config_rx_tx_keyword,
1255 (void *)&cmd_config_rx_tx_all,
1256 (void *)&cmd_config_rx_tx_name,
1257 (void *)&cmd_config_rx_tx_value,
1262 /* *** config max packet length *** */
1263 struct cmd_config_max_pkt_len_result {
1264 cmdline_fixed_string_t port;
1265 cmdline_fixed_string_t keyword;
1266 cmdline_fixed_string_t all;
1267 cmdline_fixed_string_t name;
1272 cmd_config_max_pkt_len_parsed(void *parsed_result,
1273 __attribute__((unused)) struct cmdline *cl,
1274 __attribute__((unused)) void *data)
1276 struct cmd_config_max_pkt_len_result *res = parsed_result;
1278 if (!all_ports_stopped()) {
1279 printf("Please stop all ports first\n");
1283 if (!strcmp(res->name, "max-pkt-len")) {
1284 if (res->value < ETHER_MIN_LEN) {
1285 printf("max-pkt-len can not be less than %d\n",
1289 if (res->value == rx_mode.max_rx_pkt_len)
1292 rx_mode.max_rx_pkt_len = res->value;
1293 if (res->value > ETHER_MAX_LEN)
1294 rx_mode.jumbo_frame = 1;
1296 rx_mode.jumbo_frame = 0;
1298 printf("Unknown parameter\n");
1304 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1307 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1308 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1310 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1313 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1314 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1316 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1317 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1319 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1320 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1323 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1324 .f = cmd_config_max_pkt_len_parsed,
1326 .help_str = "port config all max-pkt-len value",
1328 (void *)&cmd_config_max_pkt_len_port,
1329 (void *)&cmd_config_max_pkt_len_keyword,
1330 (void *)&cmd_config_max_pkt_len_all,
1331 (void *)&cmd_config_max_pkt_len_name,
1332 (void *)&cmd_config_max_pkt_len_value,
1337 /* *** configure port MTU *** */
1338 struct cmd_config_mtu_result {
1339 cmdline_fixed_string_t port;
1340 cmdline_fixed_string_t keyword;
1341 cmdline_fixed_string_t mtu;
1347 cmd_config_mtu_parsed(void *parsed_result,
1348 __attribute__((unused)) struct cmdline *cl,
1349 __attribute__((unused)) void *data)
1351 struct cmd_config_mtu_result *res = parsed_result;
1353 if (res->value < ETHER_MIN_LEN) {
1354 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1357 port_mtu_set(res->port_id, res->value);
1360 cmdline_parse_token_string_t cmd_config_mtu_port =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1363 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1364 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1366 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1367 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1369 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1370 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1371 cmdline_parse_token_num_t cmd_config_mtu_value =
1372 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1374 cmdline_parse_inst_t cmd_config_mtu = {
1375 .f = cmd_config_mtu_parsed,
1377 .help_str = "port config mtu value",
1379 (void *)&cmd_config_mtu_port,
1380 (void *)&cmd_config_mtu_keyword,
1381 (void *)&cmd_config_mtu_mtu,
1382 (void *)&cmd_config_mtu_port_id,
1383 (void *)&cmd_config_mtu_value,
1388 /* *** configure rx mode *** */
1389 struct cmd_config_rx_mode_flag {
1390 cmdline_fixed_string_t port;
1391 cmdline_fixed_string_t keyword;
1392 cmdline_fixed_string_t all;
1393 cmdline_fixed_string_t name;
1394 cmdline_fixed_string_t value;
1398 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1399 __attribute__((unused)) struct cmdline *cl,
1400 __attribute__((unused)) void *data)
1402 struct cmd_config_rx_mode_flag *res = parsed_result;
1404 if (!all_ports_stopped()) {
1405 printf("Please stop all ports first\n");
1409 if (!strcmp(res->name, "crc-strip")) {
1410 if (!strcmp(res->value, "on"))
1411 rx_mode.hw_strip_crc = 1;
1412 else if (!strcmp(res->value, "off"))
1413 rx_mode.hw_strip_crc = 0;
1415 printf("Unknown parameter\n");
1418 } else if (!strcmp(res->name, "rx-cksum")) {
1419 if (!strcmp(res->value, "on"))
1420 rx_mode.hw_ip_checksum = 1;
1421 else if (!strcmp(res->value, "off"))
1422 rx_mode.hw_ip_checksum = 0;
1424 printf("Unknown parameter\n");
1427 } else if (!strcmp(res->name, "hw-vlan")) {
1428 if (!strcmp(res->value, "on")) {
1429 rx_mode.hw_vlan_filter = 1;
1430 rx_mode.hw_vlan_strip = 1;
1432 else if (!strcmp(res->value, "off")) {
1433 rx_mode.hw_vlan_filter = 0;
1434 rx_mode.hw_vlan_strip = 0;
1437 printf("Unknown parameter\n");
1440 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1441 if (!strcmp(res->value, "on"))
1442 rx_mode.hw_vlan_filter = 1;
1443 else if (!strcmp(res->value, "off"))
1444 rx_mode.hw_vlan_filter = 0;
1446 printf("Unknown parameter\n");
1449 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1450 if (!strcmp(res->value, "on"))
1451 rx_mode.hw_vlan_strip = 1;
1452 else if (!strcmp(res->value, "off"))
1453 rx_mode.hw_vlan_strip = 0;
1455 printf("Unknown parameter\n");
1458 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1459 if (!strcmp(res->value, "on"))
1460 rx_mode.hw_vlan_extend = 1;
1461 else if (!strcmp(res->value, "off"))
1462 rx_mode.hw_vlan_extend = 0;
1464 printf("Unknown parameter\n");
1467 } else if (!strcmp(res->name, "drop-en")) {
1468 if (!strcmp(res->value, "on"))
1470 else if (!strcmp(res->value, "off"))
1473 printf("Unknown parameter\n");
1477 printf("Unknown parameter\n");
1483 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1486 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1488 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1491 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1493 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1495 "crc-strip#rx-cksum#hw-vlan#"
1496 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1497 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1501 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1502 .f = cmd_config_rx_mode_flag_parsed,
1504 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1505 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1507 (void *)&cmd_config_rx_mode_flag_port,
1508 (void *)&cmd_config_rx_mode_flag_keyword,
1509 (void *)&cmd_config_rx_mode_flag_all,
1510 (void *)&cmd_config_rx_mode_flag_name,
1511 (void *)&cmd_config_rx_mode_flag_value,
1516 /* *** configure rss *** */
1517 struct cmd_config_rss {
1518 cmdline_fixed_string_t port;
1519 cmdline_fixed_string_t keyword;
1520 cmdline_fixed_string_t all;
1521 cmdline_fixed_string_t name;
1522 cmdline_fixed_string_t value;
1526 cmd_config_rss_parsed(void *parsed_result,
1527 __attribute__((unused)) struct cmdline *cl,
1528 __attribute__((unused)) void *data)
1530 struct cmd_config_rss *res = parsed_result;
1531 struct rte_eth_rss_conf rss_conf;
1534 if (!strcmp(res->value, "all"))
1535 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1536 ETH_RSS_UDP | ETH_RSS_SCTP |
1538 else if (!strcmp(res->value, "ip"))
1539 rss_conf.rss_hf = ETH_RSS_IP;
1540 else if (!strcmp(res->value, "udp"))
1541 rss_conf.rss_hf = ETH_RSS_UDP;
1542 else if (!strcmp(res->value, "tcp"))
1543 rss_conf.rss_hf = ETH_RSS_TCP;
1544 else if (!strcmp(res->value, "sctp"))
1545 rss_conf.rss_hf = ETH_RSS_SCTP;
1546 else if (!strcmp(res->value, "ether"))
1547 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1548 else if (!strcmp(res->value, "none"))
1549 rss_conf.rss_hf = 0;
1551 printf("Unknown parameter\n");
1554 rss_conf.rss_key = NULL;
1555 for (i = 0; i < rte_eth_dev_count(); i++)
1556 rte_eth_dev_rss_hash_update(i, &rss_conf);
1559 cmdline_parse_token_string_t cmd_config_rss_port =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1561 cmdline_parse_token_string_t cmd_config_rss_keyword =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1563 cmdline_parse_token_string_t cmd_config_rss_all =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1565 cmdline_parse_token_string_t cmd_config_rss_name =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1567 cmdline_parse_token_string_t cmd_config_rss_value =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1569 "all#ip#tcp#udp#sctp#ether#none");
1571 cmdline_parse_inst_t cmd_config_rss = {
1572 .f = cmd_config_rss_parsed,
1574 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1576 (void *)&cmd_config_rss_port,
1577 (void *)&cmd_config_rss_keyword,
1578 (void *)&cmd_config_rss_all,
1579 (void *)&cmd_config_rss_name,
1580 (void *)&cmd_config_rss_value,
1585 /* *** configure rss hash key *** */
1586 struct cmd_config_rss_hash_key {
1587 cmdline_fixed_string_t port;
1588 cmdline_fixed_string_t config;
1590 cmdline_fixed_string_t rss_hash_key;
1591 cmdline_fixed_string_t rss_type;
1592 cmdline_fixed_string_t key;
1595 #define RSS_HASH_KEY_LENGTH 40
1597 hexa_digit_to_value(char hexa_digit)
1599 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1600 return (uint8_t) (hexa_digit - '0');
1601 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1602 return (uint8_t) ((hexa_digit - 'a') + 10);
1603 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1604 return (uint8_t) ((hexa_digit - 'A') + 10);
1605 /* Invalid hexa digit */
1610 parse_and_check_key_hexa_digit(char *key, int idx)
1614 hexa_v = hexa_digit_to_value(key[idx]);
1616 printf("invalid key: character %c at position %d is not a "
1617 "valid hexa digit\n", key[idx], idx);
1622 cmd_config_rss_hash_key_parsed(void *parsed_result,
1623 __attribute__((unused)) struct cmdline *cl,
1624 __attribute__((unused)) void *data)
1626 struct cmd_config_rss_hash_key *res = parsed_result;
1627 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1632 /* Check the length of the RSS hash key */
1633 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1634 printf("key length: %d invalid - key must be a string of %d"
1635 "hexa-decimal numbers\n", (int) strlen(res->key),
1636 RSS_HASH_KEY_LENGTH * 2);
1639 /* Translate RSS hash key into binary representation */
1640 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1641 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1644 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1647 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1649 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1650 RSS_HASH_KEY_LENGTH);
1653 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1655 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1658 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1659 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1660 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1662 rss_hash_key, "rss-hash-key");
1663 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1665 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1666 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1667 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1668 "ipv6-tcp-ex#ipv6-udp-ex");
1669 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1672 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1673 .f = cmd_config_rss_hash_key_parsed,
1676 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1677 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1678 "ipv6-sctp|ipv6-other|l2-payload|"
1679 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1681 (void *)&cmd_config_rss_hash_key_port,
1682 (void *)&cmd_config_rss_hash_key_config,
1683 (void *)&cmd_config_rss_hash_key_port_id,
1684 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1685 (void *)&cmd_config_rss_hash_key_rss_type,
1686 (void *)&cmd_config_rss_hash_key_value,
1691 /* *** configure port rxq/txq start/stop *** */
1692 struct cmd_config_rxtx_queue {
1693 cmdline_fixed_string_t port;
1695 cmdline_fixed_string_t rxtxq;
1697 cmdline_fixed_string_t opname;
1701 cmd_config_rxtx_queue_parsed(void *parsed_result,
1702 __attribute__((unused)) struct cmdline *cl,
1703 __attribute__((unused)) void *data)
1705 struct cmd_config_rxtx_queue *res = parsed_result;
1710 if (test_done == 0) {
1711 printf("Please stop forwarding first\n");
1715 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1718 if (port_is_started(res->portid) != 1) {
1719 printf("Please start port %u first\n", res->portid);
1723 if (!strcmp(res->rxtxq, "rxq"))
1725 else if (!strcmp(res->rxtxq, "txq"))
1728 printf("Unknown parameter\n");
1732 if (isrx && rx_queue_id_is_invalid(res->qid))
1734 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1737 if (!strcmp(res->opname, "start"))
1739 else if (!strcmp(res->opname, "stop"))
1742 printf("Unknown parameter\n");
1746 if (isstart && isrx)
1747 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1748 else if (!isstart && isrx)
1749 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1750 else if (isstart && !isrx)
1751 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1753 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1755 if (ret == -ENOTSUP)
1756 printf("Function not supported in PMD driver\n");
1759 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1761 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1762 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1763 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1765 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1766 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1767 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1771 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1772 .f = cmd_config_rxtx_queue_parsed,
1774 .help_str = "port X rxq|txq ID start|stop",
1776 (void *)&cmd_config_speed_all_port,
1777 (void *)&cmd_config_rxtx_queue_portid,
1778 (void *)&cmd_config_rxtx_queue_rxtxq,
1779 (void *)&cmd_config_rxtx_queue_qid,
1780 (void *)&cmd_config_rxtx_queue_opname,
1785 /* *** Configure RSS RETA *** */
1786 struct cmd_config_rss_reta {
1787 cmdline_fixed_string_t port;
1788 cmdline_fixed_string_t keyword;
1790 cmdline_fixed_string_t name;
1791 cmdline_fixed_string_t list_name;
1792 cmdline_fixed_string_t list_of_items;
1796 parse_reta_config(const char *str,
1797 struct rte_eth_rss_reta_entry64 *reta_conf,
1798 uint16_t nb_entries)
1802 uint16_t hash_index, idx, shift;
1805 const char *p, *p0 = str;
1812 unsigned long int_fld[_NUM_FLD];
1813 char *str_fld[_NUM_FLD];
1815 while ((p = strchr(p0,'(')) != NULL) {
1817 if((p0 = strchr(p,')')) == NULL)
1821 if(size >= sizeof(s))
1824 snprintf(s, sizeof(s), "%.*s", size, p);
1825 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1827 for (i = 0; i < _NUM_FLD; i++) {
1829 int_fld[i] = strtoul(str_fld[i], &end, 0);
1830 if (errno != 0 || end == str_fld[i] ||
1835 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1836 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1838 if (hash_index >= nb_entries) {
1839 printf("Invalid RETA hash index=%d\n", hash_index);
1843 idx = hash_index / RTE_RETA_GROUP_SIZE;
1844 shift = hash_index % RTE_RETA_GROUP_SIZE;
1845 reta_conf[idx].mask |= (1ULL << shift);
1846 reta_conf[idx].reta[shift] = nb_queue;
1853 cmd_set_rss_reta_parsed(void *parsed_result,
1854 __attribute__((unused)) struct cmdline *cl,
1855 __attribute__((unused)) void *data)
1858 struct rte_eth_dev_info dev_info;
1859 struct rte_eth_rss_reta_entry64 reta_conf[8];
1860 struct cmd_config_rss_reta *res = parsed_result;
1862 memset(&dev_info, 0, sizeof(dev_info));
1863 rte_eth_dev_info_get(res->port_id, &dev_info);
1864 if (dev_info.reta_size == 0) {
1865 printf("Redirection table size is 0 which is "
1866 "invalid for RSS\n");
1869 printf("The reta size of port %d is %u\n",
1870 res->port_id, dev_info.reta_size);
1871 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1872 printf("Currently do not support more than %u entries of "
1873 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1877 memset(reta_conf, 0, sizeof(reta_conf));
1878 if (!strcmp(res->list_name, "reta")) {
1879 if (parse_reta_config(res->list_of_items, reta_conf,
1880 dev_info.reta_size)) {
1881 printf("Invalid RSS Redirection Table "
1882 "config entered\n");
1885 ret = rte_eth_dev_rss_reta_update(res->port_id,
1886 reta_conf, dev_info.reta_size);
1888 printf("Bad redirection table parameter, "
1889 "return code = %d \n", ret);
1893 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1895 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1896 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1897 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1898 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1899 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1901 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1903 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1904 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1906 cmdline_parse_inst_t cmd_config_rss_reta = {
1907 .f = cmd_set_rss_reta_parsed,
1909 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1911 (void *)&cmd_config_rss_reta_port,
1912 (void *)&cmd_config_rss_reta_keyword,
1913 (void *)&cmd_config_rss_reta_port_id,
1914 (void *)&cmd_config_rss_reta_name,
1915 (void *)&cmd_config_rss_reta_list_name,
1916 (void *)&cmd_config_rss_reta_list_of_items,
1921 /* *** SHOW PORT RETA INFO *** */
1922 struct cmd_showport_reta {
1923 cmdline_fixed_string_t show;
1924 cmdline_fixed_string_t port;
1926 cmdline_fixed_string_t rss;
1927 cmdline_fixed_string_t reta;
1929 cmdline_fixed_string_t list_of_items;
1933 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1934 uint16_t nb_entries,
1938 const char *p, *p0 = str;
1942 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1945 p = strchr(p0, '(');
1949 p0 = strchr(p, ')');
1953 if (size >= sizeof(s)) {
1954 printf("The string size exceeds the internal buffer size\n");
1957 snprintf(s, sizeof(s), "%.*s", size, p);
1958 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1959 if (ret <= 0 || ret != num) {
1960 printf("The bits of masks do not match the number of "
1961 "reta entries: %u\n", num);
1964 for (i = 0; i < ret; i++)
1965 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1971 cmd_showport_reta_parsed(void *parsed_result,
1972 __attribute__((unused)) struct cmdline *cl,
1973 __attribute__((unused)) void *data)
1975 struct cmd_showport_reta *res = parsed_result;
1976 struct rte_eth_rss_reta_entry64 reta_conf[8];
1977 struct rte_eth_dev_info dev_info;
1979 memset(&dev_info, 0, sizeof(dev_info));
1980 rte_eth_dev_info_get(res->port_id, &dev_info);
1981 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1982 res->size > ETH_RSS_RETA_SIZE_512) {
1983 printf("Invalid redirection table size: %u\n", res->size);
1987 memset(reta_conf, 0, sizeof(reta_conf));
1988 if (showport_parse_reta_config(reta_conf, res->size,
1989 res->list_of_items) < 0) {
1990 printf("Invalid string: %s for reta masks\n",
1991 res->list_of_items);
1994 port_rss_reta_info(res->port_id, reta_conf, res->size);
1997 cmdline_parse_token_string_t cmd_showport_reta_show =
1998 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1999 cmdline_parse_token_string_t cmd_showport_reta_port =
2000 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2001 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2002 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2003 cmdline_parse_token_string_t cmd_showport_reta_rss =
2004 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2005 cmdline_parse_token_string_t cmd_showport_reta_reta =
2006 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2007 cmdline_parse_token_num_t cmd_showport_reta_size =
2008 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2009 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2010 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2011 list_of_items, NULL);
2013 cmdline_parse_inst_t cmd_showport_reta = {
2014 .f = cmd_showport_reta_parsed,
2016 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2018 (void *)&cmd_showport_reta_show,
2019 (void *)&cmd_showport_reta_port,
2020 (void *)&cmd_showport_reta_port_id,
2021 (void *)&cmd_showport_reta_rss,
2022 (void *)&cmd_showport_reta_reta,
2023 (void *)&cmd_showport_reta_size,
2024 (void *)&cmd_showport_reta_list_of_items,
2029 /* *** Show RSS hash configuration *** */
2030 struct cmd_showport_rss_hash {
2031 cmdline_fixed_string_t show;
2032 cmdline_fixed_string_t port;
2034 cmdline_fixed_string_t rss_hash;
2035 cmdline_fixed_string_t rss_type;
2036 cmdline_fixed_string_t key; /* optional argument */
2039 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2040 __attribute__((unused)) struct cmdline *cl,
2043 struct cmd_showport_rss_hash *res = parsed_result;
2045 port_rss_hash_conf_show(res->port_id, res->rss_type,
2046 show_rss_key != NULL);
2049 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2050 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2051 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2052 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2053 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2054 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2055 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2056 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2058 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2059 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2060 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2061 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2062 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2063 "ipv6-tcp-ex#ipv6-udp-ex");
2064 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2065 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2067 cmdline_parse_inst_t cmd_showport_rss_hash = {
2068 .f = cmd_showport_rss_hash_parsed,
2071 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2072 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2073 "ipv6-sctp|ipv6-other|l2-payload|"
2074 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2076 (void *)&cmd_showport_rss_hash_show,
2077 (void *)&cmd_showport_rss_hash_port,
2078 (void *)&cmd_showport_rss_hash_port_id,
2079 (void *)&cmd_showport_rss_hash_rss_hash,
2080 (void *)&cmd_showport_rss_hash_rss_hash_info,
2085 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2086 .f = cmd_showport_rss_hash_parsed,
2089 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2090 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2091 "ipv6-sctp|ipv6-other|l2-payload|"
2092 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2094 (void *)&cmd_showport_rss_hash_show,
2095 (void *)&cmd_showport_rss_hash_port,
2096 (void *)&cmd_showport_rss_hash_port_id,
2097 (void *)&cmd_showport_rss_hash_rss_hash,
2098 (void *)&cmd_showport_rss_hash_rss_hash_info,
2099 (void *)&cmd_showport_rss_hash_rss_key,
2104 /* *** Configure DCB *** */
2105 struct cmd_config_dcb {
2106 cmdline_fixed_string_t port;
2107 cmdline_fixed_string_t config;
2109 cmdline_fixed_string_t dcb;
2110 cmdline_fixed_string_t vt;
2111 cmdline_fixed_string_t vt_en;
2113 cmdline_fixed_string_t pfc;
2114 cmdline_fixed_string_t pfc_en;
2118 cmd_config_dcb_parsed(void *parsed_result,
2119 __attribute__((unused)) struct cmdline *cl,
2120 __attribute__((unused)) void *data)
2122 struct cmd_config_dcb *res = parsed_result;
2123 portid_t port_id = res->port_id;
2124 struct rte_port *port;
2128 port = &ports[port_id];
2129 /** Check if the port is not started **/
2130 if (port->port_status != RTE_PORT_STOPPED) {
2131 printf("Please stop port %d first\n", port_id);
2135 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2136 printf("The invalid number of traffic class,"
2137 " only 4 or 8 allowed.\n");
2141 if (nb_fwd_lcores < res->num_tcs) {
2142 printf("nb_cores shouldn't be less than number of TCs.\n");
2145 if (!strncmp(res->pfc_en, "on", 2))
2150 /* DCB in VT mode */
2151 if (!strncmp(res->vt_en, "on", 2))
2152 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2153 (enum rte_eth_nb_tcs)res->num_tcs,
2156 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2157 (enum rte_eth_nb_tcs)res->num_tcs,
2162 printf("Cannot initialize network ports.\n");
2166 cmd_reconfig_device_queue(port_id, 1, 1);
2169 cmdline_parse_token_string_t cmd_config_dcb_port =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2171 cmdline_parse_token_string_t cmd_config_dcb_config =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2173 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2174 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2175 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2177 cmdline_parse_token_string_t cmd_config_dcb_vt =
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2179 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2181 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2182 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2183 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2185 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2188 cmdline_parse_inst_t cmd_config_dcb = {
2189 .f = cmd_config_dcb_parsed,
2191 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2193 (void *)&cmd_config_dcb_port,
2194 (void *)&cmd_config_dcb_config,
2195 (void *)&cmd_config_dcb_port_id,
2196 (void *)&cmd_config_dcb_dcb,
2197 (void *)&cmd_config_dcb_vt,
2198 (void *)&cmd_config_dcb_vt_en,
2199 (void *)&cmd_config_dcb_num_tcs,
2200 (void *)&cmd_config_dcb_pfc,
2201 (void *)&cmd_config_dcb_pfc_en,
2206 /* *** configure number of packets per burst *** */
2207 struct cmd_config_burst {
2208 cmdline_fixed_string_t port;
2209 cmdline_fixed_string_t keyword;
2210 cmdline_fixed_string_t all;
2211 cmdline_fixed_string_t name;
2216 cmd_config_burst_parsed(void *parsed_result,
2217 __attribute__((unused)) struct cmdline *cl,
2218 __attribute__((unused)) void *data)
2220 struct cmd_config_burst *res = parsed_result;
2222 if (!all_ports_stopped()) {
2223 printf("Please stop all ports first\n");
2227 if (!strcmp(res->name, "burst")) {
2228 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2229 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2232 nb_pkt_per_burst = res->value;
2234 printf("Unknown parameter\n");
2240 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2243 cmdline_parse_token_string_t cmd_config_burst_port =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2245 cmdline_parse_token_string_t cmd_config_burst_keyword =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2247 cmdline_parse_token_string_t cmd_config_burst_all =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2249 cmdline_parse_token_string_t cmd_config_burst_name =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2251 cmdline_parse_token_num_t cmd_config_burst_value =
2252 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2254 cmdline_parse_inst_t cmd_config_burst = {
2255 .f = cmd_config_burst_parsed,
2257 .help_str = "port config all burst value",
2259 (void *)&cmd_config_burst_port,
2260 (void *)&cmd_config_burst_keyword,
2261 (void *)&cmd_config_burst_all,
2262 (void *)&cmd_config_burst_name,
2263 (void *)&cmd_config_burst_value,
2268 /* *** configure rx/tx queues *** */
2269 struct cmd_config_thresh {
2270 cmdline_fixed_string_t port;
2271 cmdline_fixed_string_t keyword;
2272 cmdline_fixed_string_t all;
2273 cmdline_fixed_string_t name;
2278 cmd_config_thresh_parsed(void *parsed_result,
2279 __attribute__((unused)) struct cmdline *cl,
2280 __attribute__((unused)) void *data)
2282 struct cmd_config_thresh *res = parsed_result;
2284 if (!all_ports_stopped()) {
2285 printf("Please stop all ports first\n");
2289 if (!strcmp(res->name, "txpt"))
2290 tx_pthresh = res->value;
2291 else if(!strcmp(res->name, "txht"))
2292 tx_hthresh = res->value;
2293 else if(!strcmp(res->name, "txwt"))
2294 tx_wthresh = res->value;
2295 else if(!strcmp(res->name, "rxpt"))
2296 rx_pthresh = res->value;
2297 else if(!strcmp(res->name, "rxht"))
2298 rx_hthresh = res->value;
2299 else if(!strcmp(res->name, "rxwt"))
2300 rx_wthresh = res->value;
2302 printf("Unknown parameter\n");
2308 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2311 cmdline_parse_token_string_t cmd_config_thresh_port =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2313 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2315 cmdline_parse_token_string_t cmd_config_thresh_all =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2317 cmdline_parse_token_string_t cmd_config_thresh_name =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2319 "txpt#txht#txwt#rxpt#rxht#rxwt");
2320 cmdline_parse_token_num_t cmd_config_thresh_value =
2321 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2323 cmdline_parse_inst_t cmd_config_thresh = {
2324 .f = cmd_config_thresh_parsed,
2326 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2328 (void *)&cmd_config_thresh_port,
2329 (void *)&cmd_config_thresh_keyword,
2330 (void *)&cmd_config_thresh_all,
2331 (void *)&cmd_config_thresh_name,
2332 (void *)&cmd_config_thresh_value,
2337 /* *** configure free/rs threshold *** */
2338 struct cmd_config_threshold {
2339 cmdline_fixed_string_t port;
2340 cmdline_fixed_string_t keyword;
2341 cmdline_fixed_string_t all;
2342 cmdline_fixed_string_t name;
2347 cmd_config_threshold_parsed(void *parsed_result,
2348 __attribute__((unused)) struct cmdline *cl,
2349 __attribute__((unused)) void *data)
2351 struct cmd_config_threshold *res = parsed_result;
2353 if (!all_ports_stopped()) {
2354 printf("Please stop all ports first\n");
2358 if (!strcmp(res->name, "txfreet"))
2359 tx_free_thresh = res->value;
2360 else if (!strcmp(res->name, "txrst"))
2361 tx_rs_thresh = res->value;
2362 else if (!strcmp(res->name, "rxfreet"))
2363 rx_free_thresh = res->value;
2365 printf("Unknown parameter\n");
2371 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2374 cmdline_parse_token_string_t cmd_config_threshold_port =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2376 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2379 cmdline_parse_token_string_t cmd_config_threshold_all =
2380 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2381 cmdline_parse_token_string_t cmd_config_threshold_name =
2382 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2383 "txfreet#txrst#rxfreet");
2384 cmdline_parse_token_num_t cmd_config_threshold_value =
2385 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2387 cmdline_parse_inst_t cmd_config_threshold = {
2388 .f = cmd_config_threshold_parsed,
2390 .help_str = "port config all txfreet|txrst|rxfreet value",
2392 (void *)&cmd_config_threshold_port,
2393 (void *)&cmd_config_threshold_keyword,
2394 (void *)&cmd_config_threshold_all,
2395 (void *)&cmd_config_threshold_name,
2396 (void *)&cmd_config_threshold_value,
2402 struct cmd_stop_result {
2403 cmdline_fixed_string_t stop;
2406 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2407 __attribute__((unused)) struct cmdline *cl,
2408 __attribute__((unused)) void *data)
2410 stop_packet_forwarding();
2413 cmdline_parse_token_string_t cmd_stop_stop =
2414 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2416 cmdline_parse_inst_t cmd_stop = {
2417 .f = cmd_stop_parsed,
2419 .help_str = "stop - stop packet forwarding",
2421 (void *)&cmd_stop_stop,
2426 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2429 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2430 unsigned int *parsed_items, int check_unique_values)
2432 unsigned int nb_item;
2440 * First parse all items in the list and store their value.
2445 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2447 if ((c >= '0') && (c <= '9')) {
2448 value = (unsigned int) (value * 10 + (c - '0'));
2453 printf("character %c is not a decimal digit\n", c);
2457 printf("No valid value before comma\n");
2460 if (nb_item < max_items) {
2461 parsed_items[nb_item] = value;
2467 if (nb_item >= max_items) {
2468 printf("Number of %s = %u > %u (maximum items)\n",
2469 item_name, nb_item + 1, max_items);
2472 parsed_items[nb_item++] = value;
2473 if (! check_unique_values)
2477 * Then, check that all values in the list are differents.
2478 * No optimization here...
2480 for (i = 0; i < nb_item; i++) {
2481 for (j = i + 1; j < nb_item; j++) {
2482 if (parsed_items[j] == parsed_items[i]) {
2483 printf("duplicated %s %u at index %u and %u\n",
2484 item_name, parsed_items[i], i, j);
2492 struct cmd_set_list_result {
2493 cmdline_fixed_string_t cmd_keyword;
2494 cmdline_fixed_string_t list_name;
2495 cmdline_fixed_string_t list_of_items;
2498 static void cmd_set_list_parsed(void *parsed_result,
2499 __attribute__((unused)) struct cmdline *cl,
2500 __attribute__((unused)) void *data)
2502 struct cmd_set_list_result *res;
2504 unsigned int lcorelist[RTE_MAX_LCORE];
2505 unsigned int portlist[RTE_MAX_ETHPORTS];
2507 unsigned int nb_item;
2509 if (test_done == 0) {
2510 printf("Please stop forwarding first\n");
2514 res = parsed_result;
2515 if (!strcmp(res->list_name, "corelist")) {
2516 nb_item = parse_item_list(res->list_of_items, "core",
2518 parsed_items.lcorelist, 1);
2520 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2523 if (!strcmp(res->list_name, "portlist")) {
2524 nb_item = parse_item_list(res->list_of_items, "port",
2526 parsed_items.portlist, 1);
2528 set_fwd_ports_list(parsed_items.portlist, nb_item);
2532 cmdline_parse_token_string_t cmd_set_list_keyword =
2533 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2535 cmdline_parse_token_string_t cmd_set_list_name =
2536 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2537 "corelist#portlist");
2538 cmdline_parse_token_string_t cmd_set_list_of_items =
2539 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2542 cmdline_parse_inst_t cmd_set_fwd_list = {
2543 .f = cmd_set_list_parsed,
2545 .help_str = "set corelist|portlist x[,y]*",
2547 (void *)&cmd_set_list_keyword,
2548 (void *)&cmd_set_list_name,
2549 (void *)&cmd_set_list_of_items,
2554 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2556 struct cmd_setmask_result {
2557 cmdline_fixed_string_t set;
2558 cmdline_fixed_string_t mask;
2562 static void cmd_set_mask_parsed(void *parsed_result,
2563 __attribute__((unused)) struct cmdline *cl,
2564 __attribute__((unused)) void *data)
2566 struct cmd_setmask_result *res = parsed_result;
2568 if (test_done == 0) {
2569 printf("Please stop forwarding first\n");
2572 if (!strcmp(res->mask, "coremask"))
2573 set_fwd_lcores_mask(res->hexavalue);
2574 else if (!strcmp(res->mask, "portmask"))
2575 set_fwd_ports_mask(res->hexavalue);
2578 cmdline_parse_token_string_t cmd_setmask_set =
2579 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2580 cmdline_parse_token_string_t cmd_setmask_mask =
2581 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2582 "coremask#portmask");
2583 cmdline_parse_token_num_t cmd_setmask_value =
2584 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2586 cmdline_parse_inst_t cmd_set_fwd_mask = {
2587 .f = cmd_set_mask_parsed,
2589 .help_str = "set coremask|portmask hexadecimal value",
2591 (void *)&cmd_setmask_set,
2592 (void *)&cmd_setmask_mask,
2593 (void *)&cmd_setmask_value,
2599 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2601 struct cmd_set_result {
2602 cmdline_fixed_string_t set;
2603 cmdline_fixed_string_t what;
2607 static void cmd_set_parsed(void *parsed_result,
2608 __attribute__((unused)) struct cmdline *cl,
2609 __attribute__((unused)) void *data)
2611 struct cmd_set_result *res = parsed_result;
2612 if (!strcmp(res->what, "nbport"))
2613 set_fwd_ports_number(res->value);
2614 else if (!strcmp(res->what, "nbcore"))
2615 set_fwd_lcores_number(res->value);
2616 else if (!strcmp(res->what, "burst"))
2617 set_nb_pkt_per_burst(res->value);
2618 else if (!strcmp(res->what, "verbose"))
2619 set_verbose_level(res->value);
2622 cmdline_parse_token_string_t cmd_set_set =
2623 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2624 cmdline_parse_token_string_t cmd_set_what =
2625 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2626 "nbport#nbcore#burst#verbose");
2627 cmdline_parse_token_num_t cmd_set_value =
2628 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2630 cmdline_parse_inst_t cmd_set_numbers = {
2631 .f = cmd_set_parsed,
2633 .help_str = "set nbport|nbcore|burst|verbose value",
2635 (void *)&cmd_set_set,
2636 (void *)&cmd_set_what,
2637 (void *)&cmd_set_value,
2642 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2644 struct cmd_set_txpkts_result {
2645 cmdline_fixed_string_t cmd_keyword;
2646 cmdline_fixed_string_t txpkts;
2647 cmdline_fixed_string_t seg_lengths;
2651 cmd_set_txpkts_parsed(void *parsed_result,
2652 __attribute__((unused)) struct cmdline *cl,
2653 __attribute__((unused)) void *data)
2655 struct cmd_set_txpkts_result *res;
2656 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2657 unsigned int nb_segs;
2659 res = parsed_result;
2660 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2661 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2663 set_tx_pkt_segments(seg_lengths, nb_segs);
2666 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2667 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2668 cmd_keyword, "set");
2669 cmdline_parse_token_string_t cmd_set_txpkts_name =
2670 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2672 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2673 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2676 cmdline_parse_inst_t cmd_set_txpkts = {
2677 .f = cmd_set_txpkts_parsed,
2679 .help_str = "set txpkts x[,y]*",
2681 (void *)&cmd_set_txpkts_keyword,
2682 (void *)&cmd_set_txpkts_name,
2683 (void *)&cmd_set_txpkts_lengths,
2688 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2690 struct cmd_set_txsplit_result {
2691 cmdline_fixed_string_t cmd_keyword;
2692 cmdline_fixed_string_t txsplit;
2693 cmdline_fixed_string_t mode;
2697 cmd_set_txsplit_parsed(void *parsed_result,
2698 __attribute__((unused)) struct cmdline *cl,
2699 __attribute__((unused)) void *data)
2701 struct cmd_set_txsplit_result *res;
2703 res = parsed_result;
2704 set_tx_pkt_split(res->mode);
2707 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2708 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2709 cmd_keyword, "set");
2710 cmdline_parse_token_string_t cmd_set_txsplit_name =
2711 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2712 txsplit, "txsplit");
2713 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2714 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2717 cmdline_parse_inst_t cmd_set_txsplit = {
2718 .f = cmd_set_txsplit_parsed,
2720 .help_str = "set txsplit on|off|rand",
2722 (void *)&cmd_set_txsplit_keyword,
2723 (void *)&cmd_set_txsplit_name,
2724 (void *)&cmd_set_txsplit_mode,
2729 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2730 struct cmd_rx_vlan_filter_all_result {
2731 cmdline_fixed_string_t rx_vlan;
2732 cmdline_fixed_string_t what;
2733 cmdline_fixed_string_t all;
2738 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2739 __attribute__((unused)) struct cmdline *cl,
2740 __attribute__((unused)) void *data)
2742 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2744 if (!strcmp(res->what, "add"))
2745 rx_vlan_all_filter_set(res->port_id, 1);
2747 rx_vlan_all_filter_set(res->port_id, 0);
2750 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2751 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2752 rx_vlan, "rx_vlan");
2753 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2754 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2756 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2757 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2759 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2760 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2763 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2764 .f = cmd_rx_vlan_filter_all_parsed,
2766 .help_str = "add/remove all identifiers to/from the set of VLAN "
2767 "Identifiers filtered by a port",
2769 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2770 (void *)&cmd_rx_vlan_filter_all_what,
2771 (void *)&cmd_rx_vlan_filter_all_all,
2772 (void *)&cmd_rx_vlan_filter_all_portid,
2777 /* *** VLAN OFFLOAD SET ON A PORT *** */
2778 struct cmd_vlan_offload_result {
2779 cmdline_fixed_string_t vlan;
2780 cmdline_fixed_string_t set;
2781 cmdline_fixed_string_t vlan_type;
2782 cmdline_fixed_string_t what;
2783 cmdline_fixed_string_t on;
2784 cmdline_fixed_string_t port_id;
2788 cmd_vlan_offload_parsed(void *parsed_result,
2789 __attribute__((unused)) struct cmdline *cl,
2790 __attribute__((unused)) void *data)
2793 struct cmd_vlan_offload_result *res = parsed_result;
2796 portid_t port_id = 0;
2800 len = strnlen(str, STR_TOKEN_SIZE);
2802 /* Get port_id first */
2810 tmp = strtoul(str, NULL, 0);
2811 /* If port_id greater that what portid_t can represent, return */
2812 if(tmp >= RTE_MAX_ETHPORTS)
2814 port_id = (portid_t)tmp;
2816 if (!strcmp(res->on, "on"))
2821 if (!strcmp(res->what, "strip"))
2822 rx_vlan_strip_set(port_id, on);
2823 else if(!strcmp(res->what, "stripq")){
2824 uint16_t queue_id = 0;
2826 /* No queue_id, return */
2828 printf("must specify (port,queue_id)\n");
2831 tmp = strtoul(str + i + 1, NULL, 0);
2832 /* If queue_id greater that what 16-bits can represent, return */
2836 queue_id = (uint16_t)tmp;
2837 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2839 else if (!strcmp(res->what, "filter"))
2840 rx_vlan_filter_set(port_id, on);
2842 vlan_extend_set(port_id, on);
2847 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2848 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2850 cmdline_parse_token_string_t cmd_vlan_offload_set =
2851 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2853 cmdline_parse_token_string_t cmd_vlan_offload_what =
2854 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2855 what, "strip#filter#qinq#stripq");
2856 cmdline_parse_token_string_t cmd_vlan_offload_on =
2857 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2859 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2860 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2863 cmdline_parse_inst_t cmd_vlan_offload = {
2864 .f = cmd_vlan_offload_parsed,
2866 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2867 " qinq(extended) for both rx/tx sides ",
2869 (void *)&cmd_vlan_offload_vlan,
2870 (void *)&cmd_vlan_offload_set,
2871 (void *)&cmd_vlan_offload_what,
2872 (void *)&cmd_vlan_offload_on,
2873 (void *)&cmd_vlan_offload_portid,
2878 /* *** VLAN TPID SET ON A PORT *** */
2879 struct cmd_vlan_tpid_result {
2880 cmdline_fixed_string_t vlan;
2881 cmdline_fixed_string_t set;
2882 cmdline_fixed_string_t vlan_type;
2883 cmdline_fixed_string_t what;
2889 cmd_vlan_tpid_parsed(void *parsed_result,
2890 __attribute__((unused)) struct cmdline *cl,
2891 __attribute__((unused)) void *data)
2893 struct cmd_vlan_tpid_result *res = parsed_result;
2894 enum rte_vlan_type vlan_type;
2896 if (!strcmp(res->vlan_type, "inner"))
2897 vlan_type = ETH_VLAN_TYPE_INNER;
2898 else if (!strcmp(res->vlan_type, "outer"))
2899 vlan_type = ETH_VLAN_TYPE_OUTER;
2901 printf("Unknown vlan type\n");
2904 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
2907 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2908 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2910 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2911 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2913 cmdline_parse_token_string_t cmd_vlan_type =
2914 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2915 vlan_type, "inner#outer");
2916 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2917 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2919 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2920 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2922 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2923 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2926 cmdline_parse_inst_t cmd_vlan_tpid = {
2927 .f = cmd_vlan_tpid_parsed,
2929 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
2932 (void *)&cmd_vlan_tpid_vlan,
2933 (void *)&cmd_vlan_tpid_set,
2934 (void *)&cmd_vlan_type,
2935 (void *)&cmd_vlan_tpid_what,
2936 (void *)&cmd_vlan_tpid_tpid,
2937 (void *)&cmd_vlan_tpid_portid,
2942 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2943 struct cmd_rx_vlan_filter_result {
2944 cmdline_fixed_string_t rx_vlan;
2945 cmdline_fixed_string_t what;
2951 cmd_rx_vlan_filter_parsed(void *parsed_result,
2952 __attribute__((unused)) struct cmdline *cl,
2953 __attribute__((unused)) void *data)
2955 struct cmd_rx_vlan_filter_result *res = parsed_result;
2957 if (!strcmp(res->what, "add"))
2958 rx_vft_set(res->port_id, res->vlan_id, 1);
2960 rx_vft_set(res->port_id, res->vlan_id, 0);
2963 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2964 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2965 rx_vlan, "rx_vlan");
2966 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2967 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2969 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2970 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2972 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2973 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2976 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2977 .f = cmd_rx_vlan_filter_parsed,
2979 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2980 "Identifiers filtered by a port",
2982 (void *)&cmd_rx_vlan_filter_rx_vlan,
2983 (void *)&cmd_rx_vlan_filter_what,
2984 (void *)&cmd_rx_vlan_filter_vlanid,
2985 (void *)&cmd_rx_vlan_filter_portid,
2990 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2991 struct cmd_tx_vlan_set_result {
2992 cmdline_fixed_string_t tx_vlan;
2993 cmdline_fixed_string_t set;
2999 cmd_tx_vlan_set_parsed(void *parsed_result,
3000 __attribute__((unused)) struct cmdline *cl,
3001 __attribute__((unused)) void *data)
3003 struct cmd_tx_vlan_set_result *res = parsed_result;
3005 tx_vlan_set(res->port_id, res->vlan_id);
3008 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3009 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3010 tx_vlan, "tx_vlan");
3011 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3012 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3014 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3015 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3017 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3018 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3021 cmdline_parse_inst_t cmd_tx_vlan_set = {
3022 .f = cmd_tx_vlan_set_parsed,
3024 .help_str = "enable hardware insertion of a single VLAN header "
3025 "with a given TAG Identifier in packets sent on a port",
3027 (void *)&cmd_tx_vlan_set_tx_vlan,
3028 (void *)&cmd_tx_vlan_set_set,
3029 (void *)&cmd_tx_vlan_set_portid,
3030 (void *)&cmd_tx_vlan_set_vlanid,
3035 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3036 struct cmd_tx_vlan_set_qinq_result {
3037 cmdline_fixed_string_t tx_vlan;
3038 cmdline_fixed_string_t set;
3041 uint16_t vlan_id_outer;
3045 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3046 __attribute__((unused)) struct cmdline *cl,
3047 __attribute__((unused)) void *data)
3049 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3051 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3054 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3055 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3056 tx_vlan, "tx_vlan");
3057 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3058 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3060 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3061 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3063 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3064 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3066 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3067 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3068 vlan_id_outer, UINT16);
3070 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3071 .f = cmd_tx_vlan_set_qinq_parsed,
3073 .help_str = "enable hardware insertion of double VLAN header "
3074 "with given TAG Identifiers in packets sent on a port",
3076 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3077 (void *)&cmd_tx_vlan_set_qinq_set,
3078 (void *)&cmd_tx_vlan_set_qinq_portid,
3079 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3080 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3085 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3086 struct cmd_tx_vlan_set_pvid_result {
3087 cmdline_fixed_string_t tx_vlan;
3088 cmdline_fixed_string_t set;
3089 cmdline_fixed_string_t pvid;
3092 cmdline_fixed_string_t mode;
3096 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3097 __attribute__((unused)) struct cmdline *cl,
3098 __attribute__((unused)) void *data)
3100 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3102 if (strcmp(res->mode, "on") == 0)
3103 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3105 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3108 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3109 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3110 tx_vlan, "tx_vlan");
3111 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3112 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3114 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3115 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3117 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3118 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3120 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3121 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3123 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3124 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3127 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3128 .f = cmd_tx_vlan_set_pvid_parsed,
3130 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3132 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3133 (void *)&cmd_tx_vlan_set_pvid_set,
3134 (void *)&cmd_tx_vlan_set_pvid_pvid,
3135 (void *)&cmd_tx_vlan_set_pvid_port_id,
3136 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3137 (void *)&cmd_tx_vlan_set_pvid_mode,
3142 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3143 struct cmd_tx_vlan_reset_result {
3144 cmdline_fixed_string_t tx_vlan;
3145 cmdline_fixed_string_t reset;
3150 cmd_tx_vlan_reset_parsed(void *parsed_result,
3151 __attribute__((unused)) struct cmdline *cl,
3152 __attribute__((unused)) void *data)
3154 struct cmd_tx_vlan_reset_result *res = parsed_result;
3156 tx_vlan_reset(res->port_id);
3159 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3160 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3161 tx_vlan, "tx_vlan");
3162 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3163 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3165 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3166 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3169 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3170 .f = cmd_tx_vlan_reset_parsed,
3172 .help_str = "disable hardware insertion of a VLAN header in packets "
3175 (void *)&cmd_tx_vlan_reset_tx_vlan,
3176 (void *)&cmd_tx_vlan_reset_reset,
3177 (void *)&cmd_tx_vlan_reset_portid,
3183 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3184 struct cmd_csum_result {
3185 cmdline_fixed_string_t csum;
3186 cmdline_fixed_string_t mode;
3187 cmdline_fixed_string_t proto;
3188 cmdline_fixed_string_t hwsw;
3193 csum_show(int port_id)
3195 struct rte_eth_dev_info dev_info;
3198 ol_flags = ports[port_id].tx_ol_flags;
3199 printf("Parse tunnel is %s\n",
3200 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3201 printf("IP checksum offload is %s\n",
3202 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3203 printf("UDP checksum offload is %s\n",
3204 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3205 printf("TCP checksum offload is %s\n",
3206 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3207 printf("SCTP checksum offload is %s\n",
3208 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3209 printf("Outer-Ip checksum offload is %s\n",
3210 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3212 /* display warnings if configuration is not supported by the NIC */
3213 rte_eth_dev_info_get(port_id, &dev_info);
3214 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3215 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3216 printf("Warning: hardware IP checksum enabled but not "
3217 "supported by port %d\n", port_id);
3219 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3220 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3221 printf("Warning: hardware UDP checksum enabled but not "
3222 "supported by port %d\n", port_id);
3224 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3225 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3226 printf("Warning: hardware TCP checksum enabled but not "
3227 "supported by port %d\n", port_id);
3229 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3230 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3231 printf("Warning: hardware SCTP checksum enabled but not "
3232 "supported by port %d\n", port_id);
3234 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3235 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3236 printf("Warning: hardware outer IP checksum enabled but not "
3237 "supported by port %d\n", port_id);
3242 cmd_csum_parsed(void *parsed_result,
3243 __attribute__((unused)) struct cmdline *cl,
3244 __attribute__((unused)) void *data)
3246 struct cmd_csum_result *res = parsed_result;
3250 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3251 printf("invalid port %d\n", res->port_id);
3255 if (!strcmp(res->mode, "set")) {
3257 if (!strcmp(res->hwsw, "hw"))
3260 if (!strcmp(res->proto, "ip")) {
3261 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3262 } else if (!strcmp(res->proto, "udp")) {
3263 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3264 } else if (!strcmp(res->proto, "tcp")) {
3265 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3266 } else if (!strcmp(res->proto, "sctp")) {
3267 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3268 } else if (!strcmp(res->proto, "outer-ip")) {
3269 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3273 ports[res->port_id].tx_ol_flags |= mask;
3275 ports[res->port_id].tx_ol_flags &= (~mask);
3277 csum_show(res->port_id);
3280 cmdline_parse_token_string_t cmd_csum_csum =
3281 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3283 cmdline_parse_token_string_t cmd_csum_mode =
3284 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3286 cmdline_parse_token_string_t cmd_csum_proto =
3287 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3288 proto, "ip#tcp#udp#sctp#outer-ip");
3289 cmdline_parse_token_string_t cmd_csum_hwsw =
3290 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3292 cmdline_parse_token_num_t cmd_csum_portid =
3293 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3296 cmdline_parse_inst_t cmd_csum_set = {
3297 .f = cmd_csum_parsed,
3299 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3300 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3302 (void *)&cmd_csum_csum,
3303 (void *)&cmd_csum_mode,
3304 (void *)&cmd_csum_proto,
3305 (void *)&cmd_csum_hwsw,
3306 (void *)&cmd_csum_portid,
3311 cmdline_parse_token_string_t cmd_csum_mode_show =
3312 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3315 cmdline_parse_inst_t cmd_csum_show = {
3316 .f = cmd_csum_parsed,
3318 .help_str = "show checksum offload configuration: csum show <port>",
3320 (void *)&cmd_csum_csum,
3321 (void *)&cmd_csum_mode_show,
3322 (void *)&cmd_csum_portid,
3327 /* Enable/disable tunnel parsing */
3328 struct cmd_csum_tunnel_result {
3329 cmdline_fixed_string_t csum;
3330 cmdline_fixed_string_t parse;
3331 cmdline_fixed_string_t onoff;
3336 cmd_csum_tunnel_parsed(void *parsed_result,
3337 __attribute__((unused)) struct cmdline *cl,
3338 __attribute__((unused)) void *data)
3340 struct cmd_csum_tunnel_result *res = parsed_result;
3342 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3345 if (!strcmp(res->onoff, "on"))
3346 ports[res->port_id].tx_ol_flags |=
3347 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3349 ports[res->port_id].tx_ol_flags &=
3350 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3352 csum_show(res->port_id);
3355 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3356 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3358 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3359 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3360 parse, "parse_tunnel");
3361 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3362 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3364 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3365 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3368 cmdline_parse_inst_t cmd_csum_tunnel = {
3369 .f = cmd_csum_tunnel_parsed,
3371 .help_str = "enable/disable parsing of tunnels for csum engine: "
3372 "csum parse_tunnel on|off <tx-port>",
3374 (void *)&cmd_csum_tunnel_csum,
3375 (void *)&cmd_csum_tunnel_parse,
3376 (void *)&cmd_csum_tunnel_onoff,
3377 (void *)&cmd_csum_tunnel_portid,
3382 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3383 struct cmd_tso_set_result {
3384 cmdline_fixed_string_t tso;
3385 cmdline_fixed_string_t mode;
3391 cmd_tso_set_parsed(void *parsed_result,
3392 __attribute__((unused)) struct cmdline *cl,
3393 __attribute__((unused)) void *data)
3395 struct cmd_tso_set_result *res = parsed_result;
3396 struct rte_eth_dev_info dev_info;
3398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3401 if (!strcmp(res->mode, "set"))
3402 ports[res->port_id].tso_segsz = res->tso_segsz;
3404 if (ports[res->port_id].tso_segsz == 0)
3405 printf("TSO is disabled\n");
3407 printf("TSO segment size is %d\n",
3408 ports[res->port_id].tso_segsz);
3410 /* display warnings if configuration is not supported by the NIC */
3411 rte_eth_dev_info_get(res->port_id, &dev_info);
3412 if ((ports[res->port_id].tso_segsz != 0) &&
3413 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3414 printf("Warning: TSO enabled but not "
3415 "supported by port %d\n", res->port_id);
3419 cmdline_parse_token_string_t cmd_tso_set_tso =
3420 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3422 cmdline_parse_token_string_t cmd_tso_set_mode =
3423 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3425 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3426 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3428 cmdline_parse_token_num_t cmd_tso_set_portid =
3429 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3432 cmdline_parse_inst_t cmd_tso_set = {
3433 .f = cmd_tso_set_parsed,
3435 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3436 "tso set <tso_segsz> <port>",
3438 (void *)&cmd_tso_set_tso,
3439 (void *)&cmd_tso_set_mode,
3440 (void *)&cmd_tso_set_tso_segsz,
3441 (void *)&cmd_tso_set_portid,
3446 cmdline_parse_token_string_t cmd_tso_show_mode =
3447 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3451 cmdline_parse_inst_t cmd_tso_show = {
3452 .f = cmd_tso_set_parsed,
3454 .help_str = "Show TSO segment size for csum engine: "
3457 (void *)&cmd_tso_set_tso,
3458 (void *)&cmd_tso_show_mode,
3459 (void *)&cmd_tso_set_portid,
3464 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3465 struct cmd_set_flush_rx {
3466 cmdline_fixed_string_t set;
3467 cmdline_fixed_string_t flush_rx;
3468 cmdline_fixed_string_t mode;
3472 cmd_set_flush_rx_parsed(void *parsed_result,
3473 __attribute__((unused)) struct cmdline *cl,
3474 __attribute__((unused)) void *data)
3476 struct cmd_set_flush_rx *res = parsed_result;
3477 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3480 cmdline_parse_token_string_t cmd_setflushrx_set =
3481 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3483 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3484 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3485 flush_rx, "flush_rx");
3486 cmdline_parse_token_string_t cmd_setflushrx_mode =
3487 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3491 cmdline_parse_inst_t cmd_set_flush_rx = {
3492 .f = cmd_set_flush_rx_parsed,
3493 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3496 (void *)&cmd_setflushrx_set,
3497 (void *)&cmd_setflushrx_flush_rx,
3498 (void *)&cmd_setflushrx_mode,
3503 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3504 struct cmd_set_link_check {
3505 cmdline_fixed_string_t set;
3506 cmdline_fixed_string_t link_check;
3507 cmdline_fixed_string_t mode;
3511 cmd_set_link_check_parsed(void *parsed_result,
3512 __attribute__((unused)) struct cmdline *cl,
3513 __attribute__((unused)) void *data)
3515 struct cmd_set_link_check *res = parsed_result;
3516 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3519 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3520 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3522 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3523 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3524 link_check, "link_check");
3525 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3526 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3530 cmdline_parse_inst_t cmd_set_link_check = {
3531 .f = cmd_set_link_check_parsed,
3532 .help_str = "set link_check on|off: enable/disable link status check "
3533 "when starting/stopping a port",
3536 (void *)&cmd_setlinkcheck_set,
3537 (void *)&cmd_setlinkcheck_link_check,
3538 (void *)&cmd_setlinkcheck_mode,
3543 #ifdef RTE_NIC_BYPASS
3544 /* *** SET NIC BYPASS MODE *** */
3545 struct cmd_set_bypass_mode_result {
3546 cmdline_fixed_string_t set;
3547 cmdline_fixed_string_t bypass;
3548 cmdline_fixed_string_t mode;
3549 cmdline_fixed_string_t value;
3554 cmd_set_bypass_mode_parsed(void *parsed_result,
3555 __attribute__((unused)) struct cmdline *cl,
3556 __attribute__((unused)) void *data)
3558 struct cmd_set_bypass_mode_result *res = parsed_result;
3559 portid_t port_id = res->port_id;
3560 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3562 if (!bypass_is_supported(port_id))
3565 if (!strcmp(res->value, "bypass"))
3566 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3567 else if (!strcmp(res->value, "isolate"))
3568 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3570 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3572 /* Set the bypass mode for the relevant port. */
3573 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3574 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3578 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3579 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3581 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3582 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3584 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3585 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3587 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3588 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3589 value, "normal#bypass#isolate");
3590 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3591 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3594 cmdline_parse_inst_t cmd_set_bypass_mode = {
3595 .f = cmd_set_bypass_mode_parsed,
3596 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3597 "Set the NIC bypass mode for port_id",
3600 (void *)&cmd_setbypass_mode_set,
3601 (void *)&cmd_setbypass_mode_bypass,
3602 (void *)&cmd_setbypass_mode_mode,
3603 (void *)&cmd_setbypass_mode_value,
3604 (void *)&cmd_setbypass_mode_port,
3609 /* *** SET NIC BYPASS EVENT *** */
3610 struct cmd_set_bypass_event_result {
3611 cmdline_fixed_string_t set;
3612 cmdline_fixed_string_t bypass;
3613 cmdline_fixed_string_t event;
3614 cmdline_fixed_string_t event_value;
3615 cmdline_fixed_string_t mode;
3616 cmdline_fixed_string_t mode_value;
3621 cmd_set_bypass_event_parsed(void *parsed_result,
3622 __attribute__((unused)) struct cmdline *cl,
3623 __attribute__((unused)) void *data)
3626 struct cmd_set_bypass_event_result *res = parsed_result;
3627 portid_t port_id = res->port_id;
3628 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3629 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3631 if (!bypass_is_supported(port_id))
3634 if (!strcmp(res->event_value, "timeout"))
3635 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3636 else if (!strcmp(res->event_value, "os_on"))
3637 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3638 else if (!strcmp(res->event_value, "os_off"))
3639 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3640 else if (!strcmp(res->event_value, "power_on"))
3641 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3642 else if (!strcmp(res->event_value, "power_off"))
3643 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3645 bypass_event = RTE_BYPASS_EVENT_NONE;
3647 if (!strcmp(res->mode_value, "bypass"))
3648 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3649 else if (!strcmp(res->mode_value, "isolate"))
3650 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3652 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3654 /* Set the watchdog timeout. */
3655 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3658 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3659 (rc = rte_eth_dev_wd_timeout_store(port_id,
3660 bypass_timeout)) != 0) {
3661 printf("Failed to set timeout value %u "
3662 "for port %d, errto code: %d.\n",
3663 bypass_timeout, port_id, rc);
3667 /* Set the bypass event to transition to bypass mode. */
3668 if (0 != rte_eth_dev_bypass_event_store(port_id,
3669 bypass_event, bypass_mode)) {
3670 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3675 cmdline_parse_token_string_t cmd_setbypass_event_set =
3676 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3678 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3679 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3681 cmdline_parse_token_string_t cmd_setbypass_event_event =
3682 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3684 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3685 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3686 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3687 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3688 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3690 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3691 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3692 mode_value, "normal#bypass#isolate");
3693 cmdline_parse_token_num_t cmd_setbypass_event_port =
3694 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3697 cmdline_parse_inst_t cmd_set_bypass_event = {
3698 .f = cmd_set_bypass_event_parsed,
3699 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3700 "mode (normal|bypass|isolate) (port_id): "
3701 "Set the NIC bypass event mode for port_id",
3704 (void *)&cmd_setbypass_event_set,
3705 (void *)&cmd_setbypass_event_bypass,
3706 (void *)&cmd_setbypass_event_event,
3707 (void *)&cmd_setbypass_event_event_value,
3708 (void *)&cmd_setbypass_event_mode,
3709 (void *)&cmd_setbypass_event_mode_value,
3710 (void *)&cmd_setbypass_event_port,
3716 /* *** SET NIC BYPASS TIMEOUT *** */
3717 struct cmd_set_bypass_timeout_result {
3718 cmdline_fixed_string_t set;
3719 cmdline_fixed_string_t bypass;
3720 cmdline_fixed_string_t timeout;
3721 cmdline_fixed_string_t value;
3725 cmd_set_bypass_timeout_parsed(void *parsed_result,
3726 __attribute__((unused)) struct cmdline *cl,
3727 __attribute__((unused)) void *data)
3729 struct cmd_set_bypass_timeout_result *res = parsed_result;
3731 if (!strcmp(res->value, "1.5"))
3732 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3733 else if (!strcmp(res->value, "2"))
3734 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3735 else if (!strcmp(res->value, "3"))
3736 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3737 else if (!strcmp(res->value, "4"))
3738 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3739 else if (!strcmp(res->value, "8"))
3740 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3741 else if (!strcmp(res->value, "16"))
3742 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3743 else if (!strcmp(res->value, "32"))
3744 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3746 bypass_timeout = RTE_BYPASS_TMT_OFF;
3749 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3750 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3752 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3755 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3756 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3757 timeout, "timeout");
3758 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3760 value, "0#1.5#2#3#4#8#16#32");
3762 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3763 .f = cmd_set_bypass_timeout_parsed,
3764 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3765 "Set the NIC bypass watchdog timeout",
3768 (void *)&cmd_setbypass_timeout_set,
3769 (void *)&cmd_setbypass_timeout_bypass,
3770 (void *)&cmd_setbypass_timeout_timeout,
3771 (void *)&cmd_setbypass_timeout_value,
3776 /* *** SHOW NIC BYPASS MODE *** */
3777 struct cmd_show_bypass_config_result {
3778 cmdline_fixed_string_t show;
3779 cmdline_fixed_string_t bypass;
3780 cmdline_fixed_string_t config;
3785 cmd_show_bypass_config_parsed(void *parsed_result,
3786 __attribute__((unused)) struct cmdline *cl,
3787 __attribute__((unused)) void *data)
3789 struct cmd_show_bypass_config_result *res = parsed_result;
3790 uint32_t event_mode;
3791 uint32_t bypass_mode;
3792 portid_t port_id = res->port_id;
3793 uint32_t timeout = bypass_timeout;
3796 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3797 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3798 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3799 {"UNKNOWN", "normal", "bypass", "isolate"};
3800 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3807 int num_events = (sizeof events) / (sizeof events[0]);
3809 if (!bypass_is_supported(port_id))
3812 /* Display the bypass mode.*/
3813 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3814 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3818 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3819 bypass_mode = RTE_BYPASS_MODE_NONE;
3821 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3824 /* Display the bypass timeout.*/
3825 if (!RTE_BYPASS_TMT_VALID(timeout))
3826 timeout = RTE_BYPASS_TMT_OFF;
3828 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3830 /* Display the bypass events and associated modes. */
3831 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3833 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3834 printf("\tFailed to get bypass mode for event = %s\n",
3837 if (!RTE_BYPASS_MODE_VALID(event_mode))
3838 event_mode = RTE_BYPASS_MODE_NONE;
3840 printf("\tbypass event: %-16s = %s\n", events[i],
3846 cmdline_parse_token_string_t cmd_showbypass_config_show =
3847 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3849 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3850 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3852 cmdline_parse_token_string_t cmd_showbypass_config_config =
3853 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3855 cmdline_parse_token_num_t cmd_showbypass_config_port =
3856 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3859 cmdline_parse_inst_t cmd_show_bypass_config = {
3860 .f = cmd_show_bypass_config_parsed,
3861 .help_str = "show bypass config (port_id): "
3862 "Show the NIC bypass config for port_id",
3865 (void *)&cmd_showbypass_config_show,
3866 (void *)&cmd_showbypass_config_bypass,
3867 (void *)&cmd_showbypass_config_config,
3868 (void *)&cmd_showbypass_config_port,
3874 #ifdef RTE_LIBRTE_PMD_BOND
3875 /* *** SET BONDING MODE *** */
3876 struct cmd_set_bonding_mode_result {
3877 cmdline_fixed_string_t set;
3878 cmdline_fixed_string_t bonding;
3879 cmdline_fixed_string_t mode;
3884 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3885 __attribute__((unused)) struct cmdline *cl,
3886 __attribute__((unused)) void *data)
3888 struct cmd_set_bonding_mode_result *res = parsed_result;
3889 portid_t port_id = res->port_id;
3891 /* Set the bonding mode for the relevant port. */
3892 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3893 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3896 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3897 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3899 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3901 bonding, "bonding");
3902 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3903 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3905 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3906 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3908 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3909 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3912 cmdline_parse_inst_t cmd_set_bonding_mode = {
3913 .f = cmd_set_bonding_mode_parsed,
3914 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3917 (void *) &cmd_setbonding_mode_set,
3918 (void *) &cmd_setbonding_mode_bonding,
3919 (void *) &cmd_setbonding_mode_mode,
3920 (void *) &cmd_setbonding_mode_value,
3921 (void *) &cmd_setbonding_mode_port,
3926 /* *** SET BALANCE XMIT POLICY *** */
3927 struct cmd_set_bonding_balance_xmit_policy_result {
3928 cmdline_fixed_string_t set;
3929 cmdline_fixed_string_t bonding;
3930 cmdline_fixed_string_t balance_xmit_policy;
3932 cmdline_fixed_string_t policy;
3935 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3936 __attribute__((unused)) struct cmdline *cl,
3937 __attribute__((unused)) void *data)
3939 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3940 portid_t port_id = res->port_id;
3943 if (!strcmp(res->policy, "l2")) {
3944 policy = BALANCE_XMIT_POLICY_LAYER2;
3945 } else if (!strcmp(res->policy, "l23")) {
3946 policy = BALANCE_XMIT_POLICY_LAYER23;
3947 } else if (!strcmp(res->policy, "l34")) {
3948 policy = BALANCE_XMIT_POLICY_LAYER34;
3950 printf("\t Invalid xmit policy selection");
3954 /* Set the bonding mode for the relevant port. */
3955 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3956 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3961 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3964 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3966 bonding, "bonding");
3967 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3969 balance_xmit_policy, "balance_xmit_policy");
3970 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3971 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3973 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3975 policy, "l2#l23#l34");
3977 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3978 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3979 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3982 (void *)&cmd_setbonding_balance_xmit_policy_set,
3983 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3984 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3985 (void *)&cmd_setbonding_balance_xmit_policy_port,
3986 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3991 /* *** SHOW NIC BONDING CONFIGURATION *** */
3992 struct cmd_show_bonding_config_result {
3993 cmdline_fixed_string_t show;
3994 cmdline_fixed_string_t bonding;
3995 cmdline_fixed_string_t config;
3999 static void cmd_show_bonding_config_parsed(void *parsed_result,
4000 __attribute__((unused)) struct cmdline *cl,
4001 __attribute__((unused)) void *data)
4003 struct cmd_show_bonding_config_result *res = parsed_result;
4005 uint8_t slaves[RTE_MAX_ETHPORTS];
4006 int num_slaves, num_active_slaves;
4009 portid_t port_id = res->port_id;
4011 /* Display the bonding mode.*/
4012 bonding_mode = rte_eth_bond_mode_get(port_id);
4013 if (bonding_mode < 0) {
4014 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4017 printf("\tBonding mode: %d\n", bonding_mode);
4019 if (bonding_mode == BONDING_MODE_BALANCE) {
4020 int balance_xmit_policy;
4022 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4023 if (balance_xmit_policy < 0) {
4024 printf("\tFailed to get balance xmit policy for port = %d\n",
4028 printf("\tBalance Xmit Policy: ");
4030 switch (balance_xmit_policy) {
4031 case BALANCE_XMIT_POLICY_LAYER2:
4032 printf("BALANCE_XMIT_POLICY_LAYER2");
4034 case BALANCE_XMIT_POLICY_LAYER23:
4035 printf("BALANCE_XMIT_POLICY_LAYER23");
4037 case BALANCE_XMIT_POLICY_LAYER34:
4038 printf("BALANCE_XMIT_POLICY_LAYER34");
4045 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4047 if (num_slaves < 0) {
4048 printf("\tFailed to get slave list for port = %d\n", port_id);
4051 if (num_slaves > 0) {
4052 printf("\tSlaves (%d): [", num_slaves);
4053 for (i = 0; i < num_slaves - 1; i++)
4054 printf("%d ", slaves[i]);
4056 printf("%d]\n", slaves[num_slaves - 1]);
4058 printf("\tSlaves: []\n");
4062 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4065 if (num_active_slaves < 0) {
4066 printf("\tFailed to get active slave list for port = %d\n", port_id);
4069 if (num_active_slaves > 0) {
4070 printf("\tActive Slaves (%d): [", num_active_slaves);
4071 for (i = 0; i < num_active_slaves - 1; i++)
4072 printf("%d ", slaves[i]);
4074 printf("%d]\n", slaves[num_active_slaves - 1]);
4077 printf("\tActive Slaves: []\n");
4081 primary_id = rte_eth_bond_primary_get(port_id);
4082 if (primary_id < 0) {
4083 printf("\tFailed to get primary slave for port = %d\n", port_id);
4086 printf("\tPrimary: [%d]\n", primary_id);
4090 cmdline_parse_token_string_t cmd_showbonding_config_show =
4091 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4093 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4094 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4095 bonding, "bonding");
4096 cmdline_parse_token_string_t cmd_showbonding_config_config =
4097 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4099 cmdline_parse_token_num_t cmd_showbonding_config_port =
4100 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4103 cmdline_parse_inst_t cmd_show_bonding_config = {
4104 .f = cmd_show_bonding_config_parsed,
4105 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4108 (void *)&cmd_showbonding_config_show,
4109 (void *)&cmd_showbonding_config_bonding,
4110 (void *)&cmd_showbonding_config_config,
4111 (void *)&cmd_showbonding_config_port,
4116 /* *** SET BONDING PRIMARY *** */
4117 struct cmd_set_bonding_primary_result {
4118 cmdline_fixed_string_t set;
4119 cmdline_fixed_string_t bonding;
4120 cmdline_fixed_string_t primary;
4125 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4126 __attribute__((unused)) struct cmdline *cl,
4127 __attribute__((unused)) void *data)
4129 struct cmd_set_bonding_primary_result *res = parsed_result;
4130 portid_t master_port_id = res->port_id;
4131 portid_t slave_port_id = res->slave_id;
4133 /* Set the primary slave for a bonded device. */
4134 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4135 printf("\t Failed to set primary slave for port = %d.\n",
4142 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4143 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4145 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4146 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4147 bonding, "bonding");
4148 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4149 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4150 primary, "primary");
4151 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4152 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4154 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4155 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4158 cmdline_parse_inst_t cmd_set_bonding_primary = {
4159 .f = cmd_set_bonding_primary_parsed,
4160 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4163 (void *)&cmd_setbonding_primary_set,
4164 (void *)&cmd_setbonding_primary_bonding,
4165 (void *)&cmd_setbonding_primary_primary,
4166 (void *)&cmd_setbonding_primary_slave,
4167 (void *)&cmd_setbonding_primary_port,
4172 /* *** ADD SLAVE *** */
4173 struct cmd_add_bonding_slave_result {
4174 cmdline_fixed_string_t add;
4175 cmdline_fixed_string_t bonding;
4176 cmdline_fixed_string_t slave;
4181 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4182 __attribute__((unused)) struct cmdline *cl,
4183 __attribute__((unused)) void *data)
4185 struct cmd_add_bonding_slave_result *res = parsed_result;
4186 portid_t master_port_id = res->port_id;
4187 portid_t slave_port_id = res->slave_id;
4189 /* Set the primary slave for a bonded device. */
4190 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4191 printf("\t Failed to add slave %d to master port = %d.\n",
4192 slave_port_id, master_port_id);
4196 set_port_slave_flag(slave_port_id);
4199 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4200 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4202 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4203 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4204 bonding, "bonding");
4205 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4206 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4208 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4209 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4211 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4212 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4215 cmdline_parse_inst_t cmd_add_bonding_slave = {
4216 .f = cmd_add_bonding_slave_parsed,
4217 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4220 (void *)&cmd_addbonding_slave_add,
4221 (void *)&cmd_addbonding_slave_bonding,
4222 (void *)&cmd_addbonding_slave_slave,
4223 (void *)&cmd_addbonding_slave_slaveid,
4224 (void *)&cmd_addbonding_slave_port,
4229 /* *** REMOVE SLAVE *** */
4230 struct cmd_remove_bonding_slave_result {
4231 cmdline_fixed_string_t remove;
4232 cmdline_fixed_string_t bonding;
4233 cmdline_fixed_string_t slave;
4238 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4239 __attribute__((unused)) struct cmdline *cl,
4240 __attribute__((unused)) void *data)
4242 struct cmd_remove_bonding_slave_result *res = parsed_result;
4243 portid_t master_port_id = res->port_id;
4244 portid_t slave_port_id = res->slave_id;
4246 /* Set the primary slave for a bonded device. */
4247 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4248 printf("\t Failed to remove slave %d from master port = %d.\n",
4249 slave_port_id, master_port_id);
4253 clear_port_slave_flag(slave_port_id);
4256 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4257 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4259 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4260 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4261 bonding, "bonding");
4262 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4263 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4265 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4266 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4268 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4269 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4272 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4273 .f = cmd_remove_bonding_slave_parsed,
4274 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4277 (void *)&cmd_removebonding_slave_remove,
4278 (void *)&cmd_removebonding_slave_bonding,
4279 (void *)&cmd_removebonding_slave_slave,
4280 (void *)&cmd_removebonding_slave_slaveid,
4281 (void *)&cmd_removebonding_slave_port,
4286 /* *** CREATE BONDED DEVICE *** */
4287 struct cmd_create_bonded_device_result {
4288 cmdline_fixed_string_t create;
4289 cmdline_fixed_string_t bonded;
4290 cmdline_fixed_string_t device;
4295 static int bond_dev_num = 0;
4297 static void cmd_create_bonded_device_parsed(void *parsed_result,
4298 __attribute__((unused)) struct cmdline *cl,
4299 __attribute__((unused)) void *data)
4301 struct cmd_create_bonded_device_result *res = parsed_result;
4302 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4305 if (test_done == 0) {
4306 printf("Please stop forwarding first\n");
4310 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4313 /* Create a new bonded device. */
4314 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4316 printf("\t Failed to create bonded device.\n");
4319 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4322 /* Update number of ports */
4323 nb_ports = rte_eth_dev_count();
4324 reconfig(port_id, res->socket);
4325 rte_eth_promiscuous_enable(port_id);
4326 ports[port_id].enabled = 1;
4331 cmdline_parse_token_string_t cmd_createbonded_device_create =
4332 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4334 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4335 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4337 cmdline_parse_token_string_t cmd_createbonded_device_device =
4338 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4340 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4341 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4343 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4344 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4347 cmdline_parse_inst_t cmd_create_bonded_device = {
4348 .f = cmd_create_bonded_device_parsed,
4349 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4352 (void *)&cmd_createbonded_device_create,
4353 (void *)&cmd_createbonded_device_bonded,
4354 (void *)&cmd_createbonded_device_device,
4355 (void *)&cmd_createbonded_device_mode,
4356 (void *)&cmd_createbonded_device_socket,
4361 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4362 struct cmd_set_bond_mac_addr_result {
4363 cmdline_fixed_string_t set;
4364 cmdline_fixed_string_t bonding;
4365 cmdline_fixed_string_t mac_addr;
4367 struct ether_addr address;
4370 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4371 __attribute__((unused)) struct cmdline *cl,
4372 __attribute__((unused)) void *data)
4374 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4377 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4380 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4382 /* check the return value and print it if is < 0 */
4384 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4387 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4388 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4389 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4390 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4392 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4393 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4395 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4396 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4397 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4398 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4400 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4401 .f = cmd_set_bond_mac_addr_parsed,
4403 .help_str = "set bonding mac_addr (port_id) (address): ",
4405 (void *)&cmd_set_bond_mac_addr_set,
4406 (void *)&cmd_set_bond_mac_addr_bonding,
4407 (void *)&cmd_set_bond_mac_addr_mac,
4408 (void *)&cmd_set_bond_mac_addr_portnum,
4409 (void *)&cmd_set_bond_mac_addr_addr,
4415 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4416 struct cmd_set_bond_mon_period_result {
4417 cmdline_fixed_string_t set;
4418 cmdline_fixed_string_t bonding;
4419 cmdline_fixed_string_t mon_period;
4424 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4425 __attribute__((unused)) struct cmdline *cl,
4426 __attribute__((unused)) void *data)
4428 struct cmd_set_bond_mon_period_result *res = parsed_result;
4431 if (res->port_num >= nb_ports) {
4432 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4436 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4438 /* check the return value and print it if is < 0 */
4440 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4443 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4444 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4446 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4447 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4448 bonding, "bonding");
4449 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4450 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4451 mon_period, "mon_period");
4452 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4453 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4455 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4456 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4459 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4460 .f = cmd_set_bond_mon_period_parsed,
4462 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4464 (void *)&cmd_set_bond_mon_period_set,
4465 (void *)&cmd_set_bond_mon_period_bonding,
4466 (void *)&cmd_set_bond_mon_period_mon_period,
4467 (void *)&cmd_set_bond_mon_period_portnum,
4468 (void *)&cmd_set_bond_mon_period_period_ms,
4473 #endif /* RTE_LIBRTE_PMD_BOND */
4475 /* *** SET FORWARDING MODE *** */
4476 struct cmd_set_fwd_mode_result {
4477 cmdline_fixed_string_t set;
4478 cmdline_fixed_string_t fwd;
4479 cmdline_fixed_string_t mode;
4482 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4483 __attribute__((unused)) struct cmdline *cl,
4484 __attribute__((unused)) void *data)
4486 struct cmd_set_fwd_mode_result *res = parsed_result;
4488 set_pkt_forwarding_mode(res->mode);
4491 cmdline_parse_token_string_t cmd_setfwd_set =
4492 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4493 cmdline_parse_token_string_t cmd_setfwd_fwd =
4494 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4495 cmdline_parse_token_string_t cmd_setfwd_mode =
4496 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4497 "" /* defined at init */);
4499 cmdline_parse_inst_t cmd_set_fwd_mode = {
4500 .f = cmd_set_fwd_mode_parsed,
4502 .help_str = NULL, /* defined at init */
4504 (void *)&cmd_setfwd_set,
4505 (void *)&cmd_setfwd_fwd,
4506 (void *)&cmd_setfwd_mode,
4511 static void cmd_set_fwd_mode_init(void)
4514 static char token[128];
4515 static char help[256];
4516 cmdline_parse_token_string_t *token_struct;
4518 modes = list_pkt_forwarding_modes();
4519 snprintf(help, sizeof help, "set fwd %s - "
4520 "set packet forwarding mode", modes);
4521 cmd_set_fwd_mode.help_str = help;
4523 /* string token separator is # */
4524 for (c = token; *modes != '\0'; modes++)
4529 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4530 token_struct->string_data.str = token;
4533 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4534 struct cmd_set_burst_tx_retry_result {
4535 cmdline_fixed_string_t set;
4536 cmdline_fixed_string_t burst;
4537 cmdline_fixed_string_t tx;
4538 cmdline_fixed_string_t delay;
4540 cmdline_fixed_string_t retry;
4544 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4545 __attribute__((unused)) struct cmdline *cl,
4546 __attribute__((unused)) void *data)
4548 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4550 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4551 && !strcmp(res->tx, "tx")) {
4552 if (!strcmp(res->delay, "delay"))
4553 burst_tx_delay_time = res->time;
4554 if (!strcmp(res->retry, "retry"))
4555 burst_tx_retry_num = res->retry_num;
4560 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4561 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4562 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4563 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4565 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4566 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4568 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4569 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4570 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4571 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4572 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4573 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4574 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4576 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4577 .f = cmd_set_burst_tx_retry_parsed,
4578 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4580 (void *)&cmd_set_burst_tx_retry_set,
4581 (void *)&cmd_set_burst_tx_retry_burst,
4582 (void *)&cmd_set_burst_tx_retry_tx,
4583 (void *)&cmd_set_burst_tx_retry_delay,
4584 (void *)&cmd_set_burst_tx_retry_time,
4585 (void *)&cmd_set_burst_tx_retry_retry,
4586 (void *)&cmd_set_burst_tx_retry_retry_num,
4591 /* *** SET PROMISC MODE *** */
4592 struct cmd_set_promisc_mode_result {
4593 cmdline_fixed_string_t set;
4594 cmdline_fixed_string_t promisc;
4595 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4596 uint8_t port_num; /* valid if "allports" argument == 0 */
4597 cmdline_fixed_string_t mode;
4600 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4601 __attribute__((unused)) struct cmdline *cl,
4604 struct cmd_set_promisc_mode_result *res = parsed_result;
4608 if (!strcmp(res->mode, "on"))
4615 FOREACH_PORT(i, ports) {
4617 rte_eth_promiscuous_enable(i);
4619 rte_eth_promiscuous_disable(i);
4624 rte_eth_promiscuous_enable(res->port_num);
4626 rte_eth_promiscuous_disable(res->port_num);
4630 cmdline_parse_token_string_t cmd_setpromisc_set =
4631 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4632 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4633 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4635 cmdline_parse_token_string_t cmd_setpromisc_portall =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4638 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4639 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4641 cmdline_parse_token_string_t cmd_setpromisc_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4645 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4646 .f = cmd_set_promisc_mode_parsed,
4648 .help_str = "set promisc all on|off: set promisc mode for all ports",
4650 (void *)&cmd_setpromisc_set,
4651 (void *)&cmd_setpromisc_promisc,
4652 (void *)&cmd_setpromisc_portall,
4653 (void *)&cmd_setpromisc_mode,
4658 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4659 .f = cmd_set_promisc_mode_parsed,
4661 .help_str = "set promisc X on|off: set promisc mode on port X",
4663 (void *)&cmd_setpromisc_set,
4664 (void *)&cmd_setpromisc_promisc,
4665 (void *)&cmd_setpromisc_portnum,
4666 (void *)&cmd_setpromisc_mode,
4671 /* *** SET ALLMULTI MODE *** */
4672 struct cmd_set_allmulti_mode_result {
4673 cmdline_fixed_string_t set;
4674 cmdline_fixed_string_t allmulti;
4675 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4676 uint8_t port_num; /* valid if "allports" argument == 0 */
4677 cmdline_fixed_string_t mode;
4680 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4681 __attribute__((unused)) struct cmdline *cl,
4684 struct cmd_set_allmulti_mode_result *res = parsed_result;
4688 if (!strcmp(res->mode, "on"))
4695 FOREACH_PORT(i, ports) {
4697 rte_eth_allmulticast_enable(i);
4699 rte_eth_allmulticast_disable(i);
4704 rte_eth_allmulticast_enable(res->port_num);
4706 rte_eth_allmulticast_disable(res->port_num);
4710 cmdline_parse_token_string_t cmd_setallmulti_set =
4711 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4712 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4715 cmdline_parse_token_string_t cmd_setallmulti_portall =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4718 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4719 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4721 cmdline_parse_token_string_t cmd_setallmulti_mode =
4722 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4725 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4726 .f = cmd_set_allmulti_mode_parsed,
4728 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4730 (void *)&cmd_setallmulti_set,
4731 (void *)&cmd_setallmulti_allmulti,
4732 (void *)&cmd_setallmulti_portall,
4733 (void *)&cmd_setallmulti_mode,
4738 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4739 .f = cmd_set_allmulti_mode_parsed,
4741 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4743 (void *)&cmd_setallmulti_set,
4744 (void *)&cmd_setallmulti_allmulti,
4745 (void *)&cmd_setallmulti_portnum,
4746 (void *)&cmd_setallmulti_mode,
4751 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4752 struct cmd_link_flow_ctrl_set_result {
4753 cmdline_fixed_string_t set;
4754 cmdline_fixed_string_t flow_ctrl;
4755 cmdline_fixed_string_t rx;
4756 cmdline_fixed_string_t rx_lfc_mode;
4757 cmdline_fixed_string_t tx;
4758 cmdline_fixed_string_t tx_lfc_mode;
4759 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4760 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4761 cmdline_fixed_string_t autoneg_str;
4762 cmdline_fixed_string_t autoneg;
4763 cmdline_fixed_string_t hw_str;
4764 uint32_t high_water;
4765 cmdline_fixed_string_t lw_str;
4767 cmdline_fixed_string_t pt_str;
4768 uint16_t pause_time;
4769 cmdline_fixed_string_t xon_str;
4774 cmdline_parse_token_string_t cmd_lfc_set_set =
4775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4777 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4779 flow_ctrl, "flow_ctrl");
4780 cmdline_parse_token_string_t cmd_lfc_set_rx =
4781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4783 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4785 rx_lfc_mode, "on#off");
4786 cmdline_parse_token_string_t cmd_lfc_set_tx =
4787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4789 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4790 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4791 tx_lfc_mode, "on#off");
4792 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4794 hw_str, "high_water");
4795 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4797 high_water, UINT32);
4798 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4800 lw_str, "low_water");
4801 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4804 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4806 pt_str, "pause_time");
4807 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4808 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4809 pause_time, UINT16);
4810 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4812 xon_str, "send_xon");
4813 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4814 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4816 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4818 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4819 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4821 mac_ctrl_frame_fwd_mode, "on#off");
4822 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4823 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4824 autoneg_str, "autoneg");
4825 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4826 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4828 cmdline_parse_token_num_t cmd_lfc_set_portid =
4829 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4832 /* forward declaration */
4834 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4837 cmdline_parse_inst_t cmd_link_flow_control_set = {
4838 .f = cmd_link_flow_ctrl_set_parsed,
4840 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4841 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4842 autoneg on|off port_id",
4844 (void *)&cmd_lfc_set_set,
4845 (void *)&cmd_lfc_set_flow_ctrl,
4846 (void *)&cmd_lfc_set_rx,
4847 (void *)&cmd_lfc_set_rx_mode,
4848 (void *)&cmd_lfc_set_tx,
4849 (void *)&cmd_lfc_set_tx_mode,
4850 (void *)&cmd_lfc_set_high_water,
4851 (void *)&cmd_lfc_set_low_water,
4852 (void *)&cmd_lfc_set_pause_time,
4853 (void *)&cmd_lfc_set_send_xon,
4854 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4855 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4856 (void *)&cmd_lfc_set_autoneg_str,
4857 (void *)&cmd_lfc_set_autoneg,
4858 (void *)&cmd_lfc_set_portid,
4863 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4864 .f = cmd_link_flow_ctrl_set_parsed,
4865 .data = (void *)&cmd_link_flow_control_set_rx,
4866 .help_str = "Change rx flow control parameter: set flow_ctrl "
4867 "rx on|off port_id",
4869 (void *)&cmd_lfc_set_set,
4870 (void *)&cmd_lfc_set_flow_ctrl,
4871 (void *)&cmd_lfc_set_rx,
4872 (void *)&cmd_lfc_set_rx_mode,
4873 (void *)&cmd_lfc_set_portid,
4878 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4879 .f = cmd_link_flow_ctrl_set_parsed,
4880 .data = (void *)&cmd_link_flow_control_set_tx,
4881 .help_str = "Change tx flow control parameter: set flow_ctrl "
4882 "tx on|off port_id",
4884 (void *)&cmd_lfc_set_set,
4885 (void *)&cmd_lfc_set_flow_ctrl,
4886 (void *)&cmd_lfc_set_tx,
4887 (void *)&cmd_lfc_set_tx_mode,
4888 (void *)&cmd_lfc_set_portid,
4893 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4894 .f = cmd_link_flow_ctrl_set_parsed,
4895 .data = (void *)&cmd_link_flow_control_set_hw,
4896 .help_str = "Change high water flow control parameter: set flow_ctrl "
4897 "high_water value port_id",
4899 (void *)&cmd_lfc_set_set,
4900 (void *)&cmd_lfc_set_flow_ctrl,
4901 (void *)&cmd_lfc_set_high_water_str,
4902 (void *)&cmd_lfc_set_high_water,
4903 (void *)&cmd_lfc_set_portid,
4908 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4909 .f = cmd_link_flow_ctrl_set_parsed,
4910 .data = (void *)&cmd_link_flow_control_set_lw,
4911 .help_str = "Change low water flow control parameter: set flow_ctrl "
4912 "low_water value port_id",
4914 (void *)&cmd_lfc_set_set,
4915 (void *)&cmd_lfc_set_flow_ctrl,
4916 (void *)&cmd_lfc_set_low_water_str,
4917 (void *)&cmd_lfc_set_low_water,
4918 (void *)&cmd_lfc_set_portid,
4923 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4924 .f = cmd_link_flow_ctrl_set_parsed,
4925 .data = (void *)&cmd_link_flow_control_set_pt,
4926 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4927 "pause_time value port_id",
4929 (void *)&cmd_lfc_set_set,
4930 (void *)&cmd_lfc_set_flow_ctrl,
4931 (void *)&cmd_lfc_set_pause_time_str,
4932 (void *)&cmd_lfc_set_pause_time,
4933 (void *)&cmd_lfc_set_portid,
4938 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4939 .f = cmd_link_flow_ctrl_set_parsed,
4940 .data = (void *)&cmd_link_flow_control_set_xon,
4941 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4942 "send_xon value port_id",
4944 (void *)&cmd_lfc_set_set,
4945 (void *)&cmd_lfc_set_flow_ctrl,
4946 (void *)&cmd_lfc_set_send_xon_str,
4947 (void *)&cmd_lfc_set_send_xon,
4948 (void *)&cmd_lfc_set_portid,
4953 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4954 .f = cmd_link_flow_ctrl_set_parsed,
4955 .data = (void *)&cmd_link_flow_control_set_macfwd,
4956 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4957 "mac_ctrl_frame_fwd on|off port_id",
4959 (void *)&cmd_lfc_set_set,
4960 (void *)&cmd_lfc_set_flow_ctrl,
4961 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4962 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4963 (void *)&cmd_lfc_set_portid,
4968 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4969 .f = cmd_link_flow_ctrl_set_parsed,
4970 .data = (void *)&cmd_link_flow_control_set_autoneg,
4971 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4972 "autoneg on|off port_id",
4974 (void *)&cmd_lfc_set_set,
4975 (void *)&cmd_lfc_set_flow_ctrl,
4976 (void *)&cmd_lfc_set_autoneg_str,
4977 (void *)&cmd_lfc_set_autoneg,
4978 (void *)&cmd_lfc_set_portid,
4984 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4985 __attribute__((unused)) struct cmdline *cl,
4988 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4989 cmdline_parse_inst_t *cmd = data;
4990 struct rte_eth_fc_conf fc_conf;
4996 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4997 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4998 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4999 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5001 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5002 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5005 /* Partial command line, retrieve current configuration */
5007 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5009 printf("cannot get current flow ctrl parameters, return"
5010 "code = %d\n", ret);
5014 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5015 (fc_conf.mode == RTE_FC_FULL))
5017 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5018 (fc_conf.mode == RTE_FC_FULL))
5022 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5023 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5025 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5026 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5028 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5030 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5031 fc_conf.high_water = res->high_water;
5033 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5034 fc_conf.low_water = res->low_water;
5036 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5037 fc_conf.pause_time = res->pause_time;
5039 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5040 fc_conf.send_xon = res->send_xon;
5042 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5043 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5044 fc_conf.mac_ctrl_frame_fwd = 1;
5046 fc_conf.mac_ctrl_frame_fwd = 0;
5049 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5050 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5052 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5054 printf("bad flow contrl parameter, return code = %d \n", ret);
5057 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5058 struct cmd_priority_flow_ctrl_set_result {
5059 cmdline_fixed_string_t set;
5060 cmdline_fixed_string_t pfc_ctrl;
5061 cmdline_fixed_string_t rx;
5062 cmdline_fixed_string_t rx_pfc_mode;
5063 cmdline_fixed_string_t tx;
5064 cmdline_fixed_string_t tx_pfc_mode;
5065 uint32_t high_water;
5067 uint16_t pause_time;
5073 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5074 __attribute__((unused)) struct cmdline *cl,
5075 __attribute__((unused)) void *data)
5077 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5078 struct rte_eth_pfc_conf pfc_conf;
5079 int rx_fc_enable, tx_fc_enable;
5083 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5084 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5085 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5086 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5088 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5089 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5092 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5093 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5094 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5095 pfc_conf.fc.high_water = res->high_water;
5096 pfc_conf.fc.low_water = res->low_water;
5097 pfc_conf.fc.pause_time = res->pause_time;
5098 pfc_conf.priority = res->priority;
5100 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5102 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5105 cmdline_parse_token_string_t cmd_pfc_set_set =
5106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5108 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5110 pfc_ctrl, "pfc_ctrl");
5111 cmdline_parse_token_string_t cmd_pfc_set_rx =
5112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5114 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5116 rx_pfc_mode, "on#off");
5117 cmdline_parse_token_string_t cmd_pfc_set_tx =
5118 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5120 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5121 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5122 tx_pfc_mode, "on#off");
5123 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5125 high_water, UINT32);
5126 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5129 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5131 pause_time, UINT16);
5132 cmdline_parse_token_num_t cmd_pfc_set_priority =
5133 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5135 cmdline_parse_token_num_t cmd_pfc_set_portid =
5136 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5139 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5140 .f = cmd_priority_flow_ctrl_set_parsed,
5142 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5143 tx on|off high_water low_water pause_time priority port_id",
5145 (void *)&cmd_pfc_set_set,
5146 (void *)&cmd_pfc_set_flow_ctrl,
5147 (void *)&cmd_pfc_set_rx,
5148 (void *)&cmd_pfc_set_rx_mode,
5149 (void *)&cmd_pfc_set_tx,
5150 (void *)&cmd_pfc_set_tx_mode,
5151 (void *)&cmd_pfc_set_high_water,
5152 (void *)&cmd_pfc_set_low_water,
5153 (void *)&cmd_pfc_set_pause_time,
5154 (void *)&cmd_pfc_set_priority,
5155 (void *)&cmd_pfc_set_portid,
5160 /* *** RESET CONFIGURATION *** */
5161 struct cmd_reset_result {
5162 cmdline_fixed_string_t reset;
5163 cmdline_fixed_string_t def;
5166 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5168 __attribute__((unused)) void *data)
5170 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5171 set_def_fwd_config();
5174 cmdline_parse_token_string_t cmd_reset_set =
5175 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5176 cmdline_parse_token_string_t cmd_reset_def =
5177 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5180 cmdline_parse_inst_t cmd_reset = {
5181 .f = cmd_reset_parsed,
5183 .help_str = "set default: reset default forwarding configuration",
5185 (void *)&cmd_reset_set,
5186 (void *)&cmd_reset_def,
5191 /* *** START FORWARDING *** */
5192 struct cmd_start_result {
5193 cmdline_fixed_string_t start;
5196 cmdline_parse_token_string_t cmd_start_start =
5197 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5199 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5200 __attribute__((unused)) struct cmdline *cl,
5201 __attribute__((unused)) void *data)
5203 start_packet_forwarding(0);
5206 cmdline_parse_inst_t cmd_start = {
5207 .f = cmd_start_parsed,
5209 .help_str = "start packet forwarding",
5211 (void *)&cmd_start_start,
5216 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5217 struct cmd_start_tx_first_result {
5218 cmdline_fixed_string_t start;
5219 cmdline_fixed_string_t tx_first;
5223 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5224 __attribute__((unused)) struct cmdline *cl,
5225 __attribute__((unused)) void *data)
5227 start_packet_forwarding(1);
5230 cmdline_parse_token_string_t cmd_start_tx_first_start =
5231 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5233 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5234 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5235 tx_first, "tx_first");
5237 cmdline_parse_inst_t cmd_start_tx_first = {
5238 .f = cmd_start_tx_first_parsed,
5240 .help_str = "start packet forwarding, after sending 1 burst of packets",
5242 (void *)&cmd_start_tx_first_start,
5243 (void *)&cmd_start_tx_first_tx_first,
5248 /* *** SET LINK UP *** */
5249 struct cmd_set_link_up_result {
5250 cmdline_fixed_string_t set;
5251 cmdline_fixed_string_t link_up;
5252 cmdline_fixed_string_t port;
5256 cmdline_parse_token_string_t cmd_set_link_up_set =
5257 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5258 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5259 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5261 cmdline_parse_token_string_t cmd_set_link_up_port =
5262 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5263 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5264 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5266 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5268 __attribute__((unused)) void *data)
5270 struct cmd_set_link_up_result *res = parsed_result;
5271 dev_set_link_up(res->port_id);
5274 cmdline_parse_inst_t cmd_set_link_up = {
5275 .f = cmd_set_link_up_parsed,
5277 .help_str = "set link-up port (port id)",
5279 (void *)&cmd_set_link_up_set,
5280 (void *)&cmd_set_link_up_link_up,
5281 (void *)&cmd_set_link_up_port,
5282 (void *)&cmd_set_link_up_port_id,
5287 /* *** SET LINK DOWN *** */
5288 struct cmd_set_link_down_result {
5289 cmdline_fixed_string_t set;
5290 cmdline_fixed_string_t link_down;
5291 cmdline_fixed_string_t port;
5295 cmdline_parse_token_string_t cmd_set_link_down_set =
5296 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5297 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5298 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5300 cmdline_parse_token_string_t cmd_set_link_down_port =
5301 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5302 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5303 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5305 static void cmd_set_link_down_parsed(
5306 __attribute__((unused)) void *parsed_result,
5307 __attribute__((unused)) struct cmdline *cl,
5308 __attribute__((unused)) void *data)
5310 struct cmd_set_link_down_result *res = parsed_result;
5311 dev_set_link_down(res->port_id);
5314 cmdline_parse_inst_t cmd_set_link_down = {
5315 .f = cmd_set_link_down_parsed,
5317 .help_str = "set link-down port (port id)",
5319 (void *)&cmd_set_link_down_set,
5320 (void *)&cmd_set_link_down_link_down,
5321 (void *)&cmd_set_link_down_port,
5322 (void *)&cmd_set_link_down_port_id,
5327 /* *** SHOW CFG *** */
5328 struct cmd_showcfg_result {
5329 cmdline_fixed_string_t show;
5330 cmdline_fixed_string_t cfg;
5331 cmdline_fixed_string_t what;
5334 static void cmd_showcfg_parsed(void *parsed_result,
5335 __attribute__((unused)) struct cmdline *cl,
5336 __attribute__((unused)) void *data)
5338 struct cmd_showcfg_result *res = parsed_result;
5339 if (!strcmp(res->what, "rxtx"))
5340 rxtx_config_display();
5341 else if (!strcmp(res->what, "cores"))
5342 fwd_lcores_config_display();
5343 else if (!strcmp(res->what, "fwd"))
5344 fwd_config_display();
5345 else if (!strcmp(res->what, "txpkts"))
5346 show_tx_pkt_segments();
5349 cmdline_parse_token_string_t cmd_showcfg_show =
5350 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5351 cmdline_parse_token_string_t cmd_showcfg_port =
5352 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5353 cmdline_parse_token_string_t cmd_showcfg_what =
5354 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5355 "rxtx#cores#fwd#txpkts");
5357 cmdline_parse_inst_t cmd_showcfg = {
5358 .f = cmd_showcfg_parsed,
5360 .help_str = "show config rxtx|cores|fwd|txpkts",
5362 (void *)&cmd_showcfg_show,
5363 (void *)&cmd_showcfg_port,
5364 (void *)&cmd_showcfg_what,
5369 /* *** SHOW ALL PORT INFO *** */
5370 struct cmd_showportall_result {
5371 cmdline_fixed_string_t show;
5372 cmdline_fixed_string_t port;
5373 cmdline_fixed_string_t what;
5374 cmdline_fixed_string_t all;
5377 static void cmd_showportall_parsed(void *parsed_result,
5378 __attribute__((unused)) struct cmdline *cl,
5379 __attribute__((unused)) void *data)
5383 struct cmd_showportall_result *res = parsed_result;
5384 if (!strcmp(res->show, "clear")) {
5385 if (!strcmp(res->what, "stats"))
5386 FOREACH_PORT(i, ports)
5388 else if (!strcmp(res->what, "xstats"))
5389 FOREACH_PORT(i, ports)
5390 nic_xstats_clear(i);
5391 } else if (!strcmp(res->what, "info"))
5392 FOREACH_PORT(i, ports)
5393 port_infos_display(i);
5394 else if (!strcmp(res->what, "stats"))
5395 FOREACH_PORT(i, ports)
5396 nic_stats_display(i);
5397 else if (!strcmp(res->what, "xstats"))
5398 FOREACH_PORT(i, ports)
5399 nic_xstats_display(i);
5400 else if (!strcmp(res->what, "fdir"))
5401 FOREACH_PORT(i, ports)
5403 else if (!strcmp(res->what, "stat_qmap"))
5404 FOREACH_PORT(i, ports)
5405 nic_stats_mapping_display(i);
5406 else if (!strcmp(res->what, "dcb_tc"))
5407 FOREACH_PORT(i, ports)
5408 port_dcb_info_display(i);
5411 cmdline_parse_token_string_t cmd_showportall_show =
5412 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5414 cmdline_parse_token_string_t cmd_showportall_port =
5415 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5416 cmdline_parse_token_string_t cmd_showportall_what =
5417 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5418 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5419 cmdline_parse_token_string_t cmd_showportall_all =
5420 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5421 cmdline_parse_inst_t cmd_showportall = {
5422 .f = cmd_showportall_parsed,
5424 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5426 (void *)&cmd_showportall_show,
5427 (void *)&cmd_showportall_port,
5428 (void *)&cmd_showportall_what,
5429 (void *)&cmd_showportall_all,
5434 /* *** SHOW PORT INFO *** */
5435 struct cmd_showport_result {
5436 cmdline_fixed_string_t show;
5437 cmdline_fixed_string_t port;
5438 cmdline_fixed_string_t what;
5442 static void cmd_showport_parsed(void *parsed_result,
5443 __attribute__((unused)) struct cmdline *cl,
5444 __attribute__((unused)) void *data)
5446 struct cmd_showport_result *res = parsed_result;
5447 if (!strcmp(res->show, "clear")) {
5448 if (!strcmp(res->what, "stats"))
5449 nic_stats_clear(res->portnum);
5450 else if (!strcmp(res->what, "xstats"))
5451 nic_xstats_clear(res->portnum);
5452 } else if (!strcmp(res->what, "info"))
5453 port_infos_display(res->portnum);
5454 else if (!strcmp(res->what, "stats"))
5455 nic_stats_display(res->portnum);
5456 else if (!strcmp(res->what, "xstats"))
5457 nic_xstats_display(res->portnum);
5458 else if (!strcmp(res->what, "fdir"))
5459 fdir_get_infos(res->portnum);
5460 else if (!strcmp(res->what, "stat_qmap"))
5461 nic_stats_mapping_display(res->portnum);
5462 else if (!strcmp(res->what, "dcb_tc"))
5463 port_dcb_info_display(res->portnum);
5466 cmdline_parse_token_string_t cmd_showport_show =
5467 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5469 cmdline_parse_token_string_t cmd_showport_port =
5470 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5471 cmdline_parse_token_string_t cmd_showport_what =
5472 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5473 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5474 cmdline_parse_token_num_t cmd_showport_portnum =
5475 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5477 cmdline_parse_inst_t cmd_showport = {
5478 .f = cmd_showport_parsed,
5480 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5482 (void *)&cmd_showport_show,
5483 (void *)&cmd_showport_port,
5484 (void *)&cmd_showport_what,
5485 (void *)&cmd_showport_portnum,
5490 /* *** SHOW QUEUE INFO *** */
5491 struct cmd_showqueue_result {
5492 cmdline_fixed_string_t show;
5493 cmdline_fixed_string_t type;
5494 cmdline_fixed_string_t what;
5500 cmd_showqueue_parsed(void *parsed_result,
5501 __attribute__((unused)) struct cmdline *cl,
5502 __attribute__((unused)) void *data)
5504 struct cmd_showqueue_result *res = parsed_result;
5506 if (!strcmp(res->type, "rxq"))
5507 rx_queue_infos_display(res->portnum, res->queuenum);
5508 else if (!strcmp(res->type, "txq"))
5509 tx_queue_infos_display(res->portnum, res->queuenum);
5512 cmdline_parse_token_string_t cmd_showqueue_show =
5513 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5514 cmdline_parse_token_string_t cmd_showqueue_type =
5515 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5516 cmdline_parse_token_string_t cmd_showqueue_what =
5517 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5518 cmdline_parse_token_num_t cmd_showqueue_portnum =
5519 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5520 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5521 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5523 cmdline_parse_inst_t cmd_showqueue = {
5524 .f = cmd_showqueue_parsed,
5526 .help_str = "show rxq|txq info <port number> <queue_number>",
5528 (void *)&cmd_showqueue_show,
5529 (void *)&cmd_showqueue_type,
5530 (void *)&cmd_showqueue_what,
5531 (void *)&cmd_showqueue_portnum,
5532 (void *)&cmd_showqueue_queuenum,
5537 /* *** READ PORT REGISTER *** */
5538 struct cmd_read_reg_result {
5539 cmdline_fixed_string_t read;
5540 cmdline_fixed_string_t reg;
5546 cmd_read_reg_parsed(void *parsed_result,
5547 __attribute__((unused)) struct cmdline *cl,
5548 __attribute__((unused)) void *data)
5550 struct cmd_read_reg_result *res = parsed_result;
5551 port_reg_display(res->port_id, res->reg_off);
5554 cmdline_parse_token_string_t cmd_read_reg_read =
5555 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5556 cmdline_parse_token_string_t cmd_read_reg_reg =
5557 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5558 cmdline_parse_token_num_t cmd_read_reg_port_id =
5559 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5560 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5561 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5563 cmdline_parse_inst_t cmd_read_reg = {
5564 .f = cmd_read_reg_parsed,
5566 .help_str = "read reg port_id reg_off",
5568 (void *)&cmd_read_reg_read,
5569 (void *)&cmd_read_reg_reg,
5570 (void *)&cmd_read_reg_port_id,
5571 (void *)&cmd_read_reg_reg_off,
5576 /* *** READ PORT REGISTER BIT FIELD *** */
5577 struct cmd_read_reg_bit_field_result {
5578 cmdline_fixed_string_t read;
5579 cmdline_fixed_string_t regfield;
5587 cmd_read_reg_bit_field_parsed(void *parsed_result,
5588 __attribute__((unused)) struct cmdline *cl,
5589 __attribute__((unused)) void *data)
5591 struct cmd_read_reg_bit_field_result *res = parsed_result;
5592 port_reg_bit_field_display(res->port_id, res->reg_off,
5593 res->bit1_pos, res->bit2_pos);
5596 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5597 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5599 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5600 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5601 regfield, "regfield");
5602 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5603 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5605 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5606 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5608 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5609 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5611 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5612 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5615 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5616 .f = cmd_read_reg_bit_field_parsed,
5618 .help_str = "read regfield port_id reg_off bit_x bit_y "
5619 "(read register bit field between bit_x and bit_y included)",
5621 (void *)&cmd_read_reg_bit_field_read,
5622 (void *)&cmd_read_reg_bit_field_regfield,
5623 (void *)&cmd_read_reg_bit_field_port_id,
5624 (void *)&cmd_read_reg_bit_field_reg_off,
5625 (void *)&cmd_read_reg_bit_field_bit1_pos,
5626 (void *)&cmd_read_reg_bit_field_bit2_pos,
5631 /* *** READ PORT REGISTER BIT *** */
5632 struct cmd_read_reg_bit_result {
5633 cmdline_fixed_string_t read;
5634 cmdline_fixed_string_t regbit;
5641 cmd_read_reg_bit_parsed(void *parsed_result,
5642 __attribute__((unused)) struct cmdline *cl,
5643 __attribute__((unused)) void *data)
5645 struct cmd_read_reg_bit_result *res = parsed_result;
5646 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5649 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5650 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5651 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5652 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5654 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5655 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5656 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5658 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5659 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5661 cmdline_parse_inst_t cmd_read_reg_bit = {
5662 .f = cmd_read_reg_bit_parsed,
5664 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5666 (void *)&cmd_read_reg_bit_read,
5667 (void *)&cmd_read_reg_bit_regbit,
5668 (void *)&cmd_read_reg_bit_port_id,
5669 (void *)&cmd_read_reg_bit_reg_off,
5670 (void *)&cmd_read_reg_bit_bit_pos,
5675 /* *** WRITE PORT REGISTER *** */
5676 struct cmd_write_reg_result {
5677 cmdline_fixed_string_t write;
5678 cmdline_fixed_string_t reg;
5685 cmd_write_reg_parsed(void *parsed_result,
5686 __attribute__((unused)) struct cmdline *cl,
5687 __attribute__((unused)) void *data)
5689 struct cmd_write_reg_result *res = parsed_result;
5690 port_reg_set(res->port_id, res->reg_off, res->value);
5693 cmdline_parse_token_string_t cmd_write_reg_write =
5694 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5695 cmdline_parse_token_string_t cmd_write_reg_reg =
5696 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5697 cmdline_parse_token_num_t cmd_write_reg_port_id =
5698 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5699 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5700 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5701 cmdline_parse_token_num_t cmd_write_reg_value =
5702 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5704 cmdline_parse_inst_t cmd_write_reg = {
5705 .f = cmd_write_reg_parsed,
5707 .help_str = "write reg port_id reg_off reg_value",
5709 (void *)&cmd_write_reg_write,
5710 (void *)&cmd_write_reg_reg,
5711 (void *)&cmd_write_reg_port_id,
5712 (void *)&cmd_write_reg_reg_off,
5713 (void *)&cmd_write_reg_value,
5718 /* *** WRITE PORT REGISTER BIT FIELD *** */
5719 struct cmd_write_reg_bit_field_result {
5720 cmdline_fixed_string_t write;
5721 cmdline_fixed_string_t regfield;
5730 cmd_write_reg_bit_field_parsed(void *parsed_result,
5731 __attribute__((unused)) struct cmdline *cl,
5732 __attribute__((unused)) void *data)
5734 struct cmd_write_reg_bit_field_result *res = parsed_result;
5735 port_reg_bit_field_set(res->port_id, res->reg_off,
5736 res->bit1_pos, res->bit2_pos, res->value);
5739 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5740 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5742 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5743 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5744 regfield, "regfield");
5745 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5746 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5748 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5751 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5754 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5755 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5757 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5758 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5761 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5762 .f = cmd_write_reg_bit_field_parsed,
5764 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5765 "(set register bit field between bit_x and bit_y included)",
5767 (void *)&cmd_write_reg_bit_field_write,
5768 (void *)&cmd_write_reg_bit_field_regfield,
5769 (void *)&cmd_write_reg_bit_field_port_id,
5770 (void *)&cmd_write_reg_bit_field_reg_off,
5771 (void *)&cmd_write_reg_bit_field_bit1_pos,
5772 (void *)&cmd_write_reg_bit_field_bit2_pos,
5773 (void *)&cmd_write_reg_bit_field_value,
5778 /* *** WRITE PORT REGISTER BIT *** */
5779 struct cmd_write_reg_bit_result {
5780 cmdline_fixed_string_t write;
5781 cmdline_fixed_string_t regbit;
5789 cmd_write_reg_bit_parsed(void *parsed_result,
5790 __attribute__((unused)) struct cmdline *cl,
5791 __attribute__((unused)) void *data)
5793 struct cmd_write_reg_bit_result *res = parsed_result;
5794 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5797 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5798 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5800 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5801 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5803 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5805 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5807 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5808 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5809 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5810 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5812 cmdline_parse_inst_t cmd_write_reg_bit = {
5813 .f = cmd_write_reg_bit_parsed,
5815 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5817 (void *)&cmd_write_reg_bit_write,
5818 (void *)&cmd_write_reg_bit_regbit,
5819 (void *)&cmd_write_reg_bit_port_id,
5820 (void *)&cmd_write_reg_bit_reg_off,
5821 (void *)&cmd_write_reg_bit_bit_pos,
5822 (void *)&cmd_write_reg_bit_value,
5827 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5828 struct cmd_read_rxd_txd_result {
5829 cmdline_fixed_string_t read;
5830 cmdline_fixed_string_t rxd_txd;
5837 cmd_read_rxd_txd_parsed(void *parsed_result,
5838 __attribute__((unused)) struct cmdline *cl,
5839 __attribute__((unused)) void *data)
5841 struct cmd_read_rxd_txd_result *res = parsed_result;
5843 if (!strcmp(res->rxd_txd, "rxd"))
5844 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5845 else if (!strcmp(res->rxd_txd, "txd"))
5846 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5849 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5850 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5851 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5852 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5854 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5855 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5856 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5857 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5858 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5859 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5861 cmdline_parse_inst_t cmd_read_rxd_txd = {
5862 .f = cmd_read_rxd_txd_parsed,
5864 .help_str = "read rxd|txd port_id queue_id rxd_id",
5866 (void *)&cmd_read_rxd_txd_read,
5867 (void *)&cmd_read_rxd_txd_rxd_txd,
5868 (void *)&cmd_read_rxd_txd_port_id,
5869 (void *)&cmd_read_rxd_txd_queue_id,
5870 (void *)&cmd_read_rxd_txd_desc_id,
5876 struct cmd_quit_result {
5877 cmdline_fixed_string_t quit;
5880 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5882 __attribute__((unused)) void *data)
5888 cmdline_parse_token_string_t cmd_quit_quit =
5889 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5891 cmdline_parse_inst_t cmd_quit = {
5892 .f = cmd_quit_parsed,
5894 .help_str = "exit application",
5896 (void *)&cmd_quit_quit,
5901 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5902 struct cmd_mac_addr_result {
5903 cmdline_fixed_string_t mac_addr_cmd;
5904 cmdline_fixed_string_t what;
5906 struct ether_addr address;
5909 static void cmd_mac_addr_parsed(void *parsed_result,
5910 __attribute__((unused)) struct cmdline *cl,
5911 __attribute__((unused)) void *data)
5913 struct cmd_mac_addr_result *res = parsed_result;
5916 if (strcmp(res->what, "add") == 0)
5917 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5919 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5921 /* check the return value and print it if is < 0 */
5923 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5927 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5928 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5930 cmdline_parse_token_string_t cmd_mac_addr_what =
5931 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5933 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5934 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5935 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5936 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5938 cmdline_parse_inst_t cmd_mac_addr = {
5939 .f = cmd_mac_addr_parsed,
5941 .help_str = "mac_addr add|remove X <address>: "
5942 "add/remove MAC address on port X",
5944 (void *)&cmd_mac_addr_cmd,
5945 (void *)&cmd_mac_addr_what,
5946 (void *)&cmd_mac_addr_portnum,
5947 (void *)&cmd_mac_addr_addr,
5953 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5954 struct cmd_set_qmap_result {
5955 cmdline_fixed_string_t set;
5956 cmdline_fixed_string_t qmap;
5957 cmdline_fixed_string_t what;
5964 cmd_set_qmap_parsed(void *parsed_result,
5965 __attribute__((unused)) struct cmdline *cl,
5966 __attribute__((unused)) void *data)
5968 struct cmd_set_qmap_result *res = parsed_result;
5969 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5971 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5974 cmdline_parse_token_string_t cmd_setqmap_set =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5977 cmdline_parse_token_string_t cmd_setqmap_qmap =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5980 cmdline_parse_token_string_t cmd_setqmap_what =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5983 cmdline_parse_token_num_t cmd_setqmap_portid =
5984 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5986 cmdline_parse_token_num_t cmd_setqmap_queueid =
5987 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5989 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5990 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5993 cmdline_parse_inst_t cmd_set_qmap = {
5994 .f = cmd_set_qmap_parsed,
5996 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5998 (void *)&cmd_setqmap_set,
5999 (void *)&cmd_setqmap_qmap,
6000 (void *)&cmd_setqmap_what,
6001 (void *)&cmd_setqmap_portid,
6002 (void *)&cmd_setqmap_queueid,
6003 (void *)&cmd_setqmap_mapvalue,
6008 /* *** CONFIGURE UNICAST HASH TABLE *** */
6009 struct cmd_set_uc_hash_table {
6010 cmdline_fixed_string_t set;
6011 cmdline_fixed_string_t port;
6013 cmdline_fixed_string_t what;
6014 struct ether_addr address;
6015 cmdline_fixed_string_t mode;
6019 cmd_set_uc_hash_parsed(void *parsed_result,
6020 __attribute__((unused)) struct cmdline *cl,
6021 __attribute__((unused)) void *data)
6024 struct cmd_set_uc_hash_table *res = parsed_result;
6026 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6028 if (strcmp(res->what, "uta") == 0)
6029 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6030 &res->address,(uint8_t)is_on);
6032 printf("bad unicast hash table parameter, return code = %d \n", ret);
6036 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6037 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6039 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6042 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6043 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6045 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6048 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6049 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6051 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6052 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6055 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6056 .f = cmd_set_uc_hash_parsed,
6058 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6060 (void *)&cmd_set_uc_hash_set,
6061 (void *)&cmd_set_uc_hash_port,
6062 (void *)&cmd_set_uc_hash_portid,
6063 (void *)&cmd_set_uc_hash_what,
6064 (void *)&cmd_set_uc_hash_mac,
6065 (void *)&cmd_set_uc_hash_mode,
6070 struct cmd_set_uc_all_hash_table {
6071 cmdline_fixed_string_t set;
6072 cmdline_fixed_string_t port;
6074 cmdline_fixed_string_t what;
6075 cmdline_fixed_string_t value;
6076 cmdline_fixed_string_t mode;
6080 cmd_set_uc_all_hash_parsed(void *parsed_result,
6081 __attribute__((unused)) struct cmdline *cl,
6082 __attribute__((unused)) void *data)
6085 struct cmd_set_uc_all_hash_table *res = parsed_result;
6087 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6089 if ((strcmp(res->what, "uta") == 0) &&
6090 (strcmp(res->value, "all") == 0))
6091 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6093 printf("bad unicast hash table parameter,"
6094 "return code = %d \n", ret);
6097 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6098 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6100 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6101 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6103 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6104 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6106 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6109 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6112 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6116 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6117 .f = cmd_set_uc_all_hash_parsed,
6119 .help_str = "set port X uta all on|off (X = port number)",
6121 (void *)&cmd_set_uc_all_hash_set,
6122 (void *)&cmd_set_uc_all_hash_port,
6123 (void *)&cmd_set_uc_all_hash_portid,
6124 (void *)&cmd_set_uc_all_hash_what,
6125 (void *)&cmd_set_uc_all_hash_value,
6126 (void *)&cmd_set_uc_all_hash_mode,
6131 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6132 struct cmd_set_vf_macvlan_filter {
6133 cmdline_fixed_string_t set;
6134 cmdline_fixed_string_t port;
6136 cmdline_fixed_string_t vf;
6138 struct ether_addr address;
6139 cmdline_fixed_string_t filter_type;
6140 cmdline_fixed_string_t mode;
6144 cmd_set_vf_macvlan_parsed(void *parsed_result,
6145 __attribute__((unused)) struct cmdline *cl,
6146 __attribute__((unused)) void *data)
6149 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6150 struct rte_eth_mac_filter filter;
6152 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6154 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6156 /* set VF MAC filter */
6160 filter.dst_id = res->vf_id;
6162 if (!strcmp(res->filter_type, "exact-mac"))
6163 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6164 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6165 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6166 else if (!strcmp(res->filter_type, "hashmac"))
6167 filter.filter_type = RTE_MAC_HASH_MATCH;
6168 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6169 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6171 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6174 ret = rte_eth_dev_filter_ctrl(res->port_id,
6175 RTE_ETH_FILTER_MACVLAN,
6179 ret = rte_eth_dev_filter_ctrl(res->port_id,
6180 RTE_ETH_FILTER_MACVLAN,
6181 RTE_ETH_FILTER_DELETE,
6185 printf("bad set MAC hash parameter, return code = %d\n", ret);
6189 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6190 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6192 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6195 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6196 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6198 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6199 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6201 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6202 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6204 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6205 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6207 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6209 filter_type, "exact-mac#exact-mac-vlan"
6210 "#hashmac#hashmac-vlan");
6211 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6212 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6215 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6216 .f = cmd_set_vf_macvlan_parsed,
6218 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6219 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6221 "exact match rule:exact match of MAC or MAC and VLAN; "
6222 "hash match rule: hash match of MAC and exact match "
6225 (void *)&cmd_set_vf_macvlan_set,
6226 (void *)&cmd_set_vf_macvlan_port,
6227 (void *)&cmd_set_vf_macvlan_portid,
6228 (void *)&cmd_set_vf_macvlan_vf,
6229 (void *)&cmd_set_vf_macvlan_vf_id,
6230 (void *)&cmd_set_vf_macvlan_mac,
6231 (void *)&cmd_set_vf_macvlan_filter_type,
6232 (void *)&cmd_set_vf_macvlan_mode,
6237 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6238 struct cmd_set_vf_traffic {
6239 cmdline_fixed_string_t set;
6240 cmdline_fixed_string_t port;
6242 cmdline_fixed_string_t vf;
6244 cmdline_fixed_string_t what;
6245 cmdline_fixed_string_t mode;
6249 cmd_set_vf_traffic_parsed(void *parsed_result,
6250 __attribute__((unused)) struct cmdline *cl,
6251 __attribute__((unused)) void *data)
6253 struct cmd_set_vf_traffic *res = parsed_result;
6254 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6255 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6257 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6260 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6263 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6266 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6267 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6269 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6272 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6273 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6275 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6276 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6278 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6279 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6282 cmdline_parse_inst_t cmd_set_vf_traffic = {
6283 .f = cmd_set_vf_traffic_parsed,
6285 .help_str = "set port X vf Y rx|tx on|off"
6286 "(X = port number,Y = vf id)",
6288 (void *)&cmd_setvf_traffic_set,
6289 (void *)&cmd_setvf_traffic_port,
6290 (void *)&cmd_setvf_traffic_portid,
6291 (void *)&cmd_setvf_traffic_vf,
6292 (void *)&cmd_setvf_traffic_vfid,
6293 (void *)&cmd_setvf_traffic_what,
6294 (void *)&cmd_setvf_traffic_mode,
6299 /* *** CONFIGURE VF RECEIVE MODE *** */
6300 struct cmd_set_vf_rxmode {
6301 cmdline_fixed_string_t set;
6302 cmdline_fixed_string_t port;
6304 cmdline_fixed_string_t vf;
6306 cmdline_fixed_string_t what;
6307 cmdline_fixed_string_t mode;
6308 cmdline_fixed_string_t on;
6312 cmd_set_vf_rxmode_parsed(void *parsed_result,
6313 __attribute__((unused)) struct cmdline *cl,
6314 __attribute__((unused)) void *data)
6317 uint16_t rx_mode = 0;
6318 struct cmd_set_vf_rxmode *res = parsed_result;
6320 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6321 if (!strcmp(res->what,"rxmode")) {
6322 if (!strcmp(res->mode, "AUPE"))
6323 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6324 else if (!strcmp(res->mode, "ROPE"))
6325 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6326 else if (!strcmp(res->mode, "BAM"))
6327 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6328 else if (!strncmp(res->mode, "MPE",3))
6329 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6332 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6334 printf("bad VF receive mode parameter, return code = %d \n",
6338 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6339 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6341 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6344 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6347 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6350 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6351 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6353 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6356 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6357 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6358 mode, "AUPE#ROPE#BAM#MPE");
6359 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6360 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6363 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6364 .f = cmd_set_vf_rxmode_parsed,
6366 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6368 (void *)&cmd_set_vf_rxmode_set,
6369 (void *)&cmd_set_vf_rxmode_port,
6370 (void *)&cmd_set_vf_rxmode_portid,
6371 (void *)&cmd_set_vf_rxmode_vf,
6372 (void *)&cmd_set_vf_rxmode_vfid,
6373 (void *)&cmd_set_vf_rxmode_what,
6374 (void *)&cmd_set_vf_rxmode_mode,
6375 (void *)&cmd_set_vf_rxmode_on,
6380 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6381 struct cmd_vf_mac_addr_result {
6382 cmdline_fixed_string_t mac_addr_cmd;
6383 cmdline_fixed_string_t what;
6384 cmdline_fixed_string_t port;
6386 cmdline_fixed_string_t vf;
6388 struct ether_addr address;
6391 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6392 __attribute__((unused)) struct cmdline *cl,
6393 __attribute__((unused)) void *data)
6395 struct cmd_vf_mac_addr_result *res = parsed_result;
6398 if (strcmp(res->what, "add") == 0)
6399 ret = rte_eth_dev_mac_addr_add(res->port_num,
6400 &res->address, res->vf_num);
6402 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6406 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6407 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6408 mac_addr_cmd,"mac_addr");
6409 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6410 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6412 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6413 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6415 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6416 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6418 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6419 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6421 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6422 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6424 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6425 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6428 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6429 .f = cmd_vf_mac_addr_parsed,
6431 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6432 "Y = VF number)add MAC address filtering for a VF on port X",
6434 (void *)&cmd_vf_mac_addr_cmd,
6435 (void *)&cmd_vf_mac_addr_what,
6436 (void *)&cmd_vf_mac_addr_port,
6437 (void *)&cmd_vf_mac_addr_portnum,
6438 (void *)&cmd_vf_mac_addr_vf,
6439 (void *)&cmd_vf_mac_addr_vfnum,
6440 (void *)&cmd_vf_mac_addr_addr,
6445 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6446 struct cmd_vf_rx_vlan_filter {
6447 cmdline_fixed_string_t rx_vlan;
6448 cmdline_fixed_string_t what;
6450 cmdline_fixed_string_t port;
6452 cmdline_fixed_string_t vf;
6457 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6458 __attribute__((unused)) struct cmdline *cl,
6459 __attribute__((unused)) void *data)
6461 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6463 if (!strcmp(res->what, "add"))
6464 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6466 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6469 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6470 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6471 rx_vlan, "rx_vlan");
6472 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6473 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6475 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6476 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6478 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6479 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6481 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6482 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6484 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6485 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6487 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6488 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6491 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6492 .f = cmd_vf_rx_vlan_filter_parsed,
6494 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6495 "Y = port number,Z = hexadecimal VF mask)",
6497 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6498 (void *)&cmd_vf_rx_vlan_filter_what,
6499 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6500 (void *)&cmd_vf_rx_vlan_filter_port,
6501 (void *)&cmd_vf_rx_vlan_filter_portid,
6502 (void *)&cmd_vf_rx_vlan_filter_vf,
6503 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6508 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6509 struct cmd_queue_rate_limit_result {
6510 cmdline_fixed_string_t set;
6511 cmdline_fixed_string_t port;
6513 cmdline_fixed_string_t queue;
6515 cmdline_fixed_string_t rate;
6519 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6520 __attribute__((unused)) struct cmdline *cl,
6521 __attribute__((unused)) void *data)
6523 struct cmd_queue_rate_limit_result *res = parsed_result;
6526 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6527 && (strcmp(res->queue, "queue") == 0)
6528 && (strcmp(res->rate, "rate") == 0))
6529 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6532 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6536 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6537 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6539 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6540 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6542 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6543 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6545 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6546 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6548 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6549 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6551 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6552 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6554 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6555 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6558 cmdline_parse_inst_t cmd_queue_rate_limit = {
6559 .f = cmd_queue_rate_limit_parsed,
6561 .help_str = "set port X queue Y rate Z:(X = port number,"
6562 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6564 (void *)&cmd_queue_rate_limit_set,
6565 (void *)&cmd_queue_rate_limit_port,
6566 (void *)&cmd_queue_rate_limit_portnum,
6567 (void *)&cmd_queue_rate_limit_queue,
6568 (void *)&cmd_queue_rate_limit_queuenum,
6569 (void *)&cmd_queue_rate_limit_rate,
6570 (void *)&cmd_queue_rate_limit_ratenum,
6575 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6576 struct cmd_vf_rate_limit_result {
6577 cmdline_fixed_string_t set;
6578 cmdline_fixed_string_t port;
6580 cmdline_fixed_string_t vf;
6582 cmdline_fixed_string_t rate;
6584 cmdline_fixed_string_t q_msk;
6588 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6589 __attribute__((unused)) struct cmdline *cl,
6590 __attribute__((unused)) void *data)
6592 struct cmd_vf_rate_limit_result *res = parsed_result;
6595 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6596 && (strcmp(res->vf, "vf") == 0)
6597 && (strcmp(res->rate, "rate") == 0)
6598 && (strcmp(res->q_msk, "queue_mask") == 0))
6599 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6600 res->rate_num, res->q_msk_val);
6602 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6606 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6607 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6609 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6612 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6615 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6618 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6621 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6624 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6625 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6627 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6628 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6629 q_msk, "queue_mask");
6630 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6631 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6634 cmdline_parse_inst_t cmd_vf_rate_limit = {
6635 .f = cmd_vf_rate_limit_parsed,
6637 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6638 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6639 "for queues of VF on port X",
6641 (void *)&cmd_vf_rate_limit_set,
6642 (void *)&cmd_vf_rate_limit_port,
6643 (void *)&cmd_vf_rate_limit_portnum,
6644 (void *)&cmd_vf_rate_limit_vf,
6645 (void *)&cmd_vf_rate_limit_vfnum,
6646 (void *)&cmd_vf_rate_limit_rate,
6647 (void *)&cmd_vf_rate_limit_ratenum,
6648 (void *)&cmd_vf_rate_limit_q_msk,
6649 (void *)&cmd_vf_rate_limit_q_msk_val,
6654 /* *** ADD TUNNEL FILTER OF A PORT *** */
6655 struct cmd_tunnel_filter_result {
6656 cmdline_fixed_string_t cmd;
6657 cmdline_fixed_string_t what;
6659 struct ether_addr outer_mac;
6660 struct ether_addr inner_mac;
6661 cmdline_ipaddr_t ip_value;
6662 uint16_t inner_vlan;
6663 cmdline_fixed_string_t tunnel_type;
6664 cmdline_fixed_string_t filter_type;
6670 cmd_tunnel_filter_parsed(void *parsed_result,
6671 __attribute__((unused)) struct cmdline *cl,
6672 __attribute__((unused)) void *data)
6674 struct cmd_tunnel_filter_result *res = parsed_result;
6675 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6678 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6680 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6681 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6682 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6684 if (res->ip_value.family == AF_INET) {
6685 tunnel_filter_conf.ip_addr.ipv4_addr =
6686 res->ip_value.addr.ipv4.s_addr;
6687 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6689 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6690 &(res->ip_value.addr.ipv6),
6691 sizeof(struct in6_addr));
6692 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6695 if (!strcmp(res->filter_type, "imac-ivlan"))
6696 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6697 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6698 tunnel_filter_conf.filter_type =
6699 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6700 else if (!strcmp(res->filter_type, "imac-tenid"))
6701 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6702 else if (!strcmp(res->filter_type, "imac"))
6703 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6704 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6705 tunnel_filter_conf.filter_type =
6706 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6707 else if (!strcmp(res->filter_type, "oip"))
6708 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6709 else if (!strcmp(res->filter_type, "iip"))
6710 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6712 printf("The filter type is not supported");
6716 if (!strcmp(res->tunnel_type, "vxlan"))
6717 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6718 else if (!strcmp(res->tunnel_type, "nvgre"))
6719 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6720 else if (!strcmp(res->tunnel_type, "ipingre"))
6721 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6723 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6727 tunnel_filter_conf.tenant_id = res->tenant_id;
6728 tunnel_filter_conf.queue_id = res->queue_num;
6729 if (!strcmp(res->what, "add"))
6730 ret = rte_eth_dev_filter_ctrl(res->port_id,
6731 RTE_ETH_FILTER_TUNNEL,
6733 &tunnel_filter_conf);
6735 ret = rte_eth_dev_filter_ctrl(res->port_id,
6736 RTE_ETH_FILTER_TUNNEL,
6737 RTE_ETH_FILTER_DELETE,
6738 &tunnel_filter_conf);
6740 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6744 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6745 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6746 cmd, "tunnel_filter");
6747 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6748 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6750 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6751 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6753 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6754 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6756 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6757 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6759 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6760 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6761 inner_vlan, UINT16);
6762 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6763 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6765 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6766 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6767 tunnel_type, "vxlan#nvgre#ipingre");
6769 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6770 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6771 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6772 "imac#omac-imac-tenid");
6773 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6774 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6776 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6777 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6780 cmdline_parse_inst_t cmd_tunnel_filter = {
6781 .f = cmd_tunnel_filter_parsed,
6783 .help_str = "add/rm tunnel filter of a port: "
6784 "tunnel_filter add port_id outer_mac inner_mac ip "
6785 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6786 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6787 "imac|omac-imac-tenid) "
6788 "tenant_id queue_num",
6790 (void *)&cmd_tunnel_filter_cmd,
6791 (void *)&cmd_tunnel_filter_what,
6792 (void *)&cmd_tunnel_filter_port_id,
6793 (void *)&cmd_tunnel_filter_outer_mac,
6794 (void *)&cmd_tunnel_filter_inner_mac,
6795 (void *)&cmd_tunnel_filter_ip_value,
6796 (void *)&cmd_tunnel_filter_innner_vlan,
6797 (void *)&cmd_tunnel_filter_tunnel_type,
6798 (void *)&cmd_tunnel_filter_filter_type,
6799 (void *)&cmd_tunnel_filter_tenant_id,
6800 (void *)&cmd_tunnel_filter_queue_num,
6805 /* *** CONFIGURE TUNNEL UDP PORT *** */
6806 struct cmd_tunnel_udp_config {
6807 cmdline_fixed_string_t cmd;
6808 cmdline_fixed_string_t what;
6814 cmd_tunnel_udp_config_parsed(void *parsed_result,
6815 __attribute__((unused)) struct cmdline *cl,
6816 __attribute__((unused)) void *data)
6818 struct cmd_tunnel_udp_config *res = parsed_result;
6819 struct rte_eth_udp_tunnel tunnel_udp;
6822 tunnel_udp.udp_port = res->udp_port;
6824 if (!strcmp(res->cmd, "rx_vxlan_port"))
6825 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6827 if (!strcmp(res->what, "add"))
6828 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
6831 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
6835 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6838 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6839 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6840 cmd, "rx_vxlan_port");
6841 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6842 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6844 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6845 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6847 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6848 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6851 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6852 .f = cmd_tunnel_udp_config_parsed,
6854 .help_str = "add/rm an tunneling UDP port filter: "
6855 "rx_vxlan_port add udp_port port_id",
6857 (void *)&cmd_tunnel_udp_config_cmd,
6858 (void *)&cmd_tunnel_udp_config_what,
6859 (void *)&cmd_tunnel_udp_config_udp_port,
6860 (void *)&cmd_tunnel_udp_config_port_id,
6865 /* *** GLOBAL CONFIG *** */
6866 struct cmd_global_config_result {
6867 cmdline_fixed_string_t cmd;
6869 cmdline_fixed_string_t cfg_type;
6874 cmd_global_config_parsed(void *parsed_result,
6875 __attribute__((unused)) struct cmdline *cl,
6876 __attribute__((unused)) void *data)
6878 struct cmd_global_config_result *res = parsed_result;
6879 struct rte_eth_global_cfg conf;
6882 memset(&conf, 0, sizeof(conf));
6883 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6884 conf.cfg.gre_key_len = res->len;
6885 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6886 RTE_ETH_FILTER_SET, &conf);
6888 printf("Global config error\n");
6891 cmdline_parse_token_string_t cmd_global_config_cmd =
6892 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6894 cmdline_parse_token_num_t cmd_global_config_port_id =
6895 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6896 cmdline_parse_token_string_t cmd_global_config_type =
6897 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6898 cfg_type, "gre-key-len");
6899 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6900 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6903 cmdline_parse_inst_t cmd_global_config = {
6904 .f = cmd_global_config_parsed,
6905 .data = (void *)NULL,
6906 .help_str = "global_config <port_id> gre-key-len <number>",
6908 (void *)&cmd_global_config_cmd,
6909 (void *)&cmd_global_config_port_id,
6910 (void *)&cmd_global_config_type,
6911 (void *)&cmd_global_config_gre_key_len,
6916 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6917 struct cmd_set_mirror_mask_result {
6918 cmdline_fixed_string_t set;
6919 cmdline_fixed_string_t port;
6921 cmdline_fixed_string_t mirror;
6923 cmdline_fixed_string_t what;
6924 cmdline_fixed_string_t value;
6925 cmdline_fixed_string_t dstpool;
6927 cmdline_fixed_string_t on;
6930 cmdline_parse_token_string_t cmd_mirror_mask_set =
6931 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6933 cmdline_parse_token_string_t cmd_mirror_mask_port =
6934 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6936 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6937 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6939 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6941 mirror, "mirror-rule");
6942 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6943 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6945 cmdline_parse_token_string_t cmd_mirror_mask_what =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6947 what, "pool-mirror-up#pool-mirror-down"
6949 cmdline_parse_token_string_t cmd_mirror_mask_value =
6950 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6952 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6953 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6954 dstpool, "dst-pool");
6955 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6956 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6958 cmdline_parse_token_string_t cmd_mirror_mask_on =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6963 cmd_set_mirror_mask_parsed(void *parsed_result,
6964 __attribute__((unused)) struct cmdline *cl,
6965 __attribute__((unused)) void *data)
6968 struct cmd_set_mirror_mask_result *res = parsed_result;
6969 struct rte_eth_mirror_conf mr_conf;
6971 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6973 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6975 mr_conf.dst_pool = res->dstpool_id;
6977 if (!strcmp(res->what, "pool-mirror-up")) {
6978 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6979 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6980 } else if (!strcmp(res->what, "pool-mirror-down")) {
6981 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6982 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6983 } else if (!strcmp(res->what, "vlan-mirror")) {
6984 mr_conf.rule_type = ETH_MIRROR_VLAN;
6985 nb_item = parse_item_list(res->value, "vlan",
6986 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6990 for (i = 0; i < nb_item; i++) {
6991 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6992 printf("Invalid vlan_id: must be < 4096\n");
6996 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6997 mr_conf.vlan.vlan_mask |= 1ULL << i;
7001 if (!strcmp(res->on, "on"))
7002 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7005 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7008 printf("mirror rule add error: (%s)\n", strerror(-ret));
7011 cmdline_parse_inst_t cmd_set_mirror_mask = {
7012 .f = cmd_set_mirror_mask_parsed,
7014 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7015 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7017 (void *)&cmd_mirror_mask_set,
7018 (void *)&cmd_mirror_mask_port,
7019 (void *)&cmd_mirror_mask_portid,
7020 (void *)&cmd_mirror_mask_mirror,
7021 (void *)&cmd_mirror_mask_ruleid,
7022 (void *)&cmd_mirror_mask_what,
7023 (void *)&cmd_mirror_mask_value,
7024 (void *)&cmd_mirror_mask_dstpool,
7025 (void *)&cmd_mirror_mask_poolid,
7026 (void *)&cmd_mirror_mask_on,
7031 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7032 struct cmd_set_mirror_link_result {
7033 cmdline_fixed_string_t set;
7034 cmdline_fixed_string_t port;
7036 cmdline_fixed_string_t mirror;
7038 cmdline_fixed_string_t what;
7039 cmdline_fixed_string_t dstpool;
7041 cmdline_fixed_string_t on;
7044 cmdline_parse_token_string_t cmd_mirror_link_set =
7045 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7047 cmdline_parse_token_string_t cmd_mirror_link_port =
7048 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7050 cmdline_parse_token_num_t cmd_mirror_link_portid =
7051 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7053 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7054 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7055 mirror, "mirror-rule");
7056 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7057 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7059 cmdline_parse_token_string_t cmd_mirror_link_what =
7060 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7061 what, "uplink-mirror#downlink-mirror");
7062 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7063 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7064 dstpool, "dst-pool");
7065 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7066 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7068 cmdline_parse_token_string_t cmd_mirror_link_on =
7069 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7073 cmd_set_mirror_link_parsed(void *parsed_result,
7074 __attribute__((unused)) struct cmdline *cl,
7075 __attribute__((unused)) void *data)
7078 struct cmd_set_mirror_link_result *res = parsed_result;
7079 struct rte_eth_mirror_conf mr_conf;
7081 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7082 if (!strcmp(res->what, "uplink-mirror"))
7083 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7085 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7087 mr_conf.dst_pool = res->dstpool_id;
7089 if (!strcmp(res->on, "on"))
7090 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7093 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7096 /* check the return value and print it if is < 0 */
7098 printf("mirror rule add error: (%s)\n", strerror(-ret));
7102 cmdline_parse_inst_t cmd_set_mirror_link = {
7103 .f = cmd_set_mirror_link_parsed,
7105 .help_str = "set port X mirror-rule Y uplink-mirror|"
7106 "downlink-mirror dst-pool Z on|off",
7108 (void *)&cmd_mirror_link_set,
7109 (void *)&cmd_mirror_link_port,
7110 (void *)&cmd_mirror_link_portid,
7111 (void *)&cmd_mirror_link_mirror,
7112 (void *)&cmd_mirror_link_ruleid,
7113 (void *)&cmd_mirror_link_what,
7114 (void *)&cmd_mirror_link_dstpool,
7115 (void *)&cmd_mirror_link_poolid,
7116 (void *)&cmd_mirror_link_on,
7121 /* *** RESET VM MIRROR RULE *** */
7122 struct cmd_rm_mirror_rule_result {
7123 cmdline_fixed_string_t reset;
7124 cmdline_fixed_string_t port;
7126 cmdline_fixed_string_t mirror;
7130 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7131 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7133 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7134 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7136 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7137 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7139 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7140 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7141 mirror, "mirror-rule");
7142 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7143 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7147 cmd_reset_mirror_rule_parsed(void *parsed_result,
7148 __attribute__((unused)) struct cmdline *cl,
7149 __attribute__((unused)) void *data)
7152 struct cmd_set_mirror_link_result *res = parsed_result;
7154 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7156 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7159 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7160 .f = cmd_reset_mirror_rule_parsed,
7162 .help_str = "reset port X mirror-rule Y",
7164 (void *)&cmd_rm_mirror_rule_reset,
7165 (void *)&cmd_rm_mirror_rule_port,
7166 (void *)&cmd_rm_mirror_rule_portid,
7167 (void *)&cmd_rm_mirror_rule_mirror,
7168 (void *)&cmd_rm_mirror_rule_ruleid,
7173 /* ******************************************************************************** */
7175 struct cmd_dump_result {
7176 cmdline_fixed_string_t dump;
7180 dump_struct_sizes(void)
7182 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7183 DUMP_SIZE(struct rte_mbuf);
7184 DUMP_SIZE(struct rte_mempool);
7185 DUMP_SIZE(struct rte_ring);
7189 static void cmd_dump_parsed(void *parsed_result,
7190 __attribute__((unused)) struct cmdline *cl,
7191 __attribute__((unused)) void *data)
7193 struct cmd_dump_result *res = parsed_result;
7195 if (!strcmp(res->dump, "dump_physmem"))
7196 rte_dump_physmem_layout(stdout);
7197 else if (!strcmp(res->dump, "dump_memzone"))
7198 rte_memzone_dump(stdout);
7199 else if (!strcmp(res->dump, "dump_log_history"))
7200 rte_log_dump_history(stdout);
7201 else if (!strcmp(res->dump, "dump_struct_sizes"))
7202 dump_struct_sizes();
7203 else if (!strcmp(res->dump, "dump_ring"))
7204 rte_ring_list_dump(stdout);
7205 else if (!strcmp(res->dump, "dump_mempool"))
7206 rte_mempool_list_dump(stdout);
7207 else if (!strcmp(res->dump, "dump_devargs"))
7208 rte_eal_devargs_dump(stdout);
7211 cmdline_parse_token_string_t cmd_dump_dump =
7212 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7216 "dump_struct_sizes#"
7221 cmdline_parse_inst_t cmd_dump = {
7222 .f = cmd_dump_parsed, /* function to call */
7223 .data = NULL, /* 2nd arg of func */
7224 .help_str = "dump status",
7225 .tokens = { /* token list, NULL terminated */
7226 (void *)&cmd_dump_dump,
7231 /* ******************************************************************************** */
7233 struct cmd_dump_one_result {
7234 cmdline_fixed_string_t dump;
7235 cmdline_fixed_string_t name;
7238 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7239 __attribute__((unused)) void *data)
7241 struct cmd_dump_one_result *res = parsed_result;
7243 if (!strcmp(res->dump, "dump_ring")) {
7245 r = rte_ring_lookup(res->name);
7247 cmdline_printf(cl, "Cannot find ring\n");
7250 rte_ring_dump(stdout, r);
7251 } else if (!strcmp(res->dump, "dump_mempool")) {
7252 struct rte_mempool *mp;
7253 mp = rte_mempool_lookup(res->name);
7255 cmdline_printf(cl, "Cannot find mempool\n");
7258 rte_mempool_dump(stdout, mp);
7262 cmdline_parse_token_string_t cmd_dump_one_dump =
7263 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7264 "dump_ring#dump_mempool");
7266 cmdline_parse_token_string_t cmd_dump_one_name =
7267 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7269 cmdline_parse_inst_t cmd_dump_one = {
7270 .f = cmd_dump_one_parsed, /* function to call */
7271 .data = NULL, /* 2nd arg of func */
7272 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7273 .tokens = { /* token list, NULL terminated */
7274 (void *)&cmd_dump_one_dump,
7275 (void *)&cmd_dump_one_name,
7280 /* *** Add/Del syn filter *** */
7281 struct cmd_syn_filter_result {
7282 cmdline_fixed_string_t filter;
7284 cmdline_fixed_string_t ops;
7285 cmdline_fixed_string_t priority;
7286 cmdline_fixed_string_t high;
7287 cmdline_fixed_string_t queue;
7292 cmd_syn_filter_parsed(void *parsed_result,
7293 __attribute__((unused)) struct cmdline *cl,
7294 __attribute__((unused)) void *data)
7296 struct cmd_syn_filter_result *res = parsed_result;
7297 struct rte_eth_syn_filter syn_filter;
7300 ret = rte_eth_dev_filter_supported(res->port_id,
7301 RTE_ETH_FILTER_SYN);
7303 printf("syn filter is not supported on port %u.\n",
7308 memset(&syn_filter, 0, sizeof(syn_filter));
7310 if (!strcmp(res->ops, "add")) {
7311 if (!strcmp(res->high, "high"))
7312 syn_filter.hig_pri = 1;
7314 syn_filter.hig_pri = 0;
7316 syn_filter.queue = res->queue_id;
7317 ret = rte_eth_dev_filter_ctrl(res->port_id,
7322 ret = rte_eth_dev_filter_ctrl(res->port_id,
7324 RTE_ETH_FILTER_DELETE,
7328 printf("syn filter programming error: (%s)\n",
7332 cmdline_parse_token_string_t cmd_syn_filter_filter =
7333 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7334 filter, "syn_filter");
7335 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7336 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7338 cmdline_parse_token_string_t cmd_syn_filter_ops =
7339 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7341 cmdline_parse_token_string_t cmd_syn_filter_priority =
7342 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7343 priority, "priority");
7344 cmdline_parse_token_string_t cmd_syn_filter_high =
7345 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7347 cmdline_parse_token_string_t cmd_syn_filter_queue =
7348 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7350 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7351 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7354 cmdline_parse_inst_t cmd_syn_filter = {
7355 .f = cmd_syn_filter_parsed,
7357 .help_str = "add/delete syn filter",
7359 (void *)&cmd_syn_filter_filter,
7360 (void *)&cmd_syn_filter_port_id,
7361 (void *)&cmd_syn_filter_ops,
7362 (void *)&cmd_syn_filter_priority,
7363 (void *)&cmd_syn_filter_high,
7364 (void *)&cmd_syn_filter_queue,
7365 (void *)&cmd_syn_filter_queue_id,
7370 /* *** ADD/REMOVE A 2tuple FILTER *** */
7371 struct cmd_2tuple_filter_result {
7372 cmdline_fixed_string_t filter;
7374 cmdline_fixed_string_t ops;
7375 cmdline_fixed_string_t dst_port;
7376 uint16_t dst_port_value;
7377 cmdline_fixed_string_t protocol;
7378 uint8_t protocol_value;
7379 cmdline_fixed_string_t mask;
7381 cmdline_fixed_string_t tcp_flags;
7382 uint8_t tcp_flags_value;
7383 cmdline_fixed_string_t priority;
7384 uint8_t priority_value;
7385 cmdline_fixed_string_t queue;
7390 cmd_2tuple_filter_parsed(void *parsed_result,
7391 __attribute__((unused)) struct cmdline *cl,
7392 __attribute__((unused)) void *data)
7394 struct rte_eth_ntuple_filter filter;
7395 struct cmd_2tuple_filter_result *res = parsed_result;
7398 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7400 printf("ntuple filter is not supported on port %u.\n",
7405 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7407 filter.flags = RTE_2TUPLE_FLAGS;
7408 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7409 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7410 filter.proto = res->protocol_value;
7411 filter.priority = res->priority_value;
7412 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7413 printf("nonzero tcp_flags is only meaningful"
7414 " when protocol is TCP.\n");
7417 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7418 printf("invalid TCP flags.\n");
7422 if (res->tcp_flags_value != 0) {
7423 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7424 filter.tcp_flags = res->tcp_flags_value;
7427 /* need convert to big endian. */
7428 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7429 filter.queue = res->queue_id;
7431 if (!strcmp(res->ops, "add"))
7432 ret = rte_eth_dev_filter_ctrl(res->port_id,
7433 RTE_ETH_FILTER_NTUPLE,
7437 ret = rte_eth_dev_filter_ctrl(res->port_id,
7438 RTE_ETH_FILTER_NTUPLE,
7439 RTE_ETH_FILTER_DELETE,
7442 printf("2tuple filter programming error: (%s)\n",
7447 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7448 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7449 filter, "2tuple_filter");
7450 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7451 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7453 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7454 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7456 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7457 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7458 dst_port, "dst_port");
7459 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7460 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7461 dst_port_value, UINT16);
7462 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7463 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7464 protocol, "protocol");
7465 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7466 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7467 protocol_value, UINT8);
7468 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7469 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7471 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7472 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7474 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7475 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7476 tcp_flags, "tcp_flags");
7477 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7478 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7479 tcp_flags_value, UINT8);
7480 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7481 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7482 priority, "priority");
7483 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7484 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7485 priority_value, UINT8);
7486 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7487 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7489 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7490 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7493 cmdline_parse_inst_t cmd_2tuple_filter = {
7494 .f = cmd_2tuple_filter_parsed,
7496 .help_str = "add a 2tuple filter",
7498 (void *)&cmd_2tuple_filter_filter,
7499 (void *)&cmd_2tuple_filter_port_id,
7500 (void *)&cmd_2tuple_filter_ops,
7501 (void *)&cmd_2tuple_filter_dst_port,
7502 (void *)&cmd_2tuple_filter_dst_port_value,
7503 (void *)&cmd_2tuple_filter_protocol,
7504 (void *)&cmd_2tuple_filter_protocol_value,
7505 (void *)&cmd_2tuple_filter_mask,
7506 (void *)&cmd_2tuple_filter_mask_value,
7507 (void *)&cmd_2tuple_filter_tcp_flags,
7508 (void *)&cmd_2tuple_filter_tcp_flags_value,
7509 (void *)&cmd_2tuple_filter_priority,
7510 (void *)&cmd_2tuple_filter_priority_value,
7511 (void *)&cmd_2tuple_filter_queue,
7512 (void *)&cmd_2tuple_filter_queue_id,
7517 /* *** ADD/REMOVE A 5tuple FILTER *** */
7518 struct cmd_5tuple_filter_result {
7519 cmdline_fixed_string_t filter;
7521 cmdline_fixed_string_t ops;
7522 cmdline_fixed_string_t dst_ip;
7523 cmdline_ipaddr_t dst_ip_value;
7524 cmdline_fixed_string_t src_ip;
7525 cmdline_ipaddr_t src_ip_value;
7526 cmdline_fixed_string_t dst_port;
7527 uint16_t dst_port_value;
7528 cmdline_fixed_string_t src_port;
7529 uint16_t src_port_value;
7530 cmdline_fixed_string_t protocol;
7531 uint8_t protocol_value;
7532 cmdline_fixed_string_t mask;
7534 cmdline_fixed_string_t tcp_flags;
7535 uint8_t tcp_flags_value;
7536 cmdline_fixed_string_t priority;
7537 uint8_t priority_value;
7538 cmdline_fixed_string_t queue;
7543 cmd_5tuple_filter_parsed(void *parsed_result,
7544 __attribute__((unused)) struct cmdline *cl,
7545 __attribute__((unused)) void *data)
7547 struct rte_eth_ntuple_filter filter;
7548 struct cmd_5tuple_filter_result *res = parsed_result;
7551 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7553 printf("ntuple filter is not supported on port %u.\n",
7558 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7560 filter.flags = RTE_5TUPLE_FLAGS;
7561 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7562 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7563 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7564 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7565 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7566 filter.proto = res->protocol_value;
7567 filter.priority = res->priority_value;
7568 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7569 printf("nonzero tcp_flags is only meaningful"
7570 " when protocol is TCP.\n");
7573 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7574 printf("invalid TCP flags.\n");
7578 if (res->tcp_flags_value != 0) {
7579 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7580 filter.tcp_flags = res->tcp_flags_value;
7583 if (res->dst_ip_value.family == AF_INET)
7584 /* no need to convert, already big endian. */
7585 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7587 if (filter.dst_ip_mask == 0) {
7588 printf("can not support ipv6 involved compare.\n");
7594 if (res->src_ip_value.family == AF_INET)
7595 /* no need to convert, already big endian. */
7596 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7598 if (filter.src_ip_mask == 0) {
7599 printf("can not support ipv6 involved compare.\n");
7604 /* need convert to big endian. */
7605 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7606 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7607 filter.queue = res->queue_id;
7609 if (!strcmp(res->ops, "add"))
7610 ret = rte_eth_dev_filter_ctrl(res->port_id,
7611 RTE_ETH_FILTER_NTUPLE,
7615 ret = rte_eth_dev_filter_ctrl(res->port_id,
7616 RTE_ETH_FILTER_NTUPLE,
7617 RTE_ETH_FILTER_DELETE,
7620 printf("5tuple filter programming error: (%s)\n",
7624 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7625 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7626 filter, "5tuple_filter");
7627 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7628 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7630 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7631 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7633 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7634 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7636 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7637 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7639 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7640 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7642 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7643 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7645 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7646 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7647 dst_port, "dst_port");
7648 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7649 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7650 dst_port_value, UINT16);
7651 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7652 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7653 src_port, "src_port");
7654 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7655 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7656 src_port_value, UINT16);
7657 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7658 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7659 protocol, "protocol");
7660 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7661 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7662 protocol_value, UINT8);
7663 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7664 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7666 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7667 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7669 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7670 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7671 tcp_flags, "tcp_flags");
7672 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7673 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7674 tcp_flags_value, UINT8);
7675 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7676 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7677 priority, "priority");
7678 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7679 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7680 priority_value, UINT8);
7681 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7682 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7684 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7685 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7688 cmdline_parse_inst_t cmd_5tuple_filter = {
7689 .f = cmd_5tuple_filter_parsed,
7691 .help_str = "add/del a 5tuple filter",
7693 (void *)&cmd_5tuple_filter_filter,
7694 (void *)&cmd_5tuple_filter_port_id,
7695 (void *)&cmd_5tuple_filter_ops,
7696 (void *)&cmd_5tuple_filter_dst_ip,
7697 (void *)&cmd_5tuple_filter_dst_ip_value,
7698 (void *)&cmd_5tuple_filter_src_ip,
7699 (void *)&cmd_5tuple_filter_src_ip_value,
7700 (void *)&cmd_5tuple_filter_dst_port,
7701 (void *)&cmd_5tuple_filter_dst_port_value,
7702 (void *)&cmd_5tuple_filter_src_port,
7703 (void *)&cmd_5tuple_filter_src_port_value,
7704 (void *)&cmd_5tuple_filter_protocol,
7705 (void *)&cmd_5tuple_filter_protocol_value,
7706 (void *)&cmd_5tuple_filter_mask,
7707 (void *)&cmd_5tuple_filter_mask_value,
7708 (void *)&cmd_5tuple_filter_tcp_flags,
7709 (void *)&cmd_5tuple_filter_tcp_flags_value,
7710 (void *)&cmd_5tuple_filter_priority,
7711 (void *)&cmd_5tuple_filter_priority_value,
7712 (void *)&cmd_5tuple_filter_queue,
7713 (void *)&cmd_5tuple_filter_queue_id,
7718 /* *** ADD/REMOVE A flex FILTER *** */
7719 struct cmd_flex_filter_result {
7720 cmdline_fixed_string_t filter;
7721 cmdline_fixed_string_t ops;
7723 cmdline_fixed_string_t len;
7725 cmdline_fixed_string_t bytes;
7726 cmdline_fixed_string_t bytes_value;
7727 cmdline_fixed_string_t mask;
7728 cmdline_fixed_string_t mask_value;
7729 cmdline_fixed_string_t priority;
7730 uint8_t priority_value;
7731 cmdline_fixed_string_t queue;
7735 static int xdigit2val(unsigned char c)
7740 else if (isupper(c))
7748 cmd_flex_filter_parsed(void *parsed_result,
7749 __attribute__((unused)) struct cmdline *cl,
7750 __attribute__((unused)) void *data)
7753 struct rte_eth_flex_filter filter;
7754 struct cmd_flex_filter_result *res = parsed_result;
7755 char *bytes_ptr, *mask_ptr;
7756 uint16_t len, i, j = 0;
7761 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7762 printf("the len exceed the max length 128\n");
7765 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7766 filter.len = res->len_value;
7767 filter.priority = res->priority_value;
7768 filter.queue = res->queue_id;
7769 bytes_ptr = res->bytes_value;
7770 mask_ptr = res->mask_value;
7772 /* translate bytes string to array. */
7773 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7774 (bytes_ptr[1] == 'X')))
7776 len = strnlen(bytes_ptr, res->len_value * 2);
7777 if (len == 0 || (len % 8 != 0)) {
7778 printf("please check len and bytes input\n");
7781 for (i = 0; i < len; i++) {
7783 if (isxdigit(c) == 0) {
7784 /* invalid characters. */
7785 printf("invalid input\n");
7788 val = xdigit2val(c);
7791 filter.bytes[j] = byte;
7792 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7799 /* translate mask string to uint8_t array. */
7800 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7801 (mask_ptr[1] == 'X')))
7803 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7805 printf("invalid input\n");
7810 for (i = 0; i < len; i++) {
7812 if (isxdigit(c) == 0) {
7813 /* invalid characters. */
7814 printf("invalid input\n");
7817 val = xdigit2val(c);
7820 filter.mask[j] = byte;
7821 printf("mask[%d]:%02x ", j, filter.mask[j]);
7829 if (!strcmp(res->ops, "add"))
7830 ret = rte_eth_dev_filter_ctrl(res->port_id,
7831 RTE_ETH_FILTER_FLEXIBLE,
7835 ret = rte_eth_dev_filter_ctrl(res->port_id,
7836 RTE_ETH_FILTER_FLEXIBLE,
7837 RTE_ETH_FILTER_DELETE,
7841 printf("flex filter setting error: (%s)\n", strerror(-ret));
7844 cmdline_parse_token_string_t cmd_flex_filter_filter =
7845 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7846 filter, "flex_filter");
7847 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7848 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7850 cmdline_parse_token_string_t cmd_flex_filter_ops =
7851 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7853 cmdline_parse_token_string_t cmd_flex_filter_len =
7854 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7856 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7857 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7859 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7860 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7862 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7863 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7865 cmdline_parse_token_string_t cmd_flex_filter_mask =
7866 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7868 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7869 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7871 cmdline_parse_token_string_t cmd_flex_filter_priority =
7872 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7873 priority, "priority");
7874 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7875 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7876 priority_value, UINT8);
7877 cmdline_parse_token_string_t cmd_flex_filter_queue =
7878 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7880 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7881 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7883 cmdline_parse_inst_t cmd_flex_filter = {
7884 .f = cmd_flex_filter_parsed,
7886 .help_str = "add/del a flex filter",
7888 (void *)&cmd_flex_filter_filter,
7889 (void *)&cmd_flex_filter_port_id,
7890 (void *)&cmd_flex_filter_ops,
7891 (void *)&cmd_flex_filter_len,
7892 (void *)&cmd_flex_filter_len_value,
7893 (void *)&cmd_flex_filter_bytes,
7894 (void *)&cmd_flex_filter_bytes_value,
7895 (void *)&cmd_flex_filter_mask,
7896 (void *)&cmd_flex_filter_mask_value,
7897 (void *)&cmd_flex_filter_priority,
7898 (void *)&cmd_flex_filter_priority_value,
7899 (void *)&cmd_flex_filter_queue,
7900 (void *)&cmd_flex_filter_queue_id,
7905 /* *** Filters Control *** */
7907 /* *** deal with ethertype filter *** */
7908 struct cmd_ethertype_filter_result {
7909 cmdline_fixed_string_t filter;
7911 cmdline_fixed_string_t ops;
7912 cmdline_fixed_string_t mac;
7913 struct ether_addr mac_addr;
7914 cmdline_fixed_string_t ethertype;
7915 uint16_t ethertype_value;
7916 cmdline_fixed_string_t drop;
7917 cmdline_fixed_string_t queue;
7921 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7922 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7923 filter, "ethertype_filter");
7924 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7925 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7927 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7928 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7930 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7931 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7932 mac, "mac_addr#mac_ignr");
7933 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7934 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7936 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7937 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7938 ethertype, "ethertype");
7939 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7940 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7941 ethertype_value, UINT16);
7942 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7943 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7945 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7946 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7948 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7949 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7953 cmd_ethertype_filter_parsed(void *parsed_result,
7954 __attribute__((unused)) struct cmdline *cl,
7955 __attribute__((unused)) void *data)
7957 struct cmd_ethertype_filter_result *res = parsed_result;
7958 struct rte_eth_ethertype_filter filter;
7961 ret = rte_eth_dev_filter_supported(res->port_id,
7962 RTE_ETH_FILTER_ETHERTYPE);
7964 printf("ethertype filter is not supported on port %u.\n",
7969 memset(&filter, 0, sizeof(filter));
7970 if (!strcmp(res->mac, "mac_addr")) {
7971 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7972 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7973 sizeof(struct ether_addr));
7975 if (!strcmp(res->drop, "drop"))
7976 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7977 filter.ether_type = res->ethertype_value;
7978 filter.queue = res->queue_id;
7980 if (!strcmp(res->ops, "add"))
7981 ret = rte_eth_dev_filter_ctrl(res->port_id,
7982 RTE_ETH_FILTER_ETHERTYPE,
7986 ret = rte_eth_dev_filter_ctrl(res->port_id,
7987 RTE_ETH_FILTER_ETHERTYPE,
7988 RTE_ETH_FILTER_DELETE,
7991 printf("ethertype filter programming error: (%s)\n",
7995 cmdline_parse_inst_t cmd_ethertype_filter = {
7996 .f = cmd_ethertype_filter_parsed,
7998 .help_str = "add or delete an ethertype filter entry",
8000 (void *)&cmd_ethertype_filter_filter,
8001 (void *)&cmd_ethertype_filter_port_id,
8002 (void *)&cmd_ethertype_filter_ops,
8003 (void *)&cmd_ethertype_filter_mac,
8004 (void *)&cmd_ethertype_filter_mac_addr,
8005 (void *)&cmd_ethertype_filter_ethertype,
8006 (void *)&cmd_ethertype_filter_ethertype_value,
8007 (void *)&cmd_ethertype_filter_drop,
8008 (void *)&cmd_ethertype_filter_queue,
8009 (void *)&cmd_ethertype_filter_queue_id,
8014 /* *** deal with flow director filter *** */
8015 struct cmd_flow_director_result {
8016 cmdline_fixed_string_t flow_director_filter;
8018 cmdline_fixed_string_t mode;
8019 cmdline_fixed_string_t mode_value;
8020 cmdline_fixed_string_t ops;
8021 cmdline_fixed_string_t flow;
8022 cmdline_fixed_string_t flow_type;
8023 cmdline_fixed_string_t ether;
8024 uint16_t ether_type;
8025 cmdline_fixed_string_t src;
8026 cmdline_ipaddr_t ip_src;
8028 cmdline_fixed_string_t dst;
8029 cmdline_ipaddr_t ip_dst;
8031 cmdline_fixed_string_t verify_tag;
8032 uint32_t verify_tag_value;
8033 cmdline_ipaddr_t tos;
8035 cmdline_ipaddr_t proto;
8036 uint8_t proto_value;
8037 cmdline_ipaddr_t ttl;
8039 cmdline_fixed_string_t vlan;
8040 uint16_t vlan_value;
8041 cmdline_fixed_string_t flexbytes;
8042 cmdline_fixed_string_t flexbytes_value;
8043 cmdline_fixed_string_t pf_vf;
8044 cmdline_fixed_string_t drop;
8045 cmdline_fixed_string_t queue;
8047 cmdline_fixed_string_t fd_id;
8048 uint32_t fd_id_value;
8049 cmdline_fixed_string_t mac;
8050 struct ether_addr mac_addr;
8051 cmdline_fixed_string_t tunnel;
8052 cmdline_fixed_string_t tunnel_type;
8053 cmdline_fixed_string_t tunnel_id;
8054 uint32_t tunnel_id_value;
8058 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8061 const char *p, *p0 = q_arg;
8063 unsigned long int_fld;
8064 char *str_fld[max_num];
8069 p = strchr(p0, '(');
8073 p0 = strchr(p, ')');
8078 if (size >= sizeof(s))
8081 snprintf(s, sizeof(s), "%.*s", size, p);
8082 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8083 if (ret < 0 || ret > max_num)
8085 for (i = 0; i < ret; i++) {
8087 int_fld = strtoul(str_fld[i], &end, 0);
8088 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8090 flexbytes[i] = (uint8_t)int_fld;
8096 str2flowtype(char *string)
8099 static const struct {
8102 } flowtype_str[] = {
8103 {"raw", RTE_ETH_FLOW_RAW},
8104 {"ipv4", RTE_ETH_FLOW_IPV4},
8105 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8106 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8107 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8108 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8109 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8110 {"ipv6", RTE_ETH_FLOW_IPV6},
8111 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8112 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8113 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8114 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8115 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8116 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8119 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8120 if (!strcmp(flowtype_str[i].str, string))
8121 return flowtype_str[i].type;
8123 return RTE_ETH_FLOW_UNKNOWN;
8126 static enum rte_eth_fdir_tunnel_type
8127 str2fdir_tunneltype(char *string)
8131 static const struct {
8133 enum rte_eth_fdir_tunnel_type type;
8134 } tunneltype_str[] = {
8135 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8136 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8139 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8140 if (!strcmp(tunneltype_str[i].str, string))
8141 return tunneltype_str[i].type;
8143 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8146 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8148 if ((ip_addr).family == AF_INET) \
8149 (ip) = (ip_addr).addr.ipv4.s_addr; \
8151 printf("invalid parameter.\n"); \
8156 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8158 if ((ip_addr).family == AF_INET6) \
8159 (void)rte_memcpy(&(ip), \
8160 &((ip_addr).addr.ipv6), \
8161 sizeof(struct in6_addr)); \
8163 printf("invalid parameter.\n"); \
8169 cmd_flow_director_filter_parsed(void *parsed_result,
8170 __attribute__((unused)) struct cmdline *cl,
8171 __attribute__((unused)) void *data)
8173 struct cmd_flow_director_result *res = parsed_result;
8174 struct rte_eth_fdir_filter entry;
8175 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8177 unsigned long vf_id;
8180 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8182 printf("flow director is not supported on port %u.\n",
8186 memset(flexbytes, 0, sizeof(flexbytes));
8187 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8189 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8190 if (strcmp(res->mode_value, "MAC-VLAN")) {
8191 printf("Please set mode to MAC-VLAN.\n");
8194 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8195 if (strcmp(res->mode_value, "Tunnel")) {
8196 printf("Please set mode to Tunnel.\n");
8200 if (strcmp(res->mode_value, "IP")) {
8201 printf("Please set mode to IP.\n");
8204 entry.input.flow_type = str2flowtype(res->flow_type);
8207 ret = parse_flexbytes(res->flexbytes_value,
8209 RTE_ETH_FDIR_MAX_FLEXLEN);
8211 printf("error: Cannot parse flexbytes input.\n");
8215 switch (entry.input.flow_type) {
8216 case RTE_ETH_FLOW_FRAG_IPV4:
8217 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8218 entry.input.flow.ip4_flow.proto = res->proto_value;
8219 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8220 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8221 IPV4_ADDR_TO_UINT(res->ip_dst,
8222 entry.input.flow.ip4_flow.dst_ip);
8223 IPV4_ADDR_TO_UINT(res->ip_src,
8224 entry.input.flow.ip4_flow.src_ip);
8225 entry.input.flow.ip4_flow.tos = res->tos_value;
8226 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8227 /* need convert to big endian. */
8228 entry.input.flow.udp4_flow.dst_port =
8229 rte_cpu_to_be_16(res->port_dst);
8230 entry.input.flow.udp4_flow.src_port =
8231 rte_cpu_to_be_16(res->port_src);
8233 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8234 IPV4_ADDR_TO_UINT(res->ip_dst,
8235 entry.input.flow.sctp4_flow.ip.dst_ip);
8236 IPV4_ADDR_TO_UINT(res->ip_src,
8237 entry.input.flow.sctp4_flow.ip.src_ip);
8238 entry.input.flow.ip4_flow.tos = res->tos_value;
8239 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8240 /* need convert to big endian. */
8241 entry.input.flow.sctp4_flow.dst_port =
8242 rte_cpu_to_be_16(res->port_dst);
8243 entry.input.flow.sctp4_flow.src_port =
8244 rte_cpu_to_be_16(res->port_src);
8245 entry.input.flow.sctp4_flow.verify_tag =
8246 rte_cpu_to_be_32(res->verify_tag_value);
8248 case RTE_ETH_FLOW_FRAG_IPV6:
8249 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8250 entry.input.flow.ipv6_flow.proto = res->proto_value;
8251 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8252 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8253 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8254 entry.input.flow.ipv6_flow.dst_ip);
8255 IPV6_ADDR_TO_ARRAY(res->ip_src,
8256 entry.input.flow.ipv6_flow.src_ip);
8257 entry.input.flow.ipv6_flow.tc = res->tos_value;
8258 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8259 /* need convert to big endian. */
8260 entry.input.flow.udp6_flow.dst_port =
8261 rte_cpu_to_be_16(res->port_dst);
8262 entry.input.flow.udp6_flow.src_port =
8263 rte_cpu_to_be_16(res->port_src);
8265 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8266 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8267 entry.input.flow.sctp6_flow.ip.dst_ip);
8268 IPV6_ADDR_TO_ARRAY(res->ip_src,
8269 entry.input.flow.sctp6_flow.ip.src_ip);
8270 entry.input.flow.ipv6_flow.tc = res->tos_value;
8271 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8272 /* need convert to big endian. */
8273 entry.input.flow.sctp6_flow.dst_port =
8274 rte_cpu_to_be_16(res->port_dst);
8275 entry.input.flow.sctp6_flow.src_port =
8276 rte_cpu_to_be_16(res->port_src);
8277 entry.input.flow.sctp6_flow.verify_tag =
8278 rte_cpu_to_be_32(res->verify_tag_value);
8280 case RTE_ETH_FLOW_L2_PAYLOAD:
8281 entry.input.flow.l2_flow.ether_type =
8282 rte_cpu_to_be_16(res->ether_type);
8288 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8289 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8291 sizeof(struct ether_addr));
8293 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8294 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8296 sizeof(struct ether_addr));
8297 entry.input.flow.tunnel_flow.tunnel_type =
8298 str2fdir_tunneltype(res->tunnel_type);
8299 entry.input.flow.tunnel_flow.tunnel_id =
8300 rte_cpu_to_be_32(res->tunnel_id_value);
8303 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8305 RTE_ETH_FDIR_MAX_FLEXLEN);
8307 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8309 entry.action.flex_off = 0; /*use 0 by default */
8310 if (!strcmp(res->drop, "drop"))
8311 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8313 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8315 if (!strcmp(res->pf_vf, "pf"))
8316 entry.input.flow_ext.is_vf = 0;
8317 else if (!strncmp(res->pf_vf, "vf", 2)) {
8318 struct rte_eth_dev_info dev_info;
8320 memset(&dev_info, 0, sizeof(dev_info));
8321 rte_eth_dev_info_get(res->port_id, &dev_info);
8323 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8324 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8325 printf("invalid parameter %s.\n", res->pf_vf);
8328 entry.input.flow_ext.is_vf = 1;
8329 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8331 printf("invalid parameter %s.\n", res->pf_vf);
8335 /* set to report FD ID by default */
8336 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8337 entry.action.rx_queue = res->queue_id;
8338 entry.soft_id = res->fd_id_value;
8339 if (!strcmp(res->ops, "add"))
8340 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8341 RTE_ETH_FILTER_ADD, &entry);
8342 else if (!strcmp(res->ops, "del"))
8343 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8344 RTE_ETH_FILTER_DELETE, &entry);
8346 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8347 RTE_ETH_FILTER_UPDATE, &entry);
8349 printf("flow director programming error: (%s)\n",
8353 cmdline_parse_token_string_t cmd_flow_director_filter =
8354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8355 flow_director_filter, "flow_director_filter");
8356 cmdline_parse_token_num_t cmd_flow_director_port_id =
8357 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8359 cmdline_parse_token_string_t cmd_flow_director_ops =
8360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8361 ops, "add#del#update");
8362 cmdline_parse_token_string_t cmd_flow_director_flow =
8363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8365 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8367 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8368 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8369 cmdline_parse_token_string_t cmd_flow_director_ether =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8372 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8374 ether_type, UINT16);
8375 cmdline_parse_token_string_t cmd_flow_director_src =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8378 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8379 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8381 cmdline_parse_token_num_t cmd_flow_director_port_src =
8382 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8384 cmdline_parse_token_string_t cmd_flow_director_dst =
8385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8387 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8388 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8390 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8391 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8393 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8395 verify_tag, "verify_tag");
8396 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8398 verify_tag_value, UINT32);
8399 cmdline_parse_token_string_t cmd_flow_director_tos =
8400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8402 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8403 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8405 cmdline_parse_token_string_t cmd_flow_director_proto =
8406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8408 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8410 proto_value, UINT8);
8411 cmdline_parse_token_string_t cmd_flow_director_ttl =
8412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8414 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8415 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8417 cmdline_parse_token_string_t cmd_flow_director_vlan =
8418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8420 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8421 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8422 vlan_value, UINT16);
8423 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8425 flexbytes, "flexbytes");
8426 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8428 flexbytes_value, NULL);
8429 cmdline_parse_token_string_t cmd_flow_director_drop =
8430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8432 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8435 cmdline_parse_token_string_t cmd_flow_director_queue =
8436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8438 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8439 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8441 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8444 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8446 fd_id_value, UINT32);
8448 cmdline_parse_token_string_t cmd_flow_director_mode =
8449 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8451 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8454 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8455 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8456 mode_value, "MAC-VLAN");
8457 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8458 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8459 mode_value, "Tunnel");
8460 cmdline_parse_token_string_t cmd_flow_director_mac =
8461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8463 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8464 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8466 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8469 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8471 tunnel_type, "NVGRE#VxLAN");
8472 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8474 tunnel_id, "tunnel-id");
8475 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8477 tunnel_id_value, UINT32);
8479 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8480 .f = cmd_flow_director_filter_parsed,
8482 .help_str = "add or delete an ip flow director entry on NIC",
8484 (void *)&cmd_flow_director_filter,
8485 (void *)&cmd_flow_director_port_id,
8486 (void *)&cmd_flow_director_mode,
8487 (void *)&cmd_flow_director_mode_ip,
8488 (void *)&cmd_flow_director_ops,
8489 (void *)&cmd_flow_director_flow,
8490 (void *)&cmd_flow_director_flow_type,
8491 (void *)&cmd_flow_director_src,
8492 (void *)&cmd_flow_director_ip_src,
8493 (void *)&cmd_flow_director_dst,
8494 (void *)&cmd_flow_director_ip_dst,
8495 (void *)&cmd_flow_director_tos,
8496 (void *)&cmd_flow_director_tos_value,
8497 (void *)&cmd_flow_director_proto,
8498 (void *)&cmd_flow_director_proto_value,
8499 (void *)&cmd_flow_director_ttl,
8500 (void *)&cmd_flow_director_ttl_value,
8501 (void *)&cmd_flow_director_vlan,
8502 (void *)&cmd_flow_director_vlan_value,
8503 (void *)&cmd_flow_director_flexbytes,
8504 (void *)&cmd_flow_director_flexbytes_value,
8505 (void *)&cmd_flow_director_drop,
8506 (void *)&cmd_flow_director_pf_vf,
8507 (void *)&cmd_flow_director_queue,
8508 (void *)&cmd_flow_director_queue_id,
8509 (void *)&cmd_flow_director_fd_id,
8510 (void *)&cmd_flow_director_fd_id_value,
8515 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8516 .f = cmd_flow_director_filter_parsed,
8518 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8520 (void *)&cmd_flow_director_filter,
8521 (void *)&cmd_flow_director_port_id,
8522 (void *)&cmd_flow_director_mode,
8523 (void *)&cmd_flow_director_mode_ip,
8524 (void *)&cmd_flow_director_ops,
8525 (void *)&cmd_flow_director_flow,
8526 (void *)&cmd_flow_director_flow_type,
8527 (void *)&cmd_flow_director_src,
8528 (void *)&cmd_flow_director_ip_src,
8529 (void *)&cmd_flow_director_port_src,
8530 (void *)&cmd_flow_director_dst,
8531 (void *)&cmd_flow_director_ip_dst,
8532 (void *)&cmd_flow_director_port_dst,
8533 (void *)&cmd_flow_director_tos,
8534 (void *)&cmd_flow_director_tos_value,
8535 (void *)&cmd_flow_director_ttl,
8536 (void *)&cmd_flow_director_ttl_value,
8537 (void *)&cmd_flow_director_vlan,
8538 (void *)&cmd_flow_director_vlan_value,
8539 (void *)&cmd_flow_director_flexbytes,
8540 (void *)&cmd_flow_director_flexbytes_value,
8541 (void *)&cmd_flow_director_drop,
8542 (void *)&cmd_flow_director_pf_vf,
8543 (void *)&cmd_flow_director_queue,
8544 (void *)&cmd_flow_director_queue_id,
8545 (void *)&cmd_flow_director_fd_id,
8546 (void *)&cmd_flow_director_fd_id_value,
8551 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8552 .f = cmd_flow_director_filter_parsed,
8554 .help_str = "add or delete a sctp flow director entry on NIC",
8556 (void *)&cmd_flow_director_filter,
8557 (void *)&cmd_flow_director_port_id,
8558 (void *)&cmd_flow_director_mode,
8559 (void *)&cmd_flow_director_mode_ip,
8560 (void *)&cmd_flow_director_ops,
8561 (void *)&cmd_flow_director_flow,
8562 (void *)&cmd_flow_director_flow_type,
8563 (void *)&cmd_flow_director_src,
8564 (void *)&cmd_flow_director_ip_src,
8565 (void *)&cmd_flow_director_port_dst,
8566 (void *)&cmd_flow_director_dst,
8567 (void *)&cmd_flow_director_ip_dst,
8568 (void *)&cmd_flow_director_port_dst,
8569 (void *)&cmd_flow_director_verify_tag,
8570 (void *)&cmd_flow_director_verify_tag_value,
8571 (void *)&cmd_flow_director_tos,
8572 (void *)&cmd_flow_director_tos_value,
8573 (void *)&cmd_flow_director_ttl,
8574 (void *)&cmd_flow_director_ttl_value,
8575 (void *)&cmd_flow_director_vlan,
8576 (void *)&cmd_flow_director_vlan_value,
8577 (void *)&cmd_flow_director_flexbytes,
8578 (void *)&cmd_flow_director_flexbytes_value,
8579 (void *)&cmd_flow_director_drop,
8580 (void *)&cmd_flow_director_pf_vf,
8581 (void *)&cmd_flow_director_queue,
8582 (void *)&cmd_flow_director_queue_id,
8583 (void *)&cmd_flow_director_fd_id,
8584 (void *)&cmd_flow_director_fd_id_value,
8589 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8590 .f = cmd_flow_director_filter_parsed,
8592 .help_str = "add or delete a L2 flow director entry on NIC",
8594 (void *)&cmd_flow_director_filter,
8595 (void *)&cmd_flow_director_port_id,
8596 (void *)&cmd_flow_director_mode,
8597 (void *)&cmd_flow_director_mode_ip,
8598 (void *)&cmd_flow_director_ops,
8599 (void *)&cmd_flow_director_flow,
8600 (void *)&cmd_flow_director_flow_type,
8601 (void *)&cmd_flow_director_ether,
8602 (void *)&cmd_flow_director_ether_type,
8603 (void *)&cmd_flow_director_flexbytes,
8604 (void *)&cmd_flow_director_flexbytes_value,
8605 (void *)&cmd_flow_director_drop,
8606 (void *)&cmd_flow_director_pf_vf,
8607 (void *)&cmd_flow_director_queue,
8608 (void *)&cmd_flow_director_queue_id,
8609 (void *)&cmd_flow_director_fd_id,
8610 (void *)&cmd_flow_director_fd_id_value,
8615 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8616 .f = cmd_flow_director_filter_parsed,
8618 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8620 (void *)&cmd_flow_director_filter,
8621 (void *)&cmd_flow_director_port_id,
8622 (void *)&cmd_flow_director_mode,
8623 (void *)&cmd_flow_director_mode_mac_vlan,
8624 (void *)&cmd_flow_director_ops,
8625 (void *)&cmd_flow_director_mac,
8626 (void *)&cmd_flow_director_mac_addr,
8627 (void *)&cmd_flow_director_vlan,
8628 (void *)&cmd_flow_director_vlan_value,
8629 (void *)&cmd_flow_director_flexbytes,
8630 (void *)&cmd_flow_director_flexbytes_value,
8631 (void *)&cmd_flow_director_drop,
8632 (void *)&cmd_flow_director_queue,
8633 (void *)&cmd_flow_director_queue_id,
8634 (void *)&cmd_flow_director_fd_id,
8635 (void *)&cmd_flow_director_fd_id_value,
8640 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8641 .f = cmd_flow_director_filter_parsed,
8643 .help_str = "add or delete a tunnel flow director entry on NIC",
8645 (void *)&cmd_flow_director_filter,
8646 (void *)&cmd_flow_director_port_id,
8647 (void *)&cmd_flow_director_mode,
8648 (void *)&cmd_flow_director_mode_tunnel,
8649 (void *)&cmd_flow_director_ops,
8650 (void *)&cmd_flow_director_mac,
8651 (void *)&cmd_flow_director_mac_addr,
8652 (void *)&cmd_flow_director_vlan,
8653 (void *)&cmd_flow_director_vlan_value,
8654 (void *)&cmd_flow_director_tunnel,
8655 (void *)&cmd_flow_director_tunnel_type,
8656 (void *)&cmd_flow_director_tunnel_id,
8657 (void *)&cmd_flow_director_tunnel_id_value,
8658 (void *)&cmd_flow_director_flexbytes,
8659 (void *)&cmd_flow_director_flexbytes_value,
8660 (void *)&cmd_flow_director_drop,
8661 (void *)&cmd_flow_director_queue,
8662 (void *)&cmd_flow_director_queue_id,
8663 (void *)&cmd_flow_director_fd_id,
8664 (void *)&cmd_flow_director_fd_id_value,
8669 struct cmd_flush_flow_director_result {
8670 cmdline_fixed_string_t flush_flow_director;
8674 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8675 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8676 flush_flow_director, "flush_flow_director");
8677 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8678 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8682 cmd_flush_flow_director_parsed(void *parsed_result,
8683 __attribute__((unused)) struct cmdline *cl,
8684 __attribute__((unused)) void *data)
8686 struct cmd_flow_director_result *res = parsed_result;
8689 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8691 printf("flow director is not supported on port %u.\n",
8696 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8697 RTE_ETH_FILTER_FLUSH, NULL);
8699 printf("flow director table flushing error: (%s)\n",
8703 cmdline_parse_inst_t cmd_flush_flow_director = {
8704 .f = cmd_flush_flow_director_parsed,
8706 .help_str = "flush all flow director entries of a device on NIC",
8708 (void *)&cmd_flush_flow_director_flush,
8709 (void *)&cmd_flush_flow_director_port_id,
8714 /* *** deal with flow director mask *** */
8715 struct cmd_flow_director_mask_result {
8716 cmdline_fixed_string_t flow_director_mask;
8718 cmdline_fixed_string_t mode;
8719 cmdline_fixed_string_t mode_value;
8720 cmdline_fixed_string_t vlan;
8722 cmdline_fixed_string_t src_mask;
8723 cmdline_ipaddr_t ipv4_src;
8724 cmdline_ipaddr_t ipv6_src;
8726 cmdline_fixed_string_t dst_mask;
8727 cmdline_ipaddr_t ipv4_dst;
8728 cmdline_ipaddr_t ipv6_dst;
8730 cmdline_fixed_string_t mac;
8731 uint8_t mac_addr_byte_mask;
8732 cmdline_fixed_string_t tunnel_id;
8733 uint32_t tunnel_id_mask;
8734 cmdline_fixed_string_t tunnel_type;
8735 uint8_t tunnel_type_mask;
8739 cmd_flow_director_mask_parsed(void *parsed_result,
8740 __attribute__((unused)) struct cmdline *cl,
8741 __attribute__((unused)) void *data)
8743 struct cmd_flow_director_mask_result *res = parsed_result;
8744 struct rte_eth_fdir_masks *mask;
8745 struct rte_port *port;
8747 if (res->port_id > nb_ports) {
8748 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8752 port = &ports[res->port_id];
8753 /** Check if the port is not started **/
8754 if (port->port_status != RTE_PORT_STOPPED) {
8755 printf("Please stop port %d first\n", res->port_id);
8759 mask = &port->dev_conf.fdir_conf.mask;
8761 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8762 if (strcmp(res->mode_value, "MAC-VLAN")) {
8763 printf("Please set mode to MAC-VLAN.\n");
8767 mask->vlan_tci_mask = res->vlan_mask;
8768 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8769 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8770 if (strcmp(res->mode_value, "Tunnel")) {
8771 printf("Please set mode to Tunnel.\n");
8775 mask->vlan_tci_mask = res->vlan_mask;
8776 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8777 mask->tunnel_id_mask = res->tunnel_id_mask;
8778 mask->tunnel_type_mask = res->tunnel_type_mask;
8780 if (strcmp(res->mode_value, "IP")) {
8781 printf("Please set mode to IP.\n");
8785 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8786 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8787 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8788 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8789 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8790 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8791 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8794 cmd_reconfig_device_queue(res->port_id, 1, 1);
8797 cmdline_parse_token_string_t cmd_flow_director_mask =
8798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8799 flow_director_mask, "flow_director_mask");
8800 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8801 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8803 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8806 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8809 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8811 src_mask, "src_mask");
8812 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8813 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8815 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8816 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8818 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8821 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8823 dst_mask, "dst_mask");
8824 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8825 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8827 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8828 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8830 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8834 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8837 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8840 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8842 mode_value, "MAC-VLAN");
8843 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8845 mode_value, "Tunnel");
8846 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8849 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8850 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8851 mac_addr_byte_mask, UINT8);
8852 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8854 tunnel_type, "tunnel-type");
8855 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8856 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8857 tunnel_type_mask, UINT8);
8858 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8860 tunnel_id, "tunnel-id");
8861 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8863 tunnel_id_mask, UINT32);
8865 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8866 .f = cmd_flow_director_mask_parsed,
8868 .help_str = "set IP mode flow director's mask on NIC",
8870 (void *)&cmd_flow_director_mask,
8871 (void *)&cmd_flow_director_mask_port_id,
8872 (void *)&cmd_flow_director_mask_mode,
8873 (void *)&cmd_flow_director_mask_mode_ip,
8874 (void *)&cmd_flow_director_mask_vlan,
8875 (void *)&cmd_flow_director_mask_vlan_value,
8876 (void *)&cmd_flow_director_mask_src,
8877 (void *)&cmd_flow_director_mask_ipv4_src,
8878 (void *)&cmd_flow_director_mask_ipv6_src,
8879 (void *)&cmd_flow_director_mask_port_src,
8880 (void *)&cmd_flow_director_mask_dst,
8881 (void *)&cmd_flow_director_mask_ipv4_dst,
8882 (void *)&cmd_flow_director_mask_ipv6_dst,
8883 (void *)&cmd_flow_director_mask_port_dst,
8888 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8889 .f = cmd_flow_director_mask_parsed,
8891 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8893 (void *)&cmd_flow_director_mask,
8894 (void *)&cmd_flow_director_mask_port_id,
8895 (void *)&cmd_flow_director_mask_mode,
8896 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8897 (void *)&cmd_flow_director_mask_vlan,
8898 (void *)&cmd_flow_director_mask_vlan_value,
8899 (void *)&cmd_flow_director_mask_mac,
8900 (void *)&cmd_flow_director_mask_mac_value,
8905 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8906 .f = cmd_flow_director_mask_parsed,
8908 .help_str = "set tunnel mode flow director's mask on NIC",
8910 (void *)&cmd_flow_director_mask,
8911 (void *)&cmd_flow_director_mask_port_id,
8912 (void *)&cmd_flow_director_mask_mode,
8913 (void *)&cmd_flow_director_mask_mode_tunnel,
8914 (void *)&cmd_flow_director_mask_vlan,
8915 (void *)&cmd_flow_director_mask_vlan_value,
8916 (void *)&cmd_flow_director_mask_mac,
8917 (void *)&cmd_flow_director_mask_mac_value,
8918 (void *)&cmd_flow_director_mask_tunnel_type,
8919 (void *)&cmd_flow_director_mask_tunnel_type_value,
8920 (void *)&cmd_flow_director_mask_tunnel_id,
8921 (void *)&cmd_flow_director_mask_tunnel_id_value,
8926 /* *** deal with flow director mask on flexible payload *** */
8927 struct cmd_flow_director_flex_mask_result {
8928 cmdline_fixed_string_t flow_director_flexmask;
8930 cmdline_fixed_string_t flow;
8931 cmdline_fixed_string_t flow_type;
8932 cmdline_fixed_string_t mask;
8936 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8937 __attribute__((unused)) struct cmdline *cl,
8938 __attribute__((unused)) void *data)
8940 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8941 struct rte_eth_fdir_info fdir_info;
8942 struct rte_eth_fdir_flex_mask flex_mask;
8943 struct rte_port *port;
8944 uint32_t flow_type_mask;
8948 if (res->port_id > nb_ports) {
8949 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8953 port = &ports[res->port_id];
8954 /** Check if the port is not started **/
8955 if (port->port_status != RTE_PORT_STOPPED) {
8956 printf("Please stop port %d first\n", res->port_id);
8960 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8961 ret = parse_flexbytes(res->mask,
8963 RTE_ETH_FDIR_MAX_FLEXLEN);
8965 printf("error: Cannot parse mask input.\n");
8969 memset(&fdir_info, 0, sizeof(fdir_info));
8970 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8971 RTE_ETH_FILTER_INFO, &fdir_info);
8973 printf("Cannot get FDir filter info\n");
8977 if (!strcmp(res->flow_type, "none")) {
8978 /* means don't specify the flow type */
8979 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8980 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8981 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8982 0, sizeof(struct rte_eth_fdir_flex_mask));
8983 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8984 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8986 sizeof(struct rte_eth_fdir_flex_mask));
8987 cmd_reconfig_device_queue(res->port_id, 1, 1);
8990 flow_type_mask = fdir_info.flow_types_mask[0];
8991 if (!strcmp(res->flow_type, "all")) {
8992 if (!flow_type_mask) {
8993 printf("No flow type supported\n");
8996 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8997 if (flow_type_mask & (1 << i)) {
8998 flex_mask.flow_type = i;
8999 fdir_set_flex_mask(res->port_id, &flex_mask);
9002 cmd_reconfig_device_queue(res->port_id, 1, 1);
9005 flex_mask.flow_type = str2flowtype(res->flow_type);
9006 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9007 printf("Flow type %s not supported on port %d\n",
9008 res->flow_type, res->port_id);
9011 fdir_set_flex_mask(res->port_id, &flex_mask);
9012 cmd_reconfig_device_queue(res->port_id, 1, 1);
9015 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9017 flow_director_flexmask,
9018 "flow_director_flex_mask");
9019 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9020 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9022 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9025 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9027 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9028 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9029 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9030 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9033 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9034 .f = cmd_flow_director_flex_mask_parsed,
9036 .help_str = "set flow director's flex mask on NIC",
9038 (void *)&cmd_flow_director_flexmask,
9039 (void *)&cmd_flow_director_flexmask_port_id,
9040 (void *)&cmd_flow_director_flexmask_flow,
9041 (void *)&cmd_flow_director_flexmask_flow_type,
9042 (void *)&cmd_flow_director_flexmask_mask,
9047 /* *** deal with flow director flexible payload configuration *** */
9048 struct cmd_flow_director_flexpayload_result {
9049 cmdline_fixed_string_t flow_director_flexpayload;
9051 cmdline_fixed_string_t payload_layer;
9052 cmdline_fixed_string_t payload_cfg;
9056 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9059 const char *p, *p0 = q_arg;
9061 unsigned long int_fld;
9062 char *str_fld[max_num];
9067 p = strchr(p0, '(');
9071 p0 = strchr(p, ')');
9076 if (size >= sizeof(s))
9079 snprintf(s, sizeof(s), "%.*s", size, p);
9080 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9081 if (ret < 0 || ret > max_num)
9083 for (i = 0; i < ret; i++) {
9085 int_fld = strtoul(str_fld[i], &end, 0);
9086 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9088 offsets[i] = (uint16_t)int_fld;
9094 cmd_flow_director_flxpld_parsed(void *parsed_result,
9095 __attribute__((unused)) struct cmdline *cl,
9096 __attribute__((unused)) void *data)
9098 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9099 struct rte_eth_flex_payload_cfg flex_cfg;
9100 struct rte_port *port;
9103 if (res->port_id > nb_ports) {
9104 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9108 port = &ports[res->port_id];
9109 /** Check if the port is not started **/
9110 if (port->port_status != RTE_PORT_STOPPED) {
9111 printf("Please stop port %d first\n", res->port_id);
9115 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9117 if (!strcmp(res->payload_layer, "raw"))
9118 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9119 else if (!strcmp(res->payload_layer, "l2"))
9120 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9121 else if (!strcmp(res->payload_layer, "l3"))
9122 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9123 else if (!strcmp(res->payload_layer, "l4"))
9124 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9126 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9127 RTE_ETH_FDIR_MAX_FLEXLEN);
9129 printf("error: Cannot parse flex payload input.\n");
9133 fdir_set_flex_payload(res->port_id, &flex_cfg);
9134 cmd_reconfig_device_queue(res->port_id, 1, 1);
9137 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9139 flow_director_flexpayload,
9140 "flow_director_flex_payload");
9141 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9142 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9144 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9146 payload_layer, "raw#l2#l3#l4");
9147 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9151 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9152 .f = cmd_flow_director_flxpld_parsed,
9154 .help_str = "set flow director's flex payload on NIC",
9156 (void *)&cmd_flow_director_flexpayload,
9157 (void *)&cmd_flow_director_flexpayload_port_id,
9158 (void *)&cmd_flow_director_flexpayload_payload_layer,
9159 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9164 /* *** Classification Filters Control *** */
9165 /* *** Get symmetric hash enable per port *** */
9166 struct cmd_get_sym_hash_ena_per_port_result {
9167 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9172 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9173 __rte_unused struct cmdline *cl,
9174 __rte_unused void *data)
9176 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9177 struct rte_eth_hash_filter_info info;
9180 if (rte_eth_dev_filter_supported(res->port_id,
9181 RTE_ETH_FILTER_HASH) < 0) {
9182 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9187 memset(&info, 0, sizeof(info));
9188 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9189 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9190 RTE_ETH_FILTER_GET, &info);
9193 printf("Cannot get symmetric hash enable per port "
9194 "on port %u\n", res->port_id);
9198 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9199 "enabled" : "disabled", res->port_id);
9202 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9203 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9204 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9205 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9206 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9209 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9210 .f = cmd_get_sym_hash_per_port_parsed,
9212 .help_str = "get_sym_hash_ena_per_port port_id",
9214 (void *)&cmd_get_sym_hash_ena_per_port_all,
9215 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9220 /* *** Set symmetric hash enable per port *** */
9221 struct cmd_set_sym_hash_ena_per_port_result {
9222 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9223 cmdline_fixed_string_t enable;
9228 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9229 __rte_unused struct cmdline *cl,
9230 __rte_unused void *data)
9232 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9233 struct rte_eth_hash_filter_info info;
9236 if (rte_eth_dev_filter_supported(res->port_id,
9237 RTE_ETH_FILTER_HASH) < 0) {
9238 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9243 memset(&info, 0, sizeof(info));
9244 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9245 if (!strcmp(res->enable, "enable"))
9246 info.info.enable = 1;
9247 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9248 RTE_ETH_FILTER_SET, &info);
9250 printf("Cannot set symmetric hash enable per port on "
9251 "port %u\n", res->port_id);
9254 printf("Symmetric hash has been set to %s on port %u\n",
9255 res->enable, res->port_id);
9258 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9259 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9260 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9261 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9262 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9264 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9265 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9266 enable, "enable#disable");
9268 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9269 .f = cmd_set_sym_hash_per_port_parsed,
9271 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9273 (void *)&cmd_set_sym_hash_ena_per_port_all,
9274 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9275 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9280 /* Get global config of hash function */
9281 struct cmd_get_hash_global_config_result {
9282 cmdline_fixed_string_t get_hash_global_config;
9287 flowtype_to_str(uint16_t ftype)
9294 {"ipv4", RTE_ETH_FLOW_IPV4},
9295 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9296 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9297 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9298 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9299 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9300 {"ipv6", RTE_ETH_FLOW_IPV6},
9301 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9302 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9303 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9304 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9305 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9306 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9309 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9310 if (ftype_table[i].ftype == ftype)
9311 return ftype_table[i].str;
9318 cmd_get_hash_global_config_parsed(void *parsed_result,
9319 __rte_unused struct cmdline *cl,
9320 __rte_unused void *data)
9322 struct cmd_get_hash_global_config_result *res = parsed_result;
9323 struct rte_eth_hash_filter_info info;
9324 uint32_t idx, offset;
9329 if (rte_eth_dev_filter_supported(res->port_id,
9330 RTE_ETH_FILTER_HASH) < 0) {
9331 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9336 memset(&info, 0, sizeof(info));
9337 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9338 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9339 RTE_ETH_FILTER_GET, &info);
9341 printf("Cannot get hash global configurations by port %d\n",
9346 switch (info.info.global_conf.hash_func) {
9347 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9348 printf("Hash function is Toeplitz\n");
9350 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9351 printf("Hash function is Simple XOR\n");
9354 printf("Unknown hash function\n");
9358 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9359 idx = i / UINT32_BIT;
9360 offset = i % UINT32_BIT;
9361 if (!(info.info.global_conf.valid_bit_mask[idx] &
9364 str = flowtype_to_str(i);
9367 printf("Symmetric hash is %s globally for flow type %s "
9369 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9370 (1UL << offset)) ? "enabled" : "disabled"), str,
9375 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9376 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9377 get_hash_global_config, "get_hash_global_config");
9378 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9379 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9382 cmdline_parse_inst_t cmd_get_hash_global_config = {
9383 .f = cmd_get_hash_global_config_parsed,
9385 .help_str = "get_hash_global_config port_id",
9387 (void *)&cmd_get_hash_global_config_all,
9388 (void *)&cmd_get_hash_global_config_port_id,
9393 /* Set global config of hash function */
9394 struct cmd_set_hash_global_config_result {
9395 cmdline_fixed_string_t set_hash_global_config;
9397 cmdline_fixed_string_t hash_func;
9398 cmdline_fixed_string_t flow_type;
9399 cmdline_fixed_string_t enable;
9403 cmd_set_hash_global_config_parsed(void *parsed_result,
9404 __rte_unused struct cmdline *cl,
9405 __rte_unused void *data)
9407 struct cmd_set_hash_global_config_result *res = parsed_result;
9408 struct rte_eth_hash_filter_info info;
9409 uint32_t ftype, idx, offset;
9412 if (rte_eth_dev_filter_supported(res->port_id,
9413 RTE_ETH_FILTER_HASH) < 0) {
9414 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9418 memset(&info, 0, sizeof(info));
9419 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9420 if (!strcmp(res->hash_func, "toeplitz"))
9421 info.info.global_conf.hash_func =
9422 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9423 else if (!strcmp(res->hash_func, "simple_xor"))
9424 info.info.global_conf.hash_func =
9425 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9426 else if (!strcmp(res->hash_func, "default"))
9427 info.info.global_conf.hash_func =
9428 RTE_ETH_HASH_FUNCTION_DEFAULT;
9430 ftype = str2flowtype(res->flow_type);
9431 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9432 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9433 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9434 if (!strcmp(res->enable, "enable"))
9435 info.info.global_conf.sym_hash_enable_mask[idx] |=
9437 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9438 RTE_ETH_FILTER_SET, &info);
9440 printf("Cannot set global hash configurations by port %d\n",
9443 printf("Global hash configurations have been set "
9444 "succcessfully by port %d\n", res->port_id);
9447 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9448 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9449 set_hash_global_config, "set_hash_global_config");
9450 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9451 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9453 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9454 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9455 hash_func, "toeplitz#simple_xor#default");
9456 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9457 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9459 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9460 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9461 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9462 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9463 enable, "enable#disable");
9465 cmdline_parse_inst_t cmd_set_hash_global_config = {
9466 .f = cmd_set_hash_global_config_parsed,
9468 .help_str = "set_hash_global_config port_id "
9469 "toeplitz|simple_xor|default "
9470 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9471 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9474 (void *)&cmd_set_hash_global_config_all,
9475 (void *)&cmd_set_hash_global_config_port_id,
9476 (void *)&cmd_set_hash_global_config_hash_func,
9477 (void *)&cmd_set_hash_global_config_flow_type,
9478 (void *)&cmd_set_hash_global_config_enable,
9483 /* Set hash input set */
9484 struct cmd_set_hash_input_set_result {
9485 cmdline_fixed_string_t set_hash_input_set;
9487 cmdline_fixed_string_t flow_type;
9488 cmdline_fixed_string_t inset_field;
9489 cmdline_fixed_string_t select;
9492 static enum rte_eth_input_set_field
9493 str2inset(char *string)
9497 static const struct {
9499 enum rte_eth_input_set_field inset;
9501 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9502 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9503 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9504 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9505 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9506 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9507 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9508 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9509 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9510 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9511 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9512 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9513 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9514 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9515 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9516 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9517 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9518 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9519 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9520 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9521 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9522 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9523 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9524 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9525 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9526 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9527 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9528 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9529 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9530 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9531 {"none", RTE_ETH_INPUT_SET_NONE},
9534 for (i = 0; i < RTE_DIM(inset_table); i++) {
9535 if (!strcmp(string, inset_table[i].str))
9536 return inset_table[i].inset;
9539 return RTE_ETH_INPUT_SET_UNKNOWN;
9543 cmd_set_hash_input_set_parsed(void *parsed_result,
9544 __rte_unused struct cmdline *cl,
9545 __rte_unused void *data)
9547 struct cmd_set_hash_input_set_result *res = parsed_result;
9548 struct rte_eth_hash_filter_info info;
9550 memset(&info, 0, sizeof(info));
9551 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9552 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9553 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9554 info.info.input_set_conf.inset_size = 1;
9555 if (!strcmp(res->select, "select"))
9556 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9557 else if (!strcmp(res->select, "add"))
9558 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9559 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9560 RTE_ETH_FILTER_SET, &info);
9563 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9564 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9565 set_hash_input_set, "set_hash_input_set");
9566 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9567 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9569 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9570 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9572 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9573 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9574 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9575 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9577 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9578 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9579 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9580 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9581 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9583 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9584 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9585 select, "select#add");
9587 cmdline_parse_inst_t cmd_set_hash_input_set = {
9588 .f = cmd_set_hash_input_set_parsed,
9590 .help_str = "set_hash_input_set <port_id> "
9591 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9592 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9593 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9594 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9595 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9596 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9597 "fld-7th|fld-8th|none select|add",
9599 (void *)&cmd_set_hash_input_set_cmd,
9600 (void *)&cmd_set_hash_input_set_port_id,
9601 (void *)&cmd_set_hash_input_set_flow_type,
9602 (void *)&cmd_set_hash_input_set_field,
9603 (void *)&cmd_set_hash_input_set_select,
9608 /* Set flow director input set */
9609 struct cmd_set_fdir_input_set_result {
9610 cmdline_fixed_string_t set_fdir_input_set;
9612 cmdline_fixed_string_t flow_type;
9613 cmdline_fixed_string_t inset_field;
9614 cmdline_fixed_string_t select;
9618 cmd_set_fdir_input_set_parsed(void *parsed_result,
9619 __rte_unused struct cmdline *cl,
9620 __rte_unused void *data)
9622 struct cmd_set_fdir_input_set_result *res = parsed_result;
9623 struct rte_eth_fdir_filter_info info;
9625 memset(&info, 0, sizeof(info));
9626 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9627 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9628 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9629 info.info.input_set_conf.inset_size = 1;
9630 if (!strcmp(res->select, "select"))
9631 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9632 else if (!strcmp(res->select, "add"))
9633 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9634 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9635 RTE_ETH_FILTER_SET, &info);
9638 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9639 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9640 set_fdir_input_set, "set_fdir_input_set");
9641 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9642 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9644 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9645 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9647 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9648 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9649 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9650 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9652 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9653 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9654 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9655 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9656 "sctp-veri-tag#none");
9657 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9658 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9659 select, "select#add");
9661 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9662 .f = cmd_set_fdir_input_set_parsed,
9664 .help_str = "set_fdir_input_set <port_id> "
9665 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9666 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9667 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9668 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9669 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9670 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9671 "sctp-veri-tag|none select|add",
9673 (void *)&cmd_set_fdir_input_set_cmd,
9674 (void *)&cmd_set_fdir_input_set_port_id,
9675 (void *)&cmd_set_fdir_input_set_flow_type,
9676 (void *)&cmd_set_fdir_input_set_field,
9677 (void *)&cmd_set_fdir_input_set_select,
9682 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9683 struct cmd_mcast_addr_result {
9684 cmdline_fixed_string_t mcast_addr_cmd;
9685 cmdline_fixed_string_t what;
9687 struct ether_addr mc_addr;
9690 static void cmd_mcast_addr_parsed(void *parsed_result,
9691 __attribute__((unused)) struct cmdline *cl,
9692 __attribute__((unused)) void *data)
9694 struct cmd_mcast_addr_result *res = parsed_result;
9696 if (!is_multicast_ether_addr(&res->mc_addr)) {
9697 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9698 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9699 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9700 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9703 if (strcmp(res->what, "add") == 0)
9704 mcast_addr_add(res->port_num, &res->mc_addr);
9706 mcast_addr_remove(res->port_num, &res->mc_addr);
9709 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9710 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9711 mcast_addr_cmd, "mcast_addr");
9712 cmdline_parse_token_string_t cmd_mcast_addr_what =
9713 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9715 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9716 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9717 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9718 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9720 cmdline_parse_inst_t cmd_mcast_addr = {
9721 .f = cmd_mcast_addr_parsed,
9723 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9725 (void *)&cmd_mcast_addr_cmd,
9726 (void *)&cmd_mcast_addr_what,
9727 (void *)&cmd_mcast_addr_portnum,
9728 (void *)&cmd_mcast_addr_addr,
9734 * only support E-tag now.
9737 /* Ether type config */
9738 struct cmd_config_l2_tunnel_eth_type_result {
9739 cmdline_fixed_string_t port;
9740 cmdline_fixed_string_t config;
9741 cmdline_fixed_string_t all;
9743 cmdline_fixed_string_t l2_tunnel;
9744 cmdline_fixed_string_t l2_tunnel_type;
9745 cmdline_fixed_string_t eth_type;
9746 uint16_t eth_type_val;
9749 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9750 TOKEN_STRING_INITIALIZER
9751 (struct cmd_config_l2_tunnel_eth_type_result,
9753 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9754 TOKEN_STRING_INITIALIZER
9755 (struct cmd_config_l2_tunnel_eth_type_result,
9757 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9758 TOKEN_STRING_INITIALIZER
9759 (struct cmd_config_l2_tunnel_eth_type_result,
9761 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9762 TOKEN_NUM_INITIALIZER
9763 (struct cmd_config_l2_tunnel_eth_type_result,
9765 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9766 TOKEN_STRING_INITIALIZER
9767 (struct cmd_config_l2_tunnel_eth_type_result,
9768 l2_tunnel, "l2-tunnel");
9769 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9770 TOKEN_STRING_INITIALIZER
9771 (struct cmd_config_l2_tunnel_eth_type_result,
9772 l2_tunnel_type, "E-tag");
9773 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9774 TOKEN_STRING_INITIALIZER
9775 (struct cmd_config_l2_tunnel_eth_type_result,
9776 eth_type, "ether-type");
9777 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9778 TOKEN_NUM_INITIALIZER
9779 (struct cmd_config_l2_tunnel_eth_type_result,
9780 eth_type_val, UINT16);
9782 static enum rte_eth_tunnel_type
9783 str2fdir_l2_tunnel_type(char *string)
9787 static const struct {
9789 enum rte_eth_tunnel_type type;
9790 } l2_tunnel_type_str[] = {
9791 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9794 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9795 if (!strcmp(l2_tunnel_type_str[i].str, string))
9796 return l2_tunnel_type_str[i].type;
9798 return RTE_TUNNEL_TYPE_NONE;
9801 /* ether type config for all ports */
9803 cmd_config_l2_tunnel_eth_type_all_parsed
9804 (void *parsed_result,
9805 __attribute__((unused)) struct cmdline *cl,
9806 __attribute__((unused)) void *data)
9808 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9809 struct rte_eth_l2_tunnel_conf entry;
9812 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9813 entry.ether_type = res->eth_type_val;
9815 FOREACH_PORT(pid, ports) {
9816 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9820 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9821 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9823 .help_str = "port config all l2-tunnel ether-type",
9825 (void *)&cmd_config_l2_tunnel_eth_type_port,
9826 (void *)&cmd_config_l2_tunnel_eth_type_config,
9827 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9828 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9829 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9830 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9831 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9836 /* ether type config for a specific port */
9838 cmd_config_l2_tunnel_eth_type_specific_parsed(
9839 void *parsed_result,
9840 __attribute__((unused)) struct cmdline *cl,
9841 __attribute__((unused)) void *data)
9843 struct cmd_config_l2_tunnel_eth_type_result *res =
9845 struct rte_eth_l2_tunnel_conf entry;
9847 if (port_id_is_invalid(res->id, ENABLED_WARN))
9850 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9851 entry.ether_type = res->eth_type_val;
9853 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9856 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9857 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9859 .help_str = "port config l2-tunnel ether-type",
9861 (void *)&cmd_config_l2_tunnel_eth_type_port,
9862 (void *)&cmd_config_l2_tunnel_eth_type_config,
9863 (void *)&cmd_config_l2_tunnel_eth_type_id,
9864 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9865 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9866 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9867 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9872 /* Enable/disable l2 tunnel */
9873 struct cmd_config_l2_tunnel_en_dis_result {
9874 cmdline_fixed_string_t port;
9875 cmdline_fixed_string_t config;
9876 cmdline_fixed_string_t all;
9878 cmdline_fixed_string_t l2_tunnel;
9879 cmdline_fixed_string_t l2_tunnel_type;
9880 cmdline_fixed_string_t en_dis;
9883 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9884 TOKEN_STRING_INITIALIZER
9885 (struct cmd_config_l2_tunnel_en_dis_result,
9887 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9888 TOKEN_STRING_INITIALIZER
9889 (struct cmd_config_l2_tunnel_en_dis_result,
9891 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9892 TOKEN_STRING_INITIALIZER
9893 (struct cmd_config_l2_tunnel_en_dis_result,
9895 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9896 TOKEN_NUM_INITIALIZER
9897 (struct cmd_config_l2_tunnel_en_dis_result,
9899 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9900 TOKEN_STRING_INITIALIZER
9901 (struct cmd_config_l2_tunnel_en_dis_result,
9902 l2_tunnel, "l2-tunnel");
9903 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9904 TOKEN_STRING_INITIALIZER
9905 (struct cmd_config_l2_tunnel_en_dis_result,
9906 l2_tunnel_type, "E-tag");
9907 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9908 TOKEN_STRING_INITIALIZER
9909 (struct cmd_config_l2_tunnel_en_dis_result,
9910 en_dis, "enable#disable");
9912 /* enable/disable l2 tunnel for all ports */
9914 cmd_config_l2_tunnel_en_dis_all_parsed(
9915 void *parsed_result,
9916 __attribute__((unused)) struct cmdline *cl,
9917 __attribute__((unused)) void *data)
9919 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9920 struct rte_eth_l2_tunnel_conf entry;
9924 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9926 if (!strcmp("enable", res->en_dis))
9931 FOREACH_PORT(pid, ports) {
9932 rte_eth_dev_l2_tunnel_offload_set(pid,
9934 ETH_L2_TUNNEL_ENABLE_MASK,
9939 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
9940 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
9942 .help_str = "port config all l2-tunnel enable/disable",
9944 (void *)&cmd_config_l2_tunnel_en_dis_port,
9945 (void *)&cmd_config_l2_tunnel_en_dis_config,
9946 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
9947 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9948 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9949 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9954 /* enable/disable l2 tunnel for a port */
9956 cmd_config_l2_tunnel_en_dis_specific_parsed(
9957 void *parsed_result,
9958 __attribute__((unused)) struct cmdline *cl,
9959 __attribute__((unused)) void *data)
9961 struct cmd_config_l2_tunnel_en_dis_result *res =
9963 struct rte_eth_l2_tunnel_conf entry;
9965 if (port_id_is_invalid(res->id, ENABLED_WARN))
9968 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9970 if (!strcmp("enable", res->en_dis))
9971 rte_eth_dev_l2_tunnel_offload_set(res->id,
9973 ETH_L2_TUNNEL_ENABLE_MASK,
9976 rte_eth_dev_l2_tunnel_offload_set(res->id,
9978 ETH_L2_TUNNEL_ENABLE_MASK,
9982 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
9983 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
9985 .help_str = "port config l2-tunnel enable/disable",
9987 (void *)&cmd_config_l2_tunnel_en_dis_port,
9988 (void *)&cmd_config_l2_tunnel_en_dis_config,
9989 (void *)&cmd_config_l2_tunnel_en_dis_id,
9990 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9991 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9992 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9997 /* E-tag configuration */
9999 /* Common result structure for all E-tag configuration */
10000 struct cmd_config_e_tag_result {
10001 cmdline_fixed_string_t e_tag;
10002 cmdline_fixed_string_t set;
10003 cmdline_fixed_string_t insertion;
10004 cmdline_fixed_string_t stripping;
10005 cmdline_fixed_string_t forwarding;
10006 cmdline_fixed_string_t filter;
10007 cmdline_fixed_string_t add;
10008 cmdline_fixed_string_t del;
10009 cmdline_fixed_string_t on;
10010 cmdline_fixed_string_t off;
10011 cmdline_fixed_string_t on_off;
10012 cmdline_fixed_string_t port_tag_id;
10013 uint32_t port_tag_id_val;
10014 cmdline_fixed_string_t e_tag_id;
10015 uint16_t e_tag_id_val;
10016 cmdline_fixed_string_t dst_pool;
10017 uint8_t dst_pool_val;
10018 cmdline_fixed_string_t port;
10020 cmdline_fixed_string_t vf;
10024 /* Common CLI fields for all E-tag configuration */
10025 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10026 TOKEN_STRING_INITIALIZER
10027 (struct cmd_config_e_tag_result,
10029 cmdline_parse_token_string_t cmd_config_e_tag_set =
10030 TOKEN_STRING_INITIALIZER
10031 (struct cmd_config_e_tag_result,
10033 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10034 TOKEN_STRING_INITIALIZER
10035 (struct cmd_config_e_tag_result,
10036 insertion, "insertion");
10037 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10038 TOKEN_STRING_INITIALIZER
10039 (struct cmd_config_e_tag_result,
10040 stripping, "stripping");
10041 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10042 TOKEN_STRING_INITIALIZER
10043 (struct cmd_config_e_tag_result,
10044 forwarding, "forwarding");
10045 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10046 TOKEN_STRING_INITIALIZER
10047 (struct cmd_config_e_tag_result,
10049 cmdline_parse_token_string_t cmd_config_e_tag_add =
10050 TOKEN_STRING_INITIALIZER
10051 (struct cmd_config_e_tag_result,
10053 cmdline_parse_token_string_t cmd_config_e_tag_del =
10054 TOKEN_STRING_INITIALIZER
10055 (struct cmd_config_e_tag_result,
10057 cmdline_parse_token_string_t cmd_config_e_tag_on =
10058 TOKEN_STRING_INITIALIZER
10059 (struct cmd_config_e_tag_result,
10061 cmdline_parse_token_string_t cmd_config_e_tag_off =
10062 TOKEN_STRING_INITIALIZER
10063 (struct cmd_config_e_tag_result,
10065 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10066 TOKEN_STRING_INITIALIZER
10067 (struct cmd_config_e_tag_result,
10069 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10070 TOKEN_STRING_INITIALIZER
10071 (struct cmd_config_e_tag_result,
10072 port_tag_id, "port-tag-id");
10073 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10074 TOKEN_NUM_INITIALIZER
10075 (struct cmd_config_e_tag_result,
10076 port_tag_id_val, UINT32);
10077 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10078 TOKEN_STRING_INITIALIZER
10079 (struct cmd_config_e_tag_result,
10080 e_tag_id, "e-tag-id");
10081 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10082 TOKEN_NUM_INITIALIZER
10083 (struct cmd_config_e_tag_result,
10084 e_tag_id_val, UINT16);
10085 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10086 TOKEN_STRING_INITIALIZER
10087 (struct cmd_config_e_tag_result,
10088 dst_pool, "dst-pool");
10089 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10090 TOKEN_NUM_INITIALIZER
10091 (struct cmd_config_e_tag_result,
10092 dst_pool_val, UINT8);
10093 cmdline_parse_token_string_t cmd_config_e_tag_port =
10094 TOKEN_STRING_INITIALIZER
10095 (struct cmd_config_e_tag_result,
10097 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10098 TOKEN_NUM_INITIALIZER
10099 (struct cmd_config_e_tag_result,
10101 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10102 TOKEN_STRING_INITIALIZER
10103 (struct cmd_config_e_tag_result,
10105 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10106 TOKEN_NUM_INITIALIZER
10107 (struct cmd_config_e_tag_result,
10110 /* E-tag insertion configuration */
10112 cmd_config_e_tag_insertion_en_parsed(
10113 void *parsed_result,
10114 __attribute__((unused)) struct cmdline *cl,
10115 __attribute__((unused)) void *data)
10117 struct cmd_config_e_tag_result *res =
10119 struct rte_eth_l2_tunnel_conf entry;
10121 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10124 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10125 entry.tunnel_id = res->port_tag_id_val;
10126 entry.vf_id = res->vf_id;
10127 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10129 ETH_L2_TUNNEL_INSERTION_MASK,
10134 cmd_config_e_tag_insertion_dis_parsed(
10135 void *parsed_result,
10136 __attribute__((unused)) struct cmdline *cl,
10137 __attribute__((unused)) void *data)
10139 struct cmd_config_e_tag_result *res =
10141 struct rte_eth_l2_tunnel_conf entry;
10143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10146 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10147 entry.vf_id = res->vf_id;
10149 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10151 ETH_L2_TUNNEL_INSERTION_MASK,
10155 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10156 .f = cmd_config_e_tag_insertion_en_parsed,
10158 .help_str = "E-tag insertion enable",
10160 (void *)&cmd_config_e_tag_e_tag,
10161 (void *)&cmd_config_e_tag_set,
10162 (void *)&cmd_config_e_tag_insertion,
10163 (void *)&cmd_config_e_tag_on,
10164 (void *)&cmd_config_e_tag_port_tag_id,
10165 (void *)&cmd_config_e_tag_port_tag_id_val,
10166 (void *)&cmd_config_e_tag_port,
10167 (void *)&cmd_config_e_tag_port_id,
10168 (void *)&cmd_config_e_tag_vf,
10169 (void *)&cmd_config_e_tag_vf_id,
10174 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10175 .f = cmd_config_e_tag_insertion_dis_parsed,
10177 .help_str = "E-tag insertion disable",
10179 (void *)&cmd_config_e_tag_e_tag,
10180 (void *)&cmd_config_e_tag_set,
10181 (void *)&cmd_config_e_tag_insertion,
10182 (void *)&cmd_config_e_tag_off,
10183 (void *)&cmd_config_e_tag_port,
10184 (void *)&cmd_config_e_tag_port_id,
10185 (void *)&cmd_config_e_tag_vf,
10186 (void *)&cmd_config_e_tag_vf_id,
10191 /* E-tag stripping configuration */
10193 cmd_config_e_tag_stripping_parsed(
10194 void *parsed_result,
10195 __attribute__((unused)) struct cmdline *cl,
10196 __attribute__((unused)) void *data)
10198 struct cmd_config_e_tag_result *res =
10200 struct rte_eth_l2_tunnel_conf entry;
10202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10205 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10207 if (!strcmp(res->on_off, "on"))
10208 rte_eth_dev_l2_tunnel_offload_set
10211 ETH_L2_TUNNEL_STRIPPING_MASK,
10214 rte_eth_dev_l2_tunnel_offload_set
10217 ETH_L2_TUNNEL_STRIPPING_MASK,
10221 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10222 .f = cmd_config_e_tag_stripping_parsed,
10224 .help_str = "E-tag stripping enable/disable",
10226 (void *)&cmd_config_e_tag_e_tag,
10227 (void *)&cmd_config_e_tag_set,
10228 (void *)&cmd_config_e_tag_stripping,
10229 (void *)&cmd_config_e_tag_on_off,
10230 (void *)&cmd_config_e_tag_port,
10231 (void *)&cmd_config_e_tag_port_id,
10236 /* E-tag forwarding configuration */
10238 cmd_config_e_tag_forwarding_parsed(
10239 void *parsed_result,
10240 __attribute__((unused)) struct cmdline *cl,
10241 __attribute__((unused)) void *data)
10243 struct cmd_config_e_tag_result *res = parsed_result;
10244 struct rte_eth_l2_tunnel_conf entry;
10246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10249 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10251 if (!strcmp(res->on_off, "on"))
10252 rte_eth_dev_l2_tunnel_offload_set
10255 ETH_L2_TUNNEL_FORWARDING_MASK,
10258 rte_eth_dev_l2_tunnel_offload_set
10261 ETH_L2_TUNNEL_FORWARDING_MASK,
10265 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10266 .f = cmd_config_e_tag_forwarding_parsed,
10268 .help_str = "E-tag forwarding enable/disable",
10270 (void *)&cmd_config_e_tag_e_tag,
10271 (void *)&cmd_config_e_tag_set,
10272 (void *)&cmd_config_e_tag_forwarding,
10273 (void *)&cmd_config_e_tag_on_off,
10274 (void *)&cmd_config_e_tag_port,
10275 (void *)&cmd_config_e_tag_port_id,
10280 /* E-tag filter configuration */
10282 cmd_config_e_tag_filter_add_parsed(
10283 void *parsed_result,
10284 __attribute__((unused)) struct cmdline *cl,
10285 __attribute__((unused)) void *data)
10287 struct cmd_config_e_tag_result *res = parsed_result;
10288 struct rte_eth_l2_tunnel_conf entry;
10291 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10294 if (res->e_tag_id_val > 0x3fff) {
10295 printf("e-tag-id must be equal or less than 0x3fff.\n");
10299 ret = rte_eth_dev_filter_supported(res->port_id,
10300 RTE_ETH_FILTER_L2_TUNNEL);
10302 printf("E-tag filter is not supported on port %u.\n",
10307 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10308 entry.tunnel_id = res->e_tag_id_val;
10309 entry.pool = res->dst_pool_val;
10311 ret = rte_eth_dev_filter_ctrl(res->port_id,
10312 RTE_ETH_FILTER_L2_TUNNEL,
10313 RTE_ETH_FILTER_ADD,
10316 printf("E-tag filter programming error: (%s)\n",
10320 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10321 .f = cmd_config_e_tag_filter_add_parsed,
10323 .help_str = "E-tag filter add",
10325 (void *)&cmd_config_e_tag_e_tag,
10326 (void *)&cmd_config_e_tag_set,
10327 (void *)&cmd_config_e_tag_filter,
10328 (void *)&cmd_config_e_tag_add,
10329 (void *)&cmd_config_e_tag_e_tag_id,
10330 (void *)&cmd_config_e_tag_e_tag_id_val,
10331 (void *)&cmd_config_e_tag_dst_pool,
10332 (void *)&cmd_config_e_tag_dst_pool_val,
10333 (void *)&cmd_config_e_tag_port,
10334 (void *)&cmd_config_e_tag_port_id,
10340 cmd_config_e_tag_filter_del_parsed(
10341 void *parsed_result,
10342 __attribute__((unused)) struct cmdline *cl,
10343 __attribute__((unused)) void *data)
10345 struct cmd_config_e_tag_result *res = parsed_result;
10346 struct rte_eth_l2_tunnel_conf entry;
10349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10352 if (res->e_tag_id_val > 0x3fff) {
10353 printf("e-tag-id must be less than 0x3fff.\n");
10357 ret = rte_eth_dev_filter_supported(res->port_id,
10358 RTE_ETH_FILTER_L2_TUNNEL);
10360 printf("E-tag filter is not supported on port %u.\n",
10365 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10366 entry.tunnel_id = res->e_tag_id_val;
10368 ret = rte_eth_dev_filter_ctrl(res->port_id,
10369 RTE_ETH_FILTER_L2_TUNNEL,
10370 RTE_ETH_FILTER_DELETE,
10373 printf("E-tag filter programming error: (%s)\n",
10377 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10378 .f = cmd_config_e_tag_filter_del_parsed,
10380 .help_str = "E-tag filter delete",
10382 (void *)&cmd_config_e_tag_e_tag,
10383 (void *)&cmd_config_e_tag_set,
10384 (void *)&cmd_config_e_tag_filter,
10385 (void *)&cmd_config_e_tag_del,
10386 (void *)&cmd_config_e_tag_e_tag_id,
10387 (void *)&cmd_config_e_tag_e_tag_id_val,
10388 (void *)&cmd_config_e_tag_port,
10389 (void *)&cmd_config_e_tag_port_id,
10394 /* ******************************************************************************** */
10396 /* list of instructions */
10397 cmdline_parse_ctx_t main_ctx[] = {
10398 (cmdline_parse_inst_t *)&cmd_help_brief,
10399 (cmdline_parse_inst_t *)&cmd_help_long,
10400 (cmdline_parse_inst_t *)&cmd_quit,
10401 (cmdline_parse_inst_t *)&cmd_showport,
10402 (cmdline_parse_inst_t *)&cmd_showqueue,
10403 (cmdline_parse_inst_t *)&cmd_showportall,
10404 (cmdline_parse_inst_t *)&cmd_showcfg,
10405 (cmdline_parse_inst_t *)&cmd_start,
10406 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10407 (cmdline_parse_inst_t *)&cmd_set_link_up,
10408 (cmdline_parse_inst_t *)&cmd_set_link_down,
10409 (cmdline_parse_inst_t *)&cmd_reset,
10410 (cmdline_parse_inst_t *)&cmd_set_numbers,
10411 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10412 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10413 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10414 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10415 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10416 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10417 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10418 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10419 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10420 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10421 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10422 (cmdline_parse_inst_t *)&cmd_set_link_check,
10423 #ifdef RTE_NIC_BYPASS
10424 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10425 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10426 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10427 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10429 #ifdef RTE_LIBRTE_PMD_BOND
10430 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10431 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10432 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10433 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10434 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10435 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10436 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10437 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10438 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10440 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10441 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10442 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10443 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10444 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10445 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10446 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10447 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10448 (cmdline_parse_inst_t *)&cmd_csum_set,
10449 (cmdline_parse_inst_t *)&cmd_csum_show,
10450 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10451 (cmdline_parse_inst_t *)&cmd_tso_set,
10452 (cmdline_parse_inst_t *)&cmd_tso_show,
10453 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10454 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10455 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10456 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10457 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10458 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10459 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10460 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10461 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10462 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10463 (cmdline_parse_inst_t *)&cmd_config_dcb,
10464 (cmdline_parse_inst_t *)&cmd_read_reg,
10465 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10466 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10467 (cmdline_parse_inst_t *)&cmd_write_reg,
10468 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10469 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10470 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10471 (cmdline_parse_inst_t *)&cmd_stop,
10472 (cmdline_parse_inst_t *)&cmd_mac_addr,
10473 (cmdline_parse_inst_t *)&cmd_set_qmap,
10474 (cmdline_parse_inst_t *)&cmd_operate_port,
10475 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10476 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10477 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10478 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10479 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10480 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10481 (cmdline_parse_inst_t *)&cmd_config_mtu,
10482 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10483 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10484 (cmdline_parse_inst_t *)&cmd_config_rss,
10485 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10486 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10487 (cmdline_parse_inst_t *)&cmd_showport_reta,
10488 (cmdline_parse_inst_t *)&cmd_config_burst,
10489 (cmdline_parse_inst_t *)&cmd_config_thresh,
10490 (cmdline_parse_inst_t *)&cmd_config_threshold,
10491 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10492 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10493 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10494 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10495 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10496 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10497 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10498 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10499 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10500 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10501 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10502 (cmdline_parse_inst_t *)&cmd_global_config,
10503 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10504 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10505 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10506 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10507 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10508 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10509 (cmdline_parse_inst_t *)&cmd_dump,
10510 (cmdline_parse_inst_t *)&cmd_dump_one,
10511 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10512 (cmdline_parse_inst_t *)&cmd_syn_filter,
10513 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10514 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10515 (cmdline_parse_inst_t *)&cmd_flex_filter,
10516 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10517 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10518 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10519 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10520 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10521 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10522 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10523 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10524 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10525 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10526 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10527 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10528 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10529 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10530 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10531 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10532 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10533 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10534 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10535 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10536 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10537 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10538 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10539 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10540 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10541 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10542 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10543 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10544 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10548 /* prompt function, called from main on MASTER lcore */
10552 /* initialize non-constant commands */
10553 cmd_set_fwd_mode_init();
10555 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10556 if (testpmd_cl == NULL)
10558 cmdline_interact(testpmd_cl);
10559 cmdline_stdin_exit(testpmd_cl);
10565 if (testpmd_cl != NULL)
10566 cmdline_quit(testpmd_cl);
10570 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10572 if (id == (portid_t)RTE_PORT_ALL) {
10575 FOREACH_PORT(pid, ports) {
10576 /* check if need_reconfig has been set to 1 */
10577 if (ports[pid].need_reconfig == 0)
10578 ports[pid].need_reconfig = dev;
10579 /* check if need_reconfig_queues has been set to 1 */
10580 if (ports[pid].need_reconfig_queues == 0)
10581 ports[pid].need_reconfig_queues = queue;
10583 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10584 /* check if need_reconfig has been set to 1 */
10585 if (ports[id].need_reconfig == 0)
10586 ports[id].need_reconfig = dev;
10587 /* check if need_reconfig_queues has been set to 1 */
10588 if (ports[id].need_reconfig_queues == 0)
10589 ports[id].need_reconfig_queues = queue;
10593 #ifdef RTE_NIC_BYPASS
10594 #include <rte_pci_dev_ids.h>
10596 bypass_is_supported(portid_t port_id)
10598 struct rte_port *port;
10599 struct rte_pci_id *pci_id;
10601 if (port_id_is_invalid(port_id, ENABLED_WARN))
10604 /* Get the device id. */
10605 port = &ports[port_id];
10606 pci_id = &port->dev_info.pci_dev->id;
10608 /* Check if NIC supports bypass. */
10609 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10613 printf("\tBypass not supported for port_id = %d.\n", port_id);