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) (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 rte_be_to_cpu_32(res->ip_value.addr.ipv4.s_addr);
6687 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6690 for (i = 0; i < 4; i++) {
6691 tunnel_filter_conf.ip_addr.ipv6_addr[i] =
6692 rte_be_to_cpu_32(res->ip_value.addr.ipv6.s6_addr32[i]);
6694 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6697 if (!strcmp(res->filter_type, "imac-ivlan"))
6698 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6699 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6700 tunnel_filter_conf.filter_type =
6701 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6702 else if (!strcmp(res->filter_type, "imac-tenid"))
6703 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6704 else if (!strcmp(res->filter_type, "imac"))
6705 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6706 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6707 tunnel_filter_conf.filter_type =
6708 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6709 else if (!strcmp(res->filter_type, "oip"))
6710 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6711 else if (!strcmp(res->filter_type, "iip"))
6712 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6714 printf("The filter type is not supported");
6718 if (!strcmp(res->tunnel_type, "vxlan"))
6719 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6720 else if (!strcmp(res->tunnel_type, "nvgre"))
6721 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6722 else if (!strcmp(res->tunnel_type, "ipingre"))
6723 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6725 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6729 tunnel_filter_conf.tenant_id = res->tenant_id;
6730 tunnel_filter_conf.queue_id = res->queue_num;
6731 if (!strcmp(res->what, "add"))
6732 ret = rte_eth_dev_filter_ctrl(res->port_id,
6733 RTE_ETH_FILTER_TUNNEL,
6735 &tunnel_filter_conf);
6737 ret = rte_eth_dev_filter_ctrl(res->port_id,
6738 RTE_ETH_FILTER_TUNNEL,
6739 RTE_ETH_FILTER_DELETE,
6740 &tunnel_filter_conf);
6742 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6746 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6747 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6748 cmd, "tunnel_filter");
6749 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6750 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6752 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6753 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6755 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6758 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6759 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6761 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6762 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6763 inner_vlan, UINT16);
6764 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6765 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6767 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6768 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6769 tunnel_type, "vxlan#nvgre#ipingre");
6771 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6772 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6773 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6774 "imac#omac-imac-tenid");
6775 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6776 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6778 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6779 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6782 cmdline_parse_inst_t cmd_tunnel_filter = {
6783 .f = cmd_tunnel_filter_parsed,
6785 .help_str = "add/rm tunnel filter of a port: "
6786 "tunnel_filter add port_id outer_mac inner_mac ip "
6787 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6788 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6789 "imac|omac-imac-tenid) "
6790 "tenant_id queue_num",
6792 (void *)&cmd_tunnel_filter_cmd,
6793 (void *)&cmd_tunnel_filter_what,
6794 (void *)&cmd_tunnel_filter_port_id,
6795 (void *)&cmd_tunnel_filter_outer_mac,
6796 (void *)&cmd_tunnel_filter_inner_mac,
6797 (void *)&cmd_tunnel_filter_ip_value,
6798 (void *)&cmd_tunnel_filter_innner_vlan,
6799 (void *)&cmd_tunnel_filter_tunnel_type,
6800 (void *)&cmd_tunnel_filter_filter_type,
6801 (void *)&cmd_tunnel_filter_tenant_id,
6802 (void *)&cmd_tunnel_filter_queue_num,
6807 /* *** CONFIGURE TUNNEL UDP PORT *** */
6808 struct cmd_tunnel_udp_config {
6809 cmdline_fixed_string_t cmd;
6810 cmdline_fixed_string_t what;
6816 cmd_tunnel_udp_config_parsed(void *parsed_result,
6817 __attribute__((unused)) struct cmdline *cl,
6818 __attribute__((unused)) void *data)
6820 struct cmd_tunnel_udp_config *res = parsed_result;
6821 struct rte_eth_udp_tunnel tunnel_udp;
6824 tunnel_udp.udp_port = res->udp_port;
6826 if (!strcmp(res->cmd, "rx_vxlan_port"))
6827 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6829 if (!strcmp(res->what, "add"))
6830 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
6833 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
6837 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6840 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6841 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6842 cmd, "rx_vxlan_port");
6843 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6844 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6846 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6847 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6849 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6850 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6853 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6854 .f = cmd_tunnel_udp_config_parsed,
6856 .help_str = "add/rm an tunneling UDP port filter: "
6857 "rx_vxlan_port add udp_port port_id",
6859 (void *)&cmd_tunnel_udp_config_cmd,
6860 (void *)&cmd_tunnel_udp_config_what,
6861 (void *)&cmd_tunnel_udp_config_udp_port,
6862 (void *)&cmd_tunnel_udp_config_port_id,
6867 /* *** GLOBAL CONFIG *** */
6868 struct cmd_global_config_result {
6869 cmdline_fixed_string_t cmd;
6871 cmdline_fixed_string_t cfg_type;
6876 cmd_global_config_parsed(void *parsed_result,
6877 __attribute__((unused)) struct cmdline *cl,
6878 __attribute__((unused)) void *data)
6880 struct cmd_global_config_result *res = parsed_result;
6881 struct rte_eth_global_cfg conf;
6884 memset(&conf, 0, sizeof(conf));
6885 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6886 conf.cfg.gre_key_len = res->len;
6887 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6888 RTE_ETH_FILTER_SET, &conf);
6890 printf("Global config error\n");
6893 cmdline_parse_token_string_t cmd_global_config_cmd =
6894 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6896 cmdline_parse_token_num_t cmd_global_config_port_id =
6897 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6898 cmdline_parse_token_string_t cmd_global_config_type =
6899 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6900 cfg_type, "gre-key-len");
6901 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6902 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6905 cmdline_parse_inst_t cmd_global_config = {
6906 .f = cmd_global_config_parsed,
6907 .data = (void *)NULL,
6908 .help_str = "global_config <port_id> gre-key-len <number>",
6910 (void *)&cmd_global_config_cmd,
6911 (void *)&cmd_global_config_port_id,
6912 (void *)&cmd_global_config_type,
6913 (void *)&cmd_global_config_gre_key_len,
6918 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6919 struct cmd_set_mirror_mask_result {
6920 cmdline_fixed_string_t set;
6921 cmdline_fixed_string_t port;
6923 cmdline_fixed_string_t mirror;
6925 cmdline_fixed_string_t what;
6926 cmdline_fixed_string_t value;
6927 cmdline_fixed_string_t dstpool;
6929 cmdline_fixed_string_t on;
6932 cmdline_parse_token_string_t cmd_mirror_mask_set =
6933 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6935 cmdline_parse_token_string_t cmd_mirror_mask_port =
6936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6938 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6939 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6941 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6943 mirror, "mirror-rule");
6944 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6945 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6947 cmdline_parse_token_string_t cmd_mirror_mask_what =
6948 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6949 what, "pool-mirror-up#pool-mirror-down"
6951 cmdline_parse_token_string_t cmd_mirror_mask_value =
6952 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6954 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6955 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6956 dstpool, "dst-pool");
6957 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6958 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6960 cmdline_parse_token_string_t cmd_mirror_mask_on =
6961 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6965 cmd_set_mirror_mask_parsed(void *parsed_result,
6966 __attribute__((unused)) struct cmdline *cl,
6967 __attribute__((unused)) void *data)
6970 struct cmd_set_mirror_mask_result *res = parsed_result;
6971 struct rte_eth_mirror_conf mr_conf;
6973 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6975 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6977 mr_conf.dst_pool = res->dstpool_id;
6979 if (!strcmp(res->what, "pool-mirror-up")) {
6980 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6981 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6982 } else if (!strcmp(res->what, "pool-mirror-down")) {
6983 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6984 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6985 } else if (!strcmp(res->what, "vlan-mirror")) {
6986 mr_conf.rule_type = ETH_MIRROR_VLAN;
6987 nb_item = parse_item_list(res->value, "vlan",
6988 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6992 for (i = 0; i < nb_item; i++) {
6993 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6994 printf("Invalid vlan_id: must be < 4096\n");
6998 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6999 mr_conf.vlan.vlan_mask |= 1ULL << i;
7003 if (!strcmp(res->on, "on"))
7004 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7007 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7010 printf("mirror rule add error: (%s)\n", strerror(-ret));
7013 cmdline_parse_inst_t cmd_set_mirror_mask = {
7014 .f = cmd_set_mirror_mask_parsed,
7016 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7017 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7019 (void *)&cmd_mirror_mask_set,
7020 (void *)&cmd_mirror_mask_port,
7021 (void *)&cmd_mirror_mask_portid,
7022 (void *)&cmd_mirror_mask_mirror,
7023 (void *)&cmd_mirror_mask_ruleid,
7024 (void *)&cmd_mirror_mask_what,
7025 (void *)&cmd_mirror_mask_value,
7026 (void *)&cmd_mirror_mask_dstpool,
7027 (void *)&cmd_mirror_mask_poolid,
7028 (void *)&cmd_mirror_mask_on,
7033 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7034 struct cmd_set_mirror_link_result {
7035 cmdline_fixed_string_t set;
7036 cmdline_fixed_string_t port;
7038 cmdline_fixed_string_t mirror;
7040 cmdline_fixed_string_t what;
7041 cmdline_fixed_string_t dstpool;
7043 cmdline_fixed_string_t on;
7046 cmdline_parse_token_string_t cmd_mirror_link_set =
7047 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7049 cmdline_parse_token_string_t cmd_mirror_link_port =
7050 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7052 cmdline_parse_token_num_t cmd_mirror_link_portid =
7053 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7055 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7056 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7057 mirror, "mirror-rule");
7058 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7059 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7061 cmdline_parse_token_string_t cmd_mirror_link_what =
7062 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7063 what, "uplink-mirror#downlink-mirror");
7064 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7065 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7066 dstpool, "dst-pool");
7067 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7068 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7070 cmdline_parse_token_string_t cmd_mirror_link_on =
7071 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7075 cmd_set_mirror_link_parsed(void *parsed_result,
7076 __attribute__((unused)) struct cmdline *cl,
7077 __attribute__((unused)) void *data)
7080 struct cmd_set_mirror_link_result *res = parsed_result;
7081 struct rte_eth_mirror_conf mr_conf;
7083 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7084 if (!strcmp(res->what, "uplink-mirror"))
7085 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7087 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7089 mr_conf.dst_pool = res->dstpool_id;
7091 if (!strcmp(res->on, "on"))
7092 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7095 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7098 /* check the return value and print it if is < 0 */
7100 printf("mirror rule add error: (%s)\n", strerror(-ret));
7104 cmdline_parse_inst_t cmd_set_mirror_link = {
7105 .f = cmd_set_mirror_link_parsed,
7107 .help_str = "set port X mirror-rule Y uplink-mirror|"
7108 "downlink-mirror dst-pool Z on|off",
7110 (void *)&cmd_mirror_link_set,
7111 (void *)&cmd_mirror_link_port,
7112 (void *)&cmd_mirror_link_portid,
7113 (void *)&cmd_mirror_link_mirror,
7114 (void *)&cmd_mirror_link_ruleid,
7115 (void *)&cmd_mirror_link_what,
7116 (void *)&cmd_mirror_link_dstpool,
7117 (void *)&cmd_mirror_link_poolid,
7118 (void *)&cmd_mirror_link_on,
7123 /* *** RESET VM MIRROR RULE *** */
7124 struct cmd_rm_mirror_rule_result {
7125 cmdline_fixed_string_t reset;
7126 cmdline_fixed_string_t port;
7128 cmdline_fixed_string_t mirror;
7132 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7133 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7135 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7136 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7138 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7139 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7141 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7142 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7143 mirror, "mirror-rule");
7144 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7145 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7149 cmd_reset_mirror_rule_parsed(void *parsed_result,
7150 __attribute__((unused)) struct cmdline *cl,
7151 __attribute__((unused)) void *data)
7154 struct cmd_set_mirror_link_result *res = parsed_result;
7156 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7158 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7161 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7162 .f = cmd_reset_mirror_rule_parsed,
7164 .help_str = "reset port X mirror-rule Y",
7166 (void *)&cmd_rm_mirror_rule_reset,
7167 (void *)&cmd_rm_mirror_rule_port,
7168 (void *)&cmd_rm_mirror_rule_portid,
7169 (void *)&cmd_rm_mirror_rule_mirror,
7170 (void *)&cmd_rm_mirror_rule_ruleid,
7175 /* ******************************************************************************** */
7177 struct cmd_dump_result {
7178 cmdline_fixed_string_t dump;
7182 dump_struct_sizes(void)
7184 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7185 DUMP_SIZE(struct rte_mbuf);
7186 DUMP_SIZE(struct rte_mempool);
7187 DUMP_SIZE(struct rte_ring);
7191 static void cmd_dump_parsed(void *parsed_result,
7192 __attribute__((unused)) struct cmdline *cl,
7193 __attribute__((unused)) void *data)
7195 struct cmd_dump_result *res = parsed_result;
7197 if (!strcmp(res->dump, "dump_physmem"))
7198 rte_dump_physmem_layout(stdout);
7199 else if (!strcmp(res->dump, "dump_memzone"))
7200 rte_memzone_dump(stdout);
7201 else if (!strcmp(res->dump, "dump_log_history"))
7202 rte_log_dump_history(stdout);
7203 else if (!strcmp(res->dump, "dump_struct_sizes"))
7204 dump_struct_sizes();
7205 else if (!strcmp(res->dump, "dump_ring"))
7206 rte_ring_list_dump(stdout);
7207 else if (!strcmp(res->dump, "dump_mempool"))
7208 rte_mempool_list_dump(stdout);
7209 else if (!strcmp(res->dump, "dump_devargs"))
7210 rte_eal_devargs_dump(stdout);
7213 cmdline_parse_token_string_t cmd_dump_dump =
7214 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7218 "dump_struct_sizes#"
7223 cmdline_parse_inst_t cmd_dump = {
7224 .f = cmd_dump_parsed, /* function to call */
7225 .data = NULL, /* 2nd arg of func */
7226 .help_str = "dump status",
7227 .tokens = { /* token list, NULL terminated */
7228 (void *)&cmd_dump_dump,
7233 /* ******************************************************************************** */
7235 struct cmd_dump_one_result {
7236 cmdline_fixed_string_t dump;
7237 cmdline_fixed_string_t name;
7240 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7241 __attribute__((unused)) void *data)
7243 struct cmd_dump_one_result *res = parsed_result;
7245 if (!strcmp(res->dump, "dump_ring")) {
7247 r = rte_ring_lookup(res->name);
7249 cmdline_printf(cl, "Cannot find ring\n");
7252 rte_ring_dump(stdout, r);
7253 } else if (!strcmp(res->dump, "dump_mempool")) {
7254 struct rte_mempool *mp;
7255 mp = rte_mempool_lookup(res->name);
7257 cmdline_printf(cl, "Cannot find mempool\n");
7260 rte_mempool_dump(stdout, mp);
7264 cmdline_parse_token_string_t cmd_dump_one_dump =
7265 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7266 "dump_ring#dump_mempool");
7268 cmdline_parse_token_string_t cmd_dump_one_name =
7269 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7271 cmdline_parse_inst_t cmd_dump_one = {
7272 .f = cmd_dump_one_parsed, /* function to call */
7273 .data = NULL, /* 2nd arg of func */
7274 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7275 .tokens = { /* token list, NULL terminated */
7276 (void *)&cmd_dump_one_dump,
7277 (void *)&cmd_dump_one_name,
7282 /* *** Add/Del syn filter *** */
7283 struct cmd_syn_filter_result {
7284 cmdline_fixed_string_t filter;
7286 cmdline_fixed_string_t ops;
7287 cmdline_fixed_string_t priority;
7288 cmdline_fixed_string_t high;
7289 cmdline_fixed_string_t queue;
7294 cmd_syn_filter_parsed(void *parsed_result,
7295 __attribute__((unused)) struct cmdline *cl,
7296 __attribute__((unused)) void *data)
7298 struct cmd_syn_filter_result *res = parsed_result;
7299 struct rte_eth_syn_filter syn_filter;
7302 ret = rte_eth_dev_filter_supported(res->port_id,
7303 RTE_ETH_FILTER_SYN);
7305 printf("syn filter is not supported on port %u.\n",
7310 memset(&syn_filter, 0, sizeof(syn_filter));
7312 if (!strcmp(res->ops, "add")) {
7313 if (!strcmp(res->high, "high"))
7314 syn_filter.hig_pri = 1;
7316 syn_filter.hig_pri = 0;
7318 syn_filter.queue = res->queue_id;
7319 ret = rte_eth_dev_filter_ctrl(res->port_id,
7324 ret = rte_eth_dev_filter_ctrl(res->port_id,
7326 RTE_ETH_FILTER_DELETE,
7330 printf("syn filter programming error: (%s)\n",
7334 cmdline_parse_token_string_t cmd_syn_filter_filter =
7335 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7336 filter, "syn_filter");
7337 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7338 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7340 cmdline_parse_token_string_t cmd_syn_filter_ops =
7341 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7343 cmdline_parse_token_string_t cmd_syn_filter_priority =
7344 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7345 priority, "priority");
7346 cmdline_parse_token_string_t cmd_syn_filter_high =
7347 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7349 cmdline_parse_token_string_t cmd_syn_filter_queue =
7350 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7352 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7353 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7356 cmdline_parse_inst_t cmd_syn_filter = {
7357 .f = cmd_syn_filter_parsed,
7359 .help_str = "add/delete syn filter",
7361 (void *)&cmd_syn_filter_filter,
7362 (void *)&cmd_syn_filter_port_id,
7363 (void *)&cmd_syn_filter_ops,
7364 (void *)&cmd_syn_filter_priority,
7365 (void *)&cmd_syn_filter_high,
7366 (void *)&cmd_syn_filter_queue,
7367 (void *)&cmd_syn_filter_queue_id,
7372 /* *** ADD/REMOVE A 2tuple FILTER *** */
7373 struct cmd_2tuple_filter_result {
7374 cmdline_fixed_string_t filter;
7376 cmdline_fixed_string_t ops;
7377 cmdline_fixed_string_t dst_port;
7378 uint16_t dst_port_value;
7379 cmdline_fixed_string_t protocol;
7380 uint8_t protocol_value;
7381 cmdline_fixed_string_t mask;
7383 cmdline_fixed_string_t tcp_flags;
7384 uint8_t tcp_flags_value;
7385 cmdline_fixed_string_t priority;
7386 uint8_t priority_value;
7387 cmdline_fixed_string_t queue;
7392 cmd_2tuple_filter_parsed(void *parsed_result,
7393 __attribute__((unused)) struct cmdline *cl,
7394 __attribute__((unused)) void *data)
7396 struct rte_eth_ntuple_filter filter;
7397 struct cmd_2tuple_filter_result *res = parsed_result;
7400 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7402 printf("ntuple filter is not supported on port %u.\n",
7407 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7409 filter.flags = RTE_2TUPLE_FLAGS;
7410 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7411 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7412 filter.proto = res->protocol_value;
7413 filter.priority = res->priority_value;
7414 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7415 printf("nonzero tcp_flags is only meaningful"
7416 " when protocol is TCP.\n");
7419 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7420 printf("invalid TCP flags.\n");
7424 if (res->tcp_flags_value != 0) {
7425 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7426 filter.tcp_flags = res->tcp_flags_value;
7429 /* need convert to big endian. */
7430 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7431 filter.queue = res->queue_id;
7433 if (!strcmp(res->ops, "add"))
7434 ret = rte_eth_dev_filter_ctrl(res->port_id,
7435 RTE_ETH_FILTER_NTUPLE,
7439 ret = rte_eth_dev_filter_ctrl(res->port_id,
7440 RTE_ETH_FILTER_NTUPLE,
7441 RTE_ETH_FILTER_DELETE,
7444 printf("2tuple filter programming error: (%s)\n",
7449 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7450 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7451 filter, "2tuple_filter");
7452 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7453 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7455 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7456 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7458 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7459 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7460 dst_port, "dst_port");
7461 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7462 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7463 dst_port_value, UINT16);
7464 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7465 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7466 protocol, "protocol");
7467 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7468 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7469 protocol_value, UINT8);
7470 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7471 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7473 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7474 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7476 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7477 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7478 tcp_flags, "tcp_flags");
7479 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7480 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7481 tcp_flags_value, UINT8);
7482 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7483 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7484 priority, "priority");
7485 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7486 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7487 priority_value, UINT8);
7488 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7489 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7491 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7492 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7495 cmdline_parse_inst_t cmd_2tuple_filter = {
7496 .f = cmd_2tuple_filter_parsed,
7498 .help_str = "add a 2tuple filter",
7500 (void *)&cmd_2tuple_filter_filter,
7501 (void *)&cmd_2tuple_filter_port_id,
7502 (void *)&cmd_2tuple_filter_ops,
7503 (void *)&cmd_2tuple_filter_dst_port,
7504 (void *)&cmd_2tuple_filter_dst_port_value,
7505 (void *)&cmd_2tuple_filter_protocol,
7506 (void *)&cmd_2tuple_filter_protocol_value,
7507 (void *)&cmd_2tuple_filter_mask,
7508 (void *)&cmd_2tuple_filter_mask_value,
7509 (void *)&cmd_2tuple_filter_tcp_flags,
7510 (void *)&cmd_2tuple_filter_tcp_flags_value,
7511 (void *)&cmd_2tuple_filter_priority,
7512 (void *)&cmd_2tuple_filter_priority_value,
7513 (void *)&cmd_2tuple_filter_queue,
7514 (void *)&cmd_2tuple_filter_queue_id,
7519 /* *** ADD/REMOVE A 5tuple FILTER *** */
7520 struct cmd_5tuple_filter_result {
7521 cmdline_fixed_string_t filter;
7523 cmdline_fixed_string_t ops;
7524 cmdline_fixed_string_t dst_ip;
7525 cmdline_ipaddr_t dst_ip_value;
7526 cmdline_fixed_string_t src_ip;
7527 cmdline_ipaddr_t src_ip_value;
7528 cmdline_fixed_string_t dst_port;
7529 uint16_t dst_port_value;
7530 cmdline_fixed_string_t src_port;
7531 uint16_t src_port_value;
7532 cmdline_fixed_string_t protocol;
7533 uint8_t protocol_value;
7534 cmdline_fixed_string_t mask;
7536 cmdline_fixed_string_t tcp_flags;
7537 uint8_t tcp_flags_value;
7538 cmdline_fixed_string_t priority;
7539 uint8_t priority_value;
7540 cmdline_fixed_string_t queue;
7545 cmd_5tuple_filter_parsed(void *parsed_result,
7546 __attribute__((unused)) struct cmdline *cl,
7547 __attribute__((unused)) void *data)
7549 struct rte_eth_ntuple_filter filter;
7550 struct cmd_5tuple_filter_result *res = parsed_result;
7553 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7555 printf("ntuple filter is not supported on port %u.\n",
7560 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7562 filter.flags = RTE_5TUPLE_FLAGS;
7563 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7564 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7565 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7566 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7567 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7568 filter.proto = res->protocol_value;
7569 filter.priority = res->priority_value;
7570 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7571 printf("nonzero tcp_flags is only meaningful"
7572 " when protocol is TCP.\n");
7575 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7576 printf("invalid TCP flags.\n");
7580 if (res->tcp_flags_value != 0) {
7581 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7582 filter.tcp_flags = res->tcp_flags_value;
7585 if (res->dst_ip_value.family == AF_INET)
7586 /* no need to convert, already big endian. */
7587 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7589 if (filter.dst_ip_mask == 0) {
7590 printf("can not support ipv6 involved compare.\n");
7596 if (res->src_ip_value.family == AF_INET)
7597 /* no need to convert, already big endian. */
7598 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7600 if (filter.src_ip_mask == 0) {
7601 printf("can not support ipv6 involved compare.\n");
7606 /* need convert to big endian. */
7607 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7608 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7609 filter.queue = res->queue_id;
7611 if (!strcmp(res->ops, "add"))
7612 ret = rte_eth_dev_filter_ctrl(res->port_id,
7613 RTE_ETH_FILTER_NTUPLE,
7617 ret = rte_eth_dev_filter_ctrl(res->port_id,
7618 RTE_ETH_FILTER_NTUPLE,
7619 RTE_ETH_FILTER_DELETE,
7622 printf("5tuple filter programming error: (%s)\n",
7626 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7627 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7628 filter, "5tuple_filter");
7629 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7630 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7632 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7633 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7635 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7636 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7638 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7639 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7641 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7642 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7644 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7645 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7647 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7648 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7649 dst_port, "dst_port");
7650 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7651 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7652 dst_port_value, UINT16);
7653 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7654 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7655 src_port, "src_port");
7656 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7657 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7658 src_port_value, UINT16);
7659 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7660 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7661 protocol, "protocol");
7662 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7663 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7664 protocol_value, UINT8);
7665 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7666 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7668 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7669 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7671 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7672 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7673 tcp_flags, "tcp_flags");
7674 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7675 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7676 tcp_flags_value, UINT8);
7677 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7678 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7679 priority, "priority");
7680 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7681 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7682 priority_value, UINT8);
7683 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7684 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7686 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7687 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7690 cmdline_parse_inst_t cmd_5tuple_filter = {
7691 .f = cmd_5tuple_filter_parsed,
7693 .help_str = "add/del a 5tuple filter",
7695 (void *)&cmd_5tuple_filter_filter,
7696 (void *)&cmd_5tuple_filter_port_id,
7697 (void *)&cmd_5tuple_filter_ops,
7698 (void *)&cmd_5tuple_filter_dst_ip,
7699 (void *)&cmd_5tuple_filter_dst_ip_value,
7700 (void *)&cmd_5tuple_filter_src_ip,
7701 (void *)&cmd_5tuple_filter_src_ip_value,
7702 (void *)&cmd_5tuple_filter_dst_port,
7703 (void *)&cmd_5tuple_filter_dst_port_value,
7704 (void *)&cmd_5tuple_filter_src_port,
7705 (void *)&cmd_5tuple_filter_src_port_value,
7706 (void *)&cmd_5tuple_filter_protocol,
7707 (void *)&cmd_5tuple_filter_protocol_value,
7708 (void *)&cmd_5tuple_filter_mask,
7709 (void *)&cmd_5tuple_filter_mask_value,
7710 (void *)&cmd_5tuple_filter_tcp_flags,
7711 (void *)&cmd_5tuple_filter_tcp_flags_value,
7712 (void *)&cmd_5tuple_filter_priority,
7713 (void *)&cmd_5tuple_filter_priority_value,
7714 (void *)&cmd_5tuple_filter_queue,
7715 (void *)&cmd_5tuple_filter_queue_id,
7720 /* *** ADD/REMOVE A flex FILTER *** */
7721 struct cmd_flex_filter_result {
7722 cmdline_fixed_string_t filter;
7723 cmdline_fixed_string_t ops;
7725 cmdline_fixed_string_t len;
7727 cmdline_fixed_string_t bytes;
7728 cmdline_fixed_string_t bytes_value;
7729 cmdline_fixed_string_t mask;
7730 cmdline_fixed_string_t mask_value;
7731 cmdline_fixed_string_t priority;
7732 uint8_t priority_value;
7733 cmdline_fixed_string_t queue;
7737 static int xdigit2val(unsigned char c)
7742 else if (isupper(c))
7750 cmd_flex_filter_parsed(void *parsed_result,
7751 __attribute__((unused)) struct cmdline *cl,
7752 __attribute__((unused)) void *data)
7755 struct rte_eth_flex_filter filter;
7756 struct cmd_flex_filter_result *res = parsed_result;
7757 char *bytes_ptr, *mask_ptr;
7758 uint16_t len, i, j = 0;
7763 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7764 printf("the len exceed the max length 128\n");
7767 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7768 filter.len = res->len_value;
7769 filter.priority = res->priority_value;
7770 filter.queue = res->queue_id;
7771 bytes_ptr = res->bytes_value;
7772 mask_ptr = res->mask_value;
7774 /* translate bytes string to array. */
7775 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7776 (bytes_ptr[1] == 'X')))
7778 len = strnlen(bytes_ptr, res->len_value * 2);
7779 if (len == 0 || (len % 8 != 0)) {
7780 printf("please check len and bytes input\n");
7783 for (i = 0; i < len; i++) {
7785 if (isxdigit(c) == 0) {
7786 /* invalid characters. */
7787 printf("invalid input\n");
7790 val = xdigit2val(c);
7793 filter.bytes[j] = byte;
7794 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7801 /* translate mask string to uint8_t array. */
7802 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7803 (mask_ptr[1] == 'X')))
7805 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7807 printf("invalid input\n");
7812 for (i = 0; i < len; i++) {
7814 if (isxdigit(c) == 0) {
7815 /* invalid characters. */
7816 printf("invalid input\n");
7819 val = xdigit2val(c);
7822 filter.mask[j] = byte;
7823 printf("mask[%d]:%02x ", j, filter.mask[j]);
7831 if (!strcmp(res->ops, "add"))
7832 ret = rte_eth_dev_filter_ctrl(res->port_id,
7833 RTE_ETH_FILTER_FLEXIBLE,
7837 ret = rte_eth_dev_filter_ctrl(res->port_id,
7838 RTE_ETH_FILTER_FLEXIBLE,
7839 RTE_ETH_FILTER_DELETE,
7843 printf("flex filter setting error: (%s)\n", strerror(-ret));
7846 cmdline_parse_token_string_t cmd_flex_filter_filter =
7847 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7848 filter, "flex_filter");
7849 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7850 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7852 cmdline_parse_token_string_t cmd_flex_filter_ops =
7853 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7855 cmdline_parse_token_string_t cmd_flex_filter_len =
7856 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7858 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7859 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7861 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7862 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7864 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7865 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7867 cmdline_parse_token_string_t cmd_flex_filter_mask =
7868 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7870 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7871 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7873 cmdline_parse_token_string_t cmd_flex_filter_priority =
7874 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7875 priority, "priority");
7876 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7877 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7878 priority_value, UINT8);
7879 cmdline_parse_token_string_t cmd_flex_filter_queue =
7880 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7882 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7883 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7885 cmdline_parse_inst_t cmd_flex_filter = {
7886 .f = cmd_flex_filter_parsed,
7888 .help_str = "add/del a flex filter",
7890 (void *)&cmd_flex_filter_filter,
7891 (void *)&cmd_flex_filter_port_id,
7892 (void *)&cmd_flex_filter_ops,
7893 (void *)&cmd_flex_filter_len,
7894 (void *)&cmd_flex_filter_len_value,
7895 (void *)&cmd_flex_filter_bytes,
7896 (void *)&cmd_flex_filter_bytes_value,
7897 (void *)&cmd_flex_filter_mask,
7898 (void *)&cmd_flex_filter_mask_value,
7899 (void *)&cmd_flex_filter_priority,
7900 (void *)&cmd_flex_filter_priority_value,
7901 (void *)&cmd_flex_filter_queue,
7902 (void *)&cmd_flex_filter_queue_id,
7907 /* *** Filters Control *** */
7909 /* *** deal with ethertype filter *** */
7910 struct cmd_ethertype_filter_result {
7911 cmdline_fixed_string_t filter;
7913 cmdline_fixed_string_t ops;
7914 cmdline_fixed_string_t mac;
7915 struct ether_addr mac_addr;
7916 cmdline_fixed_string_t ethertype;
7917 uint16_t ethertype_value;
7918 cmdline_fixed_string_t drop;
7919 cmdline_fixed_string_t queue;
7923 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7924 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7925 filter, "ethertype_filter");
7926 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7927 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7929 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7930 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7932 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7933 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7934 mac, "mac_addr#mac_ignr");
7935 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7936 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7938 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7939 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7940 ethertype, "ethertype");
7941 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7942 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7943 ethertype_value, UINT16);
7944 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7945 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7947 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7948 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7950 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7951 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7955 cmd_ethertype_filter_parsed(void *parsed_result,
7956 __attribute__((unused)) struct cmdline *cl,
7957 __attribute__((unused)) void *data)
7959 struct cmd_ethertype_filter_result *res = parsed_result;
7960 struct rte_eth_ethertype_filter filter;
7963 ret = rte_eth_dev_filter_supported(res->port_id,
7964 RTE_ETH_FILTER_ETHERTYPE);
7966 printf("ethertype filter is not supported on port %u.\n",
7971 memset(&filter, 0, sizeof(filter));
7972 if (!strcmp(res->mac, "mac_addr")) {
7973 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7974 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7975 sizeof(struct ether_addr));
7977 if (!strcmp(res->drop, "drop"))
7978 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7979 filter.ether_type = res->ethertype_value;
7980 filter.queue = res->queue_id;
7982 if (!strcmp(res->ops, "add"))
7983 ret = rte_eth_dev_filter_ctrl(res->port_id,
7984 RTE_ETH_FILTER_ETHERTYPE,
7988 ret = rte_eth_dev_filter_ctrl(res->port_id,
7989 RTE_ETH_FILTER_ETHERTYPE,
7990 RTE_ETH_FILTER_DELETE,
7993 printf("ethertype filter programming error: (%s)\n",
7997 cmdline_parse_inst_t cmd_ethertype_filter = {
7998 .f = cmd_ethertype_filter_parsed,
8000 .help_str = "add or delete an ethertype filter entry",
8002 (void *)&cmd_ethertype_filter_filter,
8003 (void *)&cmd_ethertype_filter_port_id,
8004 (void *)&cmd_ethertype_filter_ops,
8005 (void *)&cmd_ethertype_filter_mac,
8006 (void *)&cmd_ethertype_filter_mac_addr,
8007 (void *)&cmd_ethertype_filter_ethertype,
8008 (void *)&cmd_ethertype_filter_ethertype_value,
8009 (void *)&cmd_ethertype_filter_drop,
8010 (void *)&cmd_ethertype_filter_queue,
8011 (void *)&cmd_ethertype_filter_queue_id,
8016 /* *** deal with flow director filter *** */
8017 struct cmd_flow_director_result {
8018 cmdline_fixed_string_t flow_director_filter;
8020 cmdline_fixed_string_t mode;
8021 cmdline_fixed_string_t mode_value;
8022 cmdline_fixed_string_t ops;
8023 cmdline_fixed_string_t flow;
8024 cmdline_fixed_string_t flow_type;
8025 cmdline_fixed_string_t ether;
8026 uint16_t ether_type;
8027 cmdline_fixed_string_t src;
8028 cmdline_ipaddr_t ip_src;
8030 cmdline_fixed_string_t dst;
8031 cmdline_ipaddr_t ip_dst;
8033 cmdline_fixed_string_t verify_tag;
8034 uint32_t verify_tag_value;
8035 cmdline_ipaddr_t tos;
8037 cmdline_ipaddr_t proto;
8038 uint8_t proto_value;
8039 cmdline_ipaddr_t ttl;
8041 cmdline_fixed_string_t vlan;
8042 uint16_t vlan_value;
8043 cmdline_fixed_string_t flexbytes;
8044 cmdline_fixed_string_t flexbytes_value;
8045 cmdline_fixed_string_t pf_vf;
8046 cmdline_fixed_string_t drop;
8047 cmdline_fixed_string_t queue;
8049 cmdline_fixed_string_t fd_id;
8050 uint32_t fd_id_value;
8051 cmdline_fixed_string_t mac;
8052 struct ether_addr mac_addr;
8053 cmdline_fixed_string_t tunnel;
8054 cmdline_fixed_string_t tunnel_type;
8055 cmdline_fixed_string_t tunnel_id;
8056 uint32_t tunnel_id_value;
8060 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8063 const char *p, *p0 = q_arg;
8065 unsigned long int_fld;
8066 char *str_fld[max_num];
8071 p = strchr(p0, '(');
8075 p0 = strchr(p, ')');
8080 if (size >= sizeof(s))
8083 snprintf(s, sizeof(s), "%.*s", size, p);
8084 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8085 if (ret < 0 || ret > max_num)
8087 for (i = 0; i < ret; i++) {
8089 int_fld = strtoul(str_fld[i], &end, 0);
8090 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8092 flexbytes[i] = (uint8_t)int_fld;
8098 str2flowtype(char *string)
8101 static const struct {
8104 } flowtype_str[] = {
8105 {"raw", RTE_ETH_FLOW_RAW},
8106 {"ipv4", RTE_ETH_FLOW_IPV4},
8107 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8108 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8109 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8110 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8111 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8112 {"ipv6", RTE_ETH_FLOW_IPV6},
8113 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8114 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8115 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8116 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8117 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8118 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8121 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8122 if (!strcmp(flowtype_str[i].str, string))
8123 return flowtype_str[i].type;
8125 return RTE_ETH_FLOW_UNKNOWN;
8128 static enum rte_eth_fdir_tunnel_type
8129 str2fdir_tunneltype(char *string)
8133 static const struct {
8135 enum rte_eth_fdir_tunnel_type type;
8136 } tunneltype_str[] = {
8137 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8138 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8141 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8142 if (!strcmp(tunneltype_str[i].str, string))
8143 return tunneltype_str[i].type;
8145 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8148 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8150 if ((ip_addr).family == AF_INET) \
8151 (ip) = (ip_addr).addr.ipv4.s_addr; \
8153 printf("invalid parameter.\n"); \
8158 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8160 if ((ip_addr).family == AF_INET6) \
8161 (void)rte_memcpy(&(ip), \
8162 &((ip_addr).addr.ipv6), \
8163 sizeof(struct in6_addr)); \
8165 printf("invalid parameter.\n"); \
8171 cmd_flow_director_filter_parsed(void *parsed_result,
8172 __attribute__((unused)) struct cmdline *cl,
8173 __attribute__((unused)) void *data)
8175 struct cmd_flow_director_result *res = parsed_result;
8176 struct rte_eth_fdir_filter entry;
8177 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8179 unsigned long vf_id;
8182 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8184 printf("flow director is not supported on port %u.\n",
8188 memset(flexbytes, 0, sizeof(flexbytes));
8189 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8191 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8192 if (strcmp(res->mode_value, "MAC-VLAN")) {
8193 printf("Please set mode to MAC-VLAN.\n");
8196 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8197 if (strcmp(res->mode_value, "Tunnel")) {
8198 printf("Please set mode to Tunnel.\n");
8202 if (strcmp(res->mode_value, "IP")) {
8203 printf("Please set mode to IP.\n");
8206 entry.input.flow_type = str2flowtype(res->flow_type);
8209 ret = parse_flexbytes(res->flexbytes_value,
8211 RTE_ETH_FDIR_MAX_FLEXLEN);
8213 printf("error: Cannot parse flexbytes input.\n");
8217 switch (entry.input.flow_type) {
8218 case RTE_ETH_FLOW_FRAG_IPV4:
8219 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8220 entry.input.flow.ip4_flow.proto = res->proto_value;
8221 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8222 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8223 IPV4_ADDR_TO_UINT(res->ip_dst,
8224 entry.input.flow.ip4_flow.dst_ip);
8225 IPV4_ADDR_TO_UINT(res->ip_src,
8226 entry.input.flow.ip4_flow.src_ip);
8227 entry.input.flow.ip4_flow.tos = res->tos_value;
8228 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8229 /* need convert to big endian. */
8230 entry.input.flow.udp4_flow.dst_port =
8231 rte_cpu_to_be_16(res->port_dst);
8232 entry.input.flow.udp4_flow.src_port =
8233 rte_cpu_to_be_16(res->port_src);
8235 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8236 IPV4_ADDR_TO_UINT(res->ip_dst,
8237 entry.input.flow.sctp4_flow.ip.dst_ip);
8238 IPV4_ADDR_TO_UINT(res->ip_src,
8239 entry.input.flow.sctp4_flow.ip.src_ip);
8240 entry.input.flow.ip4_flow.tos = res->tos_value;
8241 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8242 /* need convert to big endian. */
8243 entry.input.flow.sctp4_flow.dst_port =
8244 rte_cpu_to_be_16(res->port_dst);
8245 entry.input.flow.sctp4_flow.src_port =
8246 rte_cpu_to_be_16(res->port_src);
8247 entry.input.flow.sctp4_flow.verify_tag =
8248 rte_cpu_to_be_32(res->verify_tag_value);
8250 case RTE_ETH_FLOW_FRAG_IPV6:
8251 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8252 entry.input.flow.ipv6_flow.proto = res->proto_value;
8253 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8254 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8255 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8256 entry.input.flow.ipv6_flow.dst_ip);
8257 IPV6_ADDR_TO_ARRAY(res->ip_src,
8258 entry.input.flow.ipv6_flow.src_ip);
8259 entry.input.flow.ipv6_flow.tc = res->tos_value;
8260 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8261 /* need convert to big endian. */
8262 entry.input.flow.udp6_flow.dst_port =
8263 rte_cpu_to_be_16(res->port_dst);
8264 entry.input.flow.udp6_flow.src_port =
8265 rte_cpu_to_be_16(res->port_src);
8267 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8268 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8269 entry.input.flow.sctp6_flow.ip.dst_ip);
8270 IPV6_ADDR_TO_ARRAY(res->ip_src,
8271 entry.input.flow.sctp6_flow.ip.src_ip);
8272 entry.input.flow.ipv6_flow.tc = res->tos_value;
8273 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8274 /* need convert to big endian. */
8275 entry.input.flow.sctp6_flow.dst_port =
8276 rte_cpu_to_be_16(res->port_dst);
8277 entry.input.flow.sctp6_flow.src_port =
8278 rte_cpu_to_be_16(res->port_src);
8279 entry.input.flow.sctp6_flow.verify_tag =
8280 rte_cpu_to_be_32(res->verify_tag_value);
8282 case RTE_ETH_FLOW_L2_PAYLOAD:
8283 entry.input.flow.l2_flow.ether_type =
8284 rte_cpu_to_be_16(res->ether_type);
8290 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8291 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8293 sizeof(struct ether_addr));
8295 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8296 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8298 sizeof(struct ether_addr));
8299 entry.input.flow.tunnel_flow.tunnel_type =
8300 str2fdir_tunneltype(res->tunnel_type);
8301 entry.input.flow.tunnel_flow.tunnel_id =
8302 rte_cpu_to_be_32(res->tunnel_id_value);
8305 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8307 RTE_ETH_FDIR_MAX_FLEXLEN);
8309 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8311 entry.action.flex_off = 0; /*use 0 by default */
8312 if (!strcmp(res->drop, "drop"))
8313 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8315 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8317 if (!strcmp(res->pf_vf, "pf"))
8318 entry.input.flow_ext.is_vf = 0;
8319 else if (!strncmp(res->pf_vf, "vf", 2)) {
8320 struct rte_eth_dev_info dev_info;
8322 memset(&dev_info, 0, sizeof(dev_info));
8323 rte_eth_dev_info_get(res->port_id, &dev_info);
8325 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8326 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8327 printf("invalid parameter %s.\n", res->pf_vf);
8330 entry.input.flow_ext.is_vf = 1;
8331 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8333 printf("invalid parameter %s.\n", res->pf_vf);
8337 /* set to report FD ID by default */
8338 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8339 entry.action.rx_queue = res->queue_id;
8340 entry.soft_id = res->fd_id_value;
8341 if (!strcmp(res->ops, "add"))
8342 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8343 RTE_ETH_FILTER_ADD, &entry);
8344 else if (!strcmp(res->ops, "del"))
8345 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8346 RTE_ETH_FILTER_DELETE, &entry);
8348 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8349 RTE_ETH_FILTER_UPDATE, &entry);
8351 printf("flow director programming error: (%s)\n",
8355 cmdline_parse_token_string_t cmd_flow_director_filter =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8357 flow_director_filter, "flow_director_filter");
8358 cmdline_parse_token_num_t cmd_flow_director_port_id =
8359 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8361 cmdline_parse_token_string_t cmd_flow_director_ops =
8362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8363 ops, "add#del#update");
8364 cmdline_parse_token_string_t cmd_flow_director_flow =
8365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8367 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8369 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8370 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8371 cmdline_parse_token_string_t cmd_flow_director_ether =
8372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8374 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8376 ether_type, UINT16);
8377 cmdline_parse_token_string_t cmd_flow_director_src =
8378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8380 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8381 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8383 cmdline_parse_token_num_t cmd_flow_director_port_src =
8384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8386 cmdline_parse_token_string_t cmd_flow_director_dst =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8389 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8390 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8392 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8395 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8397 verify_tag, "verify_tag");
8398 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8399 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8400 verify_tag_value, UINT32);
8401 cmdline_parse_token_string_t cmd_flow_director_tos =
8402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8404 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8405 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8407 cmdline_parse_token_string_t cmd_flow_director_proto =
8408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8410 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8411 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8412 proto_value, UINT8);
8413 cmdline_parse_token_string_t cmd_flow_director_ttl =
8414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8416 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8417 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8419 cmdline_parse_token_string_t cmd_flow_director_vlan =
8420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8422 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8423 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8424 vlan_value, UINT16);
8425 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8427 flexbytes, "flexbytes");
8428 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8430 flexbytes_value, NULL);
8431 cmdline_parse_token_string_t cmd_flow_director_drop =
8432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8434 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8437 cmdline_parse_token_string_t cmd_flow_director_queue =
8438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8440 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8441 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8443 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8444 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8446 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8447 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8448 fd_id_value, UINT32);
8450 cmdline_parse_token_string_t cmd_flow_director_mode =
8451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8453 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8456 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8458 mode_value, "MAC-VLAN");
8459 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8461 mode_value, "Tunnel");
8462 cmdline_parse_token_string_t cmd_flow_director_mac =
8463 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8465 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8466 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8468 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8471 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8473 tunnel_type, "NVGRE#VxLAN");
8474 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8476 tunnel_id, "tunnel-id");
8477 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8478 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8479 tunnel_id_value, UINT32);
8481 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8482 .f = cmd_flow_director_filter_parsed,
8484 .help_str = "add or delete an ip flow director entry on NIC",
8486 (void *)&cmd_flow_director_filter,
8487 (void *)&cmd_flow_director_port_id,
8488 (void *)&cmd_flow_director_mode,
8489 (void *)&cmd_flow_director_mode_ip,
8490 (void *)&cmd_flow_director_ops,
8491 (void *)&cmd_flow_director_flow,
8492 (void *)&cmd_flow_director_flow_type,
8493 (void *)&cmd_flow_director_src,
8494 (void *)&cmd_flow_director_ip_src,
8495 (void *)&cmd_flow_director_dst,
8496 (void *)&cmd_flow_director_ip_dst,
8497 (void *)&cmd_flow_director_tos,
8498 (void *)&cmd_flow_director_tos_value,
8499 (void *)&cmd_flow_director_proto,
8500 (void *)&cmd_flow_director_proto_value,
8501 (void *)&cmd_flow_director_ttl,
8502 (void *)&cmd_flow_director_ttl_value,
8503 (void *)&cmd_flow_director_vlan,
8504 (void *)&cmd_flow_director_vlan_value,
8505 (void *)&cmd_flow_director_flexbytes,
8506 (void *)&cmd_flow_director_flexbytes_value,
8507 (void *)&cmd_flow_director_drop,
8508 (void *)&cmd_flow_director_pf_vf,
8509 (void *)&cmd_flow_director_queue,
8510 (void *)&cmd_flow_director_queue_id,
8511 (void *)&cmd_flow_director_fd_id,
8512 (void *)&cmd_flow_director_fd_id_value,
8517 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8518 .f = cmd_flow_director_filter_parsed,
8520 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8522 (void *)&cmd_flow_director_filter,
8523 (void *)&cmd_flow_director_port_id,
8524 (void *)&cmd_flow_director_mode,
8525 (void *)&cmd_flow_director_mode_ip,
8526 (void *)&cmd_flow_director_ops,
8527 (void *)&cmd_flow_director_flow,
8528 (void *)&cmd_flow_director_flow_type,
8529 (void *)&cmd_flow_director_src,
8530 (void *)&cmd_flow_director_ip_src,
8531 (void *)&cmd_flow_director_port_src,
8532 (void *)&cmd_flow_director_dst,
8533 (void *)&cmd_flow_director_ip_dst,
8534 (void *)&cmd_flow_director_port_dst,
8535 (void *)&cmd_flow_director_tos,
8536 (void *)&cmd_flow_director_tos_value,
8537 (void *)&cmd_flow_director_ttl,
8538 (void *)&cmd_flow_director_ttl_value,
8539 (void *)&cmd_flow_director_vlan,
8540 (void *)&cmd_flow_director_vlan_value,
8541 (void *)&cmd_flow_director_flexbytes,
8542 (void *)&cmd_flow_director_flexbytes_value,
8543 (void *)&cmd_flow_director_drop,
8544 (void *)&cmd_flow_director_pf_vf,
8545 (void *)&cmd_flow_director_queue,
8546 (void *)&cmd_flow_director_queue_id,
8547 (void *)&cmd_flow_director_fd_id,
8548 (void *)&cmd_flow_director_fd_id_value,
8553 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8554 .f = cmd_flow_director_filter_parsed,
8556 .help_str = "add or delete a sctp flow director entry on NIC",
8558 (void *)&cmd_flow_director_filter,
8559 (void *)&cmd_flow_director_port_id,
8560 (void *)&cmd_flow_director_mode,
8561 (void *)&cmd_flow_director_mode_ip,
8562 (void *)&cmd_flow_director_ops,
8563 (void *)&cmd_flow_director_flow,
8564 (void *)&cmd_flow_director_flow_type,
8565 (void *)&cmd_flow_director_src,
8566 (void *)&cmd_flow_director_ip_src,
8567 (void *)&cmd_flow_director_port_dst,
8568 (void *)&cmd_flow_director_dst,
8569 (void *)&cmd_flow_director_ip_dst,
8570 (void *)&cmd_flow_director_port_dst,
8571 (void *)&cmd_flow_director_verify_tag,
8572 (void *)&cmd_flow_director_verify_tag_value,
8573 (void *)&cmd_flow_director_tos,
8574 (void *)&cmd_flow_director_tos_value,
8575 (void *)&cmd_flow_director_ttl,
8576 (void *)&cmd_flow_director_ttl_value,
8577 (void *)&cmd_flow_director_vlan,
8578 (void *)&cmd_flow_director_vlan_value,
8579 (void *)&cmd_flow_director_flexbytes,
8580 (void *)&cmd_flow_director_flexbytes_value,
8581 (void *)&cmd_flow_director_drop,
8582 (void *)&cmd_flow_director_pf_vf,
8583 (void *)&cmd_flow_director_queue,
8584 (void *)&cmd_flow_director_queue_id,
8585 (void *)&cmd_flow_director_fd_id,
8586 (void *)&cmd_flow_director_fd_id_value,
8591 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8592 .f = cmd_flow_director_filter_parsed,
8594 .help_str = "add or delete a L2 flow director entry on NIC",
8596 (void *)&cmd_flow_director_filter,
8597 (void *)&cmd_flow_director_port_id,
8598 (void *)&cmd_flow_director_mode,
8599 (void *)&cmd_flow_director_mode_ip,
8600 (void *)&cmd_flow_director_ops,
8601 (void *)&cmd_flow_director_flow,
8602 (void *)&cmd_flow_director_flow_type,
8603 (void *)&cmd_flow_director_ether,
8604 (void *)&cmd_flow_director_ether_type,
8605 (void *)&cmd_flow_director_flexbytes,
8606 (void *)&cmd_flow_director_flexbytes_value,
8607 (void *)&cmd_flow_director_drop,
8608 (void *)&cmd_flow_director_pf_vf,
8609 (void *)&cmd_flow_director_queue,
8610 (void *)&cmd_flow_director_queue_id,
8611 (void *)&cmd_flow_director_fd_id,
8612 (void *)&cmd_flow_director_fd_id_value,
8617 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8618 .f = cmd_flow_director_filter_parsed,
8620 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8622 (void *)&cmd_flow_director_filter,
8623 (void *)&cmd_flow_director_port_id,
8624 (void *)&cmd_flow_director_mode,
8625 (void *)&cmd_flow_director_mode_mac_vlan,
8626 (void *)&cmd_flow_director_ops,
8627 (void *)&cmd_flow_director_mac,
8628 (void *)&cmd_flow_director_mac_addr,
8629 (void *)&cmd_flow_director_vlan,
8630 (void *)&cmd_flow_director_vlan_value,
8631 (void *)&cmd_flow_director_flexbytes,
8632 (void *)&cmd_flow_director_flexbytes_value,
8633 (void *)&cmd_flow_director_drop,
8634 (void *)&cmd_flow_director_queue,
8635 (void *)&cmd_flow_director_queue_id,
8636 (void *)&cmd_flow_director_fd_id,
8637 (void *)&cmd_flow_director_fd_id_value,
8642 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8643 .f = cmd_flow_director_filter_parsed,
8645 .help_str = "add or delete a tunnel flow director entry on NIC",
8647 (void *)&cmd_flow_director_filter,
8648 (void *)&cmd_flow_director_port_id,
8649 (void *)&cmd_flow_director_mode,
8650 (void *)&cmd_flow_director_mode_tunnel,
8651 (void *)&cmd_flow_director_ops,
8652 (void *)&cmd_flow_director_mac,
8653 (void *)&cmd_flow_director_mac_addr,
8654 (void *)&cmd_flow_director_vlan,
8655 (void *)&cmd_flow_director_vlan_value,
8656 (void *)&cmd_flow_director_tunnel,
8657 (void *)&cmd_flow_director_tunnel_type,
8658 (void *)&cmd_flow_director_tunnel_id,
8659 (void *)&cmd_flow_director_tunnel_id_value,
8660 (void *)&cmd_flow_director_flexbytes,
8661 (void *)&cmd_flow_director_flexbytes_value,
8662 (void *)&cmd_flow_director_drop,
8663 (void *)&cmd_flow_director_queue,
8664 (void *)&cmd_flow_director_queue_id,
8665 (void *)&cmd_flow_director_fd_id,
8666 (void *)&cmd_flow_director_fd_id_value,
8671 struct cmd_flush_flow_director_result {
8672 cmdline_fixed_string_t flush_flow_director;
8676 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8677 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8678 flush_flow_director, "flush_flow_director");
8679 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8680 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8684 cmd_flush_flow_director_parsed(void *parsed_result,
8685 __attribute__((unused)) struct cmdline *cl,
8686 __attribute__((unused)) void *data)
8688 struct cmd_flow_director_result *res = parsed_result;
8691 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8693 printf("flow director is not supported on port %u.\n",
8698 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8699 RTE_ETH_FILTER_FLUSH, NULL);
8701 printf("flow director table flushing error: (%s)\n",
8705 cmdline_parse_inst_t cmd_flush_flow_director = {
8706 .f = cmd_flush_flow_director_parsed,
8708 .help_str = "flush all flow director entries of a device on NIC",
8710 (void *)&cmd_flush_flow_director_flush,
8711 (void *)&cmd_flush_flow_director_port_id,
8716 /* *** deal with flow director mask *** */
8717 struct cmd_flow_director_mask_result {
8718 cmdline_fixed_string_t flow_director_mask;
8720 cmdline_fixed_string_t mode;
8721 cmdline_fixed_string_t mode_value;
8722 cmdline_fixed_string_t vlan;
8724 cmdline_fixed_string_t src_mask;
8725 cmdline_ipaddr_t ipv4_src;
8726 cmdline_ipaddr_t ipv6_src;
8728 cmdline_fixed_string_t dst_mask;
8729 cmdline_ipaddr_t ipv4_dst;
8730 cmdline_ipaddr_t ipv6_dst;
8732 cmdline_fixed_string_t mac;
8733 uint8_t mac_addr_byte_mask;
8734 cmdline_fixed_string_t tunnel_id;
8735 uint32_t tunnel_id_mask;
8736 cmdline_fixed_string_t tunnel_type;
8737 uint8_t tunnel_type_mask;
8741 cmd_flow_director_mask_parsed(void *parsed_result,
8742 __attribute__((unused)) struct cmdline *cl,
8743 __attribute__((unused)) void *data)
8745 struct cmd_flow_director_mask_result *res = parsed_result;
8746 struct rte_eth_fdir_masks *mask;
8747 struct rte_port *port;
8749 if (res->port_id > nb_ports) {
8750 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8754 port = &ports[res->port_id];
8755 /** Check if the port is not started **/
8756 if (port->port_status != RTE_PORT_STOPPED) {
8757 printf("Please stop port %d first\n", res->port_id);
8761 mask = &port->dev_conf.fdir_conf.mask;
8763 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8764 if (strcmp(res->mode_value, "MAC-VLAN")) {
8765 printf("Please set mode to MAC-VLAN.\n");
8769 mask->vlan_tci_mask = res->vlan_mask;
8770 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8771 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8772 if (strcmp(res->mode_value, "Tunnel")) {
8773 printf("Please set mode to Tunnel.\n");
8777 mask->vlan_tci_mask = res->vlan_mask;
8778 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8779 mask->tunnel_id_mask = res->tunnel_id_mask;
8780 mask->tunnel_type_mask = res->tunnel_type_mask;
8782 if (strcmp(res->mode_value, "IP")) {
8783 printf("Please set mode to IP.\n");
8787 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8788 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8789 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8790 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8791 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8792 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8793 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8796 cmd_reconfig_device_queue(res->port_id, 1, 1);
8799 cmdline_parse_token_string_t cmd_flow_director_mask =
8800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8801 flow_director_mask, "flow_director_mask");
8802 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8803 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8805 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8808 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8809 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8811 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8813 src_mask, "src_mask");
8814 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8815 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8817 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8818 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8820 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8821 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8823 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8825 dst_mask, "dst_mask");
8826 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8827 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8829 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8830 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8832 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8833 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8836 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8839 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8842 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8844 mode_value, "MAC-VLAN");
8845 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8847 mode_value, "Tunnel");
8848 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8851 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8852 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8853 mac_addr_byte_mask, UINT8);
8854 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8856 tunnel_type, "tunnel-type");
8857 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8858 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8859 tunnel_type_mask, UINT8);
8860 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8862 tunnel_id, "tunnel-id");
8863 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8865 tunnel_id_mask, UINT32);
8867 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8868 .f = cmd_flow_director_mask_parsed,
8870 .help_str = "set IP mode flow director's mask on NIC",
8872 (void *)&cmd_flow_director_mask,
8873 (void *)&cmd_flow_director_mask_port_id,
8874 (void *)&cmd_flow_director_mask_mode,
8875 (void *)&cmd_flow_director_mask_mode_ip,
8876 (void *)&cmd_flow_director_mask_vlan,
8877 (void *)&cmd_flow_director_mask_vlan_value,
8878 (void *)&cmd_flow_director_mask_src,
8879 (void *)&cmd_flow_director_mask_ipv4_src,
8880 (void *)&cmd_flow_director_mask_ipv6_src,
8881 (void *)&cmd_flow_director_mask_port_src,
8882 (void *)&cmd_flow_director_mask_dst,
8883 (void *)&cmd_flow_director_mask_ipv4_dst,
8884 (void *)&cmd_flow_director_mask_ipv6_dst,
8885 (void *)&cmd_flow_director_mask_port_dst,
8890 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8891 .f = cmd_flow_director_mask_parsed,
8893 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8895 (void *)&cmd_flow_director_mask,
8896 (void *)&cmd_flow_director_mask_port_id,
8897 (void *)&cmd_flow_director_mask_mode,
8898 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8899 (void *)&cmd_flow_director_mask_vlan,
8900 (void *)&cmd_flow_director_mask_vlan_value,
8901 (void *)&cmd_flow_director_mask_mac,
8902 (void *)&cmd_flow_director_mask_mac_value,
8907 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8908 .f = cmd_flow_director_mask_parsed,
8910 .help_str = "set tunnel mode flow director's mask on NIC",
8912 (void *)&cmd_flow_director_mask,
8913 (void *)&cmd_flow_director_mask_port_id,
8914 (void *)&cmd_flow_director_mask_mode,
8915 (void *)&cmd_flow_director_mask_mode_tunnel,
8916 (void *)&cmd_flow_director_mask_vlan,
8917 (void *)&cmd_flow_director_mask_vlan_value,
8918 (void *)&cmd_flow_director_mask_mac,
8919 (void *)&cmd_flow_director_mask_mac_value,
8920 (void *)&cmd_flow_director_mask_tunnel_type,
8921 (void *)&cmd_flow_director_mask_tunnel_type_value,
8922 (void *)&cmd_flow_director_mask_tunnel_id,
8923 (void *)&cmd_flow_director_mask_tunnel_id_value,
8928 /* *** deal with flow director mask on flexible payload *** */
8929 struct cmd_flow_director_flex_mask_result {
8930 cmdline_fixed_string_t flow_director_flexmask;
8932 cmdline_fixed_string_t flow;
8933 cmdline_fixed_string_t flow_type;
8934 cmdline_fixed_string_t mask;
8938 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8939 __attribute__((unused)) struct cmdline *cl,
8940 __attribute__((unused)) void *data)
8942 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8943 struct rte_eth_fdir_info fdir_info;
8944 struct rte_eth_fdir_flex_mask flex_mask;
8945 struct rte_port *port;
8946 uint32_t flow_type_mask;
8950 if (res->port_id > nb_ports) {
8951 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8955 port = &ports[res->port_id];
8956 /** Check if the port is not started **/
8957 if (port->port_status != RTE_PORT_STOPPED) {
8958 printf("Please stop port %d first\n", res->port_id);
8962 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8963 ret = parse_flexbytes(res->mask,
8965 RTE_ETH_FDIR_MAX_FLEXLEN);
8967 printf("error: Cannot parse mask input.\n");
8971 memset(&fdir_info, 0, sizeof(fdir_info));
8972 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8973 RTE_ETH_FILTER_INFO, &fdir_info);
8975 printf("Cannot get FDir filter info\n");
8979 if (!strcmp(res->flow_type, "none")) {
8980 /* means don't specify the flow type */
8981 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8982 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8983 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8984 0, sizeof(struct rte_eth_fdir_flex_mask));
8985 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8986 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8988 sizeof(struct rte_eth_fdir_flex_mask));
8989 cmd_reconfig_device_queue(res->port_id, 1, 1);
8992 flow_type_mask = fdir_info.flow_types_mask[0];
8993 if (!strcmp(res->flow_type, "all")) {
8994 if (!flow_type_mask) {
8995 printf("No flow type supported\n");
8998 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8999 if (flow_type_mask & (1 << i)) {
9000 flex_mask.flow_type = i;
9001 fdir_set_flex_mask(res->port_id, &flex_mask);
9004 cmd_reconfig_device_queue(res->port_id, 1, 1);
9007 flex_mask.flow_type = str2flowtype(res->flow_type);
9008 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9009 printf("Flow type %s not supported on port %d\n",
9010 res->flow_type, res->port_id);
9013 fdir_set_flex_mask(res->port_id, &flex_mask);
9014 cmd_reconfig_device_queue(res->port_id, 1, 1);
9017 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9018 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9019 flow_director_flexmask,
9020 "flow_director_flex_mask");
9021 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9022 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9024 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9027 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9029 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9030 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9031 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9035 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9036 .f = cmd_flow_director_flex_mask_parsed,
9038 .help_str = "set flow director's flex mask on NIC",
9040 (void *)&cmd_flow_director_flexmask,
9041 (void *)&cmd_flow_director_flexmask_port_id,
9042 (void *)&cmd_flow_director_flexmask_flow,
9043 (void *)&cmd_flow_director_flexmask_flow_type,
9044 (void *)&cmd_flow_director_flexmask_mask,
9049 /* *** deal with flow director flexible payload configuration *** */
9050 struct cmd_flow_director_flexpayload_result {
9051 cmdline_fixed_string_t flow_director_flexpayload;
9053 cmdline_fixed_string_t payload_layer;
9054 cmdline_fixed_string_t payload_cfg;
9058 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9061 const char *p, *p0 = q_arg;
9063 unsigned long int_fld;
9064 char *str_fld[max_num];
9069 p = strchr(p0, '(');
9073 p0 = strchr(p, ')');
9078 if (size >= sizeof(s))
9081 snprintf(s, sizeof(s), "%.*s", size, p);
9082 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9083 if (ret < 0 || ret > max_num)
9085 for (i = 0; i < ret; i++) {
9087 int_fld = strtoul(str_fld[i], &end, 0);
9088 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9090 offsets[i] = (uint16_t)int_fld;
9096 cmd_flow_director_flxpld_parsed(void *parsed_result,
9097 __attribute__((unused)) struct cmdline *cl,
9098 __attribute__((unused)) void *data)
9100 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9101 struct rte_eth_flex_payload_cfg flex_cfg;
9102 struct rte_port *port;
9105 if (res->port_id > nb_ports) {
9106 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9110 port = &ports[res->port_id];
9111 /** Check if the port is not started **/
9112 if (port->port_status != RTE_PORT_STOPPED) {
9113 printf("Please stop port %d first\n", res->port_id);
9117 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9119 if (!strcmp(res->payload_layer, "raw"))
9120 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9121 else if (!strcmp(res->payload_layer, "l2"))
9122 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9123 else if (!strcmp(res->payload_layer, "l3"))
9124 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9125 else if (!strcmp(res->payload_layer, "l4"))
9126 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9128 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9129 RTE_ETH_FDIR_MAX_FLEXLEN);
9131 printf("error: Cannot parse flex payload input.\n");
9135 fdir_set_flex_payload(res->port_id, &flex_cfg);
9136 cmd_reconfig_device_queue(res->port_id, 1, 1);
9139 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9141 flow_director_flexpayload,
9142 "flow_director_flex_payload");
9143 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9144 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9146 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9148 payload_layer, "raw#l2#l3#l4");
9149 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9153 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9154 .f = cmd_flow_director_flxpld_parsed,
9156 .help_str = "set flow director's flex payload on NIC",
9158 (void *)&cmd_flow_director_flexpayload,
9159 (void *)&cmd_flow_director_flexpayload_port_id,
9160 (void *)&cmd_flow_director_flexpayload_payload_layer,
9161 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9166 /* *** Classification Filters Control *** */
9167 /* *** Get symmetric hash enable per port *** */
9168 struct cmd_get_sym_hash_ena_per_port_result {
9169 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9174 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9175 __rte_unused struct cmdline *cl,
9176 __rte_unused void *data)
9178 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9179 struct rte_eth_hash_filter_info info;
9182 if (rte_eth_dev_filter_supported(res->port_id,
9183 RTE_ETH_FILTER_HASH) < 0) {
9184 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9189 memset(&info, 0, sizeof(info));
9190 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9191 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9192 RTE_ETH_FILTER_GET, &info);
9195 printf("Cannot get symmetric hash enable per port "
9196 "on port %u\n", res->port_id);
9200 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9201 "enabled" : "disabled", res->port_id);
9204 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9205 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9206 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9207 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9208 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9211 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9212 .f = cmd_get_sym_hash_per_port_parsed,
9214 .help_str = "get_sym_hash_ena_per_port port_id",
9216 (void *)&cmd_get_sym_hash_ena_per_port_all,
9217 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9222 /* *** Set symmetric hash enable per port *** */
9223 struct cmd_set_sym_hash_ena_per_port_result {
9224 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9225 cmdline_fixed_string_t enable;
9230 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9231 __rte_unused struct cmdline *cl,
9232 __rte_unused void *data)
9234 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9235 struct rte_eth_hash_filter_info info;
9238 if (rte_eth_dev_filter_supported(res->port_id,
9239 RTE_ETH_FILTER_HASH) < 0) {
9240 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9245 memset(&info, 0, sizeof(info));
9246 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9247 if (!strcmp(res->enable, "enable"))
9248 info.info.enable = 1;
9249 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9250 RTE_ETH_FILTER_SET, &info);
9252 printf("Cannot set symmetric hash enable per port on "
9253 "port %u\n", res->port_id);
9256 printf("Symmetric hash has been set to %s on port %u\n",
9257 res->enable, res->port_id);
9260 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9261 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9262 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9263 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9264 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9266 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9267 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9268 enable, "enable#disable");
9270 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9271 .f = cmd_set_sym_hash_per_port_parsed,
9273 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9275 (void *)&cmd_set_sym_hash_ena_per_port_all,
9276 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9277 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9282 /* Get global config of hash function */
9283 struct cmd_get_hash_global_config_result {
9284 cmdline_fixed_string_t get_hash_global_config;
9289 flowtype_to_str(uint16_t ftype)
9296 {"ipv4", RTE_ETH_FLOW_IPV4},
9297 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9298 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9299 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9300 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9301 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9302 {"ipv6", RTE_ETH_FLOW_IPV6},
9303 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9304 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9305 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9306 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9307 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9308 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9311 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9312 if (ftype_table[i].ftype == ftype)
9313 return ftype_table[i].str;
9320 cmd_get_hash_global_config_parsed(void *parsed_result,
9321 __rte_unused struct cmdline *cl,
9322 __rte_unused void *data)
9324 struct cmd_get_hash_global_config_result *res = parsed_result;
9325 struct rte_eth_hash_filter_info info;
9326 uint32_t idx, offset;
9331 if (rte_eth_dev_filter_supported(res->port_id,
9332 RTE_ETH_FILTER_HASH) < 0) {
9333 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9338 memset(&info, 0, sizeof(info));
9339 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9340 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9341 RTE_ETH_FILTER_GET, &info);
9343 printf("Cannot get hash global configurations by port %d\n",
9348 switch (info.info.global_conf.hash_func) {
9349 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9350 printf("Hash function is Toeplitz\n");
9352 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9353 printf("Hash function is Simple XOR\n");
9356 printf("Unknown hash function\n");
9360 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9361 idx = i / UINT32_BIT;
9362 offset = i % UINT32_BIT;
9363 if (!(info.info.global_conf.valid_bit_mask[idx] &
9366 str = flowtype_to_str(i);
9369 printf("Symmetric hash is %s globally for flow type %s "
9371 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9372 (1UL << offset)) ? "enabled" : "disabled"), str,
9377 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9378 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9379 get_hash_global_config, "get_hash_global_config");
9380 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9381 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9384 cmdline_parse_inst_t cmd_get_hash_global_config = {
9385 .f = cmd_get_hash_global_config_parsed,
9387 .help_str = "get_hash_global_config port_id",
9389 (void *)&cmd_get_hash_global_config_all,
9390 (void *)&cmd_get_hash_global_config_port_id,
9395 /* Set global config of hash function */
9396 struct cmd_set_hash_global_config_result {
9397 cmdline_fixed_string_t set_hash_global_config;
9399 cmdline_fixed_string_t hash_func;
9400 cmdline_fixed_string_t flow_type;
9401 cmdline_fixed_string_t enable;
9405 cmd_set_hash_global_config_parsed(void *parsed_result,
9406 __rte_unused struct cmdline *cl,
9407 __rte_unused void *data)
9409 struct cmd_set_hash_global_config_result *res = parsed_result;
9410 struct rte_eth_hash_filter_info info;
9411 uint32_t ftype, idx, offset;
9414 if (rte_eth_dev_filter_supported(res->port_id,
9415 RTE_ETH_FILTER_HASH) < 0) {
9416 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9420 memset(&info, 0, sizeof(info));
9421 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9422 if (!strcmp(res->hash_func, "toeplitz"))
9423 info.info.global_conf.hash_func =
9424 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9425 else if (!strcmp(res->hash_func, "simple_xor"))
9426 info.info.global_conf.hash_func =
9427 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9428 else if (!strcmp(res->hash_func, "default"))
9429 info.info.global_conf.hash_func =
9430 RTE_ETH_HASH_FUNCTION_DEFAULT;
9432 ftype = str2flowtype(res->flow_type);
9433 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9434 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9435 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9436 if (!strcmp(res->enable, "enable"))
9437 info.info.global_conf.sym_hash_enable_mask[idx] |=
9439 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9440 RTE_ETH_FILTER_SET, &info);
9442 printf("Cannot set global hash configurations by port %d\n",
9445 printf("Global hash configurations have been set "
9446 "succcessfully by port %d\n", res->port_id);
9449 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9450 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9451 set_hash_global_config, "set_hash_global_config");
9452 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9453 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9455 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9456 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9457 hash_func, "toeplitz#simple_xor#default");
9458 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9459 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9461 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9462 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9463 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9464 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9465 enable, "enable#disable");
9467 cmdline_parse_inst_t cmd_set_hash_global_config = {
9468 .f = cmd_set_hash_global_config_parsed,
9470 .help_str = "set_hash_global_config port_id "
9471 "toeplitz|simple_xor|default "
9472 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9473 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9476 (void *)&cmd_set_hash_global_config_all,
9477 (void *)&cmd_set_hash_global_config_port_id,
9478 (void *)&cmd_set_hash_global_config_hash_func,
9479 (void *)&cmd_set_hash_global_config_flow_type,
9480 (void *)&cmd_set_hash_global_config_enable,
9485 /* Set hash input set */
9486 struct cmd_set_hash_input_set_result {
9487 cmdline_fixed_string_t set_hash_input_set;
9489 cmdline_fixed_string_t flow_type;
9490 cmdline_fixed_string_t inset_field;
9491 cmdline_fixed_string_t select;
9494 static enum rte_eth_input_set_field
9495 str2inset(char *string)
9499 static const struct {
9501 enum rte_eth_input_set_field inset;
9503 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9504 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9505 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9506 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9507 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9508 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9509 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9510 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9511 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9512 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9513 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9514 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9515 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9516 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9517 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9518 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9519 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9520 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9521 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9522 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9523 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9524 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9525 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9526 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9527 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9528 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9529 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9530 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9531 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9532 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9533 {"none", RTE_ETH_INPUT_SET_NONE},
9536 for (i = 0; i < RTE_DIM(inset_table); i++) {
9537 if (!strcmp(string, inset_table[i].str))
9538 return inset_table[i].inset;
9541 return RTE_ETH_INPUT_SET_UNKNOWN;
9545 cmd_set_hash_input_set_parsed(void *parsed_result,
9546 __rte_unused struct cmdline *cl,
9547 __rte_unused void *data)
9549 struct cmd_set_hash_input_set_result *res = parsed_result;
9550 struct rte_eth_hash_filter_info info;
9552 memset(&info, 0, sizeof(info));
9553 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9554 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9555 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9556 info.info.input_set_conf.inset_size = 1;
9557 if (!strcmp(res->select, "select"))
9558 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9559 else if (!strcmp(res->select, "add"))
9560 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9561 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9562 RTE_ETH_FILTER_SET, &info);
9565 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9566 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9567 set_hash_input_set, "set_hash_input_set");
9568 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9569 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9571 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9572 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9574 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9575 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9576 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9577 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9579 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9580 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9581 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9582 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9583 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9585 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9586 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9587 select, "select#add");
9589 cmdline_parse_inst_t cmd_set_hash_input_set = {
9590 .f = cmd_set_hash_input_set_parsed,
9592 .help_str = "set_hash_input_set <port_id> "
9593 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9594 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9595 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9596 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9597 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9598 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9599 "fld-7th|fld-8th|none select|add",
9601 (void *)&cmd_set_hash_input_set_cmd,
9602 (void *)&cmd_set_hash_input_set_port_id,
9603 (void *)&cmd_set_hash_input_set_flow_type,
9604 (void *)&cmd_set_hash_input_set_field,
9605 (void *)&cmd_set_hash_input_set_select,
9610 /* Set flow director input set */
9611 struct cmd_set_fdir_input_set_result {
9612 cmdline_fixed_string_t set_fdir_input_set;
9614 cmdline_fixed_string_t flow_type;
9615 cmdline_fixed_string_t inset_field;
9616 cmdline_fixed_string_t select;
9620 cmd_set_fdir_input_set_parsed(void *parsed_result,
9621 __rte_unused struct cmdline *cl,
9622 __rte_unused void *data)
9624 struct cmd_set_fdir_input_set_result *res = parsed_result;
9625 struct rte_eth_fdir_filter_info info;
9627 memset(&info, 0, sizeof(info));
9628 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9629 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9630 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9631 info.info.input_set_conf.inset_size = 1;
9632 if (!strcmp(res->select, "select"))
9633 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9634 else if (!strcmp(res->select, "add"))
9635 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9636 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9637 RTE_ETH_FILTER_SET, &info);
9640 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9641 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9642 set_fdir_input_set, "set_fdir_input_set");
9643 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9644 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9646 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9647 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9649 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9650 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9651 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9652 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9654 "ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9655 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9656 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9657 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9658 "sctp-veri-tag#none");
9659 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9660 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9661 select, "select#add");
9663 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9664 .f = cmd_set_fdir_input_set_parsed,
9666 .help_str = "set_fdir_input_set <port_id> "
9667 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9668 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9669 "ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9670 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9671 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9672 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9673 "sctp-veri-tag|none select|add",
9675 (void *)&cmd_set_fdir_input_set_cmd,
9676 (void *)&cmd_set_fdir_input_set_port_id,
9677 (void *)&cmd_set_fdir_input_set_flow_type,
9678 (void *)&cmd_set_fdir_input_set_field,
9679 (void *)&cmd_set_fdir_input_set_select,
9684 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9685 struct cmd_mcast_addr_result {
9686 cmdline_fixed_string_t mcast_addr_cmd;
9687 cmdline_fixed_string_t what;
9689 struct ether_addr mc_addr;
9692 static void cmd_mcast_addr_parsed(void *parsed_result,
9693 __attribute__((unused)) struct cmdline *cl,
9694 __attribute__((unused)) void *data)
9696 struct cmd_mcast_addr_result *res = parsed_result;
9698 if (!is_multicast_ether_addr(&res->mc_addr)) {
9699 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9700 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9701 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9702 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9705 if (strcmp(res->what, "add") == 0)
9706 mcast_addr_add(res->port_num, &res->mc_addr);
9708 mcast_addr_remove(res->port_num, &res->mc_addr);
9711 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9712 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9713 mcast_addr_cmd, "mcast_addr");
9714 cmdline_parse_token_string_t cmd_mcast_addr_what =
9715 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9717 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9718 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9719 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9720 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9722 cmdline_parse_inst_t cmd_mcast_addr = {
9723 .f = cmd_mcast_addr_parsed,
9725 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9727 (void *)&cmd_mcast_addr_cmd,
9728 (void *)&cmd_mcast_addr_what,
9729 (void *)&cmd_mcast_addr_portnum,
9730 (void *)&cmd_mcast_addr_addr,
9736 * only support E-tag now.
9739 /* Ether type config */
9740 struct cmd_config_l2_tunnel_eth_type_result {
9741 cmdline_fixed_string_t port;
9742 cmdline_fixed_string_t config;
9743 cmdline_fixed_string_t all;
9745 cmdline_fixed_string_t l2_tunnel;
9746 cmdline_fixed_string_t l2_tunnel_type;
9747 cmdline_fixed_string_t eth_type;
9748 uint16_t eth_type_val;
9751 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9752 TOKEN_STRING_INITIALIZER
9753 (struct cmd_config_l2_tunnel_eth_type_result,
9755 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9756 TOKEN_STRING_INITIALIZER
9757 (struct cmd_config_l2_tunnel_eth_type_result,
9759 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9760 TOKEN_STRING_INITIALIZER
9761 (struct cmd_config_l2_tunnel_eth_type_result,
9763 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9764 TOKEN_NUM_INITIALIZER
9765 (struct cmd_config_l2_tunnel_eth_type_result,
9767 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9768 TOKEN_STRING_INITIALIZER
9769 (struct cmd_config_l2_tunnel_eth_type_result,
9770 l2_tunnel, "l2-tunnel");
9771 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9772 TOKEN_STRING_INITIALIZER
9773 (struct cmd_config_l2_tunnel_eth_type_result,
9774 l2_tunnel_type, "E-tag");
9775 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9776 TOKEN_STRING_INITIALIZER
9777 (struct cmd_config_l2_tunnel_eth_type_result,
9778 eth_type, "ether-type");
9779 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9780 TOKEN_NUM_INITIALIZER
9781 (struct cmd_config_l2_tunnel_eth_type_result,
9782 eth_type_val, UINT16);
9784 static enum rte_eth_tunnel_type
9785 str2fdir_l2_tunnel_type(char *string)
9789 static const struct {
9791 enum rte_eth_tunnel_type type;
9792 } l2_tunnel_type_str[] = {
9793 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9796 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9797 if (!strcmp(l2_tunnel_type_str[i].str, string))
9798 return l2_tunnel_type_str[i].type;
9800 return RTE_TUNNEL_TYPE_NONE;
9803 /* ether type config for all ports */
9805 cmd_config_l2_tunnel_eth_type_all_parsed
9806 (void *parsed_result,
9807 __attribute__((unused)) struct cmdline *cl,
9808 __attribute__((unused)) void *data)
9810 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9811 struct rte_eth_l2_tunnel_conf entry;
9814 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9815 entry.ether_type = res->eth_type_val;
9817 FOREACH_PORT(pid, ports) {
9818 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9822 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9823 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9825 .help_str = "port config all l2-tunnel ether-type",
9827 (void *)&cmd_config_l2_tunnel_eth_type_port,
9828 (void *)&cmd_config_l2_tunnel_eth_type_config,
9829 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9830 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9831 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9832 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9833 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9838 /* ether type config for a specific port */
9840 cmd_config_l2_tunnel_eth_type_specific_parsed(
9841 void *parsed_result,
9842 __attribute__((unused)) struct cmdline *cl,
9843 __attribute__((unused)) void *data)
9845 struct cmd_config_l2_tunnel_eth_type_result *res =
9847 struct rte_eth_l2_tunnel_conf entry;
9849 if (port_id_is_invalid(res->id, ENABLED_WARN))
9852 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9853 entry.ether_type = res->eth_type_val;
9855 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9858 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9859 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9861 .help_str = "port config l2-tunnel ether-type",
9863 (void *)&cmd_config_l2_tunnel_eth_type_port,
9864 (void *)&cmd_config_l2_tunnel_eth_type_config,
9865 (void *)&cmd_config_l2_tunnel_eth_type_id,
9866 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9867 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9868 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9869 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9874 /* Enable/disable l2 tunnel */
9875 struct cmd_config_l2_tunnel_en_dis_result {
9876 cmdline_fixed_string_t port;
9877 cmdline_fixed_string_t config;
9878 cmdline_fixed_string_t all;
9880 cmdline_fixed_string_t l2_tunnel;
9881 cmdline_fixed_string_t l2_tunnel_type;
9882 cmdline_fixed_string_t en_dis;
9885 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9886 TOKEN_STRING_INITIALIZER
9887 (struct cmd_config_l2_tunnel_en_dis_result,
9889 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9890 TOKEN_STRING_INITIALIZER
9891 (struct cmd_config_l2_tunnel_en_dis_result,
9893 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9894 TOKEN_STRING_INITIALIZER
9895 (struct cmd_config_l2_tunnel_en_dis_result,
9897 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9898 TOKEN_NUM_INITIALIZER
9899 (struct cmd_config_l2_tunnel_en_dis_result,
9901 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9902 TOKEN_STRING_INITIALIZER
9903 (struct cmd_config_l2_tunnel_en_dis_result,
9904 l2_tunnel, "l2-tunnel");
9905 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9906 TOKEN_STRING_INITIALIZER
9907 (struct cmd_config_l2_tunnel_en_dis_result,
9908 l2_tunnel_type, "E-tag");
9909 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9910 TOKEN_STRING_INITIALIZER
9911 (struct cmd_config_l2_tunnel_en_dis_result,
9912 en_dis, "enable#disable");
9914 /* enable/disable l2 tunnel for all ports */
9916 cmd_config_l2_tunnel_en_dis_all_parsed(
9917 void *parsed_result,
9918 __attribute__((unused)) struct cmdline *cl,
9919 __attribute__((unused)) void *data)
9921 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9922 struct rte_eth_l2_tunnel_conf entry;
9926 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9928 if (!strcmp("enable", res->en_dis))
9933 FOREACH_PORT(pid, ports) {
9934 rte_eth_dev_l2_tunnel_offload_set(pid,
9936 ETH_L2_TUNNEL_ENABLE_MASK,
9941 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
9942 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
9944 .help_str = "port config all l2-tunnel enable/disable",
9946 (void *)&cmd_config_l2_tunnel_en_dis_port,
9947 (void *)&cmd_config_l2_tunnel_en_dis_config,
9948 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
9949 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9950 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9951 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9956 /* enable/disable l2 tunnel for a port */
9958 cmd_config_l2_tunnel_en_dis_specific_parsed(
9959 void *parsed_result,
9960 __attribute__((unused)) struct cmdline *cl,
9961 __attribute__((unused)) void *data)
9963 struct cmd_config_l2_tunnel_en_dis_result *res =
9965 struct rte_eth_l2_tunnel_conf entry;
9967 if (port_id_is_invalid(res->id, ENABLED_WARN))
9970 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9972 if (!strcmp("enable", res->en_dis))
9973 rte_eth_dev_l2_tunnel_offload_set(res->id,
9975 ETH_L2_TUNNEL_ENABLE_MASK,
9978 rte_eth_dev_l2_tunnel_offload_set(res->id,
9980 ETH_L2_TUNNEL_ENABLE_MASK,
9984 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
9985 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
9987 .help_str = "port config l2-tunnel enable/disable",
9989 (void *)&cmd_config_l2_tunnel_en_dis_port,
9990 (void *)&cmd_config_l2_tunnel_en_dis_config,
9991 (void *)&cmd_config_l2_tunnel_en_dis_id,
9992 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9993 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9994 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9999 /* E-tag configuration */
10001 /* Common result structure for all E-tag configuration */
10002 struct cmd_config_e_tag_result {
10003 cmdline_fixed_string_t e_tag;
10004 cmdline_fixed_string_t set;
10005 cmdline_fixed_string_t insertion;
10006 cmdline_fixed_string_t stripping;
10007 cmdline_fixed_string_t forwarding;
10008 cmdline_fixed_string_t filter;
10009 cmdline_fixed_string_t add;
10010 cmdline_fixed_string_t del;
10011 cmdline_fixed_string_t on;
10012 cmdline_fixed_string_t off;
10013 cmdline_fixed_string_t on_off;
10014 cmdline_fixed_string_t port_tag_id;
10015 uint32_t port_tag_id_val;
10016 cmdline_fixed_string_t e_tag_id;
10017 uint16_t e_tag_id_val;
10018 cmdline_fixed_string_t dst_pool;
10019 uint8_t dst_pool_val;
10020 cmdline_fixed_string_t port;
10022 cmdline_fixed_string_t vf;
10026 /* Common CLI fields for all E-tag configuration */
10027 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10028 TOKEN_STRING_INITIALIZER
10029 (struct cmd_config_e_tag_result,
10031 cmdline_parse_token_string_t cmd_config_e_tag_set =
10032 TOKEN_STRING_INITIALIZER
10033 (struct cmd_config_e_tag_result,
10035 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10036 TOKEN_STRING_INITIALIZER
10037 (struct cmd_config_e_tag_result,
10038 insertion, "insertion");
10039 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10040 TOKEN_STRING_INITIALIZER
10041 (struct cmd_config_e_tag_result,
10042 stripping, "stripping");
10043 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10044 TOKEN_STRING_INITIALIZER
10045 (struct cmd_config_e_tag_result,
10046 forwarding, "forwarding");
10047 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10048 TOKEN_STRING_INITIALIZER
10049 (struct cmd_config_e_tag_result,
10051 cmdline_parse_token_string_t cmd_config_e_tag_add =
10052 TOKEN_STRING_INITIALIZER
10053 (struct cmd_config_e_tag_result,
10055 cmdline_parse_token_string_t cmd_config_e_tag_del =
10056 TOKEN_STRING_INITIALIZER
10057 (struct cmd_config_e_tag_result,
10059 cmdline_parse_token_string_t cmd_config_e_tag_on =
10060 TOKEN_STRING_INITIALIZER
10061 (struct cmd_config_e_tag_result,
10063 cmdline_parse_token_string_t cmd_config_e_tag_off =
10064 TOKEN_STRING_INITIALIZER
10065 (struct cmd_config_e_tag_result,
10067 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10068 TOKEN_STRING_INITIALIZER
10069 (struct cmd_config_e_tag_result,
10071 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10072 TOKEN_STRING_INITIALIZER
10073 (struct cmd_config_e_tag_result,
10074 port_tag_id, "port-tag-id");
10075 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10076 TOKEN_NUM_INITIALIZER
10077 (struct cmd_config_e_tag_result,
10078 port_tag_id_val, UINT32);
10079 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10080 TOKEN_STRING_INITIALIZER
10081 (struct cmd_config_e_tag_result,
10082 e_tag_id, "e-tag-id");
10083 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10084 TOKEN_NUM_INITIALIZER
10085 (struct cmd_config_e_tag_result,
10086 e_tag_id_val, UINT16);
10087 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10088 TOKEN_STRING_INITIALIZER
10089 (struct cmd_config_e_tag_result,
10090 dst_pool, "dst-pool");
10091 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10092 TOKEN_NUM_INITIALIZER
10093 (struct cmd_config_e_tag_result,
10094 dst_pool_val, UINT8);
10095 cmdline_parse_token_string_t cmd_config_e_tag_port =
10096 TOKEN_STRING_INITIALIZER
10097 (struct cmd_config_e_tag_result,
10099 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10100 TOKEN_NUM_INITIALIZER
10101 (struct cmd_config_e_tag_result,
10103 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10104 TOKEN_STRING_INITIALIZER
10105 (struct cmd_config_e_tag_result,
10107 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10108 TOKEN_NUM_INITIALIZER
10109 (struct cmd_config_e_tag_result,
10112 /* E-tag insertion configuration */
10114 cmd_config_e_tag_insertion_en_parsed(
10115 void *parsed_result,
10116 __attribute__((unused)) struct cmdline *cl,
10117 __attribute__((unused)) void *data)
10119 struct cmd_config_e_tag_result *res =
10121 struct rte_eth_l2_tunnel_conf entry;
10123 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10126 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10127 entry.tunnel_id = res->port_tag_id_val;
10128 entry.vf_id = res->vf_id;
10129 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10131 ETH_L2_TUNNEL_INSERTION_MASK,
10136 cmd_config_e_tag_insertion_dis_parsed(
10137 void *parsed_result,
10138 __attribute__((unused)) struct cmdline *cl,
10139 __attribute__((unused)) void *data)
10141 struct cmd_config_e_tag_result *res =
10143 struct rte_eth_l2_tunnel_conf entry;
10145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10148 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10149 entry.vf_id = res->vf_id;
10151 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10153 ETH_L2_TUNNEL_INSERTION_MASK,
10157 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10158 .f = cmd_config_e_tag_insertion_en_parsed,
10160 .help_str = "E-tag insertion enable",
10162 (void *)&cmd_config_e_tag_e_tag,
10163 (void *)&cmd_config_e_tag_set,
10164 (void *)&cmd_config_e_tag_insertion,
10165 (void *)&cmd_config_e_tag_on,
10166 (void *)&cmd_config_e_tag_port_tag_id,
10167 (void *)&cmd_config_e_tag_port_tag_id_val,
10168 (void *)&cmd_config_e_tag_port,
10169 (void *)&cmd_config_e_tag_port_id,
10170 (void *)&cmd_config_e_tag_vf,
10171 (void *)&cmd_config_e_tag_vf_id,
10176 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10177 .f = cmd_config_e_tag_insertion_dis_parsed,
10179 .help_str = "E-tag insertion disable",
10181 (void *)&cmd_config_e_tag_e_tag,
10182 (void *)&cmd_config_e_tag_set,
10183 (void *)&cmd_config_e_tag_insertion,
10184 (void *)&cmd_config_e_tag_off,
10185 (void *)&cmd_config_e_tag_port,
10186 (void *)&cmd_config_e_tag_port_id,
10187 (void *)&cmd_config_e_tag_vf,
10188 (void *)&cmd_config_e_tag_vf_id,
10193 /* E-tag stripping configuration */
10195 cmd_config_e_tag_stripping_parsed(
10196 void *parsed_result,
10197 __attribute__((unused)) struct cmdline *cl,
10198 __attribute__((unused)) void *data)
10200 struct cmd_config_e_tag_result *res =
10202 struct rte_eth_l2_tunnel_conf entry;
10204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10207 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10209 if (!strcmp(res->on_off, "on"))
10210 rte_eth_dev_l2_tunnel_offload_set
10213 ETH_L2_TUNNEL_STRIPPING_MASK,
10216 rte_eth_dev_l2_tunnel_offload_set
10219 ETH_L2_TUNNEL_STRIPPING_MASK,
10223 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10224 .f = cmd_config_e_tag_stripping_parsed,
10226 .help_str = "E-tag stripping enable/disable",
10228 (void *)&cmd_config_e_tag_e_tag,
10229 (void *)&cmd_config_e_tag_set,
10230 (void *)&cmd_config_e_tag_stripping,
10231 (void *)&cmd_config_e_tag_on_off,
10232 (void *)&cmd_config_e_tag_port,
10233 (void *)&cmd_config_e_tag_port_id,
10238 /* E-tag forwarding configuration */
10240 cmd_config_e_tag_forwarding_parsed(
10241 void *parsed_result,
10242 __attribute__((unused)) struct cmdline *cl,
10243 __attribute__((unused)) void *data)
10245 struct cmd_config_e_tag_result *res = parsed_result;
10246 struct rte_eth_l2_tunnel_conf entry;
10248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10251 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10253 if (!strcmp(res->on_off, "on"))
10254 rte_eth_dev_l2_tunnel_offload_set
10257 ETH_L2_TUNNEL_FORWARDING_MASK,
10260 rte_eth_dev_l2_tunnel_offload_set
10263 ETH_L2_TUNNEL_FORWARDING_MASK,
10267 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10268 .f = cmd_config_e_tag_forwarding_parsed,
10270 .help_str = "E-tag forwarding enable/disable",
10272 (void *)&cmd_config_e_tag_e_tag,
10273 (void *)&cmd_config_e_tag_set,
10274 (void *)&cmd_config_e_tag_forwarding,
10275 (void *)&cmd_config_e_tag_on_off,
10276 (void *)&cmd_config_e_tag_port,
10277 (void *)&cmd_config_e_tag_port_id,
10282 /* E-tag filter configuration */
10284 cmd_config_e_tag_filter_add_parsed(
10285 void *parsed_result,
10286 __attribute__((unused)) struct cmdline *cl,
10287 __attribute__((unused)) void *data)
10289 struct cmd_config_e_tag_result *res = parsed_result;
10290 struct rte_eth_l2_tunnel_conf entry;
10293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10296 if (res->e_tag_id_val > 0x3fff) {
10297 printf("e-tag-id must be equal or less than 0x3fff.\n");
10301 ret = rte_eth_dev_filter_supported(res->port_id,
10302 RTE_ETH_FILTER_L2_TUNNEL);
10304 printf("E-tag filter is not supported on port %u.\n",
10309 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10310 entry.tunnel_id = res->e_tag_id_val;
10311 entry.pool = res->dst_pool_val;
10313 ret = rte_eth_dev_filter_ctrl(res->port_id,
10314 RTE_ETH_FILTER_L2_TUNNEL,
10315 RTE_ETH_FILTER_ADD,
10318 printf("E-tag filter programming error: (%s)\n",
10322 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10323 .f = cmd_config_e_tag_filter_add_parsed,
10325 .help_str = "E-tag filter add",
10327 (void *)&cmd_config_e_tag_e_tag,
10328 (void *)&cmd_config_e_tag_set,
10329 (void *)&cmd_config_e_tag_filter,
10330 (void *)&cmd_config_e_tag_add,
10331 (void *)&cmd_config_e_tag_e_tag_id,
10332 (void *)&cmd_config_e_tag_e_tag_id_val,
10333 (void *)&cmd_config_e_tag_dst_pool,
10334 (void *)&cmd_config_e_tag_dst_pool_val,
10335 (void *)&cmd_config_e_tag_port,
10336 (void *)&cmd_config_e_tag_port_id,
10342 cmd_config_e_tag_filter_del_parsed(
10343 void *parsed_result,
10344 __attribute__((unused)) struct cmdline *cl,
10345 __attribute__((unused)) void *data)
10347 struct cmd_config_e_tag_result *res = parsed_result;
10348 struct rte_eth_l2_tunnel_conf entry;
10351 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10354 if (res->e_tag_id_val > 0x3fff) {
10355 printf("e-tag-id must be less than 0x3fff.\n");
10359 ret = rte_eth_dev_filter_supported(res->port_id,
10360 RTE_ETH_FILTER_L2_TUNNEL);
10362 printf("E-tag filter is not supported on port %u.\n",
10367 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10368 entry.tunnel_id = res->e_tag_id_val;
10370 ret = rte_eth_dev_filter_ctrl(res->port_id,
10371 RTE_ETH_FILTER_L2_TUNNEL,
10372 RTE_ETH_FILTER_DELETE,
10375 printf("E-tag filter programming error: (%s)\n",
10379 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10380 .f = cmd_config_e_tag_filter_del_parsed,
10382 .help_str = "E-tag filter delete",
10384 (void *)&cmd_config_e_tag_e_tag,
10385 (void *)&cmd_config_e_tag_set,
10386 (void *)&cmd_config_e_tag_filter,
10387 (void *)&cmd_config_e_tag_del,
10388 (void *)&cmd_config_e_tag_e_tag_id,
10389 (void *)&cmd_config_e_tag_e_tag_id_val,
10390 (void *)&cmd_config_e_tag_port,
10391 (void *)&cmd_config_e_tag_port_id,
10396 /* ******************************************************************************** */
10398 /* list of instructions */
10399 cmdline_parse_ctx_t main_ctx[] = {
10400 (cmdline_parse_inst_t *)&cmd_help_brief,
10401 (cmdline_parse_inst_t *)&cmd_help_long,
10402 (cmdline_parse_inst_t *)&cmd_quit,
10403 (cmdline_parse_inst_t *)&cmd_showport,
10404 (cmdline_parse_inst_t *)&cmd_showqueue,
10405 (cmdline_parse_inst_t *)&cmd_showportall,
10406 (cmdline_parse_inst_t *)&cmd_showcfg,
10407 (cmdline_parse_inst_t *)&cmd_start,
10408 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10409 (cmdline_parse_inst_t *)&cmd_set_link_up,
10410 (cmdline_parse_inst_t *)&cmd_set_link_down,
10411 (cmdline_parse_inst_t *)&cmd_reset,
10412 (cmdline_parse_inst_t *)&cmd_set_numbers,
10413 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10414 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10415 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10416 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10417 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10418 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10419 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10420 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10421 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10422 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10423 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10424 (cmdline_parse_inst_t *)&cmd_set_link_check,
10425 #ifdef RTE_NIC_BYPASS
10426 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10427 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10428 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10429 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10431 #ifdef RTE_LIBRTE_PMD_BOND
10432 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10433 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10434 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10435 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10436 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10437 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10438 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10439 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10440 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10442 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10443 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10444 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10445 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10446 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10447 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10448 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10449 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10450 (cmdline_parse_inst_t *)&cmd_csum_set,
10451 (cmdline_parse_inst_t *)&cmd_csum_show,
10452 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10453 (cmdline_parse_inst_t *)&cmd_tso_set,
10454 (cmdline_parse_inst_t *)&cmd_tso_show,
10455 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10456 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10457 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10458 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10459 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10460 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10461 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10462 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10463 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10464 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10465 (cmdline_parse_inst_t *)&cmd_config_dcb,
10466 (cmdline_parse_inst_t *)&cmd_read_reg,
10467 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10468 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10469 (cmdline_parse_inst_t *)&cmd_write_reg,
10470 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10471 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10472 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10473 (cmdline_parse_inst_t *)&cmd_stop,
10474 (cmdline_parse_inst_t *)&cmd_mac_addr,
10475 (cmdline_parse_inst_t *)&cmd_set_qmap,
10476 (cmdline_parse_inst_t *)&cmd_operate_port,
10477 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10478 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10479 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10480 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10481 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10482 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10483 (cmdline_parse_inst_t *)&cmd_config_mtu,
10484 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10485 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10486 (cmdline_parse_inst_t *)&cmd_config_rss,
10487 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10488 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10489 (cmdline_parse_inst_t *)&cmd_showport_reta,
10490 (cmdline_parse_inst_t *)&cmd_config_burst,
10491 (cmdline_parse_inst_t *)&cmd_config_thresh,
10492 (cmdline_parse_inst_t *)&cmd_config_threshold,
10493 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10494 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10495 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10496 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10497 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10498 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10499 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10500 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10501 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10502 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10503 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10504 (cmdline_parse_inst_t *)&cmd_global_config,
10505 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10506 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10507 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10508 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10509 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10510 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10511 (cmdline_parse_inst_t *)&cmd_dump,
10512 (cmdline_parse_inst_t *)&cmd_dump_one,
10513 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10514 (cmdline_parse_inst_t *)&cmd_syn_filter,
10515 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10516 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10517 (cmdline_parse_inst_t *)&cmd_flex_filter,
10518 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10519 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10520 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10521 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10522 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10523 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10524 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10525 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10526 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10527 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10528 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10529 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10530 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10531 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10532 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10533 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10534 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10535 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10536 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10537 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10538 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10539 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10540 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10541 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10542 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10543 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10544 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10545 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10546 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10550 /* prompt function, called from main on MASTER lcore */
10554 /* initialize non-constant commands */
10555 cmd_set_fwd_mode_init();
10557 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10558 if (testpmd_cl == NULL)
10560 cmdline_interact(testpmd_cl);
10561 cmdline_stdin_exit(testpmd_cl);
10567 if (testpmd_cl != NULL)
10568 cmdline_quit(testpmd_cl);
10572 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10574 if (id == (portid_t)RTE_PORT_ALL) {
10577 FOREACH_PORT(pid, ports) {
10578 /* check if need_reconfig has been set to 1 */
10579 if (ports[pid].need_reconfig == 0)
10580 ports[pid].need_reconfig = dev;
10581 /* check if need_reconfig_queues has been set to 1 */
10582 if (ports[pid].need_reconfig_queues == 0)
10583 ports[pid].need_reconfig_queues = queue;
10585 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10586 /* check if need_reconfig has been set to 1 */
10587 if (ports[id].need_reconfig == 0)
10588 ports[id].need_reconfig = dev;
10589 /* check if need_reconfig_queues has been set to 1 */
10590 if (ports[id].need_reconfig_queues == 0)
10591 ports[id].need_reconfig_queues = queue;
10595 #ifdef RTE_NIC_BYPASS
10596 #include <rte_pci_dev_ids.h>
10598 bypass_is_supported(portid_t port_id)
10600 struct rte_port *port;
10601 struct rte_pci_id *pci_id;
10603 if (port_id_is_invalid(port_id, ENABLED_WARN))
10606 /* Get the device id. */
10607 port = &ports[port_id];
10608 pci_id = &port->dev_info.pci_dev->id;
10610 /* Check if NIC supports bypass. */
10611 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10615 printf("\tBypass not supported for port_id = %d.\n", port_id);