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|100000|auto)"
553 " duplex (half|full|auto)\n"
554 " Set speed and duplex for all ports or port_id\n\n"
556 "port config all (rxq|txq|rxd|txd) (value)\n"
557 " Set number for rxq/txq/rxd/txd.\n\n"
559 "port config all max-pkt-len (value)\n"
560 " Set the max packet length.\n\n"
562 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
563 "hw-vlan-strip|hw-vlan-extend|drop-en)"
565 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
568 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
569 " Set the RSS mode.\n\n"
571 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
572 " Set the RSS redirection table.\n\n"
574 "port config (port_id) dcb vt (on|off) (traffic_class)"
576 " Set the DCB mode.\n\n"
578 "port config all burst (value)\n"
579 " Set the number of packets per burst.\n\n"
581 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
583 " Set the ring prefetch/host/writeback threshold"
584 " for tx/rx queue.\n\n"
586 "port config all (txfreet|txrst|rxfreet) (value)\n"
587 " Set free threshold for rx/tx, or set"
588 " tx rs bit threshold.\n\n"
589 "port config mtu X value\n"
590 " Set the MTU of port X to a given value\n\n"
592 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
593 " Start/stop a rx/tx queue of port X. Only take effect"
594 " when port X is started\n\n"
596 "port config (port_id|all) l2-tunnel E-tag ether-type"
598 " Set the value of E-tag ether-type.\n\n"
600 "port config (port_id|all) l2-tunnel E-tag"
601 " (enable|disable)\n"
602 " Enable/disable the E-tag support.\n\n"
606 if (show_all || !strcmp(res->section, "registers")) {
614 "read reg (port_id) (address)\n"
615 " Display value of a port register.\n\n"
617 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
618 " Display a port register bit field.\n\n"
620 "read regbit (port_id) (address) (bit_x)\n"
621 " Display a single port register bit.\n\n"
623 "write reg (port_id) (address) (value)\n"
624 " Set value of a port register.\n\n"
626 "write regfield (port_id) (address) (bit_x) (bit_y)"
628 " Set bit field of a port register.\n\n"
630 "write regbit (port_id) (address) (bit_x) (value)\n"
631 " Set single bit value of a port register.\n\n"
634 if (show_all || !strcmp(res->section, "filters")) {
642 "ethertype_filter (port_id) (add|del)"
643 " (mac_addr|mac_ignr) (mac_address) ethertype"
644 " (ether_type) (drop|fwd) queue (queue_id)\n"
645 " Add/Del an ethertype filter.\n\n"
647 "2tuple_filter (port_id) (add|del)"
648 " dst_port (dst_port_value) protocol (protocol_value)"
649 " mask (mask_value) tcp_flags (tcp_flags_value)"
650 " priority (prio_value) queue (queue_id)\n"
651 " Add/Del a 2tuple filter.\n\n"
653 "5tuple_filter (port_id) (add|del)"
654 " dst_ip (dst_address) src_ip (src_address)"
655 " dst_port (dst_port_value) src_port (src_port_value)"
656 " protocol (protocol_value)"
657 " mask (mask_value) tcp_flags (tcp_flags_value)"
658 " priority (prio_value) queue (queue_id)\n"
659 " Add/Del a 5tuple filter.\n\n"
661 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
662 " Add/Del syn filter.\n\n"
664 "flex_filter (port_id) (add|del) len (len_value)"
665 " bytes (bytes_value) mask (mask_value)"
666 " priority (prio_value) queue (queue_id)\n"
667 " Add/Del a flex filter.\n\n"
669 "flow_director_filter (port_id) mode IP (add|del|update)"
670 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
671 " src (src_ip_address) dst (dst_ip_address)"
672 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
673 " vlan (vlan_value) flexbytes (flexbytes_value)"
674 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
675 " fd_id (fd_id_value)\n"
676 " Add/Del an IP type flow director filter.\n\n"
678 "flow_director_filter (port_id) mode IP (add|del|update)"
679 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
680 " src (src_ip_address) (src_port)"
681 " dst (dst_ip_address) (dst_port)"
682 " tos (tos_value) ttl (ttl_value)"
683 " vlan (vlan_value) flexbytes (flexbytes_value)"
684 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
685 " fd_id (fd_id_value)\n"
686 " Add/Del an UDP/TCP type flow director filter.\n\n"
688 "flow_director_filter (port_id) mode IP (add|del|update)"
689 " flow (ipv4-sctp|ipv6-sctp)"
690 " src (src_ip_address) (src_port)"
691 " dst (dst_ip_address) (dst_port)"
692 " tag (verification_tag) "
693 " tos (tos_value) ttl (ttl_value)"
695 " flexbytes (flexbytes_value) (drop|fwd)"
696 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
697 " Add/Del a SCTP type flow director filter.\n\n"
699 "flow_director_filter (port_id) mode IP (add|del|update)"
700 " flow l2_payload ether (ethertype)"
701 " flexbytes (flexbytes_value) (drop|fwd)"
702 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
703 " Add/Del a l2 payload type flow director filter.\n\n"
705 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
706 " mac (mac_address) vlan (vlan_value)"
707 " flexbytes (flexbytes_value) (drop|fwd)"
708 " queue (queue_id) fd_id (fd_id_value)\n"
709 " Add/Del a MAC-VLAN flow director filter.\n\n"
711 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
712 " mac (mac_address) vlan (vlan_value)"
713 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
714 " flexbytes (flexbytes_value) (drop|fwd)"
715 " queue (queue_id) fd_id (fd_id_value)\n"
716 " Add/Del a Tunnel flow director filter.\n\n"
718 "flush_flow_director (port_id)\n"
719 " Flush all flow director entries of a device.\n\n"
721 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
722 " src_mask (ipv4_src) (ipv6_src) (src_port)"
723 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
724 " Set flow director IP mask.\n\n"
726 "flow_director_mask (port_id) mode MAC-VLAN"
727 " vlan (vlan_value) mac (mac_value)\n"
728 " Set flow director MAC-VLAN mask.\n\n"
730 "flow_director_mask (port_id) mode Tunnel"
731 " vlan (vlan_value) mac (mac_value)"
732 " tunnel-type (tunnel_type_value)"
733 " tunnel-id (tunnel_id_value)\n"
734 " Set flow director Tunnel mask.\n\n"
736 "flow_director_flex_mask (port_id)"
737 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
738 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
740 " Configure mask of flex payload.\n\n"
742 "flow_director_flex_payload (port_id)"
743 " (raw|l2|l3|l4) (config)\n"
744 " Configure flex payload selection.\n\n"
746 "get_sym_hash_ena_per_port (port_id)\n"
747 " get symmetric hash enable configuration per port.\n\n"
749 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
750 " set symmetric hash enable configuration per port"
751 " to enable or disable.\n\n"
753 "get_hash_global_config (port_id)\n"
754 " Get the global configurations of hash filters.\n\n"
756 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
757 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
758 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
759 " (enable|disable)\n"
760 " Set the global configurations of hash filters.\n\n"
762 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
763 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
764 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
765 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
766 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
767 "ipv6-next-header|udp-src-port|udp-dst-port|"
768 "tcp-src-port|tcp-dst-port|sctp-src-port|"
769 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
770 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
771 "fld-8th|none) (select|add)\n"
772 " Set the input set for hash.\n\n"
774 "set_fdir_input_set (port_id) "
775 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
776 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
777 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
778 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
779 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
780 "udp-dst-port|tcp-src-port|tcp-dst-port|"
781 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
783 " Set the input set for FDir.\n\n"
788 cmdline_parse_token_string_t cmd_help_long_help =
789 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
791 cmdline_parse_token_string_t cmd_help_long_section =
792 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
793 "all#control#display#config#"
794 "ports#registers#filters");
796 cmdline_parse_inst_t cmd_help_long = {
797 .f = cmd_help_long_parsed,
799 .help_str = "show help",
801 (void *)&cmd_help_long_help,
802 (void *)&cmd_help_long_section,
808 /* *** start/stop/close all ports *** */
809 struct cmd_operate_port_result {
810 cmdline_fixed_string_t keyword;
811 cmdline_fixed_string_t name;
812 cmdline_fixed_string_t value;
815 static void cmd_operate_port_parsed(void *parsed_result,
816 __attribute__((unused)) struct cmdline *cl,
817 __attribute__((unused)) void *data)
819 struct cmd_operate_port_result *res = parsed_result;
821 if (!strcmp(res->name, "start"))
822 start_port(RTE_PORT_ALL);
823 else if (!strcmp(res->name, "stop"))
824 stop_port(RTE_PORT_ALL);
825 else if (!strcmp(res->name, "close"))
826 close_port(RTE_PORT_ALL);
828 printf("Unknown parameter\n");
831 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
832 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
834 cmdline_parse_token_string_t cmd_operate_port_all_port =
835 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
837 cmdline_parse_token_string_t cmd_operate_port_all_all =
838 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
840 cmdline_parse_inst_t cmd_operate_port = {
841 .f = cmd_operate_port_parsed,
843 .help_str = "port start|stop|close all: start/stop/close all ports",
845 (void *)&cmd_operate_port_all_cmd,
846 (void *)&cmd_operate_port_all_port,
847 (void *)&cmd_operate_port_all_all,
852 /* *** start/stop/close specific port *** */
853 struct cmd_operate_specific_port_result {
854 cmdline_fixed_string_t keyword;
855 cmdline_fixed_string_t name;
859 static void cmd_operate_specific_port_parsed(void *parsed_result,
860 __attribute__((unused)) struct cmdline *cl,
861 __attribute__((unused)) void *data)
863 struct cmd_operate_specific_port_result *res = parsed_result;
865 if (!strcmp(res->name, "start"))
866 start_port(res->value);
867 else if (!strcmp(res->name, "stop"))
868 stop_port(res->value);
869 else if (!strcmp(res->name, "close"))
870 close_port(res->value);
872 printf("Unknown parameter\n");
875 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
876 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
878 cmdline_parse_token_string_t cmd_operate_specific_port_port =
879 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
880 name, "start#stop#close");
881 cmdline_parse_token_num_t cmd_operate_specific_port_id =
882 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
885 cmdline_parse_inst_t cmd_operate_specific_port = {
886 .f = cmd_operate_specific_port_parsed,
888 .help_str = "port start|stop|close X: start/stop/close port X",
890 (void *)&cmd_operate_specific_port_cmd,
891 (void *)&cmd_operate_specific_port_port,
892 (void *)&cmd_operate_specific_port_id,
897 /* *** attach a specified port *** */
898 struct cmd_operate_attach_port_result {
899 cmdline_fixed_string_t port;
900 cmdline_fixed_string_t keyword;
901 cmdline_fixed_string_t identifier;
904 static void cmd_operate_attach_port_parsed(void *parsed_result,
905 __attribute__((unused)) struct cmdline *cl,
906 __attribute__((unused)) void *data)
908 struct cmd_operate_attach_port_result *res = parsed_result;
910 if (!strcmp(res->keyword, "attach"))
911 attach_port(res->identifier);
913 printf("Unknown parameter\n");
916 cmdline_parse_token_string_t cmd_operate_attach_port_port =
917 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
919 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
920 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
922 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
923 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
926 cmdline_parse_inst_t cmd_operate_attach_port = {
927 .f = cmd_operate_attach_port_parsed,
929 .help_str = "port attach identifier, "
930 "identifier: pci address or virtual dev name",
932 (void *)&cmd_operate_attach_port_port,
933 (void *)&cmd_operate_attach_port_keyword,
934 (void *)&cmd_operate_attach_port_identifier,
939 /* *** detach a specified port *** */
940 struct cmd_operate_detach_port_result {
941 cmdline_fixed_string_t port;
942 cmdline_fixed_string_t keyword;
946 static void cmd_operate_detach_port_parsed(void *parsed_result,
947 __attribute__((unused)) struct cmdline *cl,
948 __attribute__((unused)) void *data)
950 struct cmd_operate_detach_port_result *res = parsed_result;
952 if (!strcmp(res->keyword, "detach"))
953 detach_port(res->port_id);
955 printf("Unknown parameter\n");
958 cmdline_parse_token_string_t cmd_operate_detach_port_port =
959 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
961 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
962 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
964 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
965 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
968 cmdline_parse_inst_t cmd_operate_detach_port = {
969 .f = cmd_operate_detach_port_parsed,
971 .help_str = "port detach port_id",
973 (void *)&cmd_operate_detach_port_port,
974 (void *)&cmd_operate_detach_port_keyword,
975 (void *)&cmd_operate_detach_port_port_id,
980 /* *** configure speed for all ports *** */
981 struct cmd_config_speed_all {
982 cmdline_fixed_string_t port;
983 cmdline_fixed_string_t keyword;
984 cmdline_fixed_string_t all;
985 cmdline_fixed_string_t item1;
986 cmdline_fixed_string_t item2;
987 cmdline_fixed_string_t value1;
988 cmdline_fixed_string_t value2;
992 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
997 if (!strcmp(duplexstr, "half")) {
998 duplex = ETH_LINK_HALF_DUPLEX;
999 } else if (!strcmp(duplexstr, "full")) {
1000 duplex = ETH_LINK_FULL_DUPLEX;
1001 } else if (!strcmp(duplexstr, "auto")) {
1002 duplex = ETH_LINK_FULL_DUPLEX;
1004 printf("Unknown duplex parameter\n");
1008 if (!strcmp(speedstr, "10")) {
1009 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1010 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1011 } else if (!strcmp(speedstr, "100")) {
1012 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1013 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1015 if (duplex != ETH_LINK_FULL_DUPLEX) {
1016 printf("Invalid speed/duplex parameters\n");
1019 if (!strcmp(speedstr, "1000")) {
1020 *speed = ETH_LINK_SPEED_1G;
1021 } else if (!strcmp(speedstr, "10000")) {
1022 *speed = ETH_LINK_SPEED_10G;
1023 } else if (!strcmp(speedstr, "40000")) {
1024 *speed = ETH_LINK_SPEED_40G;
1025 } else if (!strcmp(speedstr, "100000")) {
1026 *speed = ETH_LINK_SPEED_100G;
1027 } else if (!strcmp(speedstr, "auto")) {
1028 *speed = ETH_LINK_SPEED_AUTONEG;
1030 printf("Unknown speed parameter\n");
1039 cmd_config_speed_all_parsed(void *parsed_result,
1040 __attribute__((unused)) struct cmdline *cl,
1041 __attribute__((unused)) void *data)
1043 struct cmd_config_speed_all *res = parsed_result;
1044 uint32_t link_speed;
1047 if (!all_ports_stopped()) {
1048 printf("Please stop all ports first\n");
1052 if (parse_and_check_speed_duplex(res->value1, res->value2,
1056 FOREACH_PORT(pid, ports) {
1057 ports[pid].dev_conf.link_speeds = link_speed;
1060 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1063 cmdline_parse_token_string_t cmd_config_speed_all_port =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1065 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1068 cmdline_parse_token_string_t cmd_config_speed_all_all =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1070 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1071 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1072 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1074 "10#100#1000#10000#40000#100000#auto");
1075 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1076 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1077 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1078 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1081 cmdline_parse_inst_t cmd_config_speed_all = {
1082 .f = cmd_config_speed_all_parsed,
1084 .help_str = "port config all speed 10|100|1000|10000|40000|100000|auto duplex "
1087 (void *)&cmd_config_speed_all_port,
1088 (void *)&cmd_config_speed_all_keyword,
1089 (void *)&cmd_config_speed_all_all,
1090 (void *)&cmd_config_speed_all_item1,
1091 (void *)&cmd_config_speed_all_value1,
1092 (void *)&cmd_config_speed_all_item2,
1093 (void *)&cmd_config_speed_all_value2,
1098 /* *** configure speed for specific port *** */
1099 struct cmd_config_speed_specific {
1100 cmdline_fixed_string_t port;
1101 cmdline_fixed_string_t keyword;
1103 cmdline_fixed_string_t item1;
1104 cmdline_fixed_string_t item2;
1105 cmdline_fixed_string_t value1;
1106 cmdline_fixed_string_t value2;
1110 cmd_config_speed_specific_parsed(void *parsed_result,
1111 __attribute__((unused)) struct cmdline *cl,
1112 __attribute__((unused)) void *data)
1114 struct cmd_config_speed_specific *res = parsed_result;
1115 uint32_t link_speed;
1117 if (!all_ports_stopped()) {
1118 printf("Please stop all ports first\n");
1122 if (port_id_is_invalid(res->id, ENABLED_WARN))
1125 if (parse_and_check_speed_duplex(res->value1, res->value2,
1129 ports[res->id].dev_conf.link_speeds = link_speed;
1131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1135 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1138 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1141 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1142 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1143 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1146 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1148 "10#100#1000#10000#40000#100000#auto");
1149 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1152 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1156 cmdline_parse_inst_t cmd_config_speed_specific = {
1157 .f = cmd_config_speed_specific_parsed,
1159 .help_str = "port config X speed 10|100|1000|10000|40000|100000|auto duplex "
1162 (void *)&cmd_config_speed_specific_port,
1163 (void *)&cmd_config_speed_specific_keyword,
1164 (void *)&cmd_config_speed_specific_id,
1165 (void *)&cmd_config_speed_specific_item1,
1166 (void *)&cmd_config_speed_specific_value1,
1167 (void *)&cmd_config_speed_specific_item2,
1168 (void *)&cmd_config_speed_specific_value2,
1173 /* *** configure txq/rxq, txd/rxd *** */
1174 struct cmd_config_rx_tx {
1175 cmdline_fixed_string_t port;
1176 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t all;
1178 cmdline_fixed_string_t name;
1183 cmd_config_rx_tx_parsed(void *parsed_result,
1184 __attribute__((unused)) struct cmdline *cl,
1185 __attribute__((unused)) void *data)
1187 struct cmd_config_rx_tx *res = parsed_result;
1189 if (!all_ports_stopped()) {
1190 printf("Please stop all ports first\n");
1193 if (!strcmp(res->name, "rxq")) {
1194 if (!res->value && !nb_txq) {
1195 printf("Warning: Either rx or tx queues should be non zero\n");
1198 nb_rxq = res->value;
1200 else if (!strcmp(res->name, "txq")) {
1201 if (!res->value && !nb_rxq) {
1202 printf("Warning: Either rx or tx queues should be non zero\n");
1205 nb_txq = res->value;
1207 else if (!strcmp(res->name, "rxd")) {
1208 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1209 printf("rxd %d invalid - must be > 0 && <= %d\n",
1210 res->value, RTE_TEST_RX_DESC_MAX);
1213 nb_rxd = res->value;
1214 } else if (!strcmp(res->name, "txd")) {
1215 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1216 printf("txd %d invalid - must be > 0 && <= %d\n",
1217 res->value, RTE_TEST_TX_DESC_MAX);
1220 nb_txd = res->value;
1222 printf("Unknown parameter\n");
1228 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1231 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1233 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1235 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1236 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1237 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1240 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1241 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1243 cmdline_parse_inst_t cmd_config_rx_tx = {
1244 .f = cmd_config_rx_tx_parsed,
1246 .help_str = "port config all rxq|txq|rxd|txd value",
1248 (void *)&cmd_config_rx_tx_port,
1249 (void *)&cmd_config_rx_tx_keyword,
1250 (void *)&cmd_config_rx_tx_all,
1251 (void *)&cmd_config_rx_tx_name,
1252 (void *)&cmd_config_rx_tx_value,
1257 /* *** config max packet length *** */
1258 struct cmd_config_max_pkt_len_result {
1259 cmdline_fixed_string_t port;
1260 cmdline_fixed_string_t keyword;
1261 cmdline_fixed_string_t all;
1262 cmdline_fixed_string_t name;
1267 cmd_config_max_pkt_len_parsed(void *parsed_result,
1268 __attribute__((unused)) struct cmdline *cl,
1269 __attribute__((unused)) void *data)
1271 struct cmd_config_max_pkt_len_result *res = parsed_result;
1273 if (!all_ports_stopped()) {
1274 printf("Please stop all ports first\n");
1278 if (!strcmp(res->name, "max-pkt-len")) {
1279 if (res->value < ETHER_MIN_LEN) {
1280 printf("max-pkt-len can not be less than %d\n",
1284 if (res->value == rx_mode.max_rx_pkt_len)
1287 rx_mode.max_rx_pkt_len = res->value;
1288 if (res->value > ETHER_MAX_LEN)
1289 rx_mode.jumbo_frame = 1;
1291 rx_mode.jumbo_frame = 0;
1293 printf("Unknown parameter\n");
1299 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1302 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1303 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1305 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1306 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1308 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1309 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1311 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1312 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1314 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1315 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1318 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1319 .f = cmd_config_max_pkt_len_parsed,
1321 .help_str = "port config all max-pkt-len value",
1323 (void *)&cmd_config_max_pkt_len_port,
1324 (void *)&cmd_config_max_pkt_len_keyword,
1325 (void *)&cmd_config_max_pkt_len_all,
1326 (void *)&cmd_config_max_pkt_len_name,
1327 (void *)&cmd_config_max_pkt_len_value,
1332 /* *** configure port MTU *** */
1333 struct cmd_config_mtu_result {
1334 cmdline_fixed_string_t port;
1335 cmdline_fixed_string_t keyword;
1336 cmdline_fixed_string_t mtu;
1342 cmd_config_mtu_parsed(void *parsed_result,
1343 __attribute__((unused)) struct cmdline *cl,
1344 __attribute__((unused)) void *data)
1346 struct cmd_config_mtu_result *res = parsed_result;
1348 if (res->value < ETHER_MIN_LEN) {
1349 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1352 port_mtu_set(res->port_id, res->value);
1355 cmdline_parse_token_string_t cmd_config_mtu_port =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1358 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1359 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1361 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1362 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1364 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1365 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1366 cmdline_parse_token_num_t cmd_config_mtu_value =
1367 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1369 cmdline_parse_inst_t cmd_config_mtu = {
1370 .f = cmd_config_mtu_parsed,
1372 .help_str = "port config mtu value",
1374 (void *)&cmd_config_mtu_port,
1375 (void *)&cmd_config_mtu_keyword,
1376 (void *)&cmd_config_mtu_mtu,
1377 (void *)&cmd_config_mtu_port_id,
1378 (void *)&cmd_config_mtu_value,
1383 /* *** configure rx mode *** */
1384 struct cmd_config_rx_mode_flag {
1385 cmdline_fixed_string_t port;
1386 cmdline_fixed_string_t keyword;
1387 cmdline_fixed_string_t all;
1388 cmdline_fixed_string_t name;
1389 cmdline_fixed_string_t value;
1393 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1394 __attribute__((unused)) struct cmdline *cl,
1395 __attribute__((unused)) void *data)
1397 struct cmd_config_rx_mode_flag *res = parsed_result;
1399 if (!all_ports_stopped()) {
1400 printf("Please stop all ports first\n");
1404 if (!strcmp(res->name, "crc-strip")) {
1405 if (!strcmp(res->value, "on"))
1406 rx_mode.hw_strip_crc = 1;
1407 else if (!strcmp(res->value, "off"))
1408 rx_mode.hw_strip_crc = 0;
1410 printf("Unknown parameter\n");
1413 } else if (!strcmp(res->name, "scatter")) {
1414 if (!strcmp(res->value, "on"))
1415 rx_mode.enable_scatter = 1;
1416 else if (!strcmp(res->value, "off"))
1417 rx_mode.enable_scatter = 0;
1419 printf("Unknown parameter\n");
1422 } else if (!strcmp(res->name, "rx-cksum")) {
1423 if (!strcmp(res->value, "on"))
1424 rx_mode.hw_ip_checksum = 1;
1425 else if (!strcmp(res->value, "off"))
1426 rx_mode.hw_ip_checksum = 0;
1428 printf("Unknown parameter\n");
1431 } else if (!strcmp(res->name, "hw-vlan")) {
1432 if (!strcmp(res->value, "on")) {
1433 rx_mode.hw_vlan_filter = 1;
1434 rx_mode.hw_vlan_strip = 1;
1436 else if (!strcmp(res->value, "off")) {
1437 rx_mode.hw_vlan_filter = 0;
1438 rx_mode.hw_vlan_strip = 0;
1441 printf("Unknown parameter\n");
1444 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1445 if (!strcmp(res->value, "on"))
1446 rx_mode.hw_vlan_filter = 1;
1447 else if (!strcmp(res->value, "off"))
1448 rx_mode.hw_vlan_filter = 0;
1450 printf("Unknown parameter\n");
1453 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1454 if (!strcmp(res->value, "on"))
1455 rx_mode.hw_vlan_strip = 1;
1456 else if (!strcmp(res->value, "off"))
1457 rx_mode.hw_vlan_strip = 0;
1459 printf("Unknown parameter\n");
1462 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1463 if (!strcmp(res->value, "on"))
1464 rx_mode.hw_vlan_extend = 1;
1465 else if (!strcmp(res->value, "off"))
1466 rx_mode.hw_vlan_extend = 0;
1468 printf("Unknown parameter\n");
1471 } else if (!strcmp(res->name, "drop-en")) {
1472 if (!strcmp(res->value, "on"))
1474 else if (!strcmp(res->value, "off"))
1477 printf("Unknown parameter\n");
1481 printf("Unknown parameter\n");
1487 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1490 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1492 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1495 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1496 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1497 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1499 "crc-strip#scatter#rx-cksum#hw-vlan#"
1500 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1501 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1505 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1506 .f = cmd_config_rx_mode_flag_parsed,
1508 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1509 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1511 (void *)&cmd_config_rx_mode_flag_port,
1512 (void *)&cmd_config_rx_mode_flag_keyword,
1513 (void *)&cmd_config_rx_mode_flag_all,
1514 (void *)&cmd_config_rx_mode_flag_name,
1515 (void *)&cmd_config_rx_mode_flag_value,
1520 /* *** configure rss *** */
1521 struct cmd_config_rss {
1522 cmdline_fixed_string_t port;
1523 cmdline_fixed_string_t keyword;
1524 cmdline_fixed_string_t all;
1525 cmdline_fixed_string_t name;
1526 cmdline_fixed_string_t value;
1530 cmd_config_rss_parsed(void *parsed_result,
1531 __attribute__((unused)) struct cmdline *cl,
1532 __attribute__((unused)) void *data)
1534 struct cmd_config_rss *res = parsed_result;
1535 struct rte_eth_rss_conf rss_conf;
1538 if (!strcmp(res->value, "all"))
1539 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1540 ETH_RSS_UDP | ETH_RSS_SCTP |
1542 else if (!strcmp(res->value, "ip"))
1543 rss_conf.rss_hf = ETH_RSS_IP;
1544 else if (!strcmp(res->value, "udp"))
1545 rss_conf.rss_hf = ETH_RSS_UDP;
1546 else if (!strcmp(res->value, "tcp"))
1547 rss_conf.rss_hf = ETH_RSS_TCP;
1548 else if (!strcmp(res->value, "sctp"))
1549 rss_conf.rss_hf = ETH_RSS_SCTP;
1550 else if (!strcmp(res->value, "ether"))
1551 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1552 else if (!strcmp(res->value, "none"))
1553 rss_conf.rss_hf = 0;
1555 printf("Unknown parameter\n");
1558 rss_conf.rss_key = NULL;
1559 for (i = 0; i < rte_eth_dev_count(); i++)
1560 rte_eth_dev_rss_hash_update(i, &rss_conf);
1563 cmdline_parse_token_string_t cmd_config_rss_port =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1565 cmdline_parse_token_string_t cmd_config_rss_keyword =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1567 cmdline_parse_token_string_t cmd_config_rss_all =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1569 cmdline_parse_token_string_t cmd_config_rss_name =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1571 cmdline_parse_token_string_t cmd_config_rss_value =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1573 "all#ip#tcp#udp#sctp#ether#none");
1575 cmdline_parse_inst_t cmd_config_rss = {
1576 .f = cmd_config_rss_parsed,
1578 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1580 (void *)&cmd_config_rss_port,
1581 (void *)&cmd_config_rss_keyword,
1582 (void *)&cmd_config_rss_all,
1583 (void *)&cmd_config_rss_name,
1584 (void *)&cmd_config_rss_value,
1589 /* *** configure rss hash key *** */
1590 struct cmd_config_rss_hash_key {
1591 cmdline_fixed_string_t port;
1592 cmdline_fixed_string_t config;
1594 cmdline_fixed_string_t rss_hash_key;
1595 cmdline_fixed_string_t rss_type;
1596 cmdline_fixed_string_t key;
1599 #define RSS_HASH_KEY_LENGTH 40
1601 hexa_digit_to_value(char hexa_digit)
1603 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1604 return (uint8_t) (hexa_digit - '0');
1605 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1606 return (uint8_t) ((hexa_digit - 'a') + 10);
1607 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1608 return (uint8_t) ((hexa_digit - 'A') + 10);
1609 /* Invalid hexa digit */
1614 parse_and_check_key_hexa_digit(char *key, int idx)
1618 hexa_v = hexa_digit_to_value(key[idx]);
1620 printf("invalid key: character %c at position %d is not a "
1621 "valid hexa digit\n", key[idx], idx);
1626 cmd_config_rss_hash_key_parsed(void *parsed_result,
1627 __attribute__((unused)) struct cmdline *cl,
1628 __attribute__((unused)) void *data)
1630 struct cmd_config_rss_hash_key *res = parsed_result;
1631 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1636 /* Check the length of the RSS hash key */
1637 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1638 printf("key length: %d invalid - key must be a string of %d"
1639 "hexa-decimal numbers\n", (int) strlen(res->key),
1640 RSS_HASH_KEY_LENGTH * 2);
1643 /* Translate RSS hash key into binary representation */
1644 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1645 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1648 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1651 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1653 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1654 RSS_HASH_KEY_LENGTH);
1657 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1659 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1662 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1663 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1664 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1666 rss_hash_key, "rss-hash-key");
1667 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1669 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1670 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1671 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1672 "ipv6-tcp-ex#ipv6-udp-ex");
1673 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1676 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1677 .f = cmd_config_rss_hash_key_parsed,
1680 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1681 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1682 "ipv6-sctp|ipv6-other|l2-payload|"
1683 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1685 (void *)&cmd_config_rss_hash_key_port,
1686 (void *)&cmd_config_rss_hash_key_config,
1687 (void *)&cmd_config_rss_hash_key_port_id,
1688 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1689 (void *)&cmd_config_rss_hash_key_rss_type,
1690 (void *)&cmd_config_rss_hash_key_value,
1695 /* *** configure port rxq/txq start/stop *** */
1696 struct cmd_config_rxtx_queue {
1697 cmdline_fixed_string_t port;
1699 cmdline_fixed_string_t rxtxq;
1701 cmdline_fixed_string_t opname;
1705 cmd_config_rxtx_queue_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_config_rxtx_queue *res = parsed_result;
1714 if (test_done == 0) {
1715 printf("Please stop forwarding first\n");
1719 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1722 if (port_is_started(res->portid) != 1) {
1723 printf("Please start port %u first\n", res->portid);
1727 if (!strcmp(res->rxtxq, "rxq"))
1729 else if (!strcmp(res->rxtxq, "txq"))
1732 printf("Unknown parameter\n");
1736 if (isrx && rx_queue_id_is_invalid(res->qid))
1738 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1741 if (!strcmp(res->opname, "start"))
1743 else if (!strcmp(res->opname, "stop"))
1746 printf("Unknown parameter\n");
1750 if (isstart && isrx)
1751 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1752 else if (!isstart && isrx)
1753 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1754 else if (isstart && !isrx)
1755 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1757 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1759 if (ret == -ENOTSUP)
1760 printf("Function not supported in PMD driver\n");
1763 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1765 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1766 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1767 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1769 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1770 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1771 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1775 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1776 .f = cmd_config_rxtx_queue_parsed,
1778 .help_str = "port X rxq|txq ID start|stop",
1780 (void *)&cmd_config_speed_all_port,
1781 (void *)&cmd_config_rxtx_queue_portid,
1782 (void *)&cmd_config_rxtx_queue_rxtxq,
1783 (void *)&cmd_config_rxtx_queue_qid,
1784 (void *)&cmd_config_rxtx_queue_opname,
1789 /* *** Configure RSS RETA *** */
1790 struct cmd_config_rss_reta {
1791 cmdline_fixed_string_t port;
1792 cmdline_fixed_string_t keyword;
1794 cmdline_fixed_string_t name;
1795 cmdline_fixed_string_t list_name;
1796 cmdline_fixed_string_t list_of_items;
1800 parse_reta_config(const char *str,
1801 struct rte_eth_rss_reta_entry64 *reta_conf,
1802 uint16_t nb_entries)
1806 uint16_t hash_index, idx, shift;
1809 const char *p, *p0 = str;
1816 unsigned long int_fld[_NUM_FLD];
1817 char *str_fld[_NUM_FLD];
1819 while ((p = strchr(p0,'(')) != NULL) {
1821 if((p0 = strchr(p,')')) == NULL)
1825 if(size >= sizeof(s))
1828 snprintf(s, sizeof(s), "%.*s", size, p);
1829 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1831 for (i = 0; i < _NUM_FLD; i++) {
1833 int_fld[i] = strtoul(str_fld[i], &end, 0);
1834 if (errno != 0 || end == str_fld[i] ||
1839 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1840 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1842 if (hash_index >= nb_entries) {
1843 printf("Invalid RETA hash index=%d\n", hash_index);
1847 idx = hash_index / RTE_RETA_GROUP_SIZE;
1848 shift = hash_index % RTE_RETA_GROUP_SIZE;
1849 reta_conf[idx].mask |= (1ULL << shift);
1850 reta_conf[idx].reta[shift] = nb_queue;
1857 cmd_set_rss_reta_parsed(void *parsed_result,
1858 __attribute__((unused)) struct cmdline *cl,
1859 __attribute__((unused)) void *data)
1862 struct rte_eth_dev_info dev_info;
1863 struct rte_eth_rss_reta_entry64 reta_conf[8];
1864 struct cmd_config_rss_reta *res = parsed_result;
1866 memset(&dev_info, 0, sizeof(dev_info));
1867 rte_eth_dev_info_get(res->port_id, &dev_info);
1868 if (dev_info.reta_size == 0) {
1869 printf("Redirection table size is 0 which is "
1870 "invalid for RSS\n");
1873 printf("The reta size of port %d is %u\n",
1874 res->port_id, dev_info.reta_size);
1875 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1876 printf("Currently do not support more than %u entries of "
1877 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1881 memset(reta_conf, 0, sizeof(reta_conf));
1882 if (!strcmp(res->list_name, "reta")) {
1883 if (parse_reta_config(res->list_of_items, reta_conf,
1884 dev_info.reta_size)) {
1885 printf("Invalid RSS Redirection Table "
1886 "config entered\n");
1889 ret = rte_eth_dev_rss_reta_update(res->port_id,
1890 reta_conf, dev_info.reta_size);
1892 printf("Bad redirection table parameter, "
1893 "return code = %d \n", ret);
1897 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1899 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1901 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1902 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1903 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1904 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1905 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1907 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1910 cmdline_parse_inst_t cmd_config_rss_reta = {
1911 .f = cmd_set_rss_reta_parsed,
1913 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1915 (void *)&cmd_config_rss_reta_port,
1916 (void *)&cmd_config_rss_reta_keyword,
1917 (void *)&cmd_config_rss_reta_port_id,
1918 (void *)&cmd_config_rss_reta_name,
1919 (void *)&cmd_config_rss_reta_list_name,
1920 (void *)&cmd_config_rss_reta_list_of_items,
1925 /* *** SHOW PORT RETA INFO *** */
1926 struct cmd_showport_reta {
1927 cmdline_fixed_string_t show;
1928 cmdline_fixed_string_t port;
1930 cmdline_fixed_string_t rss;
1931 cmdline_fixed_string_t reta;
1933 cmdline_fixed_string_t list_of_items;
1937 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1938 uint16_t nb_entries,
1942 const char *p, *p0 = str;
1946 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1949 p = strchr(p0, '(');
1953 p0 = strchr(p, ')');
1957 if (size >= sizeof(s)) {
1958 printf("The string size exceeds the internal buffer size\n");
1961 snprintf(s, sizeof(s), "%.*s", size, p);
1962 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1963 if (ret <= 0 || ret != num) {
1964 printf("The bits of masks do not match the number of "
1965 "reta entries: %u\n", num);
1968 for (i = 0; i < ret; i++)
1969 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1975 cmd_showport_reta_parsed(void *parsed_result,
1976 __attribute__((unused)) struct cmdline *cl,
1977 __attribute__((unused)) void *data)
1979 struct cmd_showport_reta *res = parsed_result;
1980 struct rte_eth_rss_reta_entry64 reta_conf[8];
1981 struct rte_eth_dev_info dev_info;
1983 memset(&dev_info, 0, sizeof(dev_info));
1984 rte_eth_dev_info_get(res->port_id, &dev_info);
1985 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1986 res->size > ETH_RSS_RETA_SIZE_512) {
1987 printf("Invalid redirection table size: %u\n", res->size);
1991 memset(reta_conf, 0, sizeof(reta_conf));
1992 if (showport_parse_reta_config(reta_conf, res->size,
1993 res->list_of_items) < 0) {
1994 printf("Invalid string: %s for reta masks\n",
1995 res->list_of_items);
1998 port_rss_reta_info(res->port_id, reta_conf, res->size);
2001 cmdline_parse_token_string_t cmd_showport_reta_show =
2002 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2003 cmdline_parse_token_string_t cmd_showport_reta_port =
2004 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2005 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2006 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2007 cmdline_parse_token_string_t cmd_showport_reta_rss =
2008 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2009 cmdline_parse_token_string_t cmd_showport_reta_reta =
2010 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2011 cmdline_parse_token_num_t cmd_showport_reta_size =
2012 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2013 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2014 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2015 list_of_items, NULL);
2017 cmdline_parse_inst_t cmd_showport_reta = {
2018 .f = cmd_showport_reta_parsed,
2020 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2022 (void *)&cmd_showport_reta_show,
2023 (void *)&cmd_showport_reta_port,
2024 (void *)&cmd_showport_reta_port_id,
2025 (void *)&cmd_showport_reta_rss,
2026 (void *)&cmd_showport_reta_reta,
2027 (void *)&cmd_showport_reta_size,
2028 (void *)&cmd_showport_reta_list_of_items,
2033 /* *** Show RSS hash configuration *** */
2034 struct cmd_showport_rss_hash {
2035 cmdline_fixed_string_t show;
2036 cmdline_fixed_string_t port;
2038 cmdline_fixed_string_t rss_hash;
2039 cmdline_fixed_string_t rss_type;
2040 cmdline_fixed_string_t key; /* optional argument */
2043 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2044 __attribute__((unused)) struct cmdline *cl,
2047 struct cmd_showport_rss_hash *res = parsed_result;
2049 port_rss_hash_conf_show(res->port_id, res->rss_type,
2050 show_rss_key != NULL);
2053 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2054 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2055 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2056 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2057 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2058 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2059 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2060 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2062 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2063 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2064 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2065 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2066 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2067 "ipv6-tcp-ex#ipv6-udp-ex");
2068 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2069 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2071 cmdline_parse_inst_t cmd_showport_rss_hash = {
2072 .f = cmd_showport_rss_hash_parsed,
2075 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2076 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2077 "ipv6-sctp|ipv6-other|l2-payload|"
2078 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2080 (void *)&cmd_showport_rss_hash_show,
2081 (void *)&cmd_showport_rss_hash_port,
2082 (void *)&cmd_showport_rss_hash_port_id,
2083 (void *)&cmd_showport_rss_hash_rss_hash,
2084 (void *)&cmd_showport_rss_hash_rss_hash_info,
2089 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2090 .f = cmd_showport_rss_hash_parsed,
2093 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2094 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2095 "ipv6-sctp|ipv6-other|l2-payload|"
2096 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2098 (void *)&cmd_showport_rss_hash_show,
2099 (void *)&cmd_showport_rss_hash_port,
2100 (void *)&cmd_showport_rss_hash_port_id,
2101 (void *)&cmd_showport_rss_hash_rss_hash,
2102 (void *)&cmd_showport_rss_hash_rss_hash_info,
2103 (void *)&cmd_showport_rss_hash_rss_key,
2108 /* *** Configure DCB *** */
2109 struct cmd_config_dcb {
2110 cmdline_fixed_string_t port;
2111 cmdline_fixed_string_t config;
2113 cmdline_fixed_string_t dcb;
2114 cmdline_fixed_string_t vt;
2115 cmdline_fixed_string_t vt_en;
2117 cmdline_fixed_string_t pfc;
2118 cmdline_fixed_string_t pfc_en;
2122 cmd_config_dcb_parsed(void *parsed_result,
2123 __attribute__((unused)) struct cmdline *cl,
2124 __attribute__((unused)) void *data)
2126 struct cmd_config_dcb *res = parsed_result;
2127 portid_t port_id = res->port_id;
2128 struct rte_port *port;
2132 port = &ports[port_id];
2133 /** Check if the port is not started **/
2134 if (port->port_status != RTE_PORT_STOPPED) {
2135 printf("Please stop port %d first\n", port_id);
2139 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2140 printf("The invalid number of traffic class,"
2141 " only 4 or 8 allowed.\n");
2145 if (nb_fwd_lcores < res->num_tcs) {
2146 printf("nb_cores shouldn't be less than number of TCs.\n");
2149 if (!strncmp(res->pfc_en, "on", 2))
2154 /* DCB in VT mode */
2155 if (!strncmp(res->vt_en, "on", 2))
2156 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2157 (enum rte_eth_nb_tcs)res->num_tcs,
2160 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2161 (enum rte_eth_nb_tcs)res->num_tcs,
2166 printf("Cannot initialize network ports.\n");
2170 cmd_reconfig_device_queue(port_id, 1, 1);
2173 cmdline_parse_token_string_t cmd_config_dcb_port =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2175 cmdline_parse_token_string_t cmd_config_dcb_config =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2177 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2178 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2179 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2181 cmdline_parse_token_string_t cmd_config_dcb_vt =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2183 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2185 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2186 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2187 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2188 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2189 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2190 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2192 cmdline_parse_inst_t cmd_config_dcb = {
2193 .f = cmd_config_dcb_parsed,
2195 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2197 (void *)&cmd_config_dcb_port,
2198 (void *)&cmd_config_dcb_config,
2199 (void *)&cmd_config_dcb_port_id,
2200 (void *)&cmd_config_dcb_dcb,
2201 (void *)&cmd_config_dcb_vt,
2202 (void *)&cmd_config_dcb_vt_en,
2203 (void *)&cmd_config_dcb_num_tcs,
2204 (void *)&cmd_config_dcb_pfc,
2205 (void *)&cmd_config_dcb_pfc_en,
2210 /* *** configure number of packets per burst *** */
2211 struct cmd_config_burst {
2212 cmdline_fixed_string_t port;
2213 cmdline_fixed_string_t keyword;
2214 cmdline_fixed_string_t all;
2215 cmdline_fixed_string_t name;
2220 cmd_config_burst_parsed(void *parsed_result,
2221 __attribute__((unused)) struct cmdline *cl,
2222 __attribute__((unused)) void *data)
2224 struct cmd_config_burst *res = parsed_result;
2226 if (!all_ports_stopped()) {
2227 printf("Please stop all ports first\n");
2231 if (!strcmp(res->name, "burst")) {
2232 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2233 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2236 nb_pkt_per_burst = res->value;
2238 printf("Unknown parameter\n");
2244 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2247 cmdline_parse_token_string_t cmd_config_burst_port =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2249 cmdline_parse_token_string_t cmd_config_burst_keyword =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2251 cmdline_parse_token_string_t cmd_config_burst_all =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2253 cmdline_parse_token_string_t cmd_config_burst_name =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2255 cmdline_parse_token_num_t cmd_config_burst_value =
2256 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2258 cmdline_parse_inst_t cmd_config_burst = {
2259 .f = cmd_config_burst_parsed,
2261 .help_str = "port config all burst value",
2263 (void *)&cmd_config_burst_port,
2264 (void *)&cmd_config_burst_keyword,
2265 (void *)&cmd_config_burst_all,
2266 (void *)&cmd_config_burst_name,
2267 (void *)&cmd_config_burst_value,
2272 /* *** configure rx/tx queues *** */
2273 struct cmd_config_thresh {
2274 cmdline_fixed_string_t port;
2275 cmdline_fixed_string_t keyword;
2276 cmdline_fixed_string_t all;
2277 cmdline_fixed_string_t name;
2282 cmd_config_thresh_parsed(void *parsed_result,
2283 __attribute__((unused)) struct cmdline *cl,
2284 __attribute__((unused)) void *data)
2286 struct cmd_config_thresh *res = parsed_result;
2288 if (!all_ports_stopped()) {
2289 printf("Please stop all ports first\n");
2293 if (!strcmp(res->name, "txpt"))
2294 tx_pthresh = res->value;
2295 else if(!strcmp(res->name, "txht"))
2296 tx_hthresh = res->value;
2297 else if(!strcmp(res->name, "txwt"))
2298 tx_wthresh = res->value;
2299 else if(!strcmp(res->name, "rxpt"))
2300 rx_pthresh = res->value;
2301 else if(!strcmp(res->name, "rxht"))
2302 rx_hthresh = res->value;
2303 else if(!strcmp(res->name, "rxwt"))
2304 rx_wthresh = res->value;
2306 printf("Unknown parameter\n");
2312 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2315 cmdline_parse_token_string_t cmd_config_thresh_port =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2317 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2319 cmdline_parse_token_string_t cmd_config_thresh_all =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2321 cmdline_parse_token_string_t cmd_config_thresh_name =
2322 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2323 "txpt#txht#txwt#rxpt#rxht#rxwt");
2324 cmdline_parse_token_num_t cmd_config_thresh_value =
2325 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2327 cmdline_parse_inst_t cmd_config_thresh = {
2328 .f = cmd_config_thresh_parsed,
2330 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2332 (void *)&cmd_config_thresh_port,
2333 (void *)&cmd_config_thresh_keyword,
2334 (void *)&cmd_config_thresh_all,
2335 (void *)&cmd_config_thresh_name,
2336 (void *)&cmd_config_thresh_value,
2341 /* *** configure free/rs threshold *** */
2342 struct cmd_config_threshold {
2343 cmdline_fixed_string_t port;
2344 cmdline_fixed_string_t keyword;
2345 cmdline_fixed_string_t all;
2346 cmdline_fixed_string_t name;
2351 cmd_config_threshold_parsed(void *parsed_result,
2352 __attribute__((unused)) struct cmdline *cl,
2353 __attribute__((unused)) void *data)
2355 struct cmd_config_threshold *res = parsed_result;
2357 if (!all_ports_stopped()) {
2358 printf("Please stop all ports first\n");
2362 if (!strcmp(res->name, "txfreet"))
2363 tx_free_thresh = res->value;
2364 else if (!strcmp(res->name, "txrst"))
2365 tx_rs_thresh = res->value;
2366 else if (!strcmp(res->name, "rxfreet"))
2367 rx_free_thresh = res->value;
2369 printf("Unknown parameter\n");
2375 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2378 cmdline_parse_token_string_t cmd_config_threshold_port =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2380 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2383 cmdline_parse_token_string_t cmd_config_threshold_all =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2385 cmdline_parse_token_string_t cmd_config_threshold_name =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2387 "txfreet#txrst#rxfreet");
2388 cmdline_parse_token_num_t cmd_config_threshold_value =
2389 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2391 cmdline_parse_inst_t cmd_config_threshold = {
2392 .f = cmd_config_threshold_parsed,
2394 .help_str = "port config all txfreet|txrst|rxfreet value",
2396 (void *)&cmd_config_threshold_port,
2397 (void *)&cmd_config_threshold_keyword,
2398 (void *)&cmd_config_threshold_all,
2399 (void *)&cmd_config_threshold_name,
2400 (void *)&cmd_config_threshold_value,
2406 struct cmd_stop_result {
2407 cmdline_fixed_string_t stop;
2410 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2411 __attribute__((unused)) struct cmdline *cl,
2412 __attribute__((unused)) void *data)
2414 stop_packet_forwarding();
2417 cmdline_parse_token_string_t cmd_stop_stop =
2418 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2420 cmdline_parse_inst_t cmd_stop = {
2421 .f = cmd_stop_parsed,
2423 .help_str = "stop - stop packet forwarding",
2425 (void *)&cmd_stop_stop,
2430 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2433 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2434 unsigned int *parsed_items, int check_unique_values)
2436 unsigned int nb_item;
2444 * First parse all items in the list and store their value.
2449 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2451 if ((c >= '0') && (c <= '9')) {
2452 value = (unsigned int) (value * 10 + (c - '0'));
2457 printf("character %c is not a decimal digit\n", c);
2461 printf("No valid value before comma\n");
2464 if (nb_item < max_items) {
2465 parsed_items[nb_item] = value;
2471 if (nb_item >= max_items) {
2472 printf("Number of %s = %u > %u (maximum items)\n",
2473 item_name, nb_item + 1, max_items);
2476 parsed_items[nb_item++] = value;
2477 if (! check_unique_values)
2481 * Then, check that all values in the list are differents.
2482 * No optimization here...
2484 for (i = 0; i < nb_item; i++) {
2485 for (j = i + 1; j < nb_item; j++) {
2486 if (parsed_items[j] == parsed_items[i]) {
2487 printf("duplicated %s %u at index %u and %u\n",
2488 item_name, parsed_items[i], i, j);
2496 struct cmd_set_list_result {
2497 cmdline_fixed_string_t cmd_keyword;
2498 cmdline_fixed_string_t list_name;
2499 cmdline_fixed_string_t list_of_items;
2502 static void cmd_set_list_parsed(void *parsed_result,
2503 __attribute__((unused)) struct cmdline *cl,
2504 __attribute__((unused)) void *data)
2506 struct cmd_set_list_result *res;
2508 unsigned int lcorelist[RTE_MAX_LCORE];
2509 unsigned int portlist[RTE_MAX_ETHPORTS];
2511 unsigned int nb_item;
2513 if (test_done == 0) {
2514 printf("Please stop forwarding first\n");
2518 res = parsed_result;
2519 if (!strcmp(res->list_name, "corelist")) {
2520 nb_item = parse_item_list(res->list_of_items, "core",
2522 parsed_items.lcorelist, 1);
2524 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2527 if (!strcmp(res->list_name, "portlist")) {
2528 nb_item = parse_item_list(res->list_of_items, "port",
2530 parsed_items.portlist, 1);
2532 set_fwd_ports_list(parsed_items.portlist, nb_item);
2536 cmdline_parse_token_string_t cmd_set_list_keyword =
2537 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2539 cmdline_parse_token_string_t cmd_set_list_name =
2540 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2541 "corelist#portlist");
2542 cmdline_parse_token_string_t cmd_set_list_of_items =
2543 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2546 cmdline_parse_inst_t cmd_set_fwd_list = {
2547 .f = cmd_set_list_parsed,
2549 .help_str = "set corelist|portlist x[,y]*",
2551 (void *)&cmd_set_list_keyword,
2552 (void *)&cmd_set_list_name,
2553 (void *)&cmd_set_list_of_items,
2558 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2560 struct cmd_setmask_result {
2561 cmdline_fixed_string_t set;
2562 cmdline_fixed_string_t mask;
2566 static void cmd_set_mask_parsed(void *parsed_result,
2567 __attribute__((unused)) struct cmdline *cl,
2568 __attribute__((unused)) void *data)
2570 struct cmd_setmask_result *res = parsed_result;
2572 if (test_done == 0) {
2573 printf("Please stop forwarding first\n");
2576 if (!strcmp(res->mask, "coremask"))
2577 set_fwd_lcores_mask(res->hexavalue);
2578 else if (!strcmp(res->mask, "portmask"))
2579 set_fwd_ports_mask(res->hexavalue);
2582 cmdline_parse_token_string_t cmd_setmask_set =
2583 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2584 cmdline_parse_token_string_t cmd_setmask_mask =
2585 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2586 "coremask#portmask");
2587 cmdline_parse_token_num_t cmd_setmask_value =
2588 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2590 cmdline_parse_inst_t cmd_set_fwd_mask = {
2591 .f = cmd_set_mask_parsed,
2593 .help_str = "set coremask|portmask hexadecimal value",
2595 (void *)&cmd_setmask_set,
2596 (void *)&cmd_setmask_mask,
2597 (void *)&cmd_setmask_value,
2603 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2605 struct cmd_set_result {
2606 cmdline_fixed_string_t set;
2607 cmdline_fixed_string_t what;
2611 static void cmd_set_parsed(void *parsed_result,
2612 __attribute__((unused)) struct cmdline *cl,
2613 __attribute__((unused)) void *data)
2615 struct cmd_set_result *res = parsed_result;
2616 if (!strcmp(res->what, "nbport"))
2617 set_fwd_ports_number(res->value);
2618 else if (!strcmp(res->what, "nbcore"))
2619 set_fwd_lcores_number(res->value);
2620 else if (!strcmp(res->what, "burst"))
2621 set_nb_pkt_per_burst(res->value);
2622 else if (!strcmp(res->what, "verbose"))
2623 set_verbose_level(res->value);
2626 cmdline_parse_token_string_t cmd_set_set =
2627 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2628 cmdline_parse_token_string_t cmd_set_what =
2629 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2630 "nbport#nbcore#burst#verbose");
2631 cmdline_parse_token_num_t cmd_set_value =
2632 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2634 cmdline_parse_inst_t cmd_set_numbers = {
2635 .f = cmd_set_parsed,
2637 .help_str = "set nbport|nbcore|burst|verbose value",
2639 (void *)&cmd_set_set,
2640 (void *)&cmd_set_what,
2641 (void *)&cmd_set_value,
2646 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2648 struct cmd_set_txpkts_result {
2649 cmdline_fixed_string_t cmd_keyword;
2650 cmdline_fixed_string_t txpkts;
2651 cmdline_fixed_string_t seg_lengths;
2655 cmd_set_txpkts_parsed(void *parsed_result,
2656 __attribute__((unused)) struct cmdline *cl,
2657 __attribute__((unused)) void *data)
2659 struct cmd_set_txpkts_result *res;
2660 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2661 unsigned int nb_segs;
2663 res = parsed_result;
2664 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2665 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2667 set_tx_pkt_segments(seg_lengths, nb_segs);
2670 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2671 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2672 cmd_keyword, "set");
2673 cmdline_parse_token_string_t cmd_set_txpkts_name =
2674 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2676 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2677 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2680 cmdline_parse_inst_t cmd_set_txpkts = {
2681 .f = cmd_set_txpkts_parsed,
2683 .help_str = "set txpkts x[,y]*",
2685 (void *)&cmd_set_txpkts_keyword,
2686 (void *)&cmd_set_txpkts_name,
2687 (void *)&cmd_set_txpkts_lengths,
2692 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2694 struct cmd_set_txsplit_result {
2695 cmdline_fixed_string_t cmd_keyword;
2696 cmdline_fixed_string_t txsplit;
2697 cmdline_fixed_string_t mode;
2701 cmd_set_txsplit_parsed(void *parsed_result,
2702 __attribute__((unused)) struct cmdline *cl,
2703 __attribute__((unused)) void *data)
2705 struct cmd_set_txsplit_result *res;
2707 res = parsed_result;
2708 set_tx_pkt_split(res->mode);
2711 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2712 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2713 cmd_keyword, "set");
2714 cmdline_parse_token_string_t cmd_set_txsplit_name =
2715 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2716 txsplit, "txsplit");
2717 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2718 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2721 cmdline_parse_inst_t cmd_set_txsplit = {
2722 .f = cmd_set_txsplit_parsed,
2724 .help_str = "set txsplit on|off|rand",
2726 (void *)&cmd_set_txsplit_keyword,
2727 (void *)&cmd_set_txsplit_name,
2728 (void *)&cmd_set_txsplit_mode,
2733 /* *** CONFIG TX QUEUE FLAGS *** */
2735 struct cmd_config_txqflags_result {
2736 cmdline_fixed_string_t port;
2737 cmdline_fixed_string_t config;
2738 cmdline_fixed_string_t all;
2739 cmdline_fixed_string_t what;
2743 static void cmd_config_txqflags_parsed(void *parsed_result,
2744 __attribute__((unused)) struct cmdline *cl,
2745 __attribute__((unused)) void *data)
2747 struct cmd_config_txqflags_result *res = parsed_result;
2749 if (!all_ports_stopped()) {
2750 printf("Please stop all ports first\n");
2754 if (strcmp(res->what, "txqflags")) {
2755 printf("Unknown parameter\n");
2759 if (res->hexvalue >= 0) {
2760 txq_flags = res->hexvalue;
2762 printf("txqflags must be >= 0\n");
2768 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2771 cmdline_parse_token_string_t cmd_config_txqflags_port =
2772 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2774 cmdline_parse_token_string_t cmd_config_txqflags_config =
2775 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2777 cmdline_parse_token_string_t cmd_config_txqflags_all =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2780 cmdline_parse_token_string_t cmd_config_txqflags_what =
2781 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2783 cmdline_parse_token_num_t cmd_config_txqflags_value =
2784 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2787 cmdline_parse_inst_t cmd_config_txqflags = {
2788 .f = cmd_config_txqflags_parsed,
2790 .help_str = "port config all txqflags value",
2792 (void *)&cmd_config_txqflags_port,
2793 (void *)&cmd_config_txqflags_config,
2794 (void *)&cmd_config_txqflags_all,
2795 (void *)&cmd_config_txqflags_what,
2796 (void *)&cmd_config_txqflags_value,
2801 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2802 struct cmd_rx_vlan_filter_all_result {
2803 cmdline_fixed_string_t rx_vlan;
2804 cmdline_fixed_string_t what;
2805 cmdline_fixed_string_t all;
2810 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2811 __attribute__((unused)) struct cmdline *cl,
2812 __attribute__((unused)) void *data)
2814 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2816 if (!strcmp(res->what, "add"))
2817 rx_vlan_all_filter_set(res->port_id, 1);
2819 rx_vlan_all_filter_set(res->port_id, 0);
2822 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2823 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2824 rx_vlan, "rx_vlan");
2825 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2826 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2828 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2829 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2831 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2832 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2835 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2836 .f = cmd_rx_vlan_filter_all_parsed,
2838 .help_str = "add/remove all identifiers to/from the set of VLAN "
2839 "Identifiers filtered by a port",
2841 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2842 (void *)&cmd_rx_vlan_filter_all_what,
2843 (void *)&cmd_rx_vlan_filter_all_all,
2844 (void *)&cmd_rx_vlan_filter_all_portid,
2849 /* *** VLAN OFFLOAD SET ON A PORT *** */
2850 struct cmd_vlan_offload_result {
2851 cmdline_fixed_string_t vlan;
2852 cmdline_fixed_string_t set;
2853 cmdline_fixed_string_t vlan_type;
2854 cmdline_fixed_string_t what;
2855 cmdline_fixed_string_t on;
2856 cmdline_fixed_string_t port_id;
2860 cmd_vlan_offload_parsed(void *parsed_result,
2861 __attribute__((unused)) struct cmdline *cl,
2862 __attribute__((unused)) void *data)
2865 struct cmd_vlan_offload_result *res = parsed_result;
2868 portid_t port_id = 0;
2872 len = strnlen(str, STR_TOKEN_SIZE);
2874 /* Get port_id first */
2882 tmp = strtoul(str, NULL, 0);
2883 /* If port_id greater that what portid_t can represent, return */
2884 if(tmp >= RTE_MAX_ETHPORTS)
2886 port_id = (portid_t)tmp;
2888 if (!strcmp(res->on, "on"))
2893 if (!strcmp(res->what, "strip"))
2894 rx_vlan_strip_set(port_id, on);
2895 else if(!strcmp(res->what, "stripq")){
2896 uint16_t queue_id = 0;
2898 /* No queue_id, return */
2900 printf("must specify (port,queue_id)\n");
2903 tmp = strtoul(str + i + 1, NULL, 0);
2904 /* If queue_id greater that what 16-bits can represent, return */
2908 queue_id = (uint16_t)tmp;
2909 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2911 else if (!strcmp(res->what, "filter"))
2912 rx_vlan_filter_set(port_id, on);
2914 vlan_extend_set(port_id, on);
2919 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2920 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2922 cmdline_parse_token_string_t cmd_vlan_offload_set =
2923 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2925 cmdline_parse_token_string_t cmd_vlan_offload_what =
2926 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2927 what, "strip#filter#qinq#stripq");
2928 cmdline_parse_token_string_t cmd_vlan_offload_on =
2929 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2931 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2932 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2935 cmdline_parse_inst_t cmd_vlan_offload = {
2936 .f = cmd_vlan_offload_parsed,
2938 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2939 " qinq(extended) for both rx/tx sides ",
2941 (void *)&cmd_vlan_offload_vlan,
2942 (void *)&cmd_vlan_offload_set,
2943 (void *)&cmd_vlan_offload_what,
2944 (void *)&cmd_vlan_offload_on,
2945 (void *)&cmd_vlan_offload_portid,
2950 /* *** VLAN TPID SET ON A PORT *** */
2951 struct cmd_vlan_tpid_result {
2952 cmdline_fixed_string_t vlan;
2953 cmdline_fixed_string_t set;
2954 cmdline_fixed_string_t vlan_type;
2955 cmdline_fixed_string_t what;
2961 cmd_vlan_tpid_parsed(void *parsed_result,
2962 __attribute__((unused)) struct cmdline *cl,
2963 __attribute__((unused)) void *data)
2965 struct cmd_vlan_tpid_result *res = parsed_result;
2966 enum rte_vlan_type vlan_type;
2968 if (!strcmp(res->vlan_type, "inner"))
2969 vlan_type = ETH_VLAN_TYPE_INNER;
2970 else if (!strcmp(res->vlan_type, "outer"))
2971 vlan_type = ETH_VLAN_TYPE_OUTER;
2973 printf("Unknown vlan type\n");
2976 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
2979 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2980 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2982 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2983 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2985 cmdline_parse_token_string_t cmd_vlan_type =
2986 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2987 vlan_type, "inner#outer");
2988 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2989 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2991 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2992 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2994 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2995 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2998 cmdline_parse_inst_t cmd_vlan_tpid = {
2999 .f = cmd_vlan_tpid_parsed,
3001 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
3004 (void *)&cmd_vlan_tpid_vlan,
3005 (void *)&cmd_vlan_tpid_set,
3006 (void *)&cmd_vlan_type,
3007 (void *)&cmd_vlan_tpid_what,
3008 (void *)&cmd_vlan_tpid_tpid,
3009 (void *)&cmd_vlan_tpid_portid,
3014 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3015 struct cmd_rx_vlan_filter_result {
3016 cmdline_fixed_string_t rx_vlan;
3017 cmdline_fixed_string_t what;
3023 cmd_rx_vlan_filter_parsed(void *parsed_result,
3024 __attribute__((unused)) struct cmdline *cl,
3025 __attribute__((unused)) void *data)
3027 struct cmd_rx_vlan_filter_result *res = parsed_result;
3029 if (!strcmp(res->what, "add"))
3030 rx_vft_set(res->port_id, res->vlan_id, 1);
3032 rx_vft_set(res->port_id, res->vlan_id, 0);
3035 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3036 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3037 rx_vlan, "rx_vlan");
3038 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3039 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3041 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3042 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3044 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3045 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3048 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3049 .f = cmd_rx_vlan_filter_parsed,
3051 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
3052 "Identifiers filtered by a port",
3054 (void *)&cmd_rx_vlan_filter_rx_vlan,
3055 (void *)&cmd_rx_vlan_filter_what,
3056 (void *)&cmd_rx_vlan_filter_vlanid,
3057 (void *)&cmd_rx_vlan_filter_portid,
3062 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3063 struct cmd_tx_vlan_set_result {
3064 cmdline_fixed_string_t tx_vlan;
3065 cmdline_fixed_string_t set;
3071 cmd_tx_vlan_set_parsed(void *parsed_result,
3072 __attribute__((unused)) struct cmdline *cl,
3073 __attribute__((unused)) void *data)
3075 struct cmd_tx_vlan_set_result *res = parsed_result;
3077 tx_vlan_set(res->port_id, res->vlan_id);
3080 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3081 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3082 tx_vlan, "tx_vlan");
3083 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3084 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3086 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3087 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3089 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3090 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3093 cmdline_parse_inst_t cmd_tx_vlan_set = {
3094 .f = cmd_tx_vlan_set_parsed,
3096 .help_str = "enable hardware insertion of a single VLAN header "
3097 "with a given TAG Identifier in packets sent on a port",
3099 (void *)&cmd_tx_vlan_set_tx_vlan,
3100 (void *)&cmd_tx_vlan_set_set,
3101 (void *)&cmd_tx_vlan_set_portid,
3102 (void *)&cmd_tx_vlan_set_vlanid,
3107 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3108 struct cmd_tx_vlan_set_qinq_result {
3109 cmdline_fixed_string_t tx_vlan;
3110 cmdline_fixed_string_t set;
3113 uint16_t vlan_id_outer;
3117 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3118 __attribute__((unused)) struct cmdline *cl,
3119 __attribute__((unused)) void *data)
3121 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3123 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3126 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3127 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3128 tx_vlan, "tx_vlan");
3129 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3130 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3132 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3133 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3135 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3136 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3138 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3139 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3140 vlan_id_outer, UINT16);
3142 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3143 .f = cmd_tx_vlan_set_qinq_parsed,
3145 .help_str = "enable hardware insertion of double VLAN header "
3146 "with given TAG Identifiers in packets sent on a port",
3148 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3149 (void *)&cmd_tx_vlan_set_qinq_set,
3150 (void *)&cmd_tx_vlan_set_qinq_portid,
3151 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3152 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3157 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3158 struct cmd_tx_vlan_set_pvid_result {
3159 cmdline_fixed_string_t tx_vlan;
3160 cmdline_fixed_string_t set;
3161 cmdline_fixed_string_t pvid;
3164 cmdline_fixed_string_t mode;
3168 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3169 __attribute__((unused)) struct cmdline *cl,
3170 __attribute__((unused)) void *data)
3172 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3174 if (strcmp(res->mode, "on") == 0)
3175 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3177 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3180 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3181 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3182 tx_vlan, "tx_vlan");
3183 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3184 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3186 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3187 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3189 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3190 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3192 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3193 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3195 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3196 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3199 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3200 .f = cmd_tx_vlan_set_pvid_parsed,
3202 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3204 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3205 (void *)&cmd_tx_vlan_set_pvid_set,
3206 (void *)&cmd_tx_vlan_set_pvid_pvid,
3207 (void *)&cmd_tx_vlan_set_pvid_port_id,
3208 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3209 (void *)&cmd_tx_vlan_set_pvid_mode,
3214 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3215 struct cmd_tx_vlan_reset_result {
3216 cmdline_fixed_string_t tx_vlan;
3217 cmdline_fixed_string_t reset;
3222 cmd_tx_vlan_reset_parsed(void *parsed_result,
3223 __attribute__((unused)) struct cmdline *cl,
3224 __attribute__((unused)) void *data)
3226 struct cmd_tx_vlan_reset_result *res = parsed_result;
3228 tx_vlan_reset(res->port_id);
3231 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3232 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3233 tx_vlan, "tx_vlan");
3234 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3235 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3237 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3238 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3241 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3242 .f = cmd_tx_vlan_reset_parsed,
3244 .help_str = "disable hardware insertion of a VLAN header in packets "
3247 (void *)&cmd_tx_vlan_reset_tx_vlan,
3248 (void *)&cmd_tx_vlan_reset_reset,
3249 (void *)&cmd_tx_vlan_reset_portid,
3255 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3256 struct cmd_csum_result {
3257 cmdline_fixed_string_t csum;
3258 cmdline_fixed_string_t mode;
3259 cmdline_fixed_string_t proto;
3260 cmdline_fixed_string_t hwsw;
3265 csum_show(int port_id)
3267 struct rte_eth_dev_info dev_info;
3270 ol_flags = ports[port_id].tx_ol_flags;
3271 printf("Parse tunnel is %s\n",
3272 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3273 printf("IP checksum offload is %s\n",
3274 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3275 printf("UDP checksum offload is %s\n",
3276 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3277 printf("TCP checksum offload is %s\n",
3278 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3279 printf("SCTP checksum offload is %s\n",
3280 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3281 printf("Outer-Ip checksum offload is %s\n",
3282 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3284 /* display warnings if configuration is not supported by the NIC */
3285 rte_eth_dev_info_get(port_id, &dev_info);
3286 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3287 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3288 printf("Warning: hardware IP checksum enabled but not "
3289 "supported by port %d\n", port_id);
3291 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3292 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3293 printf("Warning: hardware UDP checksum enabled but not "
3294 "supported by port %d\n", port_id);
3296 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3297 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3298 printf("Warning: hardware TCP checksum enabled but not "
3299 "supported by port %d\n", port_id);
3301 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3302 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3303 printf("Warning: hardware SCTP checksum enabled but not "
3304 "supported by port %d\n", port_id);
3306 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3307 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3308 printf("Warning: hardware outer IP checksum enabled but not "
3309 "supported by port %d\n", port_id);
3314 cmd_csum_parsed(void *parsed_result,
3315 __attribute__((unused)) struct cmdline *cl,
3316 __attribute__((unused)) void *data)
3318 struct cmd_csum_result *res = parsed_result;
3322 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3323 printf("invalid port %d\n", res->port_id);
3327 if (!strcmp(res->mode, "set")) {
3329 if (!strcmp(res->hwsw, "hw"))
3332 if (!strcmp(res->proto, "ip")) {
3333 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3334 } else if (!strcmp(res->proto, "udp")) {
3335 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3336 } else if (!strcmp(res->proto, "tcp")) {
3337 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3338 } else if (!strcmp(res->proto, "sctp")) {
3339 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3340 } else if (!strcmp(res->proto, "outer-ip")) {
3341 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3345 ports[res->port_id].tx_ol_flags |= mask;
3347 ports[res->port_id].tx_ol_flags &= (~mask);
3349 csum_show(res->port_id);
3352 cmdline_parse_token_string_t cmd_csum_csum =
3353 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3355 cmdline_parse_token_string_t cmd_csum_mode =
3356 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3358 cmdline_parse_token_string_t cmd_csum_proto =
3359 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3360 proto, "ip#tcp#udp#sctp#outer-ip");
3361 cmdline_parse_token_string_t cmd_csum_hwsw =
3362 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3364 cmdline_parse_token_num_t cmd_csum_portid =
3365 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3368 cmdline_parse_inst_t cmd_csum_set = {
3369 .f = cmd_csum_parsed,
3371 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3372 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3374 (void *)&cmd_csum_csum,
3375 (void *)&cmd_csum_mode,
3376 (void *)&cmd_csum_proto,
3377 (void *)&cmd_csum_hwsw,
3378 (void *)&cmd_csum_portid,
3383 cmdline_parse_token_string_t cmd_csum_mode_show =
3384 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3387 cmdline_parse_inst_t cmd_csum_show = {
3388 .f = cmd_csum_parsed,
3390 .help_str = "show checksum offload configuration: csum show <port>",
3392 (void *)&cmd_csum_csum,
3393 (void *)&cmd_csum_mode_show,
3394 (void *)&cmd_csum_portid,
3399 /* Enable/disable tunnel parsing */
3400 struct cmd_csum_tunnel_result {
3401 cmdline_fixed_string_t csum;
3402 cmdline_fixed_string_t parse;
3403 cmdline_fixed_string_t onoff;
3408 cmd_csum_tunnel_parsed(void *parsed_result,
3409 __attribute__((unused)) struct cmdline *cl,
3410 __attribute__((unused)) void *data)
3412 struct cmd_csum_tunnel_result *res = parsed_result;
3414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3417 if (!strcmp(res->onoff, "on"))
3418 ports[res->port_id].tx_ol_flags |=
3419 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3421 ports[res->port_id].tx_ol_flags &=
3422 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3424 csum_show(res->port_id);
3427 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3428 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3430 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3431 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3432 parse, "parse_tunnel");
3433 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3434 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3436 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3437 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3440 cmdline_parse_inst_t cmd_csum_tunnel = {
3441 .f = cmd_csum_tunnel_parsed,
3443 .help_str = "enable/disable parsing of tunnels for csum engine: "
3444 "csum parse_tunnel on|off <tx-port>",
3446 (void *)&cmd_csum_tunnel_csum,
3447 (void *)&cmd_csum_tunnel_parse,
3448 (void *)&cmd_csum_tunnel_onoff,
3449 (void *)&cmd_csum_tunnel_portid,
3454 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3455 struct cmd_tso_set_result {
3456 cmdline_fixed_string_t tso;
3457 cmdline_fixed_string_t mode;
3463 cmd_tso_set_parsed(void *parsed_result,
3464 __attribute__((unused)) struct cmdline *cl,
3465 __attribute__((unused)) void *data)
3467 struct cmd_tso_set_result *res = parsed_result;
3468 struct rte_eth_dev_info dev_info;
3470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3473 if (!strcmp(res->mode, "set"))
3474 ports[res->port_id].tso_segsz = res->tso_segsz;
3476 if (ports[res->port_id].tso_segsz == 0)
3477 printf("TSO is disabled\n");
3479 printf("TSO segment size is %d\n",
3480 ports[res->port_id].tso_segsz);
3482 /* display warnings if configuration is not supported by the NIC */
3483 rte_eth_dev_info_get(res->port_id, &dev_info);
3484 if ((ports[res->port_id].tso_segsz != 0) &&
3485 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3486 printf("Warning: TSO enabled but not "
3487 "supported by port %d\n", res->port_id);
3491 cmdline_parse_token_string_t cmd_tso_set_tso =
3492 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3494 cmdline_parse_token_string_t cmd_tso_set_mode =
3495 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3497 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3498 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3500 cmdline_parse_token_num_t cmd_tso_set_portid =
3501 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3504 cmdline_parse_inst_t cmd_tso_set = {
3505 .f = cmd_tso_set_parsed,
3507 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3508 "tso set <tso_segsz> <port>",
3510 (void *)&cmd_tso_set_tso,
3511 (void *)&cmd_tso_set_mode,
3512 (void *)&cmd_tso_set_tso_segsz,
3513 (void *)&cmd_tso_set_portid,
3518 cmdline_parse_token_string_t cmd_tso_show_mode =
3519 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3523 cmdline_parse_inst_t cmd_tso_show = {
3524 .f = cmd_tso_set_parsed,
3526 .help_str = "Show TSO segment size for csum engine: "
3529 (void *)&cmd_tso_set_tso,
3530 (void *)&cmd_tso_show_mode,
3531 (void *)&cmd_tso_set_portid,
3536 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3537 struct cmd_set_flush_rx {
3538 cmdline_fixed_string_t set;
3539 cmdline_fixed_string_t flush_rx;
3540 cmdline_fixed_string_t mode;
3544 cmd_set_flush_rx_parsed(void *parsed_result,
3545 __attribute__((unused)) struct cmdline *cl,
3546 __attribute__((unused)) void *data)
3548 struct cmd_set_flush_rx *res = parsed_result;
3549 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3552 cmdline_parse_token_string_t cmd_setflushrx_set =
3553 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3555 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3556 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3557 flush_rx, "flush_rx");
3558 cmdline_parse_token_string_t cmd_setflushrx_mode =
3559 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3563 cmdline_parse_inst_t cmd_set_flush_rx = {
3564 .f = cmd_set_flush_rx_parsed,
3565 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3568 (void *)&cmd_setflushrx_set,
3569 (void *)&cmd_setflushrx_flush_rx,
3570 (void *)&cmd_setflushrx_mode,
3575 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3576 struct cmd_set_link_check {
3577 cmdline_fixed_string_t set;
3578 cmdline_fixed_string_t link_check;
3579 cmdline_fixed_string_t mode;
3583 cmd_set_link_check_parsed(void *parsed_result,
3584 __attribute__((unused)) struct cmdline *cl,
3585 __attribute__((unused)) void *data)
3587 struct cmd_set_link_check *res = parsed_result;
3588 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3591 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3592 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3594 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3595 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3596 link_check, "link_check");
3597 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3598 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3602 cmdline_parse_inst_t cmd_set_link_check = {
3603 .f = cmd_set_link_check_parsed,
3604 .help_str = "set link_check on|off: enable/disable link status check "
3605 "when starting/stopping a port",
3608 (void *)&cmd_setlinkcheck_set,
3609 (void *)&cmd_setlinkcheck_link_check,
3610 (void *)&cmd_setlinkcheck_mode,
3615 #ifdef RTE_NIC_BYPASS
3616 /* *** SET NIC BYPASS MODE *** */
3617 struct cmd_set_bypass_mode_result {
3618 cmdline_fixed_string_t set;
3619 cmdline_fixed_string_t bypass;
3620 cmdline_fixed_string_t mode;
3621 cmdline_fixed_string_t value;
3626 cmd_set_bypass_mode_parsed(void *parsed_result,
3627 __attribute__((unused)) struct cmdline *cl,
3628 __attribute__((unused)) void *data)
3630 struct cmd_set_bypass_mode_result *res = parsed_result;
3631 portid_t port_id = res->port_id;
3632 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3634 if (!bypass_is_supported(port_id))
3637 if (!strcmp(res->value, "bypass"))
3638 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3639 else if (!strcmp(res->value, "isolate"))
3640 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3642 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3644 /* Set the bypass mode for the relevant port. */
3645 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3646 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3650 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3651 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3653 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3654 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3656 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3657 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3659 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3660 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3661 value, "normal#bypass#isolate");
3662 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3663 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3666 cmdline_parse_inst_t cmd_set_bypass_mode = {
3667 .f = cmd_set_bypass_mode_parsed,
3668 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3669 "Set the NIC bypass mode for port_id",
3672 (void *)&cmd_setbypass_mode_set,
3673 (void *)&cmd_setbypass_mode_bypass,
3674 (void *)&cmd_setbypass_mode_mode,
3675 (void *)&cmd_setbypass_mode_value,
3676 (void *)&cmd_setbypass_mode_port,
3681 /* *** SET NIC BYPASS EVENT *** */
3682 struct cmd_set_bypass_event_result {
3683 cmdline_fixed_string_t set;
3684 cmdline_fixed_string_t bypass;
3685 cmdline_fixed_string_t event;
3686 cmdline_fixed_string_t event_value;
3687 cmdline_fixed_string_t mode;
3688 cmdline_fixed_string_t mode_value;
3693 cmd_set_bypass_event_parsed(void *parsed_result,
3694 __attribute__((unused)) struct cmdline *cl,
3695 __attribute__((unused)) void *data)
3698 struct cmd_set_bypass_event_result *res = parsed_result;
3699 portid_t port_id = res->port_id;
3700 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3701 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3703 if (!bypass_is_supported(port_id))
3706 if (!strcmp(res->event_value, "timeout"))
3707 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3708 else if (!strcmp(res->event_value, "os_on"))
3709 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3710 else if (!strcmp(res->event_value, "os_off"))
3711 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3712 else if (!strcmp(res->event_value, "power_on"))
3713 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3714 else if (!strcmp(res->event_value, "power_off"))
3715 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3717 bypass_event = RTE_BYPASS_EVENT_NONE;
3719 if (!strcmp(res->mode_value, "bypass"))
3720 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3721 else if (!strcmp(res->mode_value, "isolate"))
3722 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3724 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3726 /* Set the watchdog timeout. */
3727 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3730 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3731 (rc = rte_eth_dev_wd_timeout_store(port_id,
3732 bypass_timeout)) != 0) {
3733 printf("Failed to set timeout value %u "
3734 "for port %d, errto code: %d.\n",
3735 bypass_timeout, port_id, rc);
3739 /* Set the bypass event to transition to bypass mode. */
3740 if (0 != rte_eth_dev_bypass_event_store(port_id,
3741 bypass_event, bypass_mode)) {
3742 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3747 cmdline_parse_token_string_t cmd_setbypass_event_set =
3748 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3750 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3753 cmdline_parse_token_string_t cmd_setbypass_event_event =
3754 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3756 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3758 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3759 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3760 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3762 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3763 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3764 mode_value, "normal#bypass#isolate");
3765 cmdline_parse_token_num_t cmd_setbypass_event_port =
3766 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3769 cmdline_parse_inst_t cmd_set_bypass_event = {
3770 .f = cmd_set_bypass_event_parsed,
3771 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3772 "mode (normal|bypass|isolate) (port_id): "
3773 "Set the NIC bypass event mode for port_id",
3776 (void *)&cmd_setbypass_event_set,
3777 (void *)&cmd_setbypass_event_bypass,
3778 (void *)&cmd_setbypass_event_event,
3779 (void *)&cmd_setbypass_event_event_value,
3780 (void *)&cmd_setbypass_event_mode,
3781 (void *)&cmd_setbypass_event_mode_value,
3782 (void *)&cmd_setbypass_event_port,
3788 /* *** SET NIC BYPASS TIMEOUT *** */
3789 struct cmd_set_bypass_timeout_result {
3790 cmdline_fixed_string_t set;
3791 cmdline_fixed_string_t bypass;
3792 cmdline_fixed_string_t timeout;
3793 cmdline_fixed_string_t value;
3797 cmd_set_bypass_timeout_parsed(void *parsed_result,
3798 __attribute__((unused)) struct cmdline *cl,
3799 __attribute__((unused)) void *data)
3801 struct cmd_set_bypass_timeout_result *res = parsed_result;
3803 if (!strcmp(res->value, "1.5"))
3804 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3805 else if (!strcmp(res->value, "2"))
3806 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3807 else if (!strcmp(res->value, "3"))
3808 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3809 else if (!strcmp(res->value, "4"))
3810 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3811 else if (!strcmp(res->value, "8"))
3812 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3813 else if (!strcmp(res->value, "16"))
3814 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3815 else if (!strcmp(res->value, "32"))
3816 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3818 bypass_timeout = RTE_BYPASS_TMT_OFF;
3821 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3824 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3827 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3829 timeout, "timeout");
3830 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3832 value, "0#1.5#2#3#4#8#16#32");
3834 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3835 .f = cmd_set_bypass_timeout_parsed,
3836 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3837 "Set the NIC bypass watchdog timeout",
3840 (void *)&cmd_setbypass_timeout_set,
3841 (void *)&cmd_setbypass_timeout_bypass,
3842 (void *)&cmd_setbypass_timeout_timeout,
3843 (void *)&cmd_setbypass_timeout_value,
3848 /* *** SHOW NIC BYPASS MODE *** */
3849 struct cmd_show_bypass_config_result {
3850 cmdline_fixed_string_t show;
3851 cmdline_fixed_string_t bypass;
3852 cmdline_fixed_string_t config;
3857 cmd_show_bypass_config_parsed(void *parsed_result,
3858 __attribute__((unused)) struct cmdline *cl,
3859 __attribute__((unused)) void *data)
3861 struct cmd_show_bypass_config_result *res = parsed_result;
3862 uint32_t event_mode;
3863 uint32_t bypass_mode;
3864 portid_t port_id = res->port_id;
3865 uint32_t timeout = bypass_timeout;
3868 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3869 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3870 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3871 {"UNKNOWN", "normal", "bypass", "isolate"};
3872 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3879 int num_events = (sizeof events) / (sizeof events[0]);
3881 if (!bypass_is_supported(port_id))
3884 /* Display the bypass mode.*/
3885 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3886 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3890 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3891 bypass_mode = RTE_BYPASS_MODE_NONE;
3893 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3896 /* Display the bypass timeout.*/
3897 if (!RTE_BYPASS_TMT_VALID(timeout))
3898 timeout = RTE_BYPASS_TMT_OFF;
3900 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3902 /* Display the bypass events and associated modes. */
3903 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3905 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3906 printf("\tFailed to get bypass mode for event = %s\n",
3909 if (!RTE_BYPASS_MODE_VALID(event_mode))
3910 event_mode = RTE_BYPASS_MODE_NONE;
3912 printf("\tbypass event: %-16s = %s\n", events[i],
3918 cmdline_parse_token_string_t cmd_showbypass_config_show =
3919 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3921 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3922 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3924 cmdline_parse_token_string_t cmd_showbypass_config_config =
3925 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3927 cmdline_parse_token_num_t cmd_showbypass_config_port =
3928 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3931 cmdline_parse_inst_t cmd_show_bypass_config = {
3932 .f = cmd_show_bypass_config_parsed,
3933 .help_str = "show bypass config (port_id): "
3934 "Show the NIC bypass config for port_id",
3937 (void *)&cmd_showbypass_config_show,
3938 (void *)&cmd_showbypass_config_bypass,
3939 (void *)&cmd_showbypass_config_config,
3940 (void *)&cmd_showbypass_config_port,
3946 #ifdef RTE_LIBRTE_PMD_BOND
3947 /* *** SET BONDING MODE *** */
3948 struct cmd_set_bonding_mode_result {
3949 cmdline_fixed_string_t set;
3950 cmdline_fixed_string_t bonding;
3951 cmdline_fixed_string_t mode;
3956 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3957 __attribute__((unused)) struct cmdline *cl,
3958 __attribute__((unused)) void *data)
3960 struct cmd_set_bonding_mode_result *res = parsed_result;
3961 portid_t port_id = res->port_id;
3963 /* Set the bonding mode for the relevant port. */
3964 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3965 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3968 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3971 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3973 bonding, "bonding");
3974 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3977 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3978 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3980 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3981 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3984 cmdline_parse_inst_t cmd_set_bonding_mode = {
3985 .f = cmd_set_bonding_mode_parsed,
3986 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3989 (void *) &cmd_setbonding_mode_set,
3990 (void *) &cmd_setbonding_mode_bonding,
3991 (void *) &cmd_setbonding_mode_mode,
3992 (void *) &cmd_setbonding_mode_value,
3993 (void *) &cmd_setbonding_mode_port,
3998 /* *** SET BALANCE XMIT POLICY *** */
3999 struct cmd_set_bonding_balance_xmit_policy_result {
4000 cmdline_fixed_string_t set;
4001 cmdline_fixed_string_t bonding;
4002 cmdline_fixed_string_t balance_xmit_policy;
4004 cmdline_fixed_string_t policy;
4007 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4008 __attribute__((unused)) struct cmdline *cl,
4009 __attribute__((unused)) void *data)
4011 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4012 portid_t port_id = res->port_id;
4015 if (!strcmp(res->policy, "l2")) {
4016 policy = BALANCE_XMIT_POLICY_LAYER2;
4017 } else if (!strcmp(res->policy, "l23")) {
4018 policy = BALANCE_XMIT_POLICY_LAYER23;
4019 } else if (!strcmp(res->policy, "l34")) {
4020 policy = BALANCE_XMIT_POLICY_LAYER34;
4022 printf("\t Invalid xmit policy selection");
4026 /* Set the bonding mode for the relevant port. */
4027 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4028 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4033 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4036 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4038 bonding, "bonding");
4039 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4041 balance_xmit_policy, "balance_xmit_policy");
4042 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4043 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4045 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4047 policy, "l2#l23#l34");
4049 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4050 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4051 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
4054 (void *)&cmd_setbonding_balance_xmit_policy_set,
4055 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4056 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4057 (void *)&cmd_setbonding_balance_xmit_policy_port,
4058 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4063 /* *** SHOW NIC BONDING CONFIGURATION *** */
4064 struct cmd_show_bonding_config_result {
4065 cmdline_fixed_string_t show;
4066 cmdline_fixed_string_t bonding;
4067 cmdline_fixed_string_t config;
4071 static void cmd_show_bonding_config_parsed(void *parsed_result,
4072 __attribute__((unused)) struct cmdline *cl,
4073 __attribute__((unused)) void *data)
4075 struct cmd_show_bonding_config_result *res = parsed_result;
4077 uint8_t slaves[RTE_MAX_ETHPORTS];
4078 int num_slaves, num_active_slaves;
4081 portid_t port_id = res->port_id;
4083 /* Display the bonding mode.*/
4084 bonding_mode = rte_eth_bond_mode_get(port_id);
4085 if (bonding_mode < 0) {
4086 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4089 printf("\tBonding mode: %d\n", bonding_mode);
4091 if (bonding_mode == BONDING_MODE_BALANCE) {
4092 int balance_xmit_policy;
4094 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4095 if (balance_xmit_policy < 0) {
4096 printf("\tFailed to get balance xmit policy for port = %d\n",
4100 printf("\tBalance Xmit Policy: ");
4102 switch (balance_xmit_policy) {
4103 case BALANCE_XMIT_POLICY_LAYER2:
4104 printf("BALANCE_XMIT_POLICY_LAYER2");
4106 case BALANCE_XMIT_POLICY_LAYER23:
4107 printf("BALANCE_XMIT_POLICY_LAYER23");
4109 case BALANCE_XMIT_POLICY_LAYER34:
4110 printf("BALANCE_XMIT_POLICY_LAYER34");
4117 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4119 if (num_slaves < 0) {
4120 printf("\tFailed to get slave list for port = %d\n", port_id);
4123 if (num_slaves > 0) {
4124 printf("\tSlaves (%d): [", num_slaves);
4125 for (i = 0; i < num_slaves - 1; i++)
4126 printf("%d ", slaves[i]);
4128 printf("%d]\n", slaves[num_slaves - 1]);
4130 printf("\tSlaves: []\n");
4134 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4137 if (num_active_slaves < 0) {
4138 printf("\tFailed to get active slave list for port = %d\n", port_id);
4141 if (num_active_slaves > 0) {
4142 printf("\tActive Slaves (%d): [", num_active_slaves);
4143 for (i = 0; i < num_active_slaves - 1; i++)
4144 printf("%d ", slaves[i]);
4146 printf("%d]\n", slaves[num_active_slaves - 1]);
4149 printf("\tActive Slaves: []\n");
4153 primary_id = rte_eth_bond_primary_get(port_id);
4154 if (primary_id < 0) {
4155 printf("\tFailed to get primary slave for port = %d\n", port_id);
4158 printf("\tPrimary: [%d]\n", primary_id);
4162 cmdline_parse_token_string_t cmd_showbonding_config_show =
4163 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4165 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4166 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4167 bonding, "bonding");
4168 cmdline_parse_token_string_t cmd_showbonding_config_config =
4169 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4171 cmdline_parse_token_num_t cmd_showbonding_config_port =
4172 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4175 cmdline_parse_inst_t cmd_show_bonding_config = {
4176 .f = cmd_show_bonding_config_parsed,
4177 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4180 (void *)&cmd_showbonding_config_show,
4181 (void *)&cmd_showbonding_config_bonding,
4182 (void *)&cmd_showbonding_config_config,
4183 (void *)&cmd_showbonding_config_port,
4188 /* *** SET BONDING PRIMARY *** */
4189 struct cmd_set_bonding_primary_result {
4190 cmdline_fixed_string_t set;
4191 cmdline_fixed_string_t bonding;
4192 cmdline_fixed_string_t primary;
4197 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4198 __attribute__((unused)) struct cmdline *cl,
4199 __attribute__((unused)) void *data)
4201 struct cmd_set_bonding_primary_result *res = parsed_result;
4202 portid_t master_port_id = res->port_id;
4203 portid_t slave_port_id = res->slave_id;
4205 /* Set the primary slave for a bonded device. */
4206 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4207 printf("\t Failed to set primary slave for port = %d.\n",
4214 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4215 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4217 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4218 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4219 bonding, "bonding");
4220 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4221 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4222 primary, "primary");
4223 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4224 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4226 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4227 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4230 cmdline_parse_inst_t cmd_set_bonding_primary = {
4231 .f = cmd_set_bonding_primary_parsed,
4232 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4235 (void *)&cmd_setbonding_primary_set,
4236 (void *)&cmd_setbonding_primary_bonding,
4237 (void *)&cmd_setbonding_primary_primary,
4238 (void *)&cmd_setbonding_primary_slave,
4239 (void *)&cmd_setbonding_primary_port,
4244 /* *** ADD SLAVE *** */
4245 struct cmd_add_bonding_slave_result {
4246 cmdline_fixed_string_t add;
4247 cmdline_fixed_string_t bonding;
4248 cmdline_fixed_string_t slave;
4253 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4254 __attribute__((unused)) struct cmdline *cl,
4255 __attribute__((unused)) void *data)
4257 struct cmd_add_bonding_slave_result *res = parsed_result;
4258 portid_t master_port_id = res->port_id;
4259 portid_t slave_port_id = res->slave_id;
4261 /* Set the primary slave for a bonded device. */
4262 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4263 printf("\t Failed to add slave %d to master port = %d.\n",
4264 slave_port_id, master_port_id);
4268 set_port_slave_flag(slave_port_id);
4271 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4272 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4274 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4275 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4276 bonding, "bonding");
4277 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4278 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4280 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4281 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4283 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4284 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4287 cmdline_parse_inst_t cmd_add_bonding_slave = {
4288 .f = cmd_add_bonding_slave_parsed,
4289 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4292 (void *)&cmd_addbonding_slave_add,
4293 (void *)&cmd_addbonding_slave_bonding,
4294 (void *)&cmd_addbonding_slave_slave,
4295 (void *)&cmd_addbonding_slave_slaveid,
4296 (void *)&cmd_addbonding_slave_port,
4301 /* *** REMOVE SLAVE *** */
4302 struct cmd_remove_bonding_slave_result {
4303 cmdline_fixed_string_t remove;
4304 cmdline_fixed_string_t bonding;
4305 cmdline_fixed_string_t slave;
4310 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4311 __attribute__((unused)) struct cmdline *cl,
4312 __attribute__((unused)) void *data)
4314 struct cmd_remove_bonding_slave_result *res = parsed_result;
4315 portid_t master_port_id = res->port_id;
4316 portid_t slave_port_id = res->slave_id;
4318 /* Set the primary slave for a bonded device. */
4319 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4320 printf("\t Failed to remove slave %d from master port = %d.\n",
4321 slave_port_id, master_port_id);
4325 clear_port_slave_flag(slave_port_id);
4328 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4329 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4331 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4332 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4333 bonding, "bonding");
4334 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4335 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4337 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4338 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4340 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4341 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4344 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4345 .f = cmd_remove_bonding_slave_parsed,
4346 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4349 (void *)&cmd_removebonding_slave_remove,
4350 (void *)&cmd_removebonding_slave_bonding,
4351 (void *)&cmd_removebonding_slave_slave,
4352 (void *)&cmd_removebonding_slave_slaveid,
4353 (void *)&cmd_removebonding_slave_port,
4358 /* *** CREATE BONDED DEVICE *** */
4359 struct cmd_create_bonded_device_result {
4360 cmdline_fixed_string_t create;
4361 cmdline_fixed_string_t bonded;
4362 cmdline_fixed_string_t device;
4367 static int bond_dev_num = 0;
4369 static void cmd_create_bonded_device_parsed(void *parsed_result,
4370 __attribute__((unused)) struct cmdline *cl,
4371 __attribute__((unused)) void *data)
4373 struct cmd_create_bonded_device_result *res = parsed_result;
4374 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4377 if (test_done == 0) {
4378 printf("Please stop forwarding first\n");
4382 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4385 /* Create a new bonded device. */
4386 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4388 printf("\t Failed to create bonded device.\n");
4391 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4394 /* Update number of ports */
4395 nb_ports = rte_eth_dev_count();
4396 reconfig(port_id, res->socket);
4397 rte_eth_promiscuous_enable(port_id);
4398 ports[port_id].enabled = 1;
4403 cmdline_parse_token_string_t cmd_createbonded_device_create =
4404 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4406 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4407 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4409 cmdline_parse_token_string_t cmd_createbonded_device_device =
4410 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4412 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4413 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4415 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4416 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4419 cmdline_parse_inst_t cmd_create_bonded_device = {
4420 .f = cmd_create_bonded_device_parsed,
4421 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4424 (void *)&cmd_createbonded_device_create,
4425 (void *)&cmd_createbonded_device_bonded,
4426 (void *)&cmd_createbonded_device_device,
4427 (void *)&cmd_createbonded_device_mode,
4428 (void *)&cmd_createbonded_device_socket,
4433 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4434 struct cmd_set_bond_mac_addr_result {
4435 cmdline_fixed_string_t set;
4436 cmdline_fixed_string_t bonding;
4437 cmdline_fixed_string_t mac_addr;
4439 struct ether_addr address;
4442 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4443 __attribute__((unused)) struct cmdline *cl,
4444 __attribute__((unused)) void *data)
4446 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4449 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4452 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4454 /* check the return value and print it if is < 0 */
4456 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4459 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4460 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4461 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4462 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4464 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4467 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4468 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4469 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4470 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4472 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4473 .f = cmd_set_bond_mac_addr_parsed,
4475 .help_str = "set bonding mac_addr (port_id) (address): ",
4477 (void *)&cmd_set_bond_mac_addr_set,
4478 (void *)&cmd_set_bond_mac_addr_bonding,
4479 (void *)&cmd_set_bond_mac_addr_mac,
4480 (void *)&cmd_set_bond_mac_addr_portnum,
4481 (void *)&cmd_set_bond_mac_addr_addr,
4487 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4488 struct cmd_set_bond_mon_period_result {
4489 cmdline_fixed_string_t set;
4490 cmdline_fixed_string_t bonding;
4491 cmdline_fixed_string_t mon_period;
4496 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4497 __attribute__((unused)) struct cmdline *cl,
4498 __attribute__((unused)) void *data)
4500 struct cmd_set_bond_mon_period_result *res = parsed_result;
4503 if (res->port_num >= nb_ports) {
4504 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4508 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4510 /* check the return value and print it if is < 0 */
4512 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4515 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4516 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4518 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4519 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4520 bonding, "bonding");
4521 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4522 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4523 mon_period, "mon_period");
4524 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4525 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4527 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4528 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4531 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4532 .f = cmd_set_bond_mon_period_parsed,
4534 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4536 (void *)&cmd_set_bond_mon_period_set,
4537 (void *)&cmd_set_bond_mon_period_bonding,
4538 (void *)&cmd_set_bond_mon_period_mon_period,
4539 (void *)&cmd_set_bond_mon_period_portnum,
4540 (void *)&cmd_set_bond_mon_period_period_ms,
4545 #endif /* RTE_LIBRTE_PMD_BOND */
4547 /* *** SET FORWARDING MODE *** */
4548 struct cmd_set_fwd_mode_result {
4549 cmdline_fixed_string_t set;
4550 cmdline_fixed_string_t fwd;
4551 cmdline_fixed_string_t mode;
4554 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4555 __attribute__((unused)) struct cmdline *cl,
4556 __attribute__((unused)) void *data)
4558 struct cmd_set_fwd_mode_result *res = parsed_result;
4560 set_pkt_forwarding_mode(res->mode);
4563 cmdline_parse_token_string_t cmd_setfwd_set =
4564 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4565 cmdline_parse_token_string_t cmd_setfwd_fwd =
4566 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4567 cmdline_parse_token_string_t cmd_setfwd_mode =
4568 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4569 "" /* defined at init */);
4571 cmdline_parse_inst_t cmd_set_fwd_mode = {
4572 .f = cmd_set_fwd_mode_parsed,
4574 .help_str = NULL, /* defined at init */
4576 (void *)&cmd_setfwd_set,
4577 (void *)&cmd_setfwd_fwd,
4578 (void *)&cmd_setfwd_mode,
4583 static void cmd_set_fwd_mode_init(void)
4586 static char token[128];
4587 static char help[256];
4588 cmdline_parse_token_string_t *token_struct;
4590 modes = list_pkt_forwarding_modes();
4591 snprintf(help, sizeof help, "set fwd %s - "
4592 "set packet forwarding mode", modes);
4593 cmd_set_fwd_mode.help_str = help;
4595 /* string token separator is # */
4596 for (c = token; *modes != '\0'; modes++)
4601 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4602 token_struct->string_data.str = token;
4605 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4606 struct cmd_set_burst_tx_retry_result {
4607 cmdline_fixed_string_t set;
4608 cmdline_fixed_string_t burst;
4609 cmdline_fixed_string_t tx;
4610 cmdline_fixed_string_t delay;
4612 cmdline_fixed_string_t retry;
4616 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4617 __attribute__((unused)) struct cmdline *cl,
4618 __attribute__((unused)) void *data)
4620 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4622 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4623 && !strcmp(res->tx, "tx")) {
4624 if (!strcmp(res->delay, "delay"))
4625 burst_tx_delay_time = res->time;
4626 if (!strcmp(res->retry, "retry"))
4627 burst_tx_retry_num = res->retry_num;
4632 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4633 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4634 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4635 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4637 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4639 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4640 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4641 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4642 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4643 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4645 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4646 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4648 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4649 .f = cmd_set_burst_tx_retry_parsed,
4650 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4652 (void *)&cmd_set_burst_tx_retry_set,
4653 (void *)&cmd_set_burst_tx_retry_burst,
4654 (void *)&cmd_set_burst_tx_retry_tx,
4655 (void *)&cmd_set_burst_tx_retry_delay,
4656 (void *)&cmd_set_burst_tx_retry_time,
4657 (void *)&cmd_set_burst_tx_retry_retry,
4658 (void *)&cmd_set_burst_tx_retry_retry_num,
4663 /* *** SET PROMISC MODE *** */
4664 struct cmd_set_promisc_mode_result {
4665 cmdline_fixed_string_t set;
4666 cmdline_fixed_string_t promisc;
4667 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4668 uint8_t port_num; /* valid if "allports" argument == 0 */
4669 cmdline_fixed_string_t mode;
4672 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4673 __attribute__((unused)) struct cmdline *cl,
4676 struct cmd_set_promisc_mode_result *res = parsed_result;
4680 if (!strcmp(res->mode, "on"))
4687 FOREACH_PORT(i, ports) {
4689 rte_eth_promiscuous_enable(i);
4691 rte_eth_promiscuous_disable(i);
4696 rte_eth_promiscuous_enable(res->port_num);
4698 rte_eth_promiscuous_disable(res->port_num);
4702 cmdline_parse_token_string_t cmd_setpromisc_set =
4703 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4704 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4705 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4707 cmdline_parse_token_string_t cmd_setpromisc_portall =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4710 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4711 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4713 cmdline_parse_token_string_t cmd_setpromisc_mode =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4717 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4718 .f = cmd_set_promisc_mode_parsed,
4720 .help_str = "set promisc all on|off: set promisc mode for all ports",
4722 (void *)&cmd_setpromisc_set,
4723 (void *)&cmd_setpromisc_promisc,
4724 (void *)&cmd_setpromisc_portall,
4725 (void *)&cmd_setpromisc_mode,
4730 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4731 .f = cmd_set_promisc_mode_parsed,
4733 .help_str = "set promisc X on|off: set promisc mode on port X",
4735 (void *)&cmd_setpromisc_set,
4736 (void *)&cmd_setpromisc_promisc,
4737 (void *)&cmd_setpromisc_portnum,
4738 (void *)&cmd_setpromisc_mode,
4743 /* *** SET ALLMULTI MODE *** */
4744 struct cmd_set_allmulti_mode_result {
4745 cmdline_fixed_string_t set;
4746 cmdline_fixed_string_t allmulti;
4747 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4748 uint8_t port_num; /* valid if "allports" argument == 0 */
4749 cmdline_fixed_string_t mode;
4752 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4753 __attribute__((unused)) struct cmdline *cl,
4756 struct cmd_set_allmulti_mode_result *res = parsed_result;
4760 if (!strcmp(res->mode, "on"))
4767 FOREACH_PORT(i, ports) {
4769 rte_eth_allmulticast_enable(i);
4771 rte_eth_allmulticast_disable(i);
4776 rte_eth_allmulticast_enable(res->port_num);
4778 rte_eth_allmulticast_disable(res->port_num);
4782 cmdline_parse_token_string_t cmd_setallmulti_set =
4783 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4784 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4785 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4787 cmdline_parse_token_string_t cmd_setallmulti_portall =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4790 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4791 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4793 cmdline_parse_token_string_t cmd_setallmulti_mode =
4794 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4797 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4798 .f = cmd_set_allmulti_mode_parsed,
4800 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4802 (void *)&cmd_setallmulti_set,
4803 (void *)&cmd_setallmulti_allmulti,
4804 (void *)&cmd_setallmulti_portall,
4805 (void *)&cmd_setallmulti_mode,
4810 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4811 .f = cmd_set_allmulti_mode_parsed,
4813 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4815 (void *)&cmd_setallmulti_set,
4816 (void *)&cmd_setallmulti_allmulti,
4817 (void *)&cmd_setallmulti_portnum,
4818 (void *)&cmd_setallmulti_mode,
4823 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4824 struct cmd_link_flow_ctrl_set_result {
4825 cmdline_fixed_string_t set;
4826 cmdline_fixed_string_t flow_ctrl;
4827 cmdline_fixed_string_t rx;
4828 cmdline_fixed_string_t rx_lfc_mode;
4829 cmdline_fixed_string_t tx;
4830 cmdline_fixed_string_t tx_lfc_mode;
4831 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4832 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4833 cmdline_fixed_string_t autoneg_str;
4834 cmdline_fixed_string_t autoneg;
4835 cmdline_fixed_string_t hw_str;
4836 uint32_t high_water;
4837 cmdline_fixed_string_t lw_str;
4839 cmdline_fixed_string_t pt_str;
4840 uint16_t pause_time;
4841 cmdline_fixed_string_t xon_str;
4846 cmdline_parse_token_string_t cmd_lfc_set_set =
4847 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4849 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4850 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4851 flow_ctrl, "flow_ctrl");
4852 cmdline_parse_token_string_t cmd_lfc_set_rx =
4853 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4855 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4856 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4857 rx_lfc_mode, "on#off");
4858 cmdline_parse_token_string_t cmd_lfc_set_tx =
4859 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4861 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4862 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4863 tx_lfc_mode, "on#off");
4864 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4865 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4866 hw_str, "high_water");
4867 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4868 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4869 high_water, UINT32);
4870 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4871 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4872 lw_str, "low_water");
4873 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4874 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4876 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4877 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4878 pt_str, "pause_time");
4879 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4880 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4881 pause_time, UINT16);
4882 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4883 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4884 xon_str, "send_xon");
4885 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4886 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4888 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4889 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4890 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4891 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4892 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4893 mac_ctrl_frame_fwd_mode, "on#off");
4894 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4895 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4896 autoneg_str, "autoneg");
4897 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4900 cmdline_parse_token_num_t cmd_lfc_set_portid =
4901 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4904 /* forward declaration */
4906 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4909 cmdline_parse_inst_t cmd_link_flow_control_set = {
4910 .f = cmd_link_flow_ctrl_set_parsed,
4912 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4913 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4914 autoneg on|off port_id",
4916 (void *)&cmd_lfc_set_set,
4917 (void *)&cmd_lfc_set_flow_ctrl,
4918 (void *)&cmd_lfc_set_rx,
4919 (void *)&cmd_lfc_set_rx_mode,
4920 (void *)&cmd_lfc_set_tx,
4921 (void *)&cmd_lfc_set_tx_mode,
4922 (void *)&cmd_lfc_set_high_water,
4923 (void *)&cmd_lfc_set_low_water,
4924 (void *)&cmd_lfc_set_pause_time,
4925 (void *)&cmd_lfc_set_send_xon,
4926 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4927 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4928 (void *)&cmd_lfc_set_autoneg_str,
4929 (void *)&cmd_lfc_set_autoneg,
4930 (void *)&cmd_lfc_set_portid,
4935 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4936 .f = cmd_link_flow_ctrl_set_parsed,
4937 .data = (void *)&cmd_link_flow_control_set_rx,
4938 .help_str = "Change rx flow control parameter: set flow_ctrl "
4939 "rx on|off port_id",
4941 (void *)&cmd_lfc_set_set,
4942 (void *)&cmd_lfc_set_flow_ctrl,
4943 (void *)&cmd_lfc_set_rx,
4944 (void *)&cmd_lfc_set_rx_mode,
4945 (void *)&cmd_lfc_set_portid,
4950 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4951 .f = cmd_link_flow_ctrl_set_parsed,
4952 .data = (void *)&cmd_link_flow_control_set_tx,
4953 .help_str = "Change tx flow control parameter: set flow_ctrl "
4954 "tx on|off port_id",
4956 (void *)&cmd_lfc_set_set,
4957 (void *)&cmd_lfc_set_flow_ctrl,
4958 (void *)&cmd_lfc_set_tx,
4959 (void *)&cmd_lfc_set_tx_mode,
4960 (void *)&cmd_lfc_set_portid,
4965 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4966 .f = cmd_link_flow_ctrl_set_parsed,
4967 .data = (void *)&cmd_link_flow_control_set_hw,
4968 .help_str = "Change high water flow control parameter: set flow_ctrl "
4969 "high_water value port_id",
4971 (void *)&cmd_lfc_set_set,
4972 (void *)&cmd_lfc_set_flow_ctrl,
4973 (void *)&cmd_lfc_set_high_water_str,
4974 (void *)&cmd_lfc_set_high_water,
4975 (void *)&cmd_lfc_set_portid,
4980 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4981 .f = cmd_link_flow_ctrl_set_parsed,
4982 .data = (void *)&cmd_link_flow_control_set_lw,
4983 .help_str = "Change low water flow control parameter: set flow_ctrl "
4984 "low_water value port_id",
4986 (void *)&cmd_lfc_set_set,
4987 (void *)&cmd_lfc_set_flow_ctrl,
4988 (void *)&cmd_lfc_set_low_water_str,
4989 (void *)&cmd_lfc_set_low_water,
4990 (void *)&cmd_lfc_set_portid,
4995 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4996 .f = cmd_link_flow_ctrl_set_parsed,
4997 .data = (void *)&cmd_link_flow_control_set_pt,
4998 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4999 "pause_time value port_id",
5001 (void *)&cmd_lfc_set_set,
5002 (void *)&cmd_lfc_set_flow_ctrl,
5003 (void *)&cmd_lfc_set_pause_time_str,
5004 (void *)&cmd_lfc_set_pause_time,
5005 (void *)&cmd_lfc_set_portid,
5010 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5011 .f = cmd_link_flow_ctrl_set_parsed,
5012 .data = (void *)&cmd_link_flow_control_set_xon,
5013 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
5014 "send_xon value port_id",
5016 (void *)&cmd_lfc_set_set,
5017 (void *)&cmd_lfc_set_flow_ctrl,
5018 (void *)&cmd_lfc_set_send_xon_str,
5019 (void *)&cmd_lfc_set_send_xon,
5020 (void *)&cmd_lfc_set_portid,
5025 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5026 .f = cmd_link_flow_ctrl_set_parsed,
5027 .data = (void *)&cmd_link_flow_control_set_macfwd,
5028 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
5029 "mac_ctrl_frame_fwd on|off port_id",
5031 (void *)&cmd_lfc_set_set,
5032 (void *)&cmd_lfc_set_flow_ctrl,
5033 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5034 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5035 (void *)&cmd_lfc_set_portid,
5040 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5041 .f = cmd_link_flow_ctrl_set_parsed,
5042 .data = (void *)&cmd_link_flow_control_set_autoneg,
5043 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
5044 "autoneg on|off port_id",
5046 (void *)&cmd_lfc_set_set,
5047 (void *)&cmd_lfc_set_flow_ctrl,
5048 (void *)&cmd_lfc_set_autoneg_str,
5049 (void *)&cmd_lfc_set_autoneg,
5050 (void *)&cmd_lfc_set_portid,
5056 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5057 __attribute__((unused)) struct cmdline *cl,
5060 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5061 cmdline_parse_inst_t *cmd = data;
5062 struct rte_eth_fc_conf fc_conf;
5068 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5069 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5070 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5071 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5073 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5074 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5077 /* Partial command line, retrieve current configuration */
5079 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5081 printf("cannot get current flow ctrl parameters, return"
5082 "code = %d\n", ret);
5086 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5087 (fc_conf.mode == RTE_FC_FULL))
5089 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5090 (fc_conf.mode == RTE_FC_FULL))
5094 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5095 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5097 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5098 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5100 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5102 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5103 fc_conf.high_water = res->high_water;
5105 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5106 fc_conf.low_water = res->low_water;
5108 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5109 fc_conf.pause_time = res->pause_time;
5111 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5112 fc_conf.send_xon = res->send_xon;
5114 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5115 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5116 fc_conf.mac_ctrl_frame_fwd = 1;
5118 fc_conf.mac_ctrl_frame_fwd = 0;
5121 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5122 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5124 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5126 printf("bad flow contrl parameter, return code = %d \n", ret);
5129 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5130 struct cmd_priority_flow_ctrl_set_result {
5131 cmdline_fixed_string_t set;
5132 cmdline_fixed_string_t pfc_ctrl;
5133 cmdline_fixed_string_t rx;
5134 cmdline_fixed_string_t rx_pfc_mode;
5135 cmdline_fixed_string_t tx;
5136 cmdline_fixed_string_t tx_pfc_mode;
5137 uint32_t high_water;
5139 uint16_t pause_time;
5145 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5146 __attribute__((unused)) struct cmdline *cl,
5147 __attribute__((unused)) void *data)
5149 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5150 struct rte_eth_pfc_conf pfc_conf;
5151 int rx_fc_enable, tx_fc_enable;
5155 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5156 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5157 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5158 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5160 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5161 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5164 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5165 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5166 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5167 pfc_conf.fc.high_water = res->high_water;
5168 pfc_conf.fc.low_water = res->low_water;
5169 pfc_conf.fc.pause_time = res->pause_time;
5170 pfc_conf.priority = res->priority;
5172 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5174 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5177 cmdline_parse_token_string_t cmd_pfc_set_set =
5178 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5180 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5181 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5182 pfc_ctrl, "pfc_ctrl");
5183 cmdline_parse_token_string_t cmd_pfc_set_rx =
5184 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5186 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5187 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5188 rx_pfc_mode, "on#off");
5189 cmdline_parse_token_string_t cmd_pfc_set_tx =
5190 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5192 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5193 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5194 tx_pfc_mode, "on#off");
5195 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5196 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5197 high_water, UINT32);
5198 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5199 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5201 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5202 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5203 pause_time, UINT16);
5204 cmdline_parse_token_num_t cmd_pfc_set_priority =
5205 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5207 cmdline_parse_token_num_t cmd_pfc_set_portid =
5208 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5211 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5212 .f = cmd_priority_flow_ctrl_set_parsed,
5214 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5215 tx on|off high_water low_water pause_time priority port_id",
5217 (void *)&cmd_pfc_set_set,
5218 (void *)&cmd_pfc_set_flow_ctrl,
5219 (void *)&cmd_pfc_set_rx,
5220 (void *)&cmd_pfc_set_rx_mode,
5221 (void *)&cmd_pfc_set_tx,
5222 (void *)&cmd_pfc_set_tx_mode,
5223 (void *)&cmd_pfc_set_high_water,
5224 (void *)&cmd_pfc_set_low_water,
5225 (void *)&cmd_pfc_set_pause_time,
5226 (void *)&cmd_pfc_set_priority,
5227 (void *)&cmd_pfc_set_portid,
5232 /* *** RESET CONFIGURATION *** */
5233 struct cmd_reset_result {
5234 cmdline_fixed_string_t reset;
5235 cmdline_fixed_string_t def;
5238 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5240 __attribute__((unused)) void *data)
5242 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5243 set_def_fwd_config();
5246 cmdline_parse_token_string_t cmd_reset_set =
5247 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5248 cmdline_parse_token_string_t cmd_reset_def =
5249 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5252 cmdline_parse_inst_t cmd_reset = {
5253 .f = cmd_reset_parsed,
5255 .help_str = "set default: reset default forwarding configuration",
5257 (void *)&cmd_reset_set,
5258 (void *)&cmd_reset_def,
5263 /* *** START FORWARDING *** */
5264 struct cmd_start_result {
5265 cmdline_fixed_string_t start;
5268 cmdline_parse_token_string_t cmd_start_start =
5269 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5271 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5272 __attribute__((unused)) struct cmdline *cl,
5273 __attribute__((unused)) void *data)
5275 start_packet_forwarding(0);
5278 cmdline_parse_inst_t cmd_start = {
5279 .f = cmd_start_parsed,
5281 .help_str = "start packet forwarding",
5283 (void *)&cmd_start_start,
5288 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5289 struct cmd_start_tx_first_result {
5290 cmdline_fixed_string_t start;
5291 cmdline_fixed_string_t tx_first;
5295 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5296 __attribute__((unused)) struct cmdline *cl,
5297 __attribute__((unused)) void *data)
5299 start_packet_forwarding(1);
5302 cmdline_parse_token_string_t cmd_start_tx_first_start =
5303 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5305 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5306 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5307 tx_first, "tx_first");
5309 cmdline_parse_inst_t cmd_start_tx_first = {
5310 .f = cmd_start_tx_first_parsed,
5312 .help_str = "start packet forwarding, after sending 1 burst of packets",
5314 (void *)&cmd_start_tx_first_start,
5315 (void *)&cmd_start_tx_first_tx_first,
5320 /* *** SET LINK UP *** */
5321 struct cmd_set_link_up_result {
5322 cmdline_fixed_string_t set;
5323 cmdline_fixed_string_t link_up;
5324 cmdline_fixed_string_t port;
5328 cmdline_parse_token_string_t cmd_set_link_up_set =
5329 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5330 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5331 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5333 cmdline_parse_token_string_t cmd_set_link_up_port =
5334 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5335 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5336 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5338 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5339 __attribute__((unused)) struct cmdline *cl,
5340 __attribute__((unused)) void *data)
5342 struct cmd_set_link_up_result *res = parsed_result;
5343 dev_set_link_up(res->port_id);
5346 cmdline_parse_inst_t cmd_set_link_up = {
5347 .f = cmd_set_link_up_parsed,
5349 .help_str = "set link-up port (port id)",
5351 (void *)&cmd_set_link_up_set,
5352 (void *)&cmd_set_link_up_link_up,
5353 (void *)&cmd_set_link_up_port,
5354 (void *)&cmd_set_link_up_port_id,
5359 /* *** SET LINK DOWN *** */
5360 struct cmd_set_link_down_result {
5361 cmdline_fixed_string_t set;
5362 cmdline_fixed_string_t link_down;
5363 cmdline_fixed_string_t port;
5367 cmdline_parse_token_string_t cmd_set_link_down_set =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5369 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5372 cmdline_parse_token_string_t cmd_set_link_down_port =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5374 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5375 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5377 static void cmd_set_link_down_parsed(
5378 __attribute__((unused)) void *parsed_result,
5379 __attribute__((unused)) struct cmdline *cl,
5380 __attribute__((unused)) void *data)
5382 struct cmd_set_link_down_result *res = parsed_result;
5383 dev_set_link_down(res->port_id);
5386 cmdline_parse_inst_t cmd_set_link_down = {
5387 .f = cmd_set_link_down_parsed,
5389 .help_str = "set link-down port (port id)",
5391 (void *)&cmd_set_link_down_set,
5392 (void *)&cmd_set_link_down_link_down,
5393 (void *)&cmd_set_link_down_port,
5394 (void *)&cmd_set_link_down_port_id,
5399 /* *** SHOW CFG *** */
5400 struct cmd_showcfg_result {
5401 cmdline_fixed_string_t show;
5402 cmdline_fixed_string_t cfg;
5403 cmdline_fixed_string_t what;
5406 static void cmd_showcfg_parsed(void *parsed_result,
5407 __attribute__((unused)) struct cmdline *cl,
5408 __attribute__((unused)) void *data)
5410 struct cmd_showcfg_result *res = parsed_result;
5411 if (!strcmp(res->what, "rxtx"))
5412 rxtx_config_display();
5413 else if (!strcmp(res->what, "cores"))
5414 fwd_lcores_config_display();
5415 else if (!strcmp(res->what, "fwd"))
5416 fwd_config_display();
5417 else if (!strcmp(res->what, "txpkts"))
5418 show_tx_pkt_segments();
5421 cmdline_parse_token_string_t cmd_showcfg_show =
5422 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5423 cmdline_parse_token_string_t cmd_showcfg_port =
5424 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5425 cmdline_parse_token_string_t cmd_showcfg_what =
5426 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5427 "rxtx#cores#fwd#txpkts");
5429 cmdline_parse_inst_t cmd_showcfg = {
5430 .f = cmd_showcfg_parsed,
5432 .help_str = "show config rxtx|cores|fwd|txpkts",
5434 (void *)&cmd_showcfg_show,
5435 (void *)&cmd_showcfg_port,
5436 (void *)&cmd_showcfg_what,
5441 /* *** SHOW ALL PORT INFO *** */
5442 struct cmd_showportall_result {
5443 cmdline_fixed_string_t show;
5444 cmdline_fixed_string_t port;
5445 cmdline_fixed_string_t what;
5446 cmdline_fixed_string_t all;
5449 static void cmd_showportall_parsed(void *parsed_result,
5450 __attribute__((unused)) struct cmdline *cl,
5451 __attribute__((unused)) void *data)
5455 struct cmd_showportall_result *res = parsed_result;
5456 if (!strcmp(res->show, "clear")) {
5457 if (!strcmp(res->what, "stats"))
5458 FOREACH_PORT(i, ports)
5460 else if (!strcmp(res->what, "xstats"))
5461 FOREACH_PORT(i, ports)
5462 nic_xstats_clear(i);
5463 } else if (!strcmp(res->what, "info"))
5464 FOREACH_PORT(i, ports)
5465 port_infos_display(i);
5466 else if (!strcmp(res->what, "stats"))
5467 FOREACH_PORT(i, ports)
5468 nic_stats_display(i);
5469 else if (!strcmp(res->what, "xstats"))
5470 FOREACH_PORT(i, ports)
5471 nic_xstats_display(i);
5472 else if (!strcmp(res->what, "fdir"))
5473 FOREACH_PORT(i, ports)
5475 else if (!strcmp(res->what, "stat_qmap"))
5476 FOREACH_PORT(i, ports)
5477 nic_stats_mapping_display(i);
5478 else if (!strcmp(res->what, "dcb_tc"))
5479 FOREACH_PORT(i, ports)
5480 port_dcb_info_display(i);
5483 cmdline_parse_token_string_t cmd_showportall_show =
5484 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5486 cmdline_parse_token_string_t cmd_showportall_port =
5487 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5488 cmdline_parse_token_string_t cmd_showportall_what =
5489 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5490 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5491 cmdline_parse_token_string_t cmd_showportall_all =
5492 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5493 cmdline_parse_inst_t cmd_showportall = {
5494 .f = cmd_showportall_parsed,
5496 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5498 (void *)&cmd_showportall_show,
5499 (void *)&cmd_showportall_port,
5500 (void *)&cmd_showportall_what,
5501 (void *)&cmd_showportall_all,
5506 /* *** SHOW PORT INFO *** */
5507 struct cmd_showport_result {
5508 cmdline_fixed_string_t show;
5509 cmdline_fixed_string_t port;
5510 cmdline_fixed_string_t what;
5514 static void cmd_showport_parsed(void *parsed_result,
5515 __attribute__((unused)) struct cmdline *cl,
5516 __attribute__((unused)) void *data)
5518 struct cmd_showport_result *res = parsed_result;
5519 if (!strcmp(res->show, "clear")) {
5520 if (!strcmp(res->what, "stats"))
5521 nic_stats_clear(res->portnum);
5522 else if (!strcmp(res->what, "xstats"))
5523 nic_xstats_clear(res->portnum);
5524 } else if (!strcmp(res->what, "info"))
5525 port_infos_display(res->portnum);
5526 else if (!strcmp(res->what, "stats"))
5527 nic_stats_display(res->portnum);
5528 else if (!strcmp(res->what, "xstats"))
5529 nic_xstats_display(res->portnum);
5530 else if (!strcmp(res->what, "fdir"))
5531 fdir_get_infos(res->portnum);
5532 else if (!strcmp(res->what, "stat_qmap"))
5533 nic_stats_mapping_display(res->portnum);
5534 else if (!strcmp(res->what, "dcb_tc"))
5535 port_dcb_info_display(res->portnum);
5538 cmdline_parse_token_string_t cmd_showport_show =
5539 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5541 cmdline_parse_token_string_t cmd_showport_port =
5542 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5543 cmdline_parse_token_string_t cmd_showport_what =
5544 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5545 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5546 cmdline_parse_token_num_t cmd_showport_portnum =
5547 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5549 cmdline_parse_inst_t cmd_showport = {
5550 .f = cmd_showport_parsed,
5552 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5554 (void *)&cmd_showport_show,
5555 (void *)&cmd_showport_port,
5556 (void *)&cmd_showport_what,
5557 (void *)&cmd_showport_portnum,
5562 /* *** SHOW QUEUE INFO *** */
5563 struct cmd_showqueue_result {
5564 cmdline_fixed_string_t show;
5565 cmdline_fixed_string_t type;
5566 cmdline_fixed_string_t what;
5572 cmd_showqueue_parsed(void *parsed_result,
5573 __attribute__((unused)) struct cmdline *cl,
5574 __attribute__((unused)) void *data)
5576 struct cmd_showqueue_result *res = parsed_result;
5578 if (!strcmp(res->type, "rxq"))
5579 rx_queue_infos_display(res->portnum, res->queuenum);
5580 else if (!strcmp(res->type, "txq"))
5581 tx_queue_infos_display(res->portnum, res->queuenum);
5584 cmdline_parse_token_string_t cmd_showqueue_show =
5585 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5586 cmdline_parse_token_string_t cmd_showqueue_type =
5587 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5588 cmdline_parse_token_string_t cmd_showqueue_what =
5589 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5590 cmdline_parse_token_num_t cmd_showqueue_portnum =
5591 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5592 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5593 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5595 cmdline_parse_inst_t cmd_showqueue = {
5596 .f = cmd_showqueue_parsed,
5598 .help_str = "show rxq|txq info <port number> <queue_number>",
5600 (void *)&cmd_showqueue_show,
5601 (void *)&cmd_showqueue_type,
5602 (void *)&cmd_showqueue_what,
5603 (void *)&cmd_showqueue_portnum,
5604 (void *)&cmd_showqueue_queuenum,
5609 /* *** READ PORT REGISTER *** */
5610 struct cmd_read_reg_result {
5611 cmdline_fixed_string_t read;
5612 cmdline_fixed_string_t reg;
5618 cmd_read_reg_parsed(void *parsed_result,
5619 __attribute__((unused)) struct cmdline *cl,
5620 __attribute__((unused)) void *data)
5622 struct cmd_read_reg_result *res = parsed_result;
5623 port_reg_display(res->port_id, res->reg_off);
5626 cmdline_parse_token_string_t cmd_read_reg_read =
5627 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5628 cmdline_parse_token_string_t cmd_read_reg_reg =
5629 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5630 cmdline_parse_token_num_t cmd_read_reg_port_id =
5631 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5632 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5633 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5635 cmdline_parse_inst_t cmd_read_reg = {
5636 .f = cmd_read_reg_parsed,
5638 .help_str = "read reg port_id reg_off",
5640 (void *)&cmd_read_reg_read,
5641 (void *)&cmd_read_reg_reg,
5642 (void *)&cmd_read_reg_port_id,
5643 (void *)&cmd_read_reg_reg_off,
5648 /* *** READ PORT REGISTER BIT FIELD *** */
5649 struct cmd_read_reg_bit_field_result {
5650 cmdline_fixed_string_t read;
5651 cmdline_fixed_string_t regfield;
5659 cmd_read_reg_bit_field_parsed(void *parsed_result,
5660 __attribute__((unused)) struct cmdline *cl,
5661 __attribute__((unused)) void *data)
5663 struct cmd_read_reg_bit_field_result *res = parsed_result;
5664 port_reg_bit_field_display(res->port_id, res->reg_off,
5665 res->bit1_pos, res->bit2_pos);
5668 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5669 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5671 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5672 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5673 regfield, "regfield");
5674 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5675 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5677 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5678 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5680 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5681 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5683 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5684 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5687 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5688 .f = cmd_read_reg_bit_field_parsed,
5690 .help_str = "read regfield port_id reg_off bit_x bit_y "
5691 "(read register bit field between bit_x and bit_y included)",
5693 (void *)&cmd_read_reg_bit_field_read,
5694 (void *)&cmd_read_reg_bit_field_regfield,
5695 (void *)&cmd_read_reg_bit_field_port_id,
5696 (void *)&cmd_read_reg_bit_field_reg_off,
5697 (void *)&cmd_read_reg_bit_field_bit1_pos,
5698 (void *)&cmd_read_reg_bit_field_bit2_pos,
5703 /* *** READ PORT REGISTER BIT *** */
5704 struct cmd_read_reg_bit_result {
5705 cmdline_fixed_string_t read;
5706 cmdline_fixed_string_t regbit;
5713 cmd_read_reg_bit_parsed(void *parsed_result,
5714 __attribute__((unused)) struct cmdline *cl,
5715 __attribute__((unused)) void *data)
5717 struct cmd_read_reg_bit_result *res = parsed_result;
5718 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5721 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5722 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5723 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5724 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5726 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5727 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5728 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5729 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5730 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5731 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5733 cmdline_parse_inst_t cmd_read_reg_bit = {
5734 .f = cmd_read_reg_bit_parsed,
5736 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5738 (void *)&cmd_read_reg_bit_read,
5739 (void *)&cmd_read_reg_bit_regbit,
5740 (void *)&cmd_read_reg_bit_port_id,
5741 (void *)&cmd_read_reg_bit_reg_off,
5742 (void *)&cmd_read_reg_bit_bit_pos,
5747 /* *** WRITE PORT REGISTER *** */
5748 struct cmd_write_reg_result {
5749 cmdline_fixed_string_t write;
5750 cmdline_fixed_string_t reg;
5757 cmd_write_reg_parsed(void *parsed_result,
5758 __attribute__((unused)) struct cmdline *cl,
5759 __attribute__((unused)) void *data)
5761 struct cmd_write_reg_result *res = parsed_result;
5762 port_reg_set(res->port_id, res->reg_off, res->value);
5765 cmdline_parse_token_string_t cmd_write_reg_write =
5766 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5767 cmdline_parse_token_string_t cmd_write_reg_reg =
5768 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5769 cmdline_parse_token_num_t cmd_write_reg_port_id =
5770 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5771 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5772 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5773 cmdline_parse_token_num_t cmd_write_reg_value =
5774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5776 cmdline_parse_inst_t cmd_write_reg = {
5777 .f = cmd_write_reg_parsed,
5779 .help_str = "write reg port_id reg_off reg_value",
5781 (void *)&cmd_write_reg_write,
5782 (void *)&cmd_write_reg_reg,
5783 (void *)&cmd_write_reg_port_id,
5784 (void *)&cmd_write_reg_reg_off,
5785 (void *)&cmd_write_reg_value,
5790 /* *** WRITE PORT REGISTER BIT FIELD *** */
5791 struct cmd_write_reg_bit_field_result {
5792 cmdline_fixed_string_t write;
5793 cmdline_fixed_string_t regfield;
5802 cmd_write_reg_bit_field_parsed(void *parsed_result,
5803 __attribute__((unused)) struct cmdline *cl,
5804 __attribute__((unused)) void *data)
5806 struct cmd_write_reg_bit_field_result *res = parsed_result;
5807 port_reg_bit_field_set(res->port_id, res->reg_off,
5808 res->bit1_pos, res->bit2_pos, res->value);
5811 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5812 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5814 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5815 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5816 regfield, "regfield");
5817 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5818 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5820 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5821 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5823 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5824 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5826 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5827 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5829 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5830 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5833 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5834 .f = cmd_write_reg_bit_field_parsed,
5836 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5837 "(set register bit field between bit_x and bit_y included)",
5839 (void *)&cmd_write_reg_bit_field_write,
5840 (void *)&cmd_write_reg_bit_field_regfield,
5841 (void *)&cmd_write_reg_bit_field_port_id,
5842 (void *)&cmd_write_reg_bit_field_reg_off,
5843 (void *)&cmd_write_reg_bit_field_bit1_pos,
5844 (void *)&cmd_write_reg_bit_field_bit2_pos,
5845 (void *)&cmd_write_reg_bit_field_value,
5850 /* *** WRITE PORT REGISTER BIT *** */
5851 struct cmd_write_reg_bit_result {
5852 cmdline_fixed_string_t write;
5853 cmdline_fixed_string_t regbit;
5861 cmd_write_reg_bit_parsed(void *parsed_result,
5862 __attribute__((unused)) struct cmdline *cl,
5863 __attribute__((unused)) void *data)
5865 struct cmd_write_reg_bit_result *res = parsed_result;
5866 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5869 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5870 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5872 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5873 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5875 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5876 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5877 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5878 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5879 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5880 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5881 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5882 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5884 cmdline_parse_inst_t cmd_write_reg_bit = {
5885 .f = cmd_write_reg_bit_parsed,
5887 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5889 (void *)&cmd_write_reg_bit_write,
5890 (void *)&cmd_write_reg_bit_regbit,
5891 (void *)&cmd_write_reg_bit_port_id,
5892 (void *)&cmd_write_reg_bit_reg_off,
5893 (void *)&cmd_write_reg_bit_bit_pos,
5894 (void *)&cmd_write_reg_bit_value,
5899 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5900 struct cmd_read_rxd_txd_result {
5901 cmdline_fixed_string_t read;
5902 cmdline_fixed_string_t rxd_txd;
5909 cmd_read_rxd_txd_parsed(void *parsed_result,
5910 __attribute__((unused)) struct cmdline *cl,
5911 __attribute__((unused)) void *data)
5913 struct cmd_read_rxd_txd_result *res = parsed_result;
5915 if (!strcmp(res->rxd_txd, "rxd"))
5916 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5917 else if (!strcmp(res->rxd_txd, "txd"))
5918 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5921 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5922 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5923 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5924 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5926 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5927 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5928 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5929 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5930 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5931 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5933 cmdline_parse_inst_t cmd_read_rxd_txd = {
5934 .f = cmd_read_rxd_txd_parsed,
5936 .help_str = "read rxd|txd port_id queue_id rxd_id",
5938 (void *)&cmd_read_rxd_txd_read,
5939 (void *)&cmd_read_rxd_txd_rxd_txd,
5940 (void *)&cmd_read_rxd_txd_port_id,
5941 (void *)&cmd_read_rxd_txd_queue_id,
5942 (void *)&cmd_read_rxd_txd_desc_id,
5948 struct cmd_quit_result {
5949 cmdline_fixed_string_t quit;
5952 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5954 __attribute__((unused)) void *data)
5960 cmdline_parse_token_string_t cmd_quit_quit =
5961 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5963 cmdline_parse_inst_t cmd_quit = {
5964 .f = cmd_quit_parsed,
5966 .help_str = "exit application",
5968 (void *)&cmd_quit_quit,
5973 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5974 struct cmd_mac_addr_result {
5975 cmdline_fixed_string_t mac_addr_cmd;
5976 cmdline_fixed_string_t what;
5978 struct ether_addr address;
5981 static void cmd_mac_addr_parsed(void *parsed_result,
5982 __attribute__((unused)) struct cmdline *cl,
5983 __attribute__((unused)) void *data)
5985 struct cmd_mac_addr_result *res = parsed_result;
5988 if (strcmp(res->what, "add") == 0)
5989 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5991 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5993 /* check the return value and print it if is < 0 */
5995 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5999 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6000 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6002 cmdline_parse_token_string_t cmd_mac_addr_what =
6003 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6005 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6006 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6007 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6008 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6010 cmdline_parse_inst_t cmd_mac_addr = {
6011 .f = cmd_mac_addr_parsed,
6013 .help_str = "mac_addr add|remove X <address>: "
6014 "add/remove MAC address on port X",
6016 (void *)&cmd_mac_addr_cmd,
6017 (void *)&cmd_mac_addr_what,
6018 (void *)&cmd_mac_addr_portnum,
6019 (void *)&cmd_mac_addr_addr,
6025 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6026 struct cmd_set_qmap_result {
6027 cmdline_fixed_string_t set;
6028 cmdline_fixed_string_t qmap;
6029 cmdline_fixed_string_t what;
6036 cmd_set_qmap_parsed(void *parsed_result,
6037 __attribute__((unused)) struct cmdline *cl,
6038 __attribute__((unused)) void *data)
6040 struct cmd_set_qmap_result *res = parsed_result;
6041 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6043 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6046 cmdline_parse_token_string_t cmd_setqmap_set =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6049 cmdline_parse_token_string_t cmd_setqmap_qmap =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6052 cmdline_parse_token_string_t cmd_setqmap_what =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6055 cmdline_parse_token_num_t cmd_setqmap_portid =
6056 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6058 cmdline_parse_token_num_t cmd_setqmap_queueid =
6059 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6061 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6062 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6065 cmdline_parse_inst_t cmd_set_qmap = {
6066 .f = cmd_set_qmap_parsed,
6068 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
6070 (void *)&cmd_setqmap_set,
6071 (void *)&cmd_setqmap_qmap,
6072 (void *)&cmd_setqmap_what,
6073 (void *)&cmd_setqmap_portid,
6074 (void *)&cmd_setqmap_queueid,
6075 (void *)&cmd_setqmap_mapvalue,
6080 /* *** CONFIGURE UNICAST HASH TABLE *** */
6081 struct cmd_set_uc_hash_table {
6082 cmdline_fixed_string_t set;
6083 cmdline_fixed_string_t port;
6085 cmdline_fixed_string_t what;
6086 struct ether_addr address;
6087 cmdline_fixed_string_t mode;
6091 cmd_set_uc_hash_parsed(void *parsed_result,
6092 __attribute__((unused)) struct cmdline *cl,
6093 __attribute__((unused)) void *data)
6096 struct cmd_set_uc_hash_table *res = parsed_result;
6098 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6100 if (strcmp(res->what, "uta") == 0)
6101 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6102 &res->address,(uint8_t)is_on);
6104 printf("bad unicast hash table parameter, return code = %d \n", ret);
6108 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6111 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6112 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6114 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6115 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6117 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6118 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6120 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6121 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6123 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6124 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6127 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6128 .f = cmd_set_uc_hash_parsed,
6130 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6132 (void *)&cmd_set_uc_hash_set,
6133 (void *)&cmd_set_uc_hash_port,
6134 (void *)&cmd_set_uc_hash_portid,
6135 (void *)&cmd_set_uc_hash_what,
6136 (void *)&cmd_set_uc_hash_mac,
6137 (void *)&cmd_set_uc_hash_mode,
6142 struct cmd_set_uc_all_hash_table {
6143 cmdline_fixed_string_t set;
6144 cmdline_fixed_string_t port;
6146 cmdline_fixed_string_t what;
6147 cmdline_fixed_string_t value;
6148 cmdline_fixed_string_t mode;
6152 cmd_set_uc_all_hash_parsed(void *parsed_result,
6153 __attribute__((unused)) struct cmdline *cl,
6154 __attribute__((unused)) void *data)
6157 struct cmd_set_uc_all_hash_table *res = parsed_result;
6159 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6161 if ((strcmp(res->what, "uta") == 0) &&
6162 (strcmp(res->value, "all") == 0))
6163 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6165 printf("bad unicast hash table parameter,"
6166 "return code = %d \n", ret);
6169 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6170 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6172 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6175 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6176 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6178 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6179 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6181 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6182 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6184 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6185 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6188 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6189 .f = cmd_set_uc_all_hash_parsed,
6191 .help_str = "set port X uta all on|off (X = port number)",
6193 (void *)&cmd_set_uc_all_hash_set,
6194 (void *)&cmd_set_uc_all_hash_port,
6195 (void *)&cmd_set_uc_all_hash_portid,
6196 (void *)&cmd_set_uc_all_hash_what,
6197 (void *)&cmd_set_uc_all_hash_value,
6198 (void *)&cmd_set_uc_all_hash_mode,
6203 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6204 struct cmd_set_vf_macvlan_filter {
6205 cmdline_fixed_string_t set;
6206 cmdline_fixed_string_t port;
6208 cmdline_fixed_string_t vf;
6210 struct ether_addr address;
6211 cmdline_fixed_string_t filter_type;
6212 cmdline_fixed_string_t mode;
6216 cmd_set_vf_macvlan_parsed(void *parsed_result,
6217 __attribute__((unused)) struct cmdline *cl,
6218 __attribute__((unused)) void *data)
6221 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6222 struct rte_eth_mac_filter filter;
6224 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6226 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6228 /* set VF MAC filter */
6232 filter.dst_id = res->vf_id;
6234 if (!strcmp(res->filter_type, "exact-mac"))
6235 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6236 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6237 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6238 else if (!strcmp(res->filter_type, "hashmac"))
6239 filter.filter_type = RTE_MAC_HASH_MATCH;
6240 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6241 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6243 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6246 ret = rte_eth_dev_filter_ctrl(res->port_id,
6247 RTE_ETH_FILTER_MACVLAN,
6251 ret = rte_eth_dev_filter_ctrl(res->port_id,
6252 RTE_ETH_FILTER_MACVLAN,
6253 RTE_ETH_FILTER_DELETE,
6257 printf("bad set MAC hash parameter, return code = %d\n", ret);
6261 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6262 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6264 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6265 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6267 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6268 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6270 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6271 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6273 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6274 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6276 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6277 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6279 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6280 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6281 filter_type, "exact-mac#exact-mac-vlan"
6282 "#hashmac#hashmac-vlan");
6283 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6284 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6287 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6288 .f = cmd_set_vf_macvlan_parsed,
6290 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6291 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6293 "exact match rule:exact match of MAC or MAC and VLAN; "
6294 "hash match rule: hash match of MAC and exact match "
6297 (void *)&cmd_set_vf_macvlan_set,
6298 (void *)&cmd_set_vf_macvlan_port,
6299 (void *)&cmd_set_vf_macvlan_portid,
6300 (void *)&cmd_set_vf_macvlan_vf,
6301 (void *)&cmd_set_vf_macvlan_vf_id,
6302 (void *)&cmd_set_vf_macvlan_mac,
6303 (void *)&cmd_set_vf_macvlan_filter_type,
6304 (void *)&cmd_set_vf_macvlan_mode,
6309 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6310 struct cmd_set_vf_traffic {
6311 cmdline_fixed_string_t set;
6312 cmdline_fixed_string_t port;
6314 cmdline_fixed_string_t vf;
6316 cmdline_fixed_string_t what;
6317 cmdline_fixed_string_t mode;
6321 cmd_set_vf_traffic_parsed(void *parsed_result,
6322 __attribute__((unused)) struct cmdline *cl,
6323 __attribute__((unused)) void *data)
6325 struct cmd_set_vf_traffic *res = parsed_result;
6326 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6327 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6329 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6332 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6335 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6336 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6338 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6339 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6341 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6344 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6347 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6350 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6351 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6354 cmdline_parse_inst_t cmd_set_vf_traffic = {
6355 .f = cmd_set_vf_traffic_parsed,
6357 .help_str = "set port X vf Y rx|tx on|off"
6358 "(X = port number,Y = vf id)",
6360 (void *)&cmd_setvf_traffic_set,
6361 (void *)&cmd_setvf_traffic_port,
6362 (void *)&cmd_setvf_traffic_portid,
6363 (void *)&cmd_setvf_traffic_vf,
6364 (void *)&cmd_setvf_traffic_vfid,
6365 (void *)&cmd_setvf_traffic_what,
6366 (void *)&cmd_setvf_traffic_mode,
6371 /* *** CONFIGURE VF RECEIVE MODE *** */
6372 struct cmd_set_vf_rxmode {
6373 cmdline_fixed_string_t set;
6374 cmdline_fixed_string_t port;
6376 cmdline_fixed_string_t vf;
6378 cmdline_fixed_string_t what;
6379 cmdline_fixed_string_t mode;
6380 cmdline_fixed_string_t on;
6384 cmd_set_vf_rxmode_parsed(void *parsed_result,
6385 __attribute__((unused)) struct cmdline *cl,
6386 __attribute__((unused)) void *data)
6389 uint16_t rx_mode = 0;
6390 struct cmd_set_vf_rxmode *res = parsed_result;
6392 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6393 if (!strcmp(res->what,"rxmode")) {
6394 if (!strcmp(res->mode, "AUPE"))
6395 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6396 else if (!strcmp(res->mode, "ROPE"))
6397 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6398 else if (!strcmp(res->mode, "BAM"))
6399 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6400 else if (!strncmp(res->mode, "MPE",3))
6401 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6404 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6406 printf("bad VF receive mode parameter, return code = %d \n",
6410 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6413 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6416 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6417 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6419 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6422 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6425 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6428 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6430 mode, "AUPE#ROPE#BAM#MPE");
6431 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6435 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6436 .f = cmd_set_vf_rxmode_parsed,
6438 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6440 (void *)&cmd_set_vf_rxmode_set,
6441 (void *)&cmd_set_vf_rxmode_port,
6442 (void *)&cmd_set_vf_rxmode_portid,
6443 (void *)&cmd_set_vf_rxmode_vf,
6444 (void *)&cmd_set_vf_rxmode_vfid,
6445 (void *)&cmd_set_vf_rxmode_what,
6446 (void *)&cmd_set_vf_rxmode_mode,
6447 (void *)&cmd_set_vf_rxmode_on,
6452 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6453 struct cmd_vf_mac_addr_result {
6454 cmdline_fixed_string_t mac_addr_cmd;
6455 cmdline_fixed_string_t what;
6456 cmdline_fixed_string_t port;
6458 cmdline_fixed_string_t vf;
6460 struct ether_addr address;
6463 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6464 __attribute__((unused)) struct cmdline *cl,
6465 __attribute__((unused)) void *data)
6467 struct cmd_vf_mac_addr_result *res = parsed_result;
6470 if (strcmp(res->what, "add") == 0)
6471 ret = rte_eth_dev_mac_addr_add(res->port_num,
6472 &res->address, res->vf_num);
6474 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6478 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6479 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6480 mac_addr_cmd,"mac_addr");
6481 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6482 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6484 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6485 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6487 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6488 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6490 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6491 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6493 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6494 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6496 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6497 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6500 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6501 .f = cmd_vf_mac_addr_parsed,
6503 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6504 "Y = VF number)add MAC address filtering for a VF on port X",
6506 (void *)&cmd_vf_mac_addr_cmd,
6507 (void *)&cmd_vf_mac_addr_what,
6508 (void *)&cmd_vf_mac_addr_port,
6509 (void *)&cmd_vf_mac_addr_portnum,
6510 (void *)&cmd_vf_mac_addr_vf,
6511 (void *)&cmd_vf_mac_addr_vfnum,
6512 (void *)&cmd_vf_mac_addr_addr,
6517 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6518 struct cmd_vf_rx_vlan_filter {
6519 cmdline_fixed_string_t rx_vlan;
6520 cmdline_fixed_string_t what;
6522 cmdline_fixed_string_t port;
6524 cmdline_fixed_string_t vf;
6529 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6530 __attribute__((unused)) struct cmdline *cl,
6531 __attribute__((unused)) void *data)
6533 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6535 if (!strcmp(res->what, "add"))
6536 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6538 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6541 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6542 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6543 rx_vlan, "rx_vlan");
6544 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6545 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6547 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6548 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6550 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6551 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6553 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6554 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6556 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6557 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6559 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6560 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6563 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6564 .f = cmd_vf_rx_vlan_filter_parsed,
6566 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6567 "Y = port number,Z = hexadecimal VF mask)",
6569 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6570 (void *)&cmd_vf_rx_vlan_filter_what,
6571 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6572 (void *)&cmd_vf_rx_vlan_filter_port,
6573 (void *)&cmd_vf_rx_vlan_filter_portid,
6574 (void *)&cmd_vf_rx_vlan_filter_vf,
6575 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6580 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6581 struct cmd_queue_rate_limit_result {
6582 cmdline_fixed_string_t set;
6583 cmdline_fixed_string_t port;
6585 cmdline_fixed_string_t queue;
6587 cmdline_fixed_string_t rate;
6591 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6592 __attribute__((unused)) struct cmdline *cl,
6593 __attribute__((unused)) void *data)
6595 struct cmd_queue_rate_limit_result *res = parsed_result;
6598 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6599 && (strcmp(res->queue, "queue") == 0)
6600 && (strcmp(res->rate, "rate") == 0))
6601 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6604 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6608 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6609 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6611 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6612 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6614 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6615 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6617 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6618 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6620 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6621 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6623 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6624 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6626 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6627 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6630 cmdline_parse_inst_t cmd_queue_rate_limit = {
6631 .f = cmd_queue_rate_limit_parsed,
6633 .help_str = "set port X queue Y rate Z:(X = port number,"
6634 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6636 (void *)&cmd_queue_rate_limit_set,
6637 (void *)&cmd_queue_rate_limit_port,
6638 (void *)&cmd_queue_rate_limit_portnum,
6639 (void *)&cmd_queue_rate_limit_queue,
6640 (void *)&cmd_queue_rate_limit_queuenum,
6641 (void *)&cmd_queue_rate_limit_rate,
6642 (void *)&cmd_queue_rate_limit_ratenum,
6647 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6648 struct cmd_vf_rate_limit_result {
6649 cmdline_fixed_string_t set;
6650 cmdline_fixed_string_t port;
6652 cmdline_fixed_string_t vf;
6654 cmdline_fixed_string_t rate;
6656 cmdline_fixed_string_t q_msk;
6660 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6661 __attribute__((unused)) struct cmdline *cl,
6662 __attribute__((unused)) void *data)
6664 struct cmd_vf_rate_limit_result *res = parsed_result;
6667 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6668 && (strcmp(res->vf, "vf") == 0)
6669 && (strcmp(res->rate, "rate") == 0)
6670 && (strcmp(res->q_msk, "queue_mask") == 0))
6671 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6672 res->rate_num, res->q_msk_val);
6674 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6678 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6679 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6681 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6682 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6684 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6685 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6687 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6688 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6690 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6691 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6693 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6694 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6696 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6697 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6699 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6700 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6701 q_msk, "queue_mask");
6702 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6703 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6706 cmdline_parse_inst_t cmd_vf_rate_limit = {
6707 .f = cmd_vf_rate_limit_parsed,
6709 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6710 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6711 "for queues of VF on port X",
6713 (void *)&cmd_vf_rate_limit_set,
6714 (void *)&cmd_vf_rate_limit_port,
6715 (void *)&cmd_vf_rate_limit_portnum,
6716 (void *)&cmd_vf_rate_limit_vf,
6717 (void *)&cmd_vf_rate_limit_vfnum,
6718 (void *)&cmd_vf_rate_limit_rate,
6719 (void *)&cmd_vf_rate_limit_ratenum,
6720 (void *)&cmd_vf_rate_limit_q_msk,
6721 (void *)&cmd_vf_rate_limit_q_msk_val,
6726 /* *** ADD TUNNEL FILTER OF A PORT *** */
6727 struct cmd_tunnel_filter_result {
6728 cmdline_fixed_string_t cmd;
6729 cmdline_fixed_string_t what;
6731 struct ether_addr outer_mac;
6732 struct ether_addr inner_mac;
6733 cmdline_ipaddr_t ip_value;
6734 uint16_t inner_vlan;
6735 cmdline_fixed_string_t tunnel_type;
6736 cmdline_fixed_string_t filter_type;
6742 cmd_tunnel_filter_parsed(void *parsed_result,
6743 __attribute__((unused)) struct cmdline *cl,
6744 __attribute__((unused)) void *data)
6746 struct cmd_tunnel_filter_result *res = parsed_result;
6747 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6750 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6752 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6753 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6754 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6756 if (res->ip_value.family == AF_INET) {
6757 tunnel_filter_conf.ip_addr.ipv4_addr =
6758 res->ip_value.addr.ipv4.s_addr;
6759 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6761 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6762 &(res->ip_value.addr.ipv6),
6763 sizeof(struct in6_addr));
6764 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6767 if (!strcmp(res->filter_type, "imac-ivlan"))
6768 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6769 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6770 tunnel_filter_conf.filter_type =
6771 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6772 else if (!strcmp(res->filter_type, "imac-tenid"))
6773 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6774 else if (!strcmp(res->filter_type, "imac"))
6775 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6776 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6777 tunnel_filter_conf.filter_type =
6778 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6779 else if (!strcmp(res->filter_type, "oip"))
6780 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6781 else if (!strcmp(res->filter_type, "iip"))
6782 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6784 printf("The filter type is not supported");
6788 if (!strcmp(res->tunnel_type, "vxlan"))
6789 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6790 else if (!strcmp(res->tunnel_type, "nvgre"))
6791 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6792 else if (!strcmp(res->tunnel_type, "ipingre"))
6793 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6795 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6799 tunnel_filter_conf.tenant_id = res->tenant_id;
6800 tunnel_filter_conf.queue_id = res->queue_num;
6801 if (!strcmp(res->what, "add"))
6802 ret = rte_eth_dev_filter_ctrl(res->port_id,
6803 RTE_ETH_FILTER_TUNNEL,
6805 &tunnel_filter_conf);
6807 ret = rte_eth_dev_filter_ctrl(res->port_id,
6808 RTE_ETH_FILTER_TUNNEL,
6809 RTE_ETH_FILTER_DELETE,
6810 &tunnel_filter_conf);
6812 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6816 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6817 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6818 cmd, "tunnel_filter");
6819 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6820 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6822 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6823 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6825 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6826 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6828 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6829 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6831 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6833 inner_vlan, UINT16);
6834 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6835 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6837 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6838 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6839 tunnel_type, "vxlan#nvgre#ipingre");
6841 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6842 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6843 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6844 "imac#omac-imac-tenid");
6845 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6846 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6848 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6849 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6852 cmdline_parse_inst_t cmd_tunnel_filter = {
6853 .f = cmd_tunnel_filter_parsed,
6855 .help_str = "add/rm tunnel filter of a port: "
6856 "tunnel_filter add port_id outer_mac inner_mac ip "
6857 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6858 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6859 "imac|omac-imac-tenid) "
6860 "tenant_id queue_num",
6862 (void *)&cmd_tunnel_filter_cmd,
6863 (void *)&cmd_tunnel_filter_what,
6864 (void *)&cmd_tunnel_filter_port_id,
6865 (void *)&cmd_tunnel_filter_outer_mac,
6866 (void *)&cmd_tunnel_filter_inner_mac,
6867 (void *)&cmd_tunnel_filter_ip_value,
6868 (void *)&cmd_tunnel_filter_innner_vlan,
6869 (void *)&cmd_tunnel_filter_tunnel_type,
6870 (void *)&cmd_tunnel_filter_filter_type,
6871 (void *)&cmd_tunnel_filter_tenant_id,
6872 (void *)&cmd_tunnel_filter_queue_num,
6877 /* *** CONFIGURE TUNNEL UDP PORT *** */
6878 struct cmd_tunnel_udp_config {
6879 cmdline_fixed_string_t cmd;
6880 cmdline_fixed_string_t what;
6886 cmd_tunnel_udp_config_parsed(void *parsed_result,
6887 __attribute__((unused)) struct cmdline *cl,
6888 __attribute__((unused)) void *data)
6890 struct cmd_tunnel_udp_config *res = parsed_result;
6891 struct rte_eth_udp_tunnel tunnel_udp;
6894 tunnel_udp.udp_port = res->udp_port;
6896 if (!strcmp(res->cmd, "rx_vxlan_port"))
6897 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6899 if (!strcmp(res->what, "add"))
6900 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
6903 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
6907 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6910 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6911 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6912 cmd, "rx_vxlan_port");
6913 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6914 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6916 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6917 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6919 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6920 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6923 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6924 .f = cmd_tunnel_udp_config_parsed,
6926 .help_str = "add/rm an tunneling UDP port filter: "
6927 "rx_vxlan_port add udp_port port_id",
6929 (void *)&cmd_tunnel_udp_config_cmd,
6930 (void *)&cmd_tunnel_udp_config_what,
6931 (void *)&cmd_tunnel_udp_config_udp_port,
6932 (void *)&cmd_tunnel_udp_config_port_id,
6937 /* *** GLOBAL CONFIG *** */
6938 struct cmd_global_config_result {
6939 cmdline_fixed_string_t cmd;
6941 cmdline_fixed_string_t cfg_type;
6946 cmd_global_config_parsed(void *parsed_result,
6947 __attribute__((unused)) struct cmdline *cl,
6948 __attribute__((unused)) void *data)
6950 struct cmd_global_config_result *res = parsed_result;
6951 struct rte_eth_global_cfg conf;
6954 memset(&conf, 0, sizeof(conf));
6955 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6956 conf.cfg.gre_key_len = res->len;
6957 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6958 RTE_ETH_FILTER_SET, &conf);
6960 printf("Global config error\n");
6963 cmdline_parse_token_string_t cmd_global_config_cmd =
6964 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6966 cmdline_parse_token_num_t cmd_global_config_port_id =
6967 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6968 cmdline_parse_token_string_t cmd_global_config_type =
6969 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6970 cfg_type, "gre-key-len");
6971 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6972 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6975 cmdline_parse_inst_t cmd_global_config = {
6976 .f = cmd_global_config_parsed,
6977 .data = (void *)NULL,
6978 .help_str = "global_config <port_id> gre-key-len <number>",
6980 (void *)&cmd_global_config_cmd,
6981 (void *)&cmd_global_config_port_id,
6982 (void *)&cmd_global_config_type,
6983 (void *)&cmd_global_config_gre_key_len,
6988 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6989 struct cmd_set_mirror_mask_result {
6990 cmdline_fixed_string_t set;
6991 cmdline_fixed_string_t port;
6993 cmdline_fixed_string_t mirror;
6995 cmdline_fixed_string_t what;
6996 cmdline_fixed_string_t value;
6997 cmdline_fixed_string_t dstpool;
6999 cmdline_fixed_string_t on;
7002 cmdline_parse_token_string_t cmd_mirror_mask_set =
7003 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7005 cmdline_parse_token_string_t cmd_mirror_mask_port =
7006 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7008 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7009 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7011 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7012 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7013 mirror, "mirror-rule");
7014 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7015 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7017 cmdline_parse_token_string_t cmd_mirror_mask_what =
7018 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7019 what, "pool-mirror-up#pool-mirror-down"
7021 cmdline_parse_token_string_t cmd_mirror_mask_value =
7022 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7024 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7025 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7026 dstpool, "dst-pool");
7027 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7028 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7030 cmdline_parse_token_string_t cmd_mirror_mask_on =
7031 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7035 cmd_set_mirror_mask_parsed(void *parsed_result,
7036 __attribute__((unused)) struct cmdline *cl,
7037 __attribute__((unused)) void *data)
7040 struct cmd_set_mirror_mask_result *res = parsed_result;
7041 struct rte_eth_mirror_conf mr_conf;
7043 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7045 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7047 mr_conf.dst_pool = res->dstpool_id;
7049 if (!strcmp(res->what, "pool-mirror-up")) {
7050 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7051 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7052 } else if (!strcmp(res->what, "pool-mirror-down")) {
7053 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7054 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7055 } else if (!strcmp(res->what, "vlan-mirror")) {
7056 mr_conf.rule_type = ETH_MIRROR_VLAN;
7057 nb_item = parse_item_list(res->value, "vlan",
7058 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7062 for (i = 0; i < nb_item; i++) {
7063 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7064 printf("Invalid vlan_id: must be < 4096\n");
7068 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7069 mr_conf.vlan.vlan_mask |= 1ULL << i;
7073 if (!strcmp(res->on, "on"))
7074 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7077 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7080 printf("mirror rule add error: (%s)\n", strerror(-ret));
7083 cmdline_parse_inst_t cmd_set_mirror_mask = {
7084 .f = cmd_set_mirror_mask_parsed,
7086 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7087 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7089 (void *)&cmd_mirror_mask_set,
7090 (void *)&cmd_mirror_mask_port,
7091 (void *)&cmd_mirror_mask_portid,
7092 (void *)&cmd_mirror_mask_mirror,
7093 (void *)&cmd_mirror_mask_ruleid,
7094 (void *)&cmd_mirror_mask_what,
7095 (void *)&cmd_mirror_mask_value,
7096 (void *)&cmd_mirror_mask_dstpool,
7097 (void *)&cmd_mirror_mask_poolid,
7098 (void *)&cmd_mirror_mask_on,
7103 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7104 struct cmd_set_mirror_link_result {
7105 cmdline_fixed_string_t set;
7106 cmdline_fixed_string_t port;
7108 cmdline_fixed_string_t mirror;
7110 cmdline_fixed_string_t what;
7111 cmdline_fixed_string_t dstpool;
7113 cmdline_fixed_string_t on;
7116 cmdline_parse_token_string_t cmd_mirror_link_set =
7117 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7119 cmdline_parse_token_string_t cmd_mirror_link_port =
7120 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7122 cmdline_parse_token_num_t cmd_mirror_link_portid =
7123 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7125 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7126 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7127 mirror, "mirror-rule");
7128 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7129 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7131 cmdline_parse_token_string_t cmd_mirror_link_what =
7132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7133 what, "uplink-mirror#downlink-mirror");
7134 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7135 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7136 dstpool, "dst-pool");
7137 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7138 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7140 cmdline_parse_token_string_t cmd_mirror_link_on =
7141 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7145 cmd_set_mirror_link_parsed(void *parsed_result,
7146 __attribute__((unused)) struct cmdline *cl,
7147 __attribute__((unused)) void *data)
7150 struct cmd_set_mirror_link_result *res = parsed_result;
7151 struct rte_eth_mirror_conf mr_conf;
7153 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7154 if (!strcmp(res->what, "uplink-mirror"))
7155 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7157 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7159 mr_conf.dst_pool = res->dstpool_id;
7161 if (!strcmp(res->on, "on"))
7162 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7165 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7168 /* check the return value and print it if is < 0 */
7170 printf("mirror rule add error: (%s)\n", strerror(-ret));
7174 cmdline_parse_inst_t cmd_set_mirror_link = {
7175 .f = cmd_set_mirror_link_parsed,
7177 .help_str = "set port X mirror-rule Y uplink-mirror|"
7178 "downlink-mirror dst-pool Z on|off",
7180 (void *)&cmd_mirror_link_set,
7181 (void *)&cmd_mirror_link_port,
7182 (void *)&cmd_mirror_link_portid,
7183 (void *)&cmd_mirror_link_mirror,
7184 (void *)&cmd_mirror_link_ruleid,
7185 (void *)&cmd_mirror_link_what,
7186 (void *)&cmd_mirror_link_dstpool,
7187 (void *)&cmd_mirror_link_poolid,
7188 (void *)&cmd_mirror_link_on,
7193 /* *** RESET VM MIRROR RULE *** */
7194 struct cmd_rm_mirror_rule_result {
7195 cmdline_fixed_string_t reset;
7196 cmdline_fixed_string_t port;
7198 cmdline_fixed_string_t mirror;
7202 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7203 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7205 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7206 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7208 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7209 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7211 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7212 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7213 mirror, "mirror-rule");
7214 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7215 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7219 cmd_reset_mirror_rule_parsed(void *parsed_result,
7220 __attribute__((unused)) struct cmdline *cl,
7221 __attribute__((unused)) void *data)
7224 struct cmd_set_mirror_link_result *res = parsed_result;
7226 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7228 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7231 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7232 .f = cmd_reset_mirror_rule_parsed,
7234 .help_str = "reset port X mirror-rule Y",
7236 (void *)&cmd_rm_mirror_rule_reset,
7237 (void *)&cmd_rm_mirror_rule_port,
7238 (void *)&cmd_rm_mirror_rule_portid,
7239 (void *)&cmd_rm_mirror_rule_mirror,
7240 (void *)&cmd_rm_mirror_rule_ruleid,
7245 /* ******************************************************************************** */
7247 struct cmd_dump_result {
7248 cmdline_fixed_string_t dump;
7252 dump_struct_sizes(void)
7254 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7255 DUMP_SIZE(struct rte_mbuf);
7256 DUMP_SIZE(struct rte_mempool);
7257 DUMP_SIZE(struct rte_ring);
7261 static void cmd_dump_parsed(void *parsed_result,
7262 __attribute__((unused)) struct cmdline *cl,
7263 __attribute__((unused)) void *data)
7265 struct cmd_dump_result *res = parsed_result;
7267 if (!strcmp(res->dump, "dump_physmem"))
7268 rte_dump_physmem_layout(stdout);
7269 else if (!strcmp(res->dump, "dump_memzone"))
7270 rte_memzone_dump(stdout);
7271 else if (!strcmp(res->dump, "dump_log_history"))
7272 rte_log_dump_history(stdout);
7273 else if (!strcmp(res->dump, "dump_struct_sizes"))
7274 dump_struct_sizes();
7275 else if (!strcmp(res->dump, "dump_ring"))
7276 rte_ring_list_dump(stdout);
7277 else if (!strcmp(res->dump, "dump_mempool"))
7278 rte_mempool_list_dump(stdout);
7279 else if (!strcmp(res->dump, "dump_devargs"))
7280 rte_eal_devargs_dump(stdout);
7283 cmdline_parse_token_string_t cmd_dump_dump =
7284 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7288 "dump_struct_sizes#"
7293 cmdline_parse_inst_t cmd_dump = {
7294 .f = cmd_dump_parsed, /* function to call */
7295 .data = NULL, /* 2nd arg of func */
7296 .help_str = "dump status",
7297 .tokens = { /* token list, NULL terminated */
7298 (void *)&cmd_dump_dump,
7303 /* ******************************************************************************** */
7305 struct cmd_dump_one_result {
7306 cmdline_fixed_string_t dump;
7307 cmdline_fixed_string_t name;
7310 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7311 __attribute__((unused)) void *data)
7313 struct cmd_dump_one_result *res = parsed_result;
7315 if (!strcmp(res->dump, "dump_ring")) {
7317 r = rte_ring_lookup(res->name);
7319 cmdline_printf(cl, "Cannot find ring\n");
7322 rte_ring_dump(stdout, r);
7323 } else if (!strcmp(res->dump, "dump_mempool")) {
7324 struct rte_mempool *mp;
7325 mp = rte_mempool_lookup(res->name);
7327 cmdline_printf(cl, "Cannot find mempool\n");
7330 rte_mempool_dump(stdout, mp);
7334 cmdline_parse_token_string_t cmd_dump_one_dump =
7335 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7336 "dump_ring#dump_mempool");
7338 cmdline_parse_token_string_t cmd_dump_one_name =
7339 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7341 cmdline_parse_inst_t cmd_dump_one = {
7342 .f = cmd_dump_one_parsed, /* function to call */
7343 .data = NULL, /* 2nd arg of func */
7344 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7345 .tokens = { /* token list, NULL terminated */
7346 (void *)&cmd_dump_one_dump,
7347 (void *)&cmd_dump_one_name,
7352 /* *** Add/Del syn filter *** */
7353 struct cmd_syn_filter_result {
7354 cmdline_fixed_string_t filter;
7356 cmdline_fixed_string_t ops;
7357 cmdline_fixed_string_t priority;
7358 cmdline_fixed_string_t high;
7359 cmdline_fixed_string_t queue;
7364 cmd_syn_filter_parsed(void *parsed_result,
7365 __attribute__((unused)) struct cmdline *cl,
7366 __attribute__((unused)) void *data)
7368 struct cmd_syn_filter_result *res = parsed_result;
7369 struct rte_eth_syn_filter syn_filter;
7372 ret = rte_eth_dev_filter_supported(res->port_id,
7373 RTE_ETH_FILTER_SYN);
7375 printf("syn filter is not supported on port %u.\n",
7380 memset(&syn_filter, 0, sizeof(syn_filter));
7382 if (!strcmp(res->ops, "add")) {
7383 if (!strcmp(res->high, "high"))
7384 syn_filter.hig_pri = 1;
7386 syn_filter.hig_pri = 0;
7388 syn_filter.queue = res->queue_id;
7389 ret = rte_eth_dev_filter_ctrl(res->port_id,
7394 ret = rte_eth_dev_filter_ctrl(res->port_id,
7396 RTE_ETH_FILTER_DELETE,
7400 printf("syn filter programming error: (%s)\n",
7404 cmdline_parse_token_string_t cmd_syn_filter_filter =
7405 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7406 filter, "syn_filter");
7407 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7408 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7410 cmdline_parse_token_string_t cmd_syn_filter_ops =
7411 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7413 cmdline_parse_token_string_t cmd_syn_filter_priority =
7414 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7415 priority, "priority");
7416 cmdline_parse_token_string_t cmd_syn_filter_high =
7417 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7419 cmdline_parse_token_string_t cmd_syn_filter_queue =
7420 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7422 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7423 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7426 cmdline_parse_inst_t cmd_syn_filter = {
7427 .f = cmd_syn_filter_parsed,
7429 .help_str = "add/delete syn filter",
7431 (void *)&cmd_syn_filter_filter,
7432 (void *)&cmd_syn_filter_port_id,
7433 (void *)&cmd_syn_filter_ops,
7434 (void *)&cmd_syn_filter_priority,
7435 (void *)&cmd_syn_filter_high,
7436 (void *)&cmd_syn_filter_queue,
7437 (void *)&cmd_syn_filter_queue_id,
7442 /* *** ADD/REMOVE A 2tuple FILTER *** */
7443 struct cmd_2tuple_filter_result {
7444 cmdline_fixed_string_t filter;
7446 cmdline_fixed_string_t ops;
7447 cmdline_fixed_string_t dst_port;
7448 uint16_t dst_port_value;
7449 cmdline_fixed_string_t protocol;
7450 uint8_t protocol_value;
7451 cmdline_fixed_string_t mask;
7453 cmdline_fixed_string_t tcp_flags;
7454 uint8_t tcp_flags_value;
7455 cmdline_fixed_string_t priority;
7456 uint8_t priority_value;
7457 cmdline_fixed_string_t queue;
7462 cmd_2tuple_filter_parsed(void *parsed_result,
7463 __attribute__((unused)) struct cmdline *cl,
7464 __attribute__((unused)) void *data)
7466 struct rte_eth_ntuple_filter filter;
7467 struct cmd_2tuple_filter_result *res = parsed_result;
7470 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7472 printf("ntuple filter is not supported on port %u.\n",
7477 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7479 filter.flags = RTE_2TUPLE_FLAGS;
7480 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7481 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7482 filter.proto = res->protocol_value;
7483 filter.priority = res->priority_value;
7484 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7485 printf("nonzero tcp_flags is only meaningful"
7486 " when protocol is TCP.\n");
7489 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7490 printf("invalid TCP flags.\n");
7494 if (res->tcp_flags_value != 0) {
7495 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7496 filter.tcp_flags = res->tcp_flags_value;
7499 /* need convert to big endian. */
7500 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7501 filter.queue = res->queue_id;
7503 if (!strcmp(res->ops, "add"))
7504 ret = rte_eth_dev_filter_ctrl(res->port_id,
7505 RTE_ETH_FILTER_NTUPLE,
7509 ret = rte_eth_dev_filter_ctrl(res->port_id,
7510 RTE_ETH_FILTER_NTUPLE,
7511 RTE_ETH_FILTER_DELETE,
7514 printf("2tuple filter programming error: (%s)\n",
7519 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7520 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7521 filter, "2tuple_filter");
7522 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7523 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7525 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7526 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7528 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7529 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7530 dst_port, "dst_port");
7531 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7532 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7533 dst_port_value, UINT16);
7534 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7535 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7536 protocol, "protocol");
7537 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7538 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7539 protocol_value, UINT8);
7540 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7541 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7543 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7544 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7546 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7547 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7548 tcp_flags, "tcp_flags");
7549 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7550 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7551 tcp_flags_value, UINT8);
7552 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7553 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7554 priority, "priority");
7555 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7556 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7557 priority_value, UINT8);
7558 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7559 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7561 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7562 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7565 cmdline_parse_inst_t cmd_2tuple_filter = {
7566 .f = cmd_2tuple_filter_parsed,
7568 .help_str = "add a 2tuple filter",
7570 (void *)&cmd_2tuple_filter_filter,
7571 (void *)&cmd_2tuple_filter_port_id,
7572 (void *)&cmd_2tuple_filter_ops,
7573 (void *)&cmd_2tuple_filter_dst_port,
7574 (void *)&cmd_2tuple_filter_dst_port_value,
7575 (void *)&cmd_2tuple_filter_protocol,
7576 (void *)&cmd_2tuple_filter_protocol_value,
7577 (void *)&cmd_2tuple_filter_mask,
7578 (void *)&cmd_2tuple_filter_mask_value,
7579 (void *)&cmd_2tuple_filter_tcp_flags,
7580 (void *)&cmd_2tuple_filter_tcp_flags_value,
7581 (void *)&cmd_2tuple_filter_priority,
7582 (void *)&cmd_2tuple_filter_priority_value,
7583 (void *)&cmd_2tuple_filter_queue,
7584 (void *)&cmd_2tuple_filter_queue_id,
7589 /* *** ADD/REMOVE A 5tuple FILTER *** */
7590 struct cmd_5tuple_filter_result {
7591 cmdline_fixed_string_t filter;
7593 cmdline_fixed_string_t ops;
7594 cmdline_fixed_string_t dst_ip;
7595 cmdline_ipaddr_t dst_ip_value;
7596 cmdline_fixed_string_t src_ip;
7597 cmdline_ipaddr_t src_ip_value;
7598 cmdline_fixed_string_t dst_port;
7599 uint16_t dst_port_value;
7600 cmdline_fixed_string_t src_port;
7601 uint16_t src_port_value;
7602 cmdline_fixed_string_t protocol;
7603 uint8_t protocol_value;
7604 cmdline_fixed_string_t mask;
7606 cmdline_fixed_string_t tcp_flags;
7607 uint8_t tcp_flags_value;
7608 cmdline_fixed_string_t priority;
7609 uint8_t priority_value;
7610 cmdline_fixed_string_t queue;
7615 cmd_5tuple_filter_parsed(void *parsed_result,
7616 __attribute__((unused)) struct cmdline *cl,
7617 __attribute__((unused)) void *data)
7619 struct rte_eth_ntuple_filter filter;
7620 struct cmd_5tuple_filter_result *res = parsed_result;
7623 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7625 printf("ntuple filter is not supported on port %u.\n",
7630 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7632 filter.flags = RTE_5TUPLE_FLAGS;
7633 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7634 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7635 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7636 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7637 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7638 filter.proto = res->protocol_value;
7639 filter.priority = res->priority_value;
7640 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7641 printf("nonzero tcp_flags is only meaningful"
7642 " when protocol is TCP.\n");
7645 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7646 printf("invalid TCP flags.\n");
7650 if (res->tcp_flags_value != 0) {
7651 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7652 filter.tcp_flags = res->tcp_flags_value;
7655 if (res->dst_ip_value.family == AF_INET)
7656 /* no need to convert, already big endian. */
7657 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7659 if (filter.dst_ip_mask == 0) {
7660 printf("can not support ipv6 involved compare.\n");
7666 if (res->src_ip_value.family == AF_INET)
7667 /* no need to convert, already big endian. */
7668 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7670 if (filter.src_ip_mask == 0) {
7671 printf("can not support ipv6 involved compare.\n");
7676 /* need convert to big endian. */
7677 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7678 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7679 filter.queue = res->queue_id;
7681 if (!strcmp(res->ops, "add"))
7682 ret = rte_eth_dev_filter_ctrl(res->port_id,
7683 RTE_ETH_FILTER_NTUPLE,
7687 ret = rte_eth_dev_filter_ctrl(res->port_id,
7688 RTE_ETH_FILTER_NTUPLE,
7689 RTE_ETH_FILTER_DELETE,
7692 printf("5tuple filter programming error: (%s)\n",
7696 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7697 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7698 filter, "5tuple_filter");
7699 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7700 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7702 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7703 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7705 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7706 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7708 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7709 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7711 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7712 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7714 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7715 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7717 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7718 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7719 dst_port, "dst_port");
7720 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7721 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7722 dst_port_value, UINT16);
7723 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7724 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7725 src_port, "src_port");
7726 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7727 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7728 src_port_value, UINT16);
7729 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7730 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7731 protocol, "protocol");
7732 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7733 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7734 protocol_value, UINT8);
7735 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7736 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7738 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7739 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7741 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7742 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7743 tcp_flags, "tcp_flags");
7744 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7745 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7746 tcp_flags_value, UINT8);
7747 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7748 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7749 priority, "priority");
7750 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7751 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7752 priority_value, UINT8);
7753 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7754 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7756 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7757 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7760 cmdline_parse_inst_t cmd_5tuple_filter = {
7761 .f = cmd_5tuple_filter_parsed,
7763 .help_str = "add/del a 5tuple filter",
7765 (void *)&cmd_5tuple_filter_filter,
7766 (void *)&cmd_5tuple_filter_port_id,
7767 (void *)&cmd_5tuple_filter_ops,
7768 (void *)&cmd_5tuple_filter_dst_ip,
7769 (void *)&cmd_5tuple_filter_dst_ip_value,
7770 (void *)&cmd_5tuple_filter_src_ip,
7771 (void *)&cmd_5tuple_filter_src_ip_value,
7772 (void *)&cmd_5tuple_filter_dst_port,
7773 (void *)&cmd_5tuple_filter_dst_port_value,
7774 (void *)&cmd_5tuple_filter_src_port,
7775 (void *)&cmd_5tuple_filter_src_port_value,
7776 (void *)&cmd_5tuple_filter_protocol,
7777 (void *)&cmd_5tuple_filter_protocol_value,
7778 (void *)&cmd_5tuple_filter_mask,
7779 (void *)&cmd_5tuple_filter_mask_value,
7780 (void *)&cmd_5tuple_filter_tcp_flags,
7781 (void *)&cmd_5tuple_filter_tcp_flags_value,
7782 (void *)&cmd_5tuple_filter_priority,
7783 (void *)&cmd_5tuple_filter_priority_value,
7784 (void *)&cmd_5tuple_filter_queue,
7785 (void *)&cmd_5tuple_filter_queue_id,
7790 /* *** ADD/REMOVE A flex FILTER *** */
7791 struct cmd_flex_filter_result {
7792 cmdline_fixed_string_t filter;
7793 cmdline_fixed_string_t ops;
7795 cmdline_fixed_string_t len;
7797 cmdline_fixed_string_t bytes;
7798 cmdline_fixed_string_t bytes_value;
7799 cmdline_fixed_string_t mask;
7800 cmdline_fixed_string_t mask_value;
7801 cmdline_fixed_string_t priority;
7802 uint8_t priority_value;
7803 cmdline_fixed_string_t queue;
7807 static int xdigit2val(unsigned char c)
7812 else if (isupper(c))
7820 cmd_flex_filter_parsed(void *parsed_result,
7821 __attribute__((unused)) struct cmdline *cl,
7822 __attribute__((unused)) void *data)
7825 struct rte_eth_flex_filter filter;
7826 struct cmd_flex_filter_result *res = parsed_result;
7827 char *bytes_ptr, *mask_ptr;
7828 uint16_t len, i, j = 0;
7833 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7834 printf("the len exceed the max length 128\n");
7837 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7838 filter.len = res->len_value;
7839 filter.priority = res->priority_value;
7840 filter.queue = res->queue_id;
7841 bytes_ptr = res->bytes_value;
7842 mask_ptr = res->mask_value;
7844 /* translate bytes string to array. */
7845 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7846 (bytes_ptr[1] == 'X')))
7848 len = strnlen(bytes_ptr, res->len_value * 2);
7849 if (len == 0 || (len % 8 != 0)) {
7850 printf("please check len and bytes input\n");
7853 for (i = 0; i < len; i++) {
7855 if (isxdigit(c) == 0) {
7856 /* invalid characters. */
7857 printf("invalid input\n");
7860 val = xdigit2val(c);
7863 filter.bytes[j] = byte;
7864 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7871 /* translate mask string to uint8_t array. */
7872 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7873 (mask_ptr[1] == 'X')))
7875 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7877 printf("invalid input\n");
7882 for (i = 0; i < len; i++) {
7884 if (isxdigit(c) == 0) {
7885 /* invalid characters. */
7886 printf("invalid input\n");
7889 val = xdigit2val(c);
7892 filter.mask[j] = byte;
7893 printf("mask[%d]:%02x ", j, filter.mask[j]);
7901 if (!strcmp(res->ops, "add"))
7902 ret = rte_eth_dev_filter_ctrl(res->port_id,
7903 RTE_ETH_FILTER_FLEXIBLE,
7907 ret = rte_eth_dev_filter_ctrl(res->port_id,
7908 RTE_ETH_FILTER_FLEXIBLE,
7909 RTE_ETH_FILTER_DELETE,
7913 printf("flex filter setting error: (%s)\n", strerror(-ret));
7916 cmdline_parse_token_string_t cmd_flex_filter_filter =
7917 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7918 filter, "flex_filter");
7919 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7920 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7922 cmdline_parse_token_string_t cmd_flex_filter_ops =
7923 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7925 cmdline_parse_token_string_t cmd_flex_filter_len =
7926 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7928 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7929 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7931 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7932 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7934 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7935 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7937 cmdline_parse_token_string_t cmd_flex_filter_mask =
7938 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7940 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7941 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7943 cmdline_parse_token_string_t cmd_flex_filter_priority =
7944 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7945 priority, "priority");
7946 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7947 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7948 priority_value, UINT8);
7949 cmdline_parse_token_string_t cmd_flex_filter_queue =
7950 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7952 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7953 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7955 cmdline_parse_inst_t cmd_flex_filter = {
7956 .f = cmd_flex_filter_parsed,
7958 .help_str = "add/del a flex filter",
7960 (void *)&cmd_flex_filter_filter,
7961 (void *)&cmd_flex_filter_port_id,
7962 (void *)&cmd_flex_filter_ops,
7963 (void *)&cmd_flex_filter_len,
7964 (void *)&cmd_flex_filter_len_value,
7965 (void *)&cmd_flex_filter_bytes,
7966 (void *)&cmd_flex_filter_bytes_value,
7967 (void *)&cmd_flex_filter_mask,
7968 (void *)&cmd_flex_filter_mask_value,
7969 (void *)&cmd_flex_filter_priority,
7970 (void *)&cmd_flex_filter_priority_value,
7971 (void *)&cmd_flex_filter_queue,
7972 (void *)&cmd_flex_filter_queue_id,
7977 /* *** Filters Control *** */
7979 /* *** deal with ethertype filter *** */
7980 struct cmd_ethertype_filter_result {
7981 cmdline_fixed_string_t filter;
7983 cmdline_fixed_string_t ops;
7984 cmdline_fixed_string_t mac;
7985 struct ether_addr mac_addr;
7986 cmdline_fixed_string_t ethertype;
7987 uint16_t ethertype_value;
7988 cmdline_fixed_string_t drop;
7989 cmdline_fixed_string_t queue;
7993 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7994 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7995 filter, "ethertype_filter");
7996 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7997 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7999 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8000 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8002 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8003 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8004 mac, "mac_addr#mac_ignr");
8005 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8006 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8008 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8009 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8010 ethertype, "ethertype");
8011 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8012 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8013 ethertype_value, UINT16);
8014 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8015 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8017 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8018 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8020 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8021 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8025 cmd_ethertype_filter_parsed(void *parsed_result,
8026 __attribute__((unused)) struct cmdline *cl,
8027 __attribute__((unused)) void *data)
8029 struct cmd_ethertype_filter_result *res = parsed_result;
8030 struct rte_eth_ethertype_filter filter;
8033 ret = rte_eth_dev_filter_supported(res->port_id,
8034 RTE_ETH_FILTER_ETHERTYPE);
8036 printf("ethertype filter is not supported on port %u.\n",
8041 memset(&filter, 0, sizeof(filter));
8042 if (!strcmp(res->mac, "mac_addr")) {
8043 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8044 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8045 sizeof(struct ether_addr));
8047 if (!strcmp(res->drop, "drop"))
8048 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8049 filter.ether_type = res->ethertype_value;
8050 filter.queue = res->queue_id;
8052 if (!strcmp(res->ops, "add"))
8053 ret = rte_eth_dev_filter_ctrl(res->port_id,
8054 RTE_ETH_FILTER_ETHERTYPE,
8058 ret = rte_eth_dev_filter_ctrl(res->port_id,
8059 RTE_ETH_FILTER_ETHERTYPE,
8060 RTE_ETH_FILTER_DELETE,
8063 printf("ethertype filter programming error: (%s)\n",
8067 cmdline_parse_inst_t cmd_ethertype_filter = {
8068 .f = cmd_ethertype_filter_parsed,
8070 .help_str = "add or delete an ethertype filter entry",
8072 (void *)&cmd_ethertype_filter_filter,
8073 (void *)&cmd_ethertype_filter_port_id,
8074 (void *)&cmd_ethertype_filter_ops,
8075 (void *)&cmd_ethertype_filter_mac,
8076 (void *)&cmd_ethertype_filter_mac_addr,
8077 (void *)&cmd_ethertype_filter_ethertype,
8078 (void *)&cmd_ethertype_filter_ethertype_value,
8079 (void *)&cmd_ethertype_filter_drop,
8080 (void *)&cmd_ethertype_filter_queue,
8081 (void *)&cmd_ethertype_filter_queue_id,
8086 /* *** deal with flow director filter *** */
8087 struct cmd_flow_director_result {
8088 cmdline_fixed_string_t flow_director_filter;
8090 cmdline_fixed_string_t mode;
8091 cmdline_fixed_string_t mode_value;
8092 cmdline_fixed_string_t ops;
8093 cmdline_fixed_string_t flow;
8094 cmdline_fixed_string_t flow_type;
8095 cmdline_fixed_string_t ether;
8096 uint16_t ether_type;
8097 cmdline_fixed_string_t src;
8098 cmdline_ipaddr_t ip_src;
8100 cmdline_fixed_string_t dst;
8101 cmdline_ipaddr_t ip_dst;
8103 cmdline_fixed_string_t verify_tag;
8104 uint32_t verify_tag_value;
8105 cmdline_ipaddr_t tos;
8107 cmdline_ipaddr_t proto;
8108 uint8_t proto_value;
8109 cmdline_ipaddr_t ttl;
8111 cmdline_fixed_string_t vlan;
8112 uint16_t vlan_value;
8113 cmdline_fixed_string_t flexbytes;
8114 cmdline_fixed_string_t flexbytes_value;
8115 cmdline_fixed_string_t pf_vf;
8116 cmdline_fixed_string_t drop;
8117 cmdline_fixed_string_t queue;
8119 cmdline_fixed_string_t fd_id;
8120 uint32_t fd_id_value;
8121 cmdline_fixed_string_t mac;
8122 struct ether_addr mac_addr;
8123 cmdline_fixed_string_t tunnel;
8124 cmdline_fixed_string_t tunnel_type;
8125 cmdline_fixed_string_t tunnel_id;
8126 uint32_t tunnel_id_value;
8130 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8133 const char *p, *p0 = q_arg;
8135 unsigned long int_fld;
8136 char *str_fld[max_num];
8141 p = strchr(p0, '(');
8145 p0 = strchr(p, ')');
8150 if (size >= sizeof(s))
8153 snprintf(s, sizeof(s), "%.*s", size, p);
8154 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8155 if (ret < 0 || ret > max_num)
8157 for (i = 0; i < ret; i++) {
8159 int_fld = strtoul(str_fld[i], &end, 0);
8160 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8162 flexbytes[i] = (uint8_t)int_fld;
8168 str2flowtype(char *string)
8171 static const struct {
8174 } flowtype_str[] = {
8175 {"raw", RTE_ETH_FLOW_RAW},
8176 {"ipv4", RTE_ETH_FLOW_IPV4},
8177 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8178 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8179 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8180 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8181 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8182 {"ipv6", RTE_ETH_FLOW_IPV6},
8183 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8184 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8185 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8186 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8187 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8188 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8191 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8192 if (!strcmp(flowtype_str[i].str, string))
8193 return flowtype_str[i].type;
8195 return RTE_ETH_FLOW_UNKNOWN;
8198 static enum rte_eth_fdir_tunnel_type
8199 str2fdir_tunneltype(char *string)
8203 static const struct {
8205 enum rte_eth_fdir_tunnel_type type;
8206 } tunneltype_str[] = {
8207 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8208 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8211 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8212 if (!strcmp(tunneltype_str[i].str, string))
8213 return tunneltype_str[i].type;
8215 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8218 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8220 if ((ip_addr).family == AF_INET) \
8221 (ip) = (ip_addr).addr.ipv4.s_addr; \
8223 printf("invalid parameter.\n"); \
8228 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8230 if ((ip_addr).family == AF_INET6) \
8231 (void)rte_memcpy(&(ip), \
8232 &((ip_addr).addr.ipv6), \
8233 sizeof(struct in6_addr)); \
8235 printf("invalid parameter.\n"); \
8241 cmd_flow_director_filter_parsed(void *parsed_result,
8242 __attribute__((unused)) struct cmdline *cl,
8243 __attribute__((unused)) void *data)
8245 struct cmd_flow_director_result *res = parsed_result;
8246 struct rte_eth_fdir_filter entry;
8247 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8249 unsigned long vf_id;
8252 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8254 printf("flow director is not supported on port %u.\n",
8258 memset(flexbytes, 0, sizeof(flexbytes));
8259 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8261 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8262 if (strcmp(res->mode_value, "MAC-VLAN")) {
8263 printf("Please set mode to MAC-VLAN.\n");
8266 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8267 if (strcmp(res->mode_value, "Tunnel")) {
8268 printf("Please set mode to Tunnel.\n");
8272 if (strcmp(res->mode_value, "IP")) {
8273 printf("Please set mode to IP.\n");
8276 entry.input.flow_type = str2flowtype(res->flow_type);
8279 ret = parse_flexbytes(res->flexbytes_value,
8281 RTE_ETH_FDIR_MAX_FLEXLEN);
8283 printf("error: Cannot parse flexbytes input.\n");
8287 switch (entry.input.flow_type) {
8288 case RTE_ETH_FLOW_FRAG_IPV4:
8289 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8290 entry.input.flow.ip4_flow.proto = res->proto_value;
8291 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8292 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8293 IPV4_ADDR_TO_UINT(res->ip_dst,
8294 entry.input.flow.ip4_flow.dst_ip);
8295 IPV4_ADDR_TO_UINT(res->ip_src,
8296 entry.input.flow.ip4_flow.src_ip);
8297 entry.input.flow.ip4_flow.tos = res->tos_value;
8298 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8299 /* need convert to big endian. */
8300 entry.input.flow.udp4_flow.dst_port =
8301 rte_cpu_to_be_16(res->port_dst);
8302 entry.input.flow.udp4_flow.src_port =
8303 rte_cpu_to_be_16(res->port_src);
8305 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8306 IPV4_ADDR_TO_UINT(res->ip_dst,
8307 entry.input.flow.sctp4_flow.ip.dst_ip);
8308 IPV4_ADDR_TO_UINT(res->ip_src,
8309 entry.input.flow.sctp4_flow.ip.src_ip);
8310 entry.input.flow.ip4_flow.tos = res->tos_value;
8311 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8312 /* need convert to big endian. */
8313 entry.input.flow.sctp4_flow.dst_port =
8314 rte_cpu_to_be_16(res->port_dst);
8315 entry.input.flow.sctp4_flow.src_port =
8316 rte_cpu_to_be_16(res->port_src);
8317 entry.input.flow.sctp4_flow.verify_tag =
8318 rte_cpu_to_be_32(res->verify_tag_value);
8320 case RTE_ETH_FLOW_FRAG_IPV6:
8321 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8322 entry.input.flow.ipv6_flow.proto = res->proto_value;
8323 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8324 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8325 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8326 entry.input.flow.ipv6_flow.dst_ip);
8327 IPV6_ADDR_TO_ARRAY(res->ip_src,
8328 entry.input.flow.ipv6_flow.src_ip);
8329 entry.input.flow.ipv6_flow.tc = res->tos_value;
8330 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8331 /* need convert to big endian. */
8332 entry.input.flow.udp6_flow.dst_port =
8333 rte_cpu_to_be_16(res->port_dst);
8334 entry.input.flow.udp6_flow.src_port =
8335 rte_cpu_to_be_16(res->port_src);
8337 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8338 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8339 entry.input.flow.sctp6_flow.ip.dst_ip);
8340 IPV6_ADDR_TO_ARRAY(res->ip_src,
8341 entry.input.flow.sctp6_flow.ip.src_ip);
8342 entry.input.flow.ipv6_flow.tc = res->tos_value;
8343 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8344 /* need convert to big endian. */
8345 entry.input.flow.sctp6_flow.dst_port =
8346 rte_cpu_to_be_16(res->port_dst);
8347 entry.input.flow.sctp6_flow.src_port =
8348 rte_cpu_to_be_16(res->port_src);
8349 entry.input.flow.sctp6_flow.verify_tag =
8350 rte_cpu_to_be_32(res->verify_tag_value);
8352 case RTE_ETH_FLOW_L2_PAYLOAD:
8353 entry.input.flow.l2_flow.ether_type =
8354 rte_cpu_to_be_16(res->ether_type);
8360 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8361 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8363 sizeof(struct ether_addr));
8365 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8366 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8368 sizeof(struct ether_addr));
8369 entry.input.flow.tunnel_flow.tunnel_type =
8370 str2fdir_tunneltype(res->tunnel_type);
8371 entry.input.flow.tunnel_flow.tunnel_id =
8372 rte_cpu_to_be_32(res->tunnel_id_value);
8375 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8377 RTE_ETH_FDIR_MAX_FLEXLEN);
8379 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8381 entry.action.flex_off = 0; /*use 0 by default */
8382 if (!strcmp(res->drop, "drop"))
8383 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8385 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8387 if (!strcmp(res->pf_vf, "pf"))
8388 entry.input.flow_ext.is_vf = 0;
8389 else if (!strncmp(res->pf_vf, "vf", 2)) {
8390 struct rte_eth_dev_info dev_info;
8392 memset(&dev_info, 0, sizeof(dev_info));
8393 rte_eth_dev_info_get(res->port_id, &dev_info);
8395 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8396 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8397 printf("invalid parameter %s.\n", res->pf_vf);
8400 entry.input.flow_ext.is_vf = 1;
8401 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8403 printf("invalid parameter %s.\n", res->pf_vf);
8407 /* set to report FD ID by default */
8408 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8409 entry.action.rx_queue = res->queue_id;
8410 entry.soft_id = res->fd_id_value;
8411 if (!strcmp(res->ops, "add"))
8412 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8413 RTE_ETH_FILTER_ADD, &entry);
8414 else if (!strcmp(res->ops, "del"))
8415 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8416 RTE_ETH_FILTER_DELETE, &entry);
8418 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8419 RTE_ETH_FILTER_UPDATE, &entry);
8421 printf("flow director programming error: (%s)\n",
8425 cmdline_parse_token_string_t cmd_flow_director_filter =
8426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8427 flow_director_filter, "flow_director_filter");
8428 cmdline_parse_token_num_t cmd_flow_director_port_id =
8429 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8431 cmdline_parse_token_string_t cmd_flow_director_ops =
8432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8433 ops, "add#del#update");
8434 cmdline_parse_token_string_t cmd_flow_director_flow =
8435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8437 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8439 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8440 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8441 cmdline_parse_token_string_t cmd_flow_director_ether =
8442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8444 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8446 ether_type, UINT16);
8447 cmdline_parse_token_string_t cmd_flow_director_src =
8448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8450 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8451 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8453 cmdline_parse_token_num_t cmd_flow_director_port_src =
8454 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8456 cmdline_parse_token_string_t cmd_flow_director_dst =
8457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8459 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8460 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8462 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8463 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8465 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8467 verify_tag, "verify_tag");
8468 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8469 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8470 verify_tag_value, UINT32);
8471 cmdline_parse_token_string_t cmd_flow_director_tos =
8472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8474 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8475 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8477 cmdline_parse_token_string_t cmd_flow_director_proto =
8478 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8480 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8481 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8482 proto_value, UINT8);
8483 cmdline_parse_token_string_t cmd_flow_director_ttl =
8484 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8486 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8487 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8489 cmdline_parse_token_string_t cmd_flow_director_vlan =
8490 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8492 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8493 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8494 vlan_value, UINT16);
8495 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8497 flexbytes, "flexbytes");
8498 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8499 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8500 flexbytes_value, NULL);
8501 cmdline_parse_token_string_t cmd_flow_director_drop =
8502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8504 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8507 cmdline_parse_token_string_t cmd_flow_director_queue =
8508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8510 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8511 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8513 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8514 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8516 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8517 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8518 fd_id_value, UINT32);
8520 cmdline_parse_token_string_t cmd_flow_director_mode =
8521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8523 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8526 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8528 mode_value, "MAC-VLAN");
8529 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8531 mode_value, "Tunnel");
8532 cmdline_parse_token_string_t cmd_flow_director_mac =
8533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8535 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8536 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8538 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8541 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8543 tunnel_type, "NVGRE#VxLAN");
8544 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8546 tunnel_id, "tunnel-id");
8547 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8548 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8549 tunnel_id_value, UINT32);
8551 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8552 .f = cmd_flow_director_filter_parsed,
8554 .help_str = "add or delete an ip flow director entry on NIC",
8556 (void *)&cmd_flow_director_filter,
8557 (void *)&cmd_flow_director_port_id,
8558 (void *)&cmd_flow_director_mode,
8559 (void *)&cmd_flow_director_mode_ip,
8560 (void *)&cmd_flow_director_ops,
8561 (void *)&cmd_flow_director_flow,
8562 (void *)&cmd_flow_director_flow_type,
8563 (void *)&cmd_flow_director_src,
8564 (void *)&cmd_flow_director_ip_src,
8565 (void *)&cmd_flow_director_dst,
8566 (void *)&cmd_flow_director_ip_dst,
8567 (void *)&cmd_flow_director_tos,
8568 (void *)&cmd_flow_director_tos_value,
8569 (void *)&cmd_flow_director_proto,
8570 (void *)&cmd_flow_director_proto_value,
8571 (void *)&cmd_flow_director_ttl,
8572 (void *)&cmd_flow_director_ttl_value,
8573 (void *)&cmd_flow_director_vlan,
8574 (void *)&cmd_flow_director_vlan_value,
8575 (void *)&cmd_flow_director_flexbytes,
8576 (void *)&cmd_flow_director_flexbytes_value,
8577 (void *)&cmd_flow_director_drop,
8578 (void *)&cmd_flow_director_pf_vf,
8579 (void *)&cmd_flow_director_queue,
8580 (void *)&cmd_flow_director_queue_id,
8581 (void *)&cmd_flow_director_fd_id,
8582 (void *)&cmd_flow_director_fd_id_value,
8587 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8588 .f = cmd_flow_director_filter_parsed,
8590 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8592 (void *)&cmd_flow_director_filter,
8593 (void *)&cmd_flow_director_port_id,
8594 (void *)&cmd_flow_director_mode,
8595 (void *)&cmd_flow_director_mode_ip,
8596 (void *)&cmd_flow_director_ops,
8597 (void *)&cmd_flow_director_flow,
8598 (void *)&cmd_flow_director_flow_type,
8599 (void *)&cmd_flow_director_src,
8600 (void *)&cmd_flow_director_ip_src,
8601 (void *)&cmd_flow_director_port_src,
8602 (void *)&cmd_flow_director_dst,
8603 (void *)&cmd_flow_director_ip_dst,
8604 (void *)&cmd_flow_director_port_dst,
8605 (void *)&cmd_flow_director_tos,
8606 (void *)&cmd_flow_director_tos_value,
8607 (void *)&cmd_flow_director_ttl,
8608 (void *)&cmd_flow_director_ttl_value,
8609 (void *)&cmd_flow_director_vlan,
8610 (void *)&cmd_flow_director_vlan_value,
8611 (void *)&cmd_flow_director_flexbytes,
8612 (void *)&cmd_flow_director_flexbytes_value,
8613 (void *)&cmd_flow_director_drop,
8614 (void *)&cmd_flow_director_pf_vf,
8615 (void *)&cmd_flow_director_queue,
8616 (void *)&cmd_flow_director_queue_id,
8617 (void *)&cmd_flow_director_fd_id,
8618 (void *)&cmd_flow_director_fd_id_value,
8623 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8624 .f = cmd_flow_director_filter_parsed,
8626 .help_str = "add or delete a sctp flow director entry on NIC",
8628 (void *)&cmd_flow_director_filter,
8629 (void *)&cmd_flow_director_port_id,
8630 (void *)&cmd_flow_director_mode,
8631 (void *)&cmd_flow_director_mode_ip,
8632 (void *)&cmd_flow_director_ops,
8633 (void *)&cmd_flow_director_flow,
8634 (void *)&cmd_flow_director_flow_type,
8635 (void *)&cmd_flow_director_src,
8636 (void *)&cmd_flow_director_ip_src,
8637 (void *)&cmd_flow_director_port_dst,
8638 (void *)&cmd_flow_director_dst,
8639 (void *)&cmd_flow_director_ip_dst,
8640 (void *)&cmd_flow_director_port_dst,
8641 (void *)&cmd_flow_director_verify_tag,
8642 (void *)&cmd_flow_director_verify_tag_value,
8643 (void *)&cmd_flow_director_tos,
8644 (void *)&cmd_flow_director_tos_value,
8645 (void *)&cmd_flow_director_ttl,
8646 (void *)&cmd_flow_director_ttl_value,
8647 (void *)&cmd_flow_director_vlan,
8648 (void *)&cmd_flow_director_vlan_value,
8649 (void *)&cmd_flow_director_flexbytes,
8650 (void *)&cmd_flow_director_flexbytes_value,
8651 (void *)&cmd_flow_director_drop,
8652 (void *)&cmd_flow_director_pf_vf,
8653 (void *)&cmd_flow_director_queue,
8654 (void *)&cmd_flow_director_queue_id,
8655 (void *)&cmd_flow_director_fd_id,
8656 (void *)&cmd_flow_director_fd_id_value,
8661 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8662 .f = cmd_flow_director_filter_parsed,
8664 .help_str = "add or delete a L2 flow director entry on NIC",
8666 (void *)&cmd_flow_director_filter,
8667 (void *)&cmd_flow_director_port_id,
8668 (void *)&cmd_flow_director_mode,
8669 (void *)&cmd_flow_director_mode_ip,
8670 (void *)&cmd_flow_director_ops,
8671 (void *)&cmd_flow_director_flow,
8672 (void *)&cmd_flow_director_flow_type,
8673 (void *)&cmd_flow_director_ether,
8674 (void *)&cmd_flow_director_ether_type,
8675 (void *)&cmd_flow_director_flexbytes,
8676 (void *)&cmd_flow_director_flexbytes_value,
8677 (void *)&cmd_flow_director_drop,
8678 (void *)&cmd_flow_director_pf_vf,
8679 (void *)&cmd_flow_director_queue,
8680 (void *)&cmd_flow_director_queue_id,
8681 (void *)&cmd_flow_director_fd_id,
8682 (void *)&cmd_flow_director_fd_id_value,
8687 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8688 .f = cmd_flow_director_filter_parsed,
8690 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8692 (void *)&cmd_flow_director_filter,
8693 (void *)&cmd_flow_director_port_id,
8694 (void *)&cmd_flow_director_mode,
8695 (void *)&cmd_flow_director_mode_mac_vlan,
8696 (void *)&cmd_flow_director_ops,
8697 (void *)&cmd_flow_director_mac,
8698 (void *)&cmd_flow_director_mac_addr,
8699 (void *)&cmd_flow_director_vlan,
8700 (void *)&cmd_flow_director_vlan_value,
8701 (void *)&cmd_flow_director_flexbytes,
8702 (void *)&cmd_flow_director_flexbytes_value,
8703 (void *)&cmd_flow_director_drop,
8704 (void *)&cmd_flow_director_queue,
8705 (void *)&cmd_flow_director_queue_id,
8706 (void *)&cmd_flow_director_fd_id,
8707 (void *)&cmd_flow_director_fd_id_value,
8712 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8713 .f = cmd_flow_director_filter_parsed,
8715 .help_str = "add or delete a tunnel flow director entry on NIC",
8717 (void *)&cmd_flow_director_filter,
8718 (void *)&cmd_flow_director_port_id,
8719 (void *)&cmd_flow_director_mode,
8720 (void *)&cmd_flow_director_mode_tunnel,
8721 (void *)&cmd_flow_director_ops,
8722 (void *)&cmd_flow_director_mac,
8723 (void *)&cmd_flow_director_mac_addr,
8724 (void *)&cmd_flow_director_vlan,
8725 (void *)&cmd_flow_director_vlan_value,
8726 (void *)&cmd_flow_director_tunnel,
8727 (void *)&cmd_flow_director_tunnel_type,
8728 (void *)&cmd_flow_director_tunnel_id,
8729 (void *)&cmd_flow_director_tunnel_id_value,
8730 (void *)&cmd_flow_director_flexbytes,
8731 (void *)&cmd_flow_director_flexbytes_value,
8732 (void *)&cmd_flow_director_drop,
8733 (void *)&cmd_flow_director_queue,
8734 (void *)&cmd_flow_director_queue_id,
8735 (void *)&cmd_flow_director_fd_id,
8736 (void *)&cmd_flow_director_fd_id_value,
8741 struct cmd_flush_flow_director_result {
8742 cmdline_fixed_string_t flush_flow_director;
8746 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8747 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8748 flush_flow_director, "flush_flow_director");
8749 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8750 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8754 cmd_flush_flow_director_parsed(void *parsed_result,
8755 __attribute__((unused)) struct cmdline *cl,
8756 __attribute__((unused)) void *data)
8758 struct cmd_flow_director_result *res = parsed_result;
8761 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8763 printf("flow director is not supported on port %u.\n",
8768 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8769 RTE_ETH_FILTER_FLUSH, NULL);
8771 printf("flow director table flushing error: (%s)\n",
8775 cmdline_parse_inst_t cmd_flush_flow_director = {
8776 .f = cmd_flush_flow_director_parsed,
8778 .help_str = "flush all flow director entries of a device on NIC",
8780 (void *)&cmd_flush_flow_director_flush,
8781 (void *)&cmd_flush_flow_director_port_id,
8786 /* *** deal with flow director mask *** */
8787 struct cmd_flow_director_mask_result {
8788 cmdline_fixed_string_t flow_director_mask;
8790 cmdline_fixed_string_t mode;
8791 cmdline_fixed_string_t mode_value;
8792 cmdline_fixed_string_t vlan;
8794 cmdline_fixed_string_t src_mask;
8795 cmdline_ipaddr_t ipv4_src;
8796 cmdline_ipaddr_t ipv6_src;
8798 cmdline_fixed_string_t dst_mask;
8799 cmdline_ipaddr_t ipv4_dst;
8800 cmdline_ipaddr_t ipv6_dst;
8802 cmdline_fixed_string_t mac;
8803 uint8_t mac_addr_byte_mask;
8804 cmdline_fixed_string_t tunnel_id;
8805 uint32_t tunnel_id_mask;
8806 cmdline_fixed_string_t tunnel_type;
8807 uint8_t tunnel_type_mask;
8811 cmd_flow_director_mask_parsed(void *parsed_result,
8812 __attribute__((unused)) struct cmdline *cl,
8813 __attribute__((unused)) void *data)
8815 struct cmd_flow_director_mask_result *res = parsed_result;
8816 struct rte_eth_fdir_masks *mask;
8817 struct rte_port *port;
8819 if (res->port_id > nb_ports) {
8820 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8824 port = &ports[res->port_id];
8825 /** Check if the port is not started **/
8826 if (port->port_status != RTE_PORT_STOPPED) {
8827 printf("Please stop port %d first\n", res->port_id);
8831 mask = &port->dev_conf.fdir_conf.mask;
8833 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8834 if (strcmp(res->mode_value, "MAC-VLAN")) {
8835 printf("Please set mode to MAC-VLAN.\n");
8839 mask->vlan_tci_mask = res->vlan_mask;
8840 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8841 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8842 if (strcmp(res->mode_value, "Tunnel")) {
8843 printf("Please set mode to Tunnel.\n");
8847 mask->vlan_tci_mask = res->vlan_mask;
8848 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8849 mask->tunnel_id_mask = res->tunnel_id_mask;
8850 mask->tunnel_type_mask = res->tunnel_type_mask;
8852 if (strcmp(res->mode_value, "IP")) {
8853 printf("Please set mode to IP.\n");
8857 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8858 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8859 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8860 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8861 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8862 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8863 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8866 cmd_reconfig_device_queue(res->port_id, 1, 1);
8869 cmdline_parse_token_string_t cmd_flow_director_mask =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8871 flow_director_mask, "flow_director_mask");
8872 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8873 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8875 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8878 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8881 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8883 src_mask, "src_mask");
8884 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8885 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8887 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8888 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8890 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8893 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8895 dst_mask, "dst_mask");
8896 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8897 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8899 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8900 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8902 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8903 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8906 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8909 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8912 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8914 mode_value, "MAC-VLAN");
8915 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8917 mode_value, "Tunnel");
8918 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8921 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8923 mac_addr_byte_mask, UINT8);
8924 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8926 tunnel_type, "tunnel-type");
8927 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8929 tunnel_type_mask, UINT8);
8930 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8932 tunnel_id, "tunnel-id");
8933 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8935 tunnel_id_mask, UINT32);
8937 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8938 .f = cmd_flow_director_mask_parsed,
8940 .help_str = "set IP mode flow director's mask on NIC",
8942 (void *)&cmd_flow_director_mask,
8943 (void *)&cmd_flow_director_mask_port_id,
8944 (void *)&cmd_flow_director_mask_mode,
8945 (void *)&cmd_flow_director_mask_mode_ip,
8946 (void *)&cmd_flow_director_mask_vlan,
8947 (void *)&cmd_flow_director_mask_vlan_value,
8948 (void *)&cmd_flow_director_mask_src,
8949 (void *)&cmd_flow_director_mask_ipv4_src,
8950 (void *)&cmd_flow_director_mask_ipv6_src,
8951 (void *)&cmd_flow_director_mask_port_src,
8952 (void *)&cmd_flow_director_mask_dst,
8953 (void *)&cmd_flow_director_mask_ipv4_dst,
8954 (void *)&cmd_flow_director_mask_ipv6_dst,
8955 (void *)&cmd_flow_director_mask_port_dst,
8960 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8961 .f = cmd_flow_director_mask_parsed,
8963 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8965 (void *)&cmd_flow_director_mask,
8966 (void *)&cmd_flow_director_mask_port_id,
8967 (void *)&cmd_flow_director_mask_mode,
8968 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8969 (void *)&cmd_flow_director_mask_vlan,
8970 (void *)&cmd_flow_director_mask_vlan_value,
8971 (void *)&cmd_flow_director_mask_mac,
8972 (void *)&cmd_flow_director_mask_mac_value,
8977 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8978 .f = cmd_flow_director_mask_parsed,
8980 .help_str = "set tunnel mode flow director's mask on NIC",
8982 (void *)&cmd_flow_director_mask,
8983 (void *)&cmd_flow_director_mask_port_id,
8984 (void *)&cmd_flow_director_mask_mode,
8985 (void *)&cmd_flow_director_mask_mode_tunnel,
8986 (void *)&cmd_flow_director_mask_vlan,
8987 (void *)&cmd_flow_director_mask_vlan_value,
8988 (void *)&cmd_flow_director_mask_mac,
8989 (void *)&cmd_flow_director_mask_mac_value,
8990 (void *)&cmd_flow_director_mask_tunnel_type,
8991 (void *)&cmd_flow_director_mask_tunnel_type_value,
8992 (void *)&cmd_flow_director_mask_tunnel_id,
8993 (void *)&cmd_flow_director_mask_tunnel_id_value,
8998 /* *** deal with flow director mask on flexible payload *** */
8999 struct cmd_flow_director_flex_mask_result {
9000 cmdline_fixed_string_t flow_director_flexmask;
9002 cmdline_fixed_string_t flow;
9003 cmdline_fixed_string_t flow_type;
9004 cmdline_fixed_string_t mask;
9008 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9009 __attribute__((unused)) struct cmdline *cl,
9010 __attribute__((unused)) void *data)
9012 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9013 struct rte_eth_fdir_info fdir_info;
9014 struct rte_eth_fdir_flex_mask flex_mask;
9015 struct rte_port *port;
9016 uint32_t flow_type_mask;
9020 if (res->port_id > nb_ports) {
9021 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9025 port = &ports[res->port_id];
9026 /** Check if the port is not started **/
9027 if (port->port_status != RTE_PORT_STOPPED) {
9028 printf("Please stop port %d first\n", res->port_id);
9032 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9033 ret = parse_flexbytes(res->mask,
9035 RTE_ETH_FDIR_MAX_FLEXLEN);
9037 printf("error: Cannot parse mask input.\n");
9041 memset(&fdir_info, 0, sizeof(fdir_info));
9042 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9043 RTE_ETH_FILTER_INFO, &fdir_info);
9045 printf("Cannot get FDir filter info\n");
9049 if (!strcmp(res->flow_type, "none")) {
9050 /* means don't specify the flow type */
9051 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9052 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9053 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9054 0, sizeof(struct rte_eth_fdir_flex_mask));
9055 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9056 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9058 sizeof(struct rte_eth_fdir_flex_mask));
9059 cmd_reconfig_device_queue(res->port_id, 1, 1);
9062 flow_type_mask = fdir_info.flow_types_mask[0];
9063 if (!strcmp(res->flow_type, "all")) {
9064 if (!flow_type_mask) {
9065 printf("No flow type supported\n");
9068 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9069 if (flow_type_mask & (1 << i)) {
9070 flex_mask.flow_type = i;
9071 fdir_set_flex_mask(res->port_id, &flex_mask);
9074 cmd_reconfig_device_queue(res->port_id, 1, 1);
9077 flex_mask.flow_type = str2flowtype(res->flow_type);
9078 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9079 printf("Flow type %s not supported on port %d\n",
9080 res->flow_type, res->port_id);
9083 fdir_set_flex_mask(res->port_id, &flex_mask);
9084 cmd_reconfig_device_queue(res->port_id, 1, 1);
9087 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9089 flow_director_flexmask,
9090 "flow_director_flex_mask");
9091 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9092 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9094 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9097 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9099 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9100 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9101 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9102 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9105 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9106 .f = cmd_flow_director_flex_mask_parsed,
9108 .help_str = "set flow director's flex mask on NIC",
9110 (void *)&cmd_flow_director_flexmask,
9111 (void *)&cmd_flow_director_flexmask_port_id,
9112 (void *)&cmd_flow_director_flexmask_flow,
9113 (void *)&cmd_flow_director_flexmask_flow_type,
9114 (void *)&cmd_flow_director_flexmask_mask,
9119 /* *** deal with flow director flexible payload configuration *** */
9120 struct cmd_flow_director_flexpayload_result {
9121 cmdline_fixed_string_t flow_director_flexpayload;
9123 cmdline_fixed_string_t payload_layer;
9124 cmdline_fixed_string_t payload_cfg;
9128 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9131 const char *p, *p0 = q_arg;
9133 unsigned long int_fld;
9134 char *str_fld[max_num];
9139 p = strchr(p0, '(');
9143 p0 = strchr(p, ')');
9148 if (size >= sizeof(s))
9151 snprintf(s, sizeof(s), "%.*s", size, p);
9152 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9153 if (ret < 0 || ret > max_num)
9155 for (i = 0; i < ret; i++) {
9157 int_fld = strtoul(str_fld[i], &end, 0);
9158 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9160 offsets[i] = (uint16_t)int_fld;
9166 cmd_flow_director_flxpld_parsed(void *parsed_result,
9167 __attribute__((unused)) struct cmdline *cl,
9168 __attribute__((unused)) void *data)
9170 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9171 struct rte_eth_flex_payload_cfg flex_cfg;
9172 struct rte_port *port;
9175 if (res->port_id > nb_ports) {
9176 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9180 port = &ports[res->port_id];
9181 /** Check if the port is not started **/
9182 if (port->port_status != RTE_PORT_STOPPED) {
9183 printf("Please stop port %d first\n", res->port_id);
9187 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9189 if (!strcmp(res->payload_layer, "raw"))
9190 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9191 else if (!strcmp(res->payload_layer, "l2"))
9192 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9193 else if (!strcmp(res->payload_layer, "l3"))
9194 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9195 else if (!strcmp(res->payload_layer, "l4"))
9196 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9198 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9199 RTE_ETH_FDIR_MAX_FLEXLEN);
9201 printf("error: Cannot parse flex payload input.\n");
9205 fdir_set_flex_payload(res->port_id, &flex_cfg);
9206 cmd_reconfig_device_queue(res->port_id, 1, 1);
9209 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9210 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9211 flow_director_flexpayload,
9212 "flow_director_flex_payload");
9213 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9214 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9216 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9218 payload_layer, "raw#l2#l3#l4");
9219 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9223 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9224 .f = cmd_flow_director_flxpld_parsed,
9226 .help_str = "set flow director's flex payload on NIC",
9228 (void *)&cmd_flow_director_flexpayload,
9229 (void *)&cmd_flow_director_flexpayload_port_id,
9230 (void *)&cmd_flow_director_flexpayload_payload_layer,
9231 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9236 /* *** Classification Filters Control *** */
9237 /* *** Get symmetric hash enable per port *** */
9238 struct cmd_get_sym_hash_ena_per_port_result {
9239 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9244 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9245 __rte_unused struct cmdline *cl,
9246 __rte_unused void *data)
9248 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9249 struct rte_eth_hash_filter_info info;
9252 if (rte_eth_dev_filter_supported(res->port_id,
9253 RTE_ETH_FILTER_HASH) < 0) {
9254 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9259 memset(&info, 0, sizeof(info));
9260 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9261 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9262 RTE_ETH_FILTER_GET, &info);
9265 printf("Cannot get symmetric hash enable per port "
9266 "on port %u\n", res->port_id);
9270 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9271 "enabled" : "disabled", res->port_id);
9274 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9275 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9276 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9277 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9278 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9281 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9282 .f = cmd_get_sym_hash_per_port_parsed,
9284 .help_str = "get_sym_hash_ena_per_port port_id",
9286 (void *)&cmd_get_sym_hash_ena_per_port_all,
9287 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9292 /* *** Set symmetric hash enable per port *** */
9293 struct cmd_set_sym_hash_ena_per_port_result {
9294 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9295 cmdline_fixed_string_t enable;
9300 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9301 __rte_unused struct cmdline *cl,
9302 __rte_unused void *data)
9304 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9305 struct rte_eth_hash_filter_info info;
9308 if (rte_eth_dev_filter_supported(res->port_id,
9309 RTE_ETH_FILTER_HASH) < 0) {
9310 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9315 memset(&info, 0, sizeof(info));
9316 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9317 if (!strcmp(res->enable, "enable"))
9318 info.info.enable = 1;
9319 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9320 RTE_ETH_FILTER_SET, &info);
9322 printf("Cannot set symmetric hash enable per port on "
9323 "port %u\n", res->port_id);
9326 printf("Symmetric hash has been set to %s on port %u\n",
9327 res->enable, res->port_id);
9330 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9331 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9332 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9333 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9334 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9336 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9337 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9338 enable, "enable#disable");
9340 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9341 .f = cmd_set_sym_hash_per_port_parsed,
9343 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9345 (void *)&cmd_set_sym_hash_ena_per_port_all,
9346 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9347 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9352 /* Get global config of hash function */
9353 struct cmd_get_hash_global_config_result {
9354 cmdline_fixed_string_t get_hash_global_config;
9359 flowtype_to_str(uint16_t ftype)
9366 {"ipv4", RTE_ETH_FLOW_IPV4},
9367 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9368 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9369 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9370 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9371 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9372 {"ipv6", RTE_ETH_FLOW_IPV6},
9373 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9374 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9375 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9376 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9377 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9378 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9381 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9382 if (ftype_table[i].ftype == ftype)
9383 return ftype_table[i].str;
9390 cmd_get_hash_global_config_parsed(void *parsed_result,
9391 __rte_unused struct cmdline *cl,
9392 __rte_unused void *data)
9394 struct cmd_get_hash_global_config_result *res = parsed_result;
9395 struct rte_eth_hash_filter_info info;
9396 uint32_t idx, offset;
9401 if (rte_eth_dev_filter_supported(res->port_id,
9402 RTE_ETH_FILTER_HASH) < 0) {
9403 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9408 memset(&info, 0, sizeof(info));
9409 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9410 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9411 RTE_ETH_FILTER_GET, &info);
9413 printf("Cannot get hash global configurations by port %d\n",
9418 switch (info.info.global_conf.hash_func) {
9419 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9420 printf("Hash function is Toeplitz\n");
9422 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9423 printf("Hash function is Simple XOR\n");
9426 printf("Unknown hash function\n");
9430 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9431 idx = i / UINT32_BIT;
9432 offset = i % UINT32_BIT;
9433 if (!(info.info.global_conf.valid_bit_mask[idx] &
9436 str = flowtype_to_str(i);
9439 printf("Symmetric hash is %s globally for flow type %s "
9441 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9442 (1UL << offset)) ? "enabled" : "disabled"), str,
9447 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9448 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9449 get_hash_global_config, "get_hash_global_config");
9450 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9451 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9454 cmdline_parse_inst_t cmd_get_hash_global_config = {
9455 .f = cmd_get_hash_global_config_parsed,
9457 .help_str = "get_hash_global_config port_id",
9459 (void *)&cmd_get_hash_global_config_all,
9460 (void *)&cmd_get_hash_global_config_port_id,
9465 /* Set global config of hash function */
9466 struct cmd_set_hash_global_config_result {
9467 cmdline_fixed_string_t set_hash_global_config;
9469 cmdline_fixed_string_t hash_func;
9470 cmdline_fixed_string_t flow_type;
9471 cmdline_fixed_string_t enable;
9475 cmd_set_hash_global_config_parsed(void *parsed_result,
9476 __rte_unused struct cmdline *cl,
9477 __rte_unused void *data)
9479 struct cmd_set_hash_global_config_result *res = parsed_result;
9480 struct rte_eth_hash_filter_info info;
9481 uint32_t ftype, idx, offset;
9484 if (rte_eth_dev_filter_supported(res->port_id,
9485 RTE_ETH_FILTER_HASH) < 0) {
9486 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9490 memset(&info, 0, sizeof(info));
9491 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9492 if (!strcmp(res->hash_func, "toeplitz"))
9493 info.info.global_conf.hash_func =
9494 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9495 else if (!strcmp(res->hash_func, "simple_xor"))
9496 info.info.global_conf.hash_func =
9497 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9498 else if (!strcmp(res->hash_func, "default"))
9499 info.info.global_conf.hash_func =
9500 RTE_ETH_HASH_FUNCTION_DEFAULT;
9502 ftype = str2flowtype(res->flow_type);
9503 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9504 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9505 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9506 if (!strcmp(res->enable, "enable"))
9507 info.info.global_conf.sym_hash_enable_mask[idx] |=
9509 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9510 RTE_ETH_FILTER_SET, &info);
9512 printf("Cannot set global hash configurations by port %d\n",
9515 printf("Global hash configurations have been set "
9516 "succcessfully by port %d\n", res->port_id);
9519 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9520 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9521 set_hash_global_config, "set_hash_global_config");
9522 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9523 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9525 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9526 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9527 hash_func, "toeplitz#simple_xor#default");
9528 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9529 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9531 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9532 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9533 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9534 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9535 enable, "enable#disable");
9537 cmdline_parse_inst_t cmd_set_hash_global_config = {
9538 .f = cmd_set_hash_global_config_parsed,
9540 .help_str = "set_hash_global_config port_id "
9541 "toeplitz|simple_xor|default "
9542 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9543 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9546 (void *)&cmd_set_hash_global_config_all,
9547 (void *)&cmd_set_hash_global_config_port_id,
9548 (void *)&cmd_set_hash_global_config_hash_func,
9549 (void *)&cmd_set_hash_global_config_flow_type,
9550 (void *)&cmd_set_hash_global_config_enable,
9555 /* Set hash input set */
9556 struct cmd_set_hash_input_set_result {
9557 cmdline_fixed_string_t set_hash_input_set;
9559 cmdline_fixed_string_t flow_type;
9560 cmdline_fixed_string_t inset_field;
9561 cmdline_fixed_string_t select;
9564 static enum rte_eth_input_set_field
9565 str2inset(char *string)
9569 static const struct {
9571 enum rte_eth_input_set_field inset;
9573 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
9574 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9575 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9576 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9577 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9578 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9579 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9580 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
9581 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9582 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9583 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9584 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9585 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
9586 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9587 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9588 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9589 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9590 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9591 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9592 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9593 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9594 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9595 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9596 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9597 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9598 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9599 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9600 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9601 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9602 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9603 {"none", RTE_ETH_INPUT_SET_NONE},
9606 for (i = 0; i < RTE_DIM(inset_table); i++) {
9607 if (!strcmp(string, inset_table[i].str))
9608 return inset_table[i].inset;
9611 return RTE_ETH_INPUT_SET_UNKNOWN;
9615 cmd_set_hash_input_set_parsed(void *parsed_result,
9616 __rte_unused struct cmdline *cl,
9617 __rte_unused void *data)
9619 struct cmd_set_hash_input_set_result *res = parsed_result;
9620 struct rte_eth_hash_filter_info info;
9622 memset(&info, 0, sizeof(info));
9623 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9624 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9625 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9626 info.info.input_set_conf.inset_size = 1;
9627 if (!strcmp(res->select, "select"))
9628 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9629 else if (!strcmp(res->select, "add"))
9630 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9631 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9632 RTE_ETH_FILTER_SET, &info);
9635 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9636 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9637 set_hash_input_set, "set_hash_input_set");
9638 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9639 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9641 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9642 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9644 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9645 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9646 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9647 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9649 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9650 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9651 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9652 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9653 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9655 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9656 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9657 select, "select#add");
9659 cmdline_parse_inst_t cmd_set_hash_input_set = {
9660 .f = cmd_set_hash_input_set_parsed,
9662 .help_str = "set_hash_input_set <port_id> "
9663 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9664 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9665 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9666 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9667 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9668 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9669 "fld-7th|fld-8th|none select|add",
9671 (void *)&cmd_set_hash_input_set_cmd,
9672 (void *)&cmd_set_hash_input_set_port_id,
9673 (void *)&cmd_set_hash_input_set_flow_type,
9674 (void *)&cmd_set_hash_input_set_field,
9675 (void *)&cmd_set_hash_input_set_select,
9680 /* Set flow director input set */
9681 struct cmd_set_fdir_input_set_result {
9682 cmdline_fixed_string_t set_fdir_input_set;
9684 cmdline_fixed_string_t flow_type;
9685 cmdline_fixed_string_t inset_field;
9686 cmdline_fixed_string_t select;
9690 cmd_set_fdir_input_set_parsed(void *parsed_result,
9691 __rte_unused struct cmdline *cl,
9692 __rte_unused void *data)
9694 struct cmd_set_fdir_input_set_result *res = parsed_result;
9695 struct rte_eth_fdir_filter_info info;
9697 memset(&info, 0, sizeof(info));
9698 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9699 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9700 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9701 info.info.input_set_conf.inset_size = 1;
9702 if (!strcmp(res->select, "select"))
9703 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9704 else if (!strcmp(res->select, "add"))
9705 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9706 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9707 RTE_ETH_FILTER_SET, &info);
9710 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9711 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9712 set_fdir_input_set, "set_fdir_input_set");
9713 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9714 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9716 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9717 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9719 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
9720 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9721 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9722 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9724 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9725 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
9726 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
9727 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9728 "sctp-veri-tag#none");
9729 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9730 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9731 select, "select#add");
9733 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9734 .f = cmd_set_fdir_input_set_parsed,
9736 .help_str = "set_fdir_input_set <port_id> "
9737 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9738 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9739 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
9740 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
9741 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
9742 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
9743 "sctp-veri-tag|none select|add",
9745 (void *)&cmd_set_fdir_input_set_cmd,
9746 (void *)&cmd_set_fdir_input_set_port_id,
9747 (void *)&cmd_set_fdir_input_set_flow_type,
9748 (void *)&cmd_set_fdir_input_set_field,
9749 (void *)&cmd_set_fdir_input_set_select,
9754 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9755 struct cmd_mcast_addr_result {
9756 cmdline_fixed_string_t mcast_addr_cmd;
9757 cmdline_fixed_string_t what;
9759 struct ether_addr mc_addr;
9762 static void cmd_mcast_addr_parsed(void *parsed_result,
9763 __attribute__((unused)) struct cmdline *cl,
9764 __attribute__((unused)) void *data)
9766 struct cmd_mcast_addr_result *res = parsed_result;
9768 if (!is_multicast_ether_addr(&res->mc_addr)) {
9769 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9770 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9771 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9772 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9775 if (strcmp(res->what, "add") == 0)
9776 mcast_addr_add(res->port_num, &res->mc_addr);
9778 mcast_addr_remove(res->port_num, &res->mc_addr);
9781 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9782 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9783 mcast_addr_cmd, "mcast_addr");
9784 cmdline_parse_token_string_t cmd_mcast_addr_what =
9785 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9787 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9788 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9789 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9790 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9792 cmdline_parse_inst_t cmd_mcast_addr = {
9793 .f = cmd_mcast_addr_parsed,
9795 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9797 (void *)&cmd_mcast_addr_cmd,
9798 (void *)&cmd_mcast_addr_what,
9799 (void *)&cmd_mcast_addr_portnum,
9800 (void *)&cmd_mcast_addr_addr,
9806 * only support E-tag now.
9809 /* Ether type config */
9810 struct cmd_config_l2_tunnel_eth_type_result {
9811 cmdline_fixed_string_t port;
9812 cmdline_fixed_string_t config;
9813 cmdline_fixed_string_t all;
9815 cmdline_fixed_string_t l2_tunnel;
9816 cmdline_fixed_string_t l2_tunnel_type;
9817 cmdline_fixed_string_t eth_type;
9818 uint16_t eth_type_val;
9821 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9822 TOKEN_STRING_INITIALIZER
9823 (struct cmd_config_l2_tunnel_eth_type_result,
9825 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9826 TOKEN_STRING_INITIALIZER
9827 (struct cmd_config_l2_tunnel_eth_type_result,
9829 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9830 TOKEN_STRING_INITIALIZER
9831 (struct cmd_config_l2_tunnel_eth_type_result,
9833 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9834 TOKEN_NUM_INITIALIZER
9835 (struct cmd_config_l2_tunnel_eth_type_result,
9837 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9838 TOKEN_STRING_INITIALIZER
9839 (struct cmd_config_l2_tunnel_eth_type_result,
9840 l2_tunnel, "l2-tunnel");
9841 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9842 TOKEN_STRING_INITIALIZER
9843 (struct cmd_config_l2_tunnel_eth_type_result,
9844 l2_tunnel_type, "E-tag");
9845 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9846 TOKEN_STRING_INITIALIZER
9847 (struct cmd_config_l2_tunnel_eth_type_result,
9848 eth_type, "ether-type");
9849 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9850 TOKEN_NUM_INITIALIZER
9851 (struct cmd_config_l2_tunnel_eth_type_result,
9852 eth_type_val, UINT16);
9854 static enum rte_eth_tunnel_type
9855 str2fdir_l2_tunnel_type(char *string)
9859 static const struct {
9861 enum rte_eth_tunnel_type type;
9862 } l2_tunnel_type_str[] = {
9863 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9866 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9867 if (!strcmp(l2_tunnel_type_str[i].str, string))
9868 return l2_tunnel_type_str[i].type;
9870 return RTE_TUNNEL_TYPE_NONE;
9873 /* ether type config for all ports */
9875 cmd_config_l2_tunnel_eth_type_all_parsed
9876 (void *parsed_result,
9877 __attribute__((unused)) struct cmdline *cl,
9878 __attribute__((unused)) void *data)
9880 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9881 struct rte_eth_l2_tunnel_conf entry;
9884 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9885 entry.ether_type = res->eth_type_val;
9887 FOREACH_PORT(pid, ports) {
9888 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9892 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9893 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9895 .help_str = "port config all l2-tunnel ether-type",
9897 (void *)&cmd_config_l2_tunnel_eth_type_port,
9898 (void *)&cmd_config_l2_tunnel_eth_type_config,
9899 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9900 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9901 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9902 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9903 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9908 /* ether type config for a specific port */
9910 cmd_config_l2_tunnel_eth_type_specific_parsed(
9911 void *parsed_result,
9912 __attribute__((unused)) struct cmdline *cl,
9913 __attribute__((unused)) void *data)
9915 struct cmd_config_l2_tunnel_eth_type_result *res =
9917 struct rte_eth_l2_tunnel_conf entry;
9919 if (port_id_is_invalid(res->id, ENABLED_WARN))
9922 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9923 entry.ether_type = res->eth_type_val;
9925 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9928 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9929 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9931 .help_str = "port config l2-tunnel ether-type",
9933 (void *)&cmd_config_l2_tunnel_eth_type_port,
9934 (void *)&cmd_config_l2_tunnel_eth_type_config,
9935 (void *)&cmd_config_l2_tunnel_eth_type_id,
9936 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9937 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9938 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9939 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9944 /* Enable/disable l2 tunnel */
9945 struct cmd_config_l2_tunnel_en_dis_result {
9946 cmdline_fixed_string_t port;
9947 cmdline_fixed_string_t config;
9948 cmdline_fixed_string_t all;
9950 cmdline_fixed_string_t l2_tunnel;
9951 cmdline_fixed_string_t l2_tunnel_type;
9952 cmdline_fixed_string_t en_dis;
9955 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9956 TOKEN_STRING_INITIALIZER
9957 (struct cmd_config_l2_tunnel_en_dis_result,
9959 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9960 TOKEN_STRING_INITIALIZER
9961 (struct cmd_config_l2_tunnel_en_dis_result,
9963 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9964 TOKEN_STRING_INITIALIZER
9965 (struct cmd_config_l2_tunnel_en_dis_result,
9967 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9968 TOKEN_NUM_INITIALIZER
9969 (struct cmd_config_l2_tunnel_en_dis_result,
9971 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9972 TOKEN_STRING_INITIALIZER
9973 (struct cmd_config_l2_tunnel_en_dis_result,
9974 l2_tunnel, "l2-tunnel");
9975 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9976 TOKEN_STRING_INITIALIZER
9977 (struct cmd_config_l2_tunnel_en_dis_result,
9978 l2_tunnel_type, "E-tag");
9979 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9980 TOKEN_STRING_INITIALIZER
9981 (struct cmd_config_l2_tunnel_en_dis_result,
9982 en_dis, "enable#disable");
9984 /* enable/disable l2 tunnel for all ports */
9986 cmd_config_l2_tunnel_en_dis_all_parsed(
9987 void *parsed_result,
9988 __attribute__((unused)) struct cmdline *cl,
9989 __attribute__((unused)) void *data)
9991 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9992 struct rte_eth_l2_tunnel_conf entry;
9996 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9998 if (!strcmp("enable", res->en_dis))
10003 FOREACH_PORT(pid, ports) {
10004 rte_eth_dev_l2_tunnel_offload_set(pid,
10006 ETH_L2_TUNNEL_ENABLE_MASK,
10011 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10012 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10014 .help_str = "port config all l2-tunnel enable/disable",
10016 (void *)&cmd_config_l2_tunnel_en_dis_port,
10017 (void *)&cmd_config_l2_tunnel_en_dis_config,
10018 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10019 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10020 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10021 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10026 /* enable/disable l2 tunnel for a port */
10028 cmd_config_l2_tunnel_en_dis_specific_parsed(
10029 void *parsed_result,
10030 __attribute__((unused)) struct cmdline *cl,
10031 __attribute__((unused)) void *data)
10033 struct cmd_config_l2_tunnel_en_dis_result *res =
10035 struct rte_eth_l2_tunnel_conf entry;
10037 if (port_id_is_invalid(res->id, ENABLED_WARN))
10040 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10042 if (!strcmp("enable", res->en_dis))
10043 rte_eth_dev_l2_tunnel_offload_set(res->id,
10045 ETH_L2_TUNNEL_ENABLE_MASK,
10048 rte_eth_dev_l2_tunnel_offload_set(res->id,
10050 ETH_L2_TUNNEL_ENABLE_MASK,
10054 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10055 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10057 .help_str = "port config l2-tunnel enable/disable",
10059 (void *)&cmd_config_l2_tunnel_en_dis_port,
10060 (void *)&cmd_config_l2_tunnel_en_dis_config,
10061 (void *)&cmd_config_l2_tunnel_en_dis_id,
10062 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10063 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10064 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10069 /* E-tag configuration */
10071 /* Common result structure for all E-tag configuration */
10072 struct cmd_config_e_tag_result {
10073 cmdline_fixed_string_t e_tag;
10074 cmdline_fixed_string_t set;
10075 cmdline_fixed_string_t insertion;
10076 cmdline_fixed_string_t stripping;
10077 cmdline_fixed_string_t forwarding;
10078 cmdline_fixed_string_t filter;
10079 cmdline_fixed_string_t add;
10080 cmdline_fixed_string_t del;
10081 cmdline_fixed_string_t on;
10082 cmdline_fixed_string_t off;
10083 cmdline_fixed_string_t on_off;
10084 cmdline_fixed_string_t port_tag_id;
10085 uint32_t port_tag_id_val;
10086 cmdline_fixed_string_t e_tag_id;
10087 uint16_t e_tag_id_val;
10088 cmdline_fixed_string_t dst_pool;
10089 uint8_t dst_pool_val;
10090 cmdline_fixed_string_t port;
10092 cmdline_fixed_string_t vf;
10096 /* Common CLI fields for all E-tag configuration */
10097 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10098 TOKEN_STRING_INITIALIZER
10099 (struct cmd_config_e_tag_result,
10101 cmdline_parse_token_string_t cmd_config_e_tag_set =
10102 TOKEN_STRING_INITIALIZER
10103 (struct cmd_config_e_tag_result,
10105 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10106 TOKEN_STRING_INITIALIZER
10107 (struct cmd_config_e_tag_result,
10108 insertion, "insertion");
10109 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10110 TOKEN_STRING_INITIALIZER
10111 (struct cmd_config_e_tag_result,
10112 stripping, "stripping");
10113 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10114 TOKEN_STRING_INITIALIZER
10115 (struct cmd_config_e_tag_result,
10116 forwarding, "forwarding");
10117 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10118 TOKEN_STRING_INITIALIZER
10119 (struct cmd_config_e_tag_result,
10121 cmdline_parse_token_string_t cmd_config_e_tag_add =
10122 TOKEN_STRING_INITIALIZER
10123 (struct cmd_config_e_tag_result,
10125 cmdline_parse_token_string_t cmd_config_e_tag_del =
10126 TOKEN_STRING_INITIALIZER
10127 (struct cmd_config_e_tag_result,
10129 cmdline_parse_token_string_t cmd_config_e_tag_on =
10130 TOKEN_STRING_INITIALIZER
10131 (struct cmd_config_e_tag_result,
10133 cmdline_parse_token_string_t cmd_config_e_tag_off =
10134 TOKEN_STRING_INITIALIZER
10135 (struct cmd_config_e_tag_result,
10137 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10138 TOKEN_STRING_INITIALIZER
10139 (struct cmd_config_e_tag_result,
10141 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10142 TOKEN_STRING_INITIALIZER
10143 (struct cmd_config_e_tag_result,
10144 port_tag_id, "port-tag-id");
10145 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10146 TOKEN_NUM_INITIALIZER
10147 (struct cmd_config_e_tag_result,
10148 port_tag_id_val, UINT32);
10149 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10150 TOKEN_STRING_INITIALIZER
10151 (struct cmd_config_e_tag_result,
10152 e_tag_id, "e-tag-id");
10153 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10154 TOKEN_NUM_INITIALIZER
10155 (struct cmd_config_e_tag_result,
10156 e_tag_id_val, UINT16);
10157 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10158 TOKEN_STRING_INITIALIZER
10159 (struct cmd_config_e_tag_result,
10160 dst_pool, "dst-pool");
10161 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10162 TOKEN_NUM_INITIALIZER
10163 (struct cmd_config_e_tag_result,
10164 dst_pool_val, UINT8);
10165 cmdline_parse_token_string_t cmd_config_e_tag_port =
10166 TOKEN_STRING_INITIALIZER
10167 (struct cmd_config_e_tag_result,
10169 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10170 TOKEN_NUM_INITIALIZER
10171 (struct cmd_config_e_tag_result,
10173 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10174 TOKEN_STRING_INITIALIZER
10175 (struct cmd_config_e_tag_result,
10177 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10178 TOKEN_NUM_INITIALIZER
10179 (struct cmd_config_e_tag_result,
10182 /* E-tag insertion configuration */
10184 cmd_config_e_tag_insertion_en_parsed(
10185 void *parsed_result,
10186 __attribute__((unused)) struct cmdline *cl,
10187 __attribute__((unused)) void *data)
10189 struct cmd_config_e_tag_result *res =
10191 struct rte_eth_l2_tunnel_conf entry;
10193 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10196 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10197 entry.tunnel_id = res->port_tag_id_val;
10198 entry.vf_id = res->vf_id;
10199 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10201 ETH_L2_TUNNEL_INSERTION_MASK,
10206 cmd_config_e_tag_insertion_dis_parsed(
10207 void *parsed_result,
10208 __attribute__((unused)) struct cmdline *cl,
10209 __attribute__((unused)) void *data)
10211 struct cmd_config_e_tag_result *res =
10213 struct rte_eth_l2_tunnel_conf entry;
10215 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10218 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10219 entry.vf_id = res->vf_id;
10221 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10223 ETH_L2_TUNNEL_INSERTION_MASK,
10227 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10228 .f = cmd_config_e_tag_insertion_en_parsed,
10230 .help_str = "E-tag insertion enable",
10232 (void *)&cmd_config_e_tag_e_tag,
10233 (void *)&cmd_config_e_tag_set,
10234 (void *)&cmd_config_e_tag_insertion,
10235 (void *)&cmd_config_e_tag_on,
10236 (void *)&cmd_config_e_tag_port_tag_id,
10237 (void *)&cmd_config_e_tag_port_tag_id_val,
10238 (void *)&cmd_config_e_tag_port,
10239 (void *)&cmd_config_e_tag_port_id,
10240 (void *)&cmd_config_e_tag_vf,
10241 (void *)&cmd_config_e_tag_vf_id,
10246 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10247 .f = cmd_config_e_tag_insertion_dis_parsed,
10249 .help_str = "E-tag insertion disable",
10251 (void *)&cmd_config_e_tag_e_tag,
10252 (void *)&cmd_config_e_tag_set,
10253 (void *)&cmd_config_e_tag_insertion,
10254 (void *)&cmd_config_e_tag_off,
10255 (void *)&cmd_config_e_tag_port,
10256 (void *)&cmd_config_e_tag_port_id,
10257 (void *)&cmd_config_e_tag_vf,
10258 (void *)&cmd_config_e_tag_vf_id,
10263 /* E-tag stripping configuration */
10265 cmd_config_e_tag_stripping_parsed(
10266 void *parsed_result,
10267 __attribute__((unused)) struct cmdline *cl,
10268 __attribute__((unused)) void *data)
10270 struct cmd_config_e_tag_result *res =
10272 struct rte_eth_l2_tunnel_conf entry;
10274 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10277 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10279 if (!strcmp(res->on_off, "on"))
10280 rte_eth_dev_l2_tunnel_offload_set
10283 ETH_L2_TUNNEL_STRIPPING_MASK,
10286 rte_eth_dev_l2_tunnel_offload_set
10289 ETH_L2_TUNNEL_STRIPPING_MASK,
10293 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10294 .f = cmd_config_e_tag_stripping_parsed,
10296 .help_str = "E-tag stripping enable/disable",
10298 (void *)&cmd_config_e_tag_e_tag,
10299 (void *)&cmd_config_e_tag_set,
10300 (void *)&cmd_config_e_tag_stripping,
10301 (void *)&cmd_config_e_tag_on_off,
10302 (void *)&cmd_config_e_tag_port,
10303 (void *)&cmd_config_e_tag_port_id,
10308 /* E-tag forwarding configuration */
10310 cmd_config_e_tag_forwarding_parsed(
10311 void *parsed_result,
10312 __attribute__((unused)) struct cmdline *cl,
10313 __attribute__((unused)) void *data)
10315 struct cmd_config_e_tag_result *res = parsed_result;
10316 struct rte_eth_l2_tunnel_conf entry;
10318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10321 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10323 if (!strcmp(res->on_off, "on"))
10324 rte_eth_dev_l2_tunnel_offload_set
10327 ETH_L2_TUNNEL_FORWARDING_MASK,
10330 rte_eth_dev_l2_tunnel_offload_set
10333 ETH_L2_TUNNEL_FORWARDING_MASK,
10337 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10338 .f = cmd_config_e_tag_forwarding_parsed,
10340 .help_str = "E-tag forwarding enable/disable",
10342 (void *)&cmd_config_e_tag_e_tag,
10343 (void *)&cmd_config_e_tag_set,
10344 (void *)&cmd_config_e_tag_forwarding,
10345 (void *)&cmd_config_e_tag_on_off,
10346 (void *)&cmd_config_e_tag_port,
10347 (void *)&cmd_config_e_tag_port_id,
10352 /* E-tag filter configuration */
10354 cmd_config_e_tag_filter_add_parsed(
10355 void *parsed_result,
10356 __attribute__((unused)) struct cmdline *cl,
10357 __attribute__((unused)) void *data)
10359 struct cmd_config_e_tag_result *res = parsed_result;
10360 struct rte_eth_l2_tunnel_conf entry;
10363 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10366 if (res->e_tag_id_val > 0x3fff) {
10367 printf("e-tag-id must be equal or less than 0x3fff.\n");
10371 ret = rte_eth_dev_filter_supported(res->port_id,
10372 RTE_ETH_FILTER_L2_TUNNEL);
10374 printf("E-tag filter is not supported on port %u.\n",
10379 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10380 entry.tunnel_id = res->e_tag_id_val;
10381 entry.pool = res->dst_pool_val;
10383 ret = rte_eth_dev_filter_ctrl(res->port_id,
10384 RTE_ETH_FILTER_L2_TUNNEL,
10385 RTE_ETH_FILTER_ADD,
10388 printf("E-tag filter programming error: (%s)\n",
10392 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10393 .f = cmd_config_e_tag_filter_add_parsed,
10395 .help_str = "E-tag filter add",
10397 (void *)&cmd_config_e_tag_e_tag,
10398 (void *)&cmd_config_e_tag_set,
10399 (void *)&cmd_config_e_tag_filter,
10400 (void *)&cmd_config_e_tag_add,
10401 (void *)&cmd_config_e_tag_e_tag_id,
10402 (void *)&cmd_config_e_tag_e_tag_id_val,
10403 (void *)&cmd_config_e_tag_dst_pool,
10404 (void *)&cmd_config_e_tag_dst_pool_val,
10405 (void *)&cmd_config_e_tag_port,
10406 (void *)&cmd_config_e_tag_port_id,
10412 cmd_config_e_tag_filter_del_parsed(
10413 void *parsed_result,
10414 __attribute__((unused)) struct cmdline *cl,
10415 __attribute__((unused)) void *data)
10417 struct cmd_config_e_tag_result *res = parsed_result;
10418 struct rte_eth_l2_tunnel_conf entry;
10421 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10424 if (res->e_tag_id_val > 0x3fff) {
10425 printf("e-tag-id must be less than 0x3fff.\n");
10429 ret = rte_eth_dev_filter_supported(res->port_id,
10430 RTE_ETH_FILTER_L2_TUNNEL);
10432 printf("E-tag filter is not supported on port %u.\n",
10437 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10438 entry.tunnel_id = res->e_tag_id_val;
10440 ret = rte_eth_dev_filter_ctrl(res->port_id,
10441 RTE_ETH_FILTER_L2_TUNNEL,
10442 RTE_ETH_FILTER_DELETE,
10445 printf("E-tag filter programming error: (%s)\n",
10449 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10450 .f = cmd_config_e_tag_filter_del_parsed,
10452 .help_str = "E-tag filter delete",
10454 (void *)&cmd_config_e_tag_e_tag,
10455 (void *)&cmd_config_e_tag_set,
10456 (void *)&cmd_config_e_tag_filter,
10457 (void *)&cmd_config_e_tag_del,
10458 (void *)&cmd_config_e_tag_e_tag_id,
10459 (void *)&cmd_config_e_tag_e_tag_id_val,
10460 (void *)&cmd_config_e_tag_port,
10461 (void *)&cmd_config_e_tag_port_id,
10466 /* ******************************************************************************** */
10468 /* list of instructions */
10469 cmdline_parse_ctx_t main_ctx[] = {
10470 (cmdline_parse_inst_t *)&cmd_help_brief,
10471 (cmdline_parse_inst_t *)&cmd_help_long,
10472 (cmdline_parse_inst_t *)&cmd_quit,
10473 (cmdline_parse_inst_t *)&cmd_showport,
10474 (cmdline_parse_inst_t *)&cmd_showqueue,
10475 (cmdline_parse_inst_t *)&cmd_showportall,
10476 (cmdline_parse_inst_t *)&cmd_showcfg,
10477 (cmdline_parse_inst_t *)&cmd_start,
10478 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10479 (cmdline_parse_inst_t *)&cmd_set_link_up,
10480 (cmdline_parse_inst_t *)&cmd_set_link_down,
10481 (cmdline_parse_inst_t *)&cmd_reset,
10482 (cmdline_parse_inst_t *)&cmd_set_numbers,
10483 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10484 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10485 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10486 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10487 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10488 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10489 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10490 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10491 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10492 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10493 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10494 (cmdline_parse_inst_t *)&cmd_set_link_check,
10495 #ifdef RTE_NIC_BYPASS
10496 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10497 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10498 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10499 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10501 #ifdef RTE_LIBRTE_PMD_BOND
10502 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10503 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10504 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10505 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10506 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10507 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10508 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10509 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10510 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10512 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10513 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10514 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10515 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10516 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10517 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10518 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10519 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10520 (cmdline_parse_inst_t *)&cmd_csum_set,
10521 (cmdline_parse_inst_t *)&cmd_csum_show,
10522 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10523 (cmdline_parse_inst_t *)&cmd_tso_set,
10524 (cmdline_parse_inst_t *)&cmd_tso_show,
10525 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10526 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10527 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10534 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10535 (cmdline_parse_inst_t *)&cmd_config_dcb,
10536 (cmdline_parse_inst_t *)&cmd_read_reg,
10537 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10538 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10539 (cmdline_parse_inst_t *)&cmd_write_reg,
10540 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10541 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10542 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10543 (cmdline_parse_inst_t *)&cmd_stop,
10544 (cmdline_parse_inst_t *)&cmd_mac_addr,
10545 (cmdline_parse_inst_t *)&cmd_set_qmap,
10546 (cmdline_parse_inst_t *)&cmd_operate_port,
10547 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10548 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10549 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10550 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10551 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10552 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10553 (cmdline_parse_inst_t *)&cmd_config_mtu,
10554 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10555 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10556 (cmdline_parse_inst_t *)&cmd_config_rss,
10557 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10558 (cmdline_parse_inst_t *)&cmd_config_txqflags,
10559 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10560 (cmdline_parse_inst_t *)&cmd_showport_reta,
10561 (cmdline_parse_inst_t *)&cmd_config_burst,
10562 (cmdline_parse_inst_t *)&cmd_config_thresh,
10563 (cmdline_parse_inst_t *)&cmd_config_threshold,
10564 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10565 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10566 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10567 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10568 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10569 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10570 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10571 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10572 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10573 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10574 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10575 (cmdline_parse_inst_t *)&cmd_global_config,
10576 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10577 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10578 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10579 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10580 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10581 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10582 (cmdline_parse_inst_t *)&cmd_dump,
10583 (cmdline_parse_inst_t *)&cmd_dump_one,
10584 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10585 (cmdline_parse_inst_t *)&cmd_syn_filter,
10586 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10587 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10588 (cmdline_parse_inst_t *)&cmd_flex_filter,
10589 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10590 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10591 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10592 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10593 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10594 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10595 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10596 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10597 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10598 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10599 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10600 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10601 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10602 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10603 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10604 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10605 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10606 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10607 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10608 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10609 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10610 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10611 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10612 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10613 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10614 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10615 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10616 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10617 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10621 /* prompt function, called from main on MASTER lcore */
10625 /* initialize non-constant commands */
10626 cmd_set_fwd_mode_init();
10628 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10629 if (testpmd_cl == NULL)
10631 cmdline_interact(testpmd_cl);
10632 cmdline_stdin_exit(testpmd_cl);
10638 if (testpmd_cl != NULL)
10639 cmdline_quit(testpmd_cl);
10643 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10645 if (id == (portid_t)RTE_PORT_ALL) {
10648 FOREACH_PORT(pid, ports) {
10649 /* check if need_reconfig has been set to 1 */
10650 if (ports[pid].need_reconfig == 0)
10651 ports[pid].need_reconfig = dev;
10652 /* check if need_reconfig_queues has been set to 1 */
10653 if (ports[pid].need_reconfig_queues == 0)
10654 ports[pid].need_reconfig_queues = queue;
10656 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10657 /* check if need_reconfig has been set to 1 */
10658 if (ports[id].need_reconfig == 0)
10659 ports[id].need_reconfig = dev;
10660 /* check if need_reconfig_queues has been set to 1 */
10661 if (ports[id].need_reconfig_queues == 0)
10662 ports[id].need_reconfig_queues = queue;
10666 #ifdef RTE_NIC_BYPASS
10667 #include <rte_pci_dev_ids.h>
10669 bypass_is_supported(portid_t port_id)
10671 struct rte_port *port;
10672 struct rte_pci_id *pci_id;
10674 if (port_id_is_invalid(port_id, ENABLED_WARN))
10677 /* Get the device id. */
10678 port = &ports[port_id];
10679 pci_id = &port->dev_info.pci_dev->id;
10681 /* Check if NIC supports bypass. */
10682 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10686 printf("\tBypass not supported for port_id = %d.\n", port_id);