4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static struct cmdline *testpmd_cl;
95 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
98 uint8_t bypass_is_supported(portid_t port_id);
101 /* *** Help command with introduction. *** */
102 struct cmd_help_brief_result {
103 cmdline_fixed_string_t help;
106 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
108 __attribute__((unused)) void *data)
113 "Help is available for the following sections:\n\n"
114 " help control : Start and stop forwarding.\n"
115 " help display : Displaying port, stats and config "
117 " help config : Configuration information.\n"
118 " help ports : Configuring ports.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
196 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
197 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
198 " Display the RSS hash functions and RSS hash key"
201 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
202 " Clear information for port_id, or all.\n\n"
204 "show (rxq|txq) info (port_id) (queue_id)\n"
205 " Display information for configured RX/TX queue.\n\n"
207 "show config (rxtx|cores|fwd|txpkts)\n"
208 " Display the given configuration.\n\n"
210 "read rxd (port_id) (queue_id) (rxd_id)\n"
211 " Display an RX descriptor of a port RX queue.\n\n"
213 "read txd (port_id) (queue_id) (txd_id)\n"
214 " Display a TX descriptor of a port TX queue.\n\n"
218 if (show_all || !strcmp(res->section, "config")) {
224 "Configuration changes only become active when"
225 " forwarding is started/restarted.\n\n"
228 " Reset forwarding to the default configuration.\n\n"
230 "set verbose (level)\n"
231 " Set the debug verbosity level X.\n\n"
234 " Set number of ports.\n\n"
237 " Set number of cores.\n\n"
239 "set coremask (mask)\n"
240 " Set the forwarding cores hexadecimal mask.\n\n"
242 "set portmask (mask)\n"
243 " Set the forwarding ports hexadecimal mask.\n\n"
246 " Set number of packets per burst.\n\n"
248 "set burst tx delay (microseconds) retry (num)\n"
249 " Set the transmit delay time and number of retries"
250 " in mac_retry forwarding mode.\n\n"
252 "set txpkts (x[,y]*)\n"
253 " Set the length of each segment of TXONLY"
254 " and optionally CSUM packets.\n\n"
256 "set txsplit (off|on|rand)\n"
257 " Set the split policy for the TX packets."
258 " Right now only applicable for CSUM and TXONLY"
261 "set corelist (x[,y]*)\n"
262 " Set the list of forwarding cores.\n\n"
264 "set portlist (x[,y]*)\n"
265 " Set the list of forwarding ports.\n\n"
267 "vlan set strip (on|off) (port_id)\n"
268 " Set the VLAN strip on a port.\n\n"
270 "vlan set stripq (on|off) (port_id,queue_id)\n"
271 " Set the VLAN strip for a queue on a port.\n\n"
273 "vlan set filter (on|off) (port_id)\n"
274 " Set the VLAN filter on a port.\n\n"
276 "vlan set qinq (on|off) (port_id)\n"
277 " Set the VLAN QinQ (extended queue in queue)"
280 "vlan set (inner|outer) tpid (value) (port_id)\n"
281 " Set the VLAN TPID for Packet Filtering on"
284 "rx_vlan add (vlan_id|all) (port_id)\n"
285 " Add a vlan_id, or all identifiers, to the set"
286 " of VLAN identifiers filtered by port_id.\n\n"
288 "rx_vlan rm (vlan_id|all) (port_id)\n"
289 " Remove a vlan_id, or all identifiers, from the set"
290 " of VLAN identifiers filtered by port_id.\n\n"
292 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
293 " Add a vlan_id, to the set of VLAN identifiers"
294 "filtered for VF(s) from port_id.\n\n"
296 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
297 " Remove a vlan_id, to the set of VLAN identifiers"
298 "filtered for VF(s) from port_id.\n\n"
300 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
301 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
302 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
303 " add a tunnel filter of a port.\n\n"
305 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
306 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
307 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
308 " remove a tunnel filter of a port.\n\n"
310 "rx_vxlan_port add (udp_port) (port_id)\n"
311 " Add an UDP port for VXLAN packet filter on a port\n\n"
313 "rx_vxlan_port rm (udp_port) (port_id)\n"
314 " Remove an UDP port for VXLAN packet filter on a port\n\n"
316 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
317 " Set hardware insertion of VLAN IDs (single or double VLAN "
318 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
320 "tx_vlan set pvid port_id vlan_id (on|off)\n"
321 " Set port based TX VLAN insertion.\n\n"
323 "tx_vlan reset (port_id)\n"
324 " Disable hardware insertion of a VLAN header in"
325 " packets sent on a port.\n\n"
327 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
328 " Select hardware or software calculation of the"
329 " checksum when transmitting a packet using the"
330 " csum forward engine.\n"
331 " ip|udp|tcp|sctp always concern the inner layer.\n"
332 " outer-ip concerns the outer IP layer in"
333 " case the packet is recognized as a tunnel packet by"
334 " the forward engine (vxlan, gre and ipip are supported)\n"
335 " Please check the NIC datasheet for HW limits.\n\n"
337 "csum parse-tunnel (on|off) (tx_port_id)\n"
338 " If disabled, treat tunnel packets as non-tunneled"
339 " packets (treat inner headers as payload). The port\n"
340 " argument is the port used for TX in csum forward"
343 "csum show (port_id)\n"
344 " Display tx checksum offload configuration\n\n"
346 "tso set (segsize) (portid)\n"
347 " Enable TCP Segmentation Offload in csum forward"
349 " Please check the NIC datasheet for HW limits.\n\n"
352 " Display the status of TCP Segmentation Offload.\n\n"
355 " Set packet forwarding mode.\n\n"
357 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
358 " Add a MAC address on port_id.\n\n"
360 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
361 " Remove a MAC address from port_id.\n\n"
363 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
364 " Add a MAC address for a VF on the port.\n\n"
366 "set port (port_id) uta (mac_address|all) (on|off)\n"
367 " Add/Remove a or all unicast hash filter(s)"
370 "set promisc (port_id|all) (on|off)\n"
371 " Set the promiscuous mode on port_id, or all.\n\n"
373 "set allmulti (port_id|all) (on|off)\n"
374 " Set the allmulti mode on port_id, or all.\n\n"
376 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
377 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
378 " (on|off) autoneg (on|off) (port_id)\n"
379 "set flow_ctrl rx (on|off) (portid)\n"
380 "set flow_ctrl tx (on|off) (portid)\n"
381 "set flow_ctrl high_water (high_water) (portid)\n"
382 "set flow_ctrl low_water (low_water) (portid)\n"
383 "set flow_ctrl pause_time (pause_time) (portid)\n"
384 "set flow_ctrl send_xon (send_xon) (portid)\n"
385 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
386 "set flow_ctrl autoneg (on|off) (port_id)\n"
387 " Set the link flow control parameter on a port.\n\n"
389 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
390 " (low_water) (pause_time) (priority) (port_id)\n"
391 " Set the priority flow control parameter on a"
394 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
395 " Set statistics mapping (qmapping 0..15) for RX/TX"
397 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
398 " on port 0 to mapping 5.\n\n"
400 "set port (port_id) vf (vf_id) rx|tx on|off\n"
401 " Enable/Disable a VF receive/tranmit from a port\n\n"
403 "set port (port_id) vf (vf_id) (mac_addr)"
404 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
405 " Add/Remove unicast or multicast MAC addr filter"
408 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
410 " AUPE:accepts untagged VLAN;"
411 "ROPE:accept unicast hash\n\n"
412 " BAM:accepts broadcast packets;"
413 "MPE:accepts all multicast packets\n\n"
414 " Enable/Disable a VF receive mode of a port\n\n"
416 "set port (port_id) queue (queue_id) rate (rate_num)\n"
417 " Set rate limit for a queue of a port\n\n"
419 "set port (port_id) vf (vf_id) rate (rate_num) "
420 "queue_mask (queue_mask_value)\n"
421 " Set rate limit for queues in VF of a port\n\n"
423 "set port (port_id) mirror-rule (rule_id)"
424 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
425 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
426 " Set pool or vlan type mirror rule on a port.\n"
427 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
428 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
431 "set port (port_id) mirror-rule (rule_id)"
432 " (uplink-mirror|downlink-mirror) dst-pool"
433 " (pool_id) (on|off)\n"
434 " Set uplink or downlink type mirror rule on a port.\n"
435 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
436 " 0 on' enable mirror income traffic to pool 0.\n\n"
438 "reset port (port_id) mirror-rule (rule_id)\n"
439 " Reset a mirror rule.\n\n"
441 "set flush_rx (on|off)\n"
442 " Flush (default) or don't flush RX streams before"
443 " forwarding. Mainly used with PCAP drivers.\n\n"
445 #ifdef RTE_NIC_BYPASS
446 "set bypass mode (normal|bypass|isolate) (port_id)\n"
447 " Set the bypass mode for the lowest port on bypass enabled"
450 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
451 "mode (normal|bypass|isolate) (port_id)\n"
452 " Set the event required to initiate specified bypass mode for"
453 " the lowest port on a bypass enabled NIC where:\n"
454 " timeout = enable bypass after watchdog timeout.\n"
455 " os_on = enable bypass when OS/board is powered on.\n"
456 " os_off = enable bypass when OS/board is powered off.\n"
457 " power_on = enable bypass when power supply is turned on.\n"
458 " power_off = enable bypass when power supply is turned off."
461 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
462 " Set the bypass watchdog timeout to 'n' seconds"
463 " where 0 = instant.\n\n"
465 "show bypass config (port_id)\n"
466 " Show the bypass configuration for a bypass enabled NIC"
467 " using the lowest port on the NIC.\n\n"
469 #ifdef RTE_LIBRTE_PMD_BOND
470 "create bonded device (mode) (socket)\n"
471 " Create a new bonded device with specific bonding mode and socket.\n\n"
473 "add bonding slave (slave_id) (port_id)\n"
474 " Add a slave device to a bonded device.\n\n"
476 "remove bonding slave (slave_id) (port_id)\n"
477 " Remove a slave device from a bonded device.\n\n"
479 "set bonding mode (value) (port_id)\n"
480 " Set the bonding mode on a bonded device.\n\n"
482 "set bonding primary (slave_id) (port_id)\n"
483 " Set the primary slave for a bonded device.\n\n"
485 "show bonding config (port_id)\n"
486 " Show the bonding config for port_id.\n\n"
488 "set bonding mac_addr (port_id) (address)\n"
489 " Set the MAC address of a bonded device.\n\n"
491 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
492 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
494 "set bonding mon_period (port_id) (value)\n"
495 " Set the bonding link status monitoring polling period in ms.\n\n"
497 "set link-up port (port_id)\n"
498 " Set link up for a port.\n\n"
500 "set link-down port (port_id)\n"
501 " Set link down for a port.\n\n"
503 "E-tag set insertion on port-tag-id (value)"
504 " port (port_id) vf (vf_id)\n"
505 " Enable E-tag insertion for a VF on a port\n\n"
507 "E-tag set insertion off port (port_id) vf (vf_id)\n"
508 " Disable E-tag insertion for a VF on a port\n\n"
510 "E-tag set stripping (on|off) port (port_id)\n"
511 " Enable/disable E-tag stripping on a port\n\n"
513 "E-tag set forwarding (on|off) port (port_id)\n"
514 " Enable/disable E-tag based forwarding"
517 "E-tag set filter add e-tag-id (value) dst-pool"
518 " (pool_id) port (port_id)\n"
519 " Add an E-tag forwarding filter on a port\n\n"
521 "E-tag set filter del e-tag-id (value) port (port_id)\n"
522 " Delete an E-tag forwarding filter on a port\n\n"
524 , list_pkt_forwarding_modes()
528 if (show_all || !strcmp(res->section, "ports")) {
534 "----------------\n\n"
536 "port start (port_id|all)\n"
537 " Start all ports or port_id.\n\n"
539 "port stop (port_id|all)\n"
540 " Stop all ports or port_id.\n\n"
542 "port close (port_id|all)\n"
543 " Close all ports or port_id.\n\n"
545 "port attach (ident)\n"
546 " Attach physical or virtual dev by pci address or virtual device name\n\n"
548 "port detach (port_id)\n"
549 " Detach physical or virtual dev by port_id\n\n"
551 "port config (port_id|all)"
552 " speed (10|100|1000|10000|40000|auto)"
553 " duplex (half|full|auto)\n"
554 " Set speed and duplex for all ports or port_id\n\n"
556 "port config all (rxq|txq|rxd|txd) (value)\n"
557 " Set number for rxq/txq/rxd/txd.\n\n"
559 "port config all max-pkt-len (value)\n"
560 " Set the max packet length.\n\n"
562 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
563 "hw-vlan-strip|hw-vlan-extend|drop-en)"
565 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
568 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
569 " Set the RSS mode.\n\n"
571 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
572 " Set the RSS redirection table.\n\n"
574 "port config (port_id) dcb vt (on|off) (traffic_class)"
576 " Set the DCB mode.\n\n"
578 "port config all burst (value)\n"
579 " Set the number of packets per burst.\n\n"
581 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
583 " Set the ring prefetch/host/writeback threshold"
584 " for tx/rx queue.\n\n"
586 "port config all (txfreet|txrst|rxfreet) (value)\n"
587 " Set free threshold for rx/tx, or set"
588 " tx rs bit threshold.\n\n"
589 "port config mtu X value\n"
590 " Set the MTU of port X to a given value\n\n"
592 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
593 " Start/stop a rx/tx queue of port X. Only take effect"
594 " when port X is started\n\n"
596 "port config (port_id|all) l2-tunnel E-tag ether-type"
598 " Set the value of E-tag ether-type.\n\n"
600 "port config (port_id|all) l2-tunnel E-tag"
601 " (enable|disable)\n"
602 " Enable/disable the E-tag support.\n\n"
606 if (show_all || !strcmp(res->section, "registers")) {
614 "read reg (port_id) (address)\n"
615 " Display value of a port register.\n\n"
617 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
618 " Display a port register bit field.\n\n"
620 "read regbit (port_id) (address) (bit_x)\n"
621 " Display a single port register bit.\n\n"
623 "write reg (port_id) (address) (value)\n"
624 " Set value of a port register.\n\n"
626 "write regfield (port_id) (address) (bit_x) (bit_y)"
628 " Set bit field of a port register.\n\n"
630 "write regbit (port_id) (address) (bit_x) (value)\n"
631 " Set single bit value of a port register.\n\n"
634 if (show_all || !strcmp(res->section, "filters")) {
642 "ethertype_filter (port_id) (add|del)"
643 " (mac_addr|mac_ignr) (mac_address) ethertype"
644 " (ether_type) (drop|fwd) queue (queue_id)\n"
645 " Add/Del an ethertype filter.\n\n"
647 "2tuple_filter (port_id) (add|del)"
648 " dst_port (dst_port_value) protocol (protocol_value)"
649 " mask (mask_value) tcp_flags (tcp_flags_value)"
650 " priority (prio_value) queue (queue_id)\n"
651 " Add/Del a 2tuple filter.\n\n"
653 "5tuple_filter (port_id) (add|del)"
654 " dst_ip (dst_address) src_ip (src_address)"
655 " dst_port (dst_port_value) src_port (src_port_value)"
656 " protocol (protocol_value)"
657 " mask (mask_value) tcp_flags (tcp_flags_value)"
658 " priority (prio_value) queue (queue_id)\n"
659 " Add/Del a 5tuple filter.\n\n"
661 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
662 " Add/Del syn filter.\n\n"
664 "flex_filter (port_id) (add|del) len (len_value)"
665 " bytes (bytes_value) mask (mask_value)"
666 " priority (prio_value) queue (queue_id)\n"
667 " Add/Del a flex filter.\n\n"
669 "flow_director_filter (port_id) mode IP (add|del|update)"
670 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
671 " src (src_ip_address) dst (dst_ip_address)"
672 " vlan (vlan_value) flexbytes (flexbytes_value)"
673 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
674 " fd_id (fd_id_value)\n"
675 " Add/Del an IP type flow director filter.\n\n"
677 "flow_director_filter (port_id) mode IP (add|del|update)"
678 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
679 " src (src_ip_address) (src_port)"
680 " dst (dst_ip_address) (dst_port)"
681 " vlan (vlan_value) flexbytes (flexbytes_value)"
682 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
683 " fd_id (fd_id_value)\n"
684 " Add/Del an UDP/TCP type flow director filter.\n\n"
686 "flow_director_filter (port_id) mode IP (add|del|update)"
687 " flow (ipv4-sctp|ipv6-sctp)"
688 " src (src_ip_address) (src_port)"
689 " dst (dst_ip_address) (dst_port)"
690 " tag (verification_tag) vlan (vlan_value)"
691 " flexbytes (flexbytes_value) (drop|fwd)"
692 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
693 " Add/Del a SCTP type flow director filter.\n\n"
695 "flow_director_filter (port_id) mode IP (add|del|update)"
696 " flow l2_payload ether (ethertype)"
697 " flexbytes (flexbytes_value) (drop|fwd)"
698 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
699 " Add/Del a l2 payload type flow director filter.\n\n"
701 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
702 " mac (mac_address) vlan (vlan_value)"
703 " flexbytes (flexbytes_value) (drop|fwd)"
704 " queue (queue_id) fd_id (fd_id_value)\n"
705 " Add/Del a MAC-VLAN flow director filter.\n\n"
707 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
708 " mac (mac_address) vlan (vlan_value)"
709 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
710 " flexbytes (flexbytes_value) (drop|fwd)"
711 " queue (queue_id) fd_id (fd_id_value)\n"
712 " Add/Del a Tunnel flow director filter.\n\n"
714 "flush_flow_director (port_id)\n"
715 " Flush all flow director entries of a device.\n\n"
717 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
718 " src_mask (ipv4_src) (ipv6_src) (src_port)"
719 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
720 " Set flow director IP mask.\n\n"
722 "flow_director_mask (port_id) mode MAC-VLAN"
723 " vlan (vlan_value) mac (mac_value)\n"
724 " Set flow director MAC-VLAN mask.\n\n"
726 "flow_director_mask (port_id) mode Tunnel"
727 " vlan (vlan_value) mac (mac_value)"
728 " tunnel-type (tunnel_type_value)"
729 " tunnel-id (tunnel_id_value)\n"
730 " Set flow director Tunnel mask.\n\n"
732 "flow_director_flex_mask (port_id)"
733 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
734 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
736 " Configure mask of flex payload.\n\n"
738 "flow_director_flex_payload (port_id)"
739 " (raw|l2|l3|l4) (config)\n"
740 " Configure flex payload selection.\n\n"
742 "get_sym_hash_ena_per_port (port_id)\n"
743 " get symmetric hash enable configuration per port.\n\n"
745 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
746 " set symmetric hash enable configuration per port"
747 " to enable or disable.\n\n"
749 "get_hash_global_config (port_id)\n"
750 " Get the global configurations of hash filters.\n\n"
752 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
753 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
754 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
755 " (enable|disable)\n"
756 " Set the global configurations of hash filters.\n\n"
758 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
759 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
760 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
761 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
762 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
763 "ipv6-next-header|udp-src-port|udp-dst-port|"
764 "tcp-src-port|tcp-dst-port|sctp-src-port|"
765 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
766 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
767 "fld-8th|none) (select|add)\n"
768 " Set the input set for hash.\n\n"
770 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
771 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
772 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
773 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
774 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
775 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
776 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
777 "fld-8th|none) (select|add)\n"
778 " Set the input set for FDir.\n\n"
783 cmdline_parse_token_string_t cmd_help_long_help =
784 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
786 cmdline_parse_token_string_t cmd_help_long_section =
787 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
788 "all#control#display#config#"
789 "ports#registers#filters");
791 cmdline_parse_inst_t cmd_help_long = {
792 .f = cmd_help_long_parsed,
794 .help_str = "show help",
796 (void *)&cmd_help_long_help,
797 (void *)&cmd_help_long_section,
803 /* *** start/stop/close all ports *** */
804 struct cmd_operate_port_result {
805 cmdline_fixed_string_t keyword;
806 cmdline_fixed_string_t name;
807 cmdline_fixed_string_t value;
810 static void cmd_operate_port_parsed(void *parsed_result,
811 __attribute__((unused)) struct cmdline *cl,
812 __attribute__((unused)) void *data)
814 struct cmd_operate_port_result *res = parsed_result;
816 if (!strcmp(res->name, "start"))
817 start_port(RTE_PORT_ALL);
818 else if (!strcmp(res->name, "stop"))
819 stop_port(RTE_PORT_ALL);
820 else if (!strcmp(res->name, "close"))
821 close_port(RTE_PORT_ALL);
823 printf("Unknown parameter\n");
826 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
827 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
829 cmdline_parse_token_string_t cmd_operate_port_all_port =
830 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
832 cmdline_parse_token_string_t cmd_operate_port_all_all =
833 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
835 cmdline_parse_inst_t cmd_operate_port = {
836 .f = cmd_operate_port_parsed,
838 .help_str = "port start|stop|close all: start/stop/close all ports",
840 (void *)&cmd_operate_port_all_cmd,
841 (void *)&cmd_operate_port_all_port,
842 (void *)&cmd_operate_port_all_all,
847 /* *** start/stop/close specific port *** */
848 struct cmd_operate_specific_port_result {
849 cmdline_fixed_string_t keyword;
850 cmdline_fixed_string_t name;
854 static void cmd_operate_specific_port_parsed(void *parsed_result,
855 __attribute__((unused)) struct cmdline *cl,
856 __attribute__((unused)) void *data)
858 struct cmd_operate_specific_port_result *res = parsed_result;
860 if (!strcmp(res->name, "start"))
861 start_port(res->value);
862 else if (!strcmp(res->name, "stop"))
863 stop_port(res->value);
864 else if (!strcmp(res->name, "close"))
865 close_port(res->value);
867 printf("Unknown parameter\n");
870 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
871 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
873 cmdline_parse_token_string_t cmd_operate_specific_port_port =
874 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
875 name, "start#stop#close");
876 cmdline_parse_token_num_t cmd_operate_specific_port_id =
877 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
880 cmdline_parse_inst_t cmd_operate_specific_port = {
881 .f = cmd_operate_specific_port_parsed,
883 .help_str = "port start|stop|close X: start/stop/close port X",
885 (void *)&cmd_operate_specific_port_cmd,
886 (void *)&cmd_operate_specific_port_port,
887 (void *)&cmd_operate_specific_port_id,
892 /* *** attach a specified port *** */
893 struct cmd_operate_attach_port_result {
894 cmdline_fixed_string_t port;
895 cmdline_fixed_string_t keyword;
896 cmdline_fixed_string_t identifier;
899 static void cmd_operate_attach_port_parsed(void *parsed_result,
900 __attribute__((unused)) struct cmdline *cl,
901 __attribute__((unused)) void *data)
903 struct cmd_operate_attach_port_result *res = parsed_result;
905 if (!strcmp(res->keyword, "attach"))
906 attach_port(res->identifier);
908 printf("Unknown parameter\n");
911 cmdline_parse_token_string_t cmd_operate_attach_port_port =
912 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
914 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
915 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
917 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
918 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
921 cmdline_parse_inst_t cmd_operate_attach_port = {
922 .f = cmd_operate_attach_port_parsed,
924 .help_str = "port attach identifier, "
925 "identifier: pci address or virtual dev name",
927 (void *)&cmd_operate_attach_port_port,
928 (void *)&cmd_operate_attach_port_keyword,
929 (void *)&cmd_operate_attach_port_identifier,
934 /* *** detach a specified port *** */
935 struct cmd_operate_detach_port_result {
936 cmdline_fixed_string_t port;
937 cmdline_fixed_string_t keyword;
941 static void cmd_operate_detach_port_parsed(void *parsed_result,
942 __attribute__((unused)) struct cmdline *cl,
943 __attribute__((unused)) void *data)
945 struct cmd_operate_detach_port_result *res = parsed_result;
947 if (!strcmp(res->keyword, "detach"))
948 detach_port(res->port_id);
950 printf("Unknown parameter\n");
953 cmdline_parse_token_string_t cmd_operate_detach_port_port =
954 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
956 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
957 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
959 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
960 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
963 cmdline_parse_inst_t cmd_operate_detach_port = {
964 .f = cmd_operate_detach_port_parsed,
966 .help_str = "port detach port_id",
968 (void *)&cmd_operate_detach_port_port,
969 (void *)&cmd_operate_detach_port_keyword,
970 (void *)&cmd_operate_detach_port_port_id,
975 /* *** configure speed for all ports *** */
976 struct cmd_config_speed_all {
977 cmdline_fixed_string_t port;
978 cmdline_fixed_string_t keyword;
979 cmdline_fixed_string_t all;
980 cmdline_fixed_string_t item1;
981 cmdline_fixed_string_t item2;
982 cmdline_fixed_string_t value1;
983 cmdline_fixed_string_t value2;
987 cmd_config_speed_all_parsed(void *parsed_result,
988 __attribute__((unused)) struct cmdline *cl,
989 __attribute__((unused)) void *data)
991 struct cmd_config_speed_all *res = parsed_result;
992 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
993 uint16_t link_duplex = 0;
996 if (!all_ports_stopped()) {
997 printf("Please stop all ports first\n");
1001 if (!strcmp(res->value1, "10"))
1002 link_speed = ETH_LINK_SPEED_10;
1003 else if (!strcmp(res->value1, "100"))
1004 link_speed = ETH_LINK_SPEED_100;
1005 else if (!strcmp(res->value1, "1000"))
1006 link_speed = ETH_LINK_SPEED_1000;
1007 else if (!strcmp(res->value1, "10000"))
1008 link_speed = ETH_LINK_SPEED_10G;
1009 else if (!strcmp(res->value1, "40000"))
1010 link_speed = ETH_LINK_SPEED_40G;
1011 else if (!strcmp(res->value1, "auto"))
1012 link_speed = ETH_LINK_SPEED_AUTONEG;
1014 printf("Unknown parameter\n");
1018 if (!strcmp(res->value2, "half"))
1019 link_duplex = ETH_LINK_HALF_DUPLEX;
1020 else if (!strcmp(res->value2, "full"))
1021 link_duplex = ETH_LINK_FULL_DUPLEX;
1022 else if (!strcmp(res->value2, "auto"))
1023 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1025 printf("Unknown parameter\n");
1029 FOREACH_PORT(pid, ports) {
1030 ports[pid].dev_conf.link_speed = link_speed;
1031 ports[pid].dev_conf.link_duplex = link_duplex;
1034 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1037 cmdline_parse_token_string_t cmd_config_speed_all_port =
1038 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1039 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1040 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1042 cmdline_parse_token_string_t cmd_config_speed_all_all =
1043 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1044 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1045 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1046 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1047 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1048 "10#100#1000#10000#40000#auto");
1049 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1051 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1052 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1055 cmdline_parse_inst_t cmd_config_speed_all = {
1056 .f = cmd_config_speed_all_parsed,
1058 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1061 (void *)&cmd_config_speed_all_port,
1062 (void *)&cmd_config_speed_all_keyword,
1063 (void *)&cmd_config_speed_all_all,
1064 (void *)&cmd_config_speed_all_item1,
1065 (void *)&cmd_config_speed_all_value1,
1066 (void *)&cmd_config_speed_all_item2,
1067 (void *)&cmd_config_speed_all_value2,
1072 /* *** configure speed for specific port *** */
1073 struct cmd_config_speed_specific {
1074 cmdline_fixed_string_t port;
1075 cmdline_fixed_string_t keyword;
1077 cmdline_fixed_string_t item1;
1078 cmdline_fixed_string_t item2;
1079 cmdline_fixed_string_t value1;
1080 cmdline_fixed_string_t value2;
1084 cmd_config_speed_specific_parsed(void *parsed_result,
1085 __attribute__((unused)) struct cmdline *cl,
1086 __attribute__((unused)) void *data)
1088 struct cmd_config_speed_specific *res = parsed_result;
1089 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1090 uint16_t link_duplex = 0;
1092 if (!all_ports_stopped()) {
1093 printf("Please stop all ports first\n");
1097 if (port_id_is_invalid(res->id, ENABLED_WARN))
1100 if (!strcmp(res->value1, "10"))
1101 link_speed = ETH_LINK_SPEED_10;
1102 else if (!strcmp(res->value1, "100"))
1103 link_speed = ETH_LINK_SPEED_100;
1104 else if (!strcmp(res->value1, "1000"))
1105 link_speed = ETH_LINK_SPEED_1000;
1106 else if (!strcmp(res->value1, "10000"))
1107 link_speed = ETH_LINK_SPEED_10000;
1108 else if (!strcmp(res->value1, "40000"))
1109 link_speed = ETH_LINK_SPEED_40G;
1110 else if (!strcmp(res->value1, "auto"))
1111 link_speed = ETH_LINK_SPEED_AUTONEG;
1113 printf("Unknown parameter\n");
1117 if (!strcmp(res->value2, "half"))
1118 link_duplex = ETH_LINK_HALF_DUPLEX;
1119 else if (!strcmp(res->value2, "full"))
1120 link_duplex = ETH_LINK_FULL_DUPLEX;
1121 else if (!strcmp(res->value2, "auto"))
1122 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1124 printf("Unknown parameter\n");
1128 ports[res->id].dev_conf.link_speed = link_speed;
1129 ports[res->id].dev_conf.link_duplex = link_duplex;
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#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|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");
1194 if (!strcmp(res->name, "rxq")) {
1195 if (res->value <= 0) {
1196 printf("rxq %d invalid - must be > 0\n", res->value);
1199 nb_rxq = res->value;
1201 else if (!strcmp(res->name, "txq")) {
1202 if (res->value <= 0) {
1203 printf("txq %d invalid - must be > 0\n", res->value);
1206 nb_txq = res->value;
1208 else if (!strcmp(res->name, "rxd")) {
1209 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1210 printf("rxd %d invalid - must be > 0 && <= %d\n",
1211 res->value, RTE_TEST_RX_DESC_MAX);
1214 nb_rxd = res->value;
1215 } else if (!strcmp(res->name, "txd")) {
1216 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1217 printf("txd %d invalid - must be > 0 && <= %d\n",
1218 res->value, RTE_TEST_TX_DESC_MAX);
1221 nb_txd = res->value;
1223 printf("Unknown parameter\n");
1229 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1232 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1234 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1236 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1238 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1239 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1241 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1242 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1244 cmdline_parse_inst_t cmd_config_rx_tx = {
1245 .f = cmd_config_rx_tx_parsed,
1247 .help_str = "port config all rxq|txq|rxd|txd value",
1249 (void *)&cmd_config_rx_tx_port,
1250 (void *)&cmd_config_rx_tx_keyword,
1251 (void *)&cmd_config_rx_tx_all,
1252 (void *)&cmd_config_rx_tx_name,
1253 (void *)&cmd_config_rx_tx_value,
1258 /* *** config max packet length *** */
1259 struct cmd_config_max_pkt_len_result {
1260 cmdline_fixed_string_t port;
1261 cmdline_fixed_string_t keyword;
1262 cmdline_fixed_string_t all;
1263 cmdline_fixed_string_t name;
1268 cmd_config_max_pkt_len_parsed(void *parsed_result,
1269 __attribute__((unused)) struct cmdline *cl,
1270 __attribute__((unused)) void *data)
1272 struct cmd_config_max_pkt_len_result *res = parsed_result;
1274 if (!all_ports_stopped()) {
1275 printf("Please stop all ports first\n");
1279 if (!strcmp(res->name, "max-pkt-len")) {
1280 if (res->value < ETHER_MIN_LEN) {
1281 printf("max-pkt-len can not be less than %d\n",
1285 if (res->value == rx_mode.max_rx_pkt_len)
1288 rx_mode.max_rx_pkt_len = res->value;
1289 if (res->value > ETHER_MAX_LEN)
1290 rx_mode.jumbo_frame = 1;
1292 rx_mode.jumbo_frame = 0;
1294 printf("Unknown parameter\n");
1300 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1303 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1304 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1306 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1307 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1309 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1310 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1312 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1315 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1316 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1319 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1320 .f = cmd_config_max_pkt_len_parsed,
1322 .help_str = "port config all max-pkt-len value",
1324 (void *)&cmd_config_max_pkt_len_port,
1325 (void *)&cmd_config_max_pkt_len_keyword,
1326 (void *)&cmd_config_max_pkt_len_all,
1327 (void *)&cmd_config_max_pkt_len_name,
1328 (void *)&cmd_config_max_pkt_len_value,
1333 /* *** configure port MTU *** */
1334 struct cmd_config_mtu_result {
1335 cmdline_fixed_string_t port;
1336 cmdline_fixed_string_t keyword;
1337 cmdline_fixed_string_t mtu;
1343 cmd_config_mtu_parsed(void *parsed_result,
1344 __attribute__((unused)) struct cmdline *cl,
1345 __attribute__((unused)) void *data)
1347 struct cmd_config_mtu_result *res = parsed_result;
1349 if (res->value < ETHER_MIN_LEN) {
1350 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1353 port_mtu_set(res->port_id, res->value);
1356 cmdline_parse_token_string_t cmd_config_mtu_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1359 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1360 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1362 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1365 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1366 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1367 cmdline_parse_token_num_t cmd_config_mtu_value =
1368 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1370 cmdline_parse_inst_t cmd_config_mtu = {
1371 .f = cmd_config_mtu_parsed,
1373 .help_str = "port config mtu value",
1375 (void *)&cmd_config_mtu_port,
1376 (void *)&cmd_config_mtu_keyword,
1377 (void *)&cmd_config_mtu_mtu,
1378 (void *)&cmd_config_mtu_port_id,
1379 (void *)&cmd_config_mtu_value,
1384 /* *** configure rx mode *** */
1385 struct cmd_config_rx_mode_flag {
1386 cmdline_fixed_string_t port;
1387 cmdline_fixed_string_t keyword;
1388 cmdline_fixed_string_t all;
1389 cmdline_fixed_string_t name;
1390 cmdline_fixed_string_t value;
1394 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1395 __attribute__((unused)) struct cmdline *cl,
1396 __attribute__((unused)) void *data)
1398 struct cmd_config_rx_mode_flag *res = parsed_result;
1400 if (!all_ports_stopped()) {
1401 printf("Please stop all ports first\n");
1405 if (!strcmp(res->name, "crc-strip")) {
1406 if (!strcmp(res->value, "on"))
1407 rx_mode.hw_strip_crc = 1;
1408 else if (!strcmp(res->value, "off"))
1409 rx_mode.hw_strip_crc = 0;
1411 printf("Unknown parameter\n");
1414 } else if (!strcmp(res->name, "rx-cksum")) {
1415 if (!strcmp(res->value, "on"))
1416 rx_mode.hw_ip_checksum = 1;
1417 else if (!strcmp(res->value, "off"))
1418 rx_mode.hw_ip_checksum = 0;
1420 printf("Unknown parameter\n");
1423 } else if (!strcmp(res->name, "hw-vlan")) {
1424 if (!strcmp(res->value, "on")) {
1425 rx_mode.hw_vlan_filter = 1;
1426 rx_mode.hw_vlan_strip = 1;
1428 else if (!strcmp(res->value, "off")) {
1429 rx_mode.hw_vlan_filter = 0;
1430 rx_mode.hw_vlan_strip = 0;
1433 printf("Unknown parameter\n");
1436 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1437 if (!strcmp(res->value, "on"))
1438 rx_mode.hw_vlan_filter = 1;
1439 else if (!strcmp(res->value, "off"))
1440 rx_mode.hw_vlan_filter = 0;
1442 printf("Unknown parameter\n");
1445 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1446 if (!strcmp(res->value, "on"))
1447 rx_mode.hw_vlan_strip = 1;
1448 else if (!strcmp(res->value, "off"))
1449 rx_mode.hw_vlan_strip = 0;
1451 printf("Unknown parameter\n");
1454 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1455 if (!strcmp(res->value, "on"))
1456 rx_mode.hw_vlan_extend = 1;
1457 else if (!strcmp(res->value, "off"))
1458 rx_mode.hw_vlan_extend = 0;
1460 printf("Unknown parameter\n");
1463 } else if (!strcmp(res->name, "drop-en")) {
1464 if (!strcmp(res->value, "on"))
1466 else if (!strcmp(res->value, "off"))
1469 printf("Unknown parameter\n");
1473 printf("Unknown parameter\n");
1479 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1482 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1484 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1485 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1487 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1489 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1491 "crc-strip#rx-cksum#hw-vlan#"
1492 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1493 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1497 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1498 .f = cmd_config_rx_mode_flag_parsed,
1500 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1501 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1503 (void *)&cmd_config_rx_mode_flag_port,
1504 (void *)&cmd_config_rx_mode_flag_keyword,
1505 (void *)&cmd_config_rx_mode_flag_all,
1506 (void *)&cmd_config_rx_mode_flag_name,
1507 (void *)&cmd_config_rx_mode_flag_value,
1512 /* *** configure rss *** */
1513 struct cmd_config_rss {
1514 cmdline_fixed_string_t port;
1515 cmdline_fixed_string_t keyword;
1516 cmdline_fixed_string_t all;
1517 cmdline_fixed_string_t name;
1518 cmdline_fixed_string_t value;
1522 cmd_config_rss_parsed(void *parsed_result,
1523 __attribute__((unused)) struct cmdline *cl,
1524 __attribute__((unused)) void *data)
1526 struct cmd_config_rss *res = parsed_result;
1527 struct rte_eth_rss_conf rss_conf;
1530 if (!strcmp(res->value, "all"))
1531 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1532 ETH_RSS_UDP | ETH_RSS_SCTP |
1534 else if (!strcmp(res->value, "ip"))
1535 rss_conf.rss_hf = ETH_RSS_IP;
1536 else if (!strcmp(res->value, "udp"))
1537 rss_conf.rss_hf = ETH_RSS_UDP;
1538 else if (!strcmp(res->value, "tcp"))
1539 rss_conf.rss_hf = ETH_RSS_TCP;
1540 else if (!strcmp(res->value, "sctp"))
1541 rss_conf.rss_hf = ETH_RSS_SCTP;
1542 else if (!strcmp(res->value, "ether"))
1543 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1544 else if (!strcmp(res->value, "none"))
1545 rss_conf.rss_hf = 0;
1547 printf("Unknown parameter\n");
1550 rss_conf.rss_key = NULL;
1551 for (i = 0; i < rte_eth_dev_count(); i++)
1552 rte_eth_dev_rss_hash_update(i, &rss_conf);
1555 cmdline_parse_token_string_t cmd_config_rss_port =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1557 cmdline_parse_token_string_t cmd_config_rss_keyword =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1559 cmdline_parse_token_string_t cmd_config_rss_all =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1561 cmdline_parse_token_string_t cmd_config_rss_name =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1563 cmdline_parse_token_string_t cmd_config_rss_value =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1565 "all#ip#tcp#udp#sctp#ether#none");
1567 cmdline_parse_inst_t cmd_config_rss = {
1568 .f = cmd_config_rss_parsed,
1570 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1572 (void *)&cmd_config_rss_port,
1573 (void *)&cmd_config_rss_keyword,
1574 (void *)&cmd_config_rss_all,
1575 (void *)&cmd_config_rss_name,
1576 (void *)&cmd_config_rss_value,
1581 /* *** configure rss hash key *** */
1582 struct cmd_config_rss_hash_key {
1583 cmdline_fixed_string_t port;
1584 cmdline_fixed_string_t config;
1586 cmdline_fixed_string_t rss_hash_key;
1587 cmdline_fixed_string_t rss_type;
1588 cmdline_fixed_string_t key;
1591 #define RSS_HASH_KEY_LENGTH 40
1593 hexa_digit_to_value(char hexa_digit)
1595 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1596 return (uint8_t) (hexa_digit - '0');
1597 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1598 return (uint8_t) ((hexa_digit - 'a') + 10);
1599 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1600 return (uint8_t) ((hexa_digit - 'A') + 10);
1601 /* Invalid hexa digit */
1606 parse_and_check_key_hexa_digit(char *key, int idx)
1610 hexa_v = hexa_digit_to_value(key[idx]);
1612 printf("invalid key: character %c at position %d is not a "
1613 "valid hexa digit\n", key[idx], idx);
1618 cmd_config_rss_hash_key_parsed(void *parsed_result,
1619 __attribute__((unused)) struct cmdline *cl,
1620 __attribute__((unused)) void *data)
1622 struct cmd_config_rss_hash_key *res = parsed_result;
1623 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1628 /* Check the length of the RSS hash key */
1629 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1630 printf("key length: %d invalid - key must be a string of %d"
1631 "hexa-decimal numbers\n", (int) strlen(res->key),
1632 RSS_HASH_KEY_LENGTH * 2);
1635 /* Translate RSS hash key into binary representation */
1636 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1637 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1640 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1643 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1645 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1646 RSS_HASH_KEY_LENGTH);
1649 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1651 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1654 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1655 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1656 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1658 rss_hash_key, "rss-hash-key");
1659 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1661 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1662 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1663 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1664 "ipv6-tcp-ex#ipv6-udp-ex");
1665 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1668 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1669 .f = cmd_config_rss_hash_key_parsed,
1672 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1673 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1674 "ipv6-sctp|ipv6-other|l2-payload|"
1675 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1677 (void *)&cmd_config_rss_hash_key_port,
1678 (void *)&cmd_config_rss_hash_key_config,
1679 (void *)&cmd_config_rss_hash_key_port_id,
1680 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1681 (void *)&cmd_config_rss_hash_key_rss_type,
1682 (void *)&cmd_config_rss_hash_key_value,
1687 /* *** configure port rxq/txq start/stop *** */
1688 struct cmd_config_rxtx_queue {
1689 cmdline_fixed_string_t port;
1691 cmdline_fixed_string_t rxtxq;
1693 cmdline_fixed_string_t opname;
1697 cmd_config_rxtx_queue_parsed(void *parsed_result,
1698 __attribute__((unused)) struct cmdline *cl,
1699 __attribute__((unused)) void *data)
1701 struct cmd_config_rxtx_queue *res = parsed_result;
1706 if (test_done == 0) {
1707 printf("Please stop forwarding first\n");
1711 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1714 if (port_is_started(res->portid) != 1) {
1715 printf("Please start port %u first\n", res->portid);
1719 if (!strcmp(res->rxtxq, "rxq"))
1721 else if (!strcmp(res->rxtxq, "txq"))
1724 printf("Unknown parameter\n");
1728 if (isrx && rx_queue_id_is_invalid(res->qid))
1730 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1733 if (!strcmp(res->opname, "start"))
1735 else if (!strcmp(res->opname, "stop"))
1738 printf("Unknown parameter\n");
1742 if (isstart && isrx)
1743 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1744 else if (!isstart && isrx)
1745 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1746 else if (isstart && !isrx)
1747 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1749 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1751 if (ret == -ENOTSUP)
1752 printf("Function not supported in PMD driver\n");
1755 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1756 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1757 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1758 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1759 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1761 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1762 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1763 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1767 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1768 .f = cmd_config_rxtx_queue_parsed,
1770 .help_str = "port X rxq|txq ID start|stop",
1772 (void *)&cmd_config_speed_all_port,
1773 (void *)&cmd_config_rxtx_queue_portid,
1774 (void *)&cmd_config_rxtx_queue_rxtxq,
1775 (void *)&cmd_config_rxtx_queue_qid,
1776 (void *)&cmd_config_rxtx_queue_opname,
1781 /* *** Configure RSS RETA *** */
1782 struct cmd_config_rss_reta {
1783 cmdline_fixed_string_t port;
1784 cmdline_fixed_string_t keyword;
1786 cmdline_fixed_string_t name;
1787 cmdline_fixed_string_t list_name;
1788 cmdline_fixed_string_t list_of_items;
1792 parse_reta_config(const char *str,
1793 struct rte_eth_rss_reta_entry64 *reta_conf,
1794 uint16_t nb_entries)
1798 uint16_t hash_index, idx, shift;
1801 const char *p, *p0 = str;
1808 unsigned long int_fld[_NUM_FLD];
1809 char *str_fld[_NUM_FLD];
1811 while ((p = strchr(p0,'(')) != NULL) {
1813 if((p0 = strchr(p,')')) == NULL)
1817 if(size >= sizeof(s))
1820 snprintf(s, sizeof(s), "%.*s", size, p);
1821 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1823 for (i = 0; i < _NUM_FLD; i++) {
1825 int_fld[i] = strtoul(str_fld[i], &end, 0);
1826 if (errno != 0 || end == str_fld[i] ||
1831 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1832 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1834 if (hash_index >= nb_entries) {
1835 printf("Invalid RETA hash index=%d\n", hash_index);
1839 idx = hash_index / RTE_RETA_GROUP_SIZE;
1840 shift = hash_index % RTE_RETA_GROUP_SIZE;
1841 reta_conf[idx].mask |= (1ULL << shift);
1842 reta_conf[idx].reta[shift] = nb_queue;
1849 cmd_set_rss_reta_parsed(void *parsed_result,
1850 __attribute__((unused)) struct cmdline *cl,
1851 __attribute__((unused)) void *data)
1854 struct rte_eth_dev_info dev_info;
1855 struct rte_eth_rss_reta_entry64 reta_conf[8];
1856 struct cmd_config_rss_reta *res = parsed_result;
1858 memset(&dev_info, 0, sizeof(dev_info));
1859 rte_eth_dev_info_get(res->port_id, &dev_info);
1860 if (dev_info.reta_size == 0) {
1861 printf("Redirection table size is 0 which is "
1862 "invalid for RSS\n");
1865 printf("The reta size of port %d is %u\n",
1866 res->port_id, dev_info.reta_size);
1867 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1868 printf("Currently do not support more than %u entries of "
1869 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1873 memset(reta_conf, 0, sizeof(reta_conf));
1874 if (!strcmp(res->list_name, "reta")) {
1875 if (parse_reta_config(res->list_of_items, reta_conf,
1876 dev_info.reta_size)) {
1877 printf("Invalid RSS Redirection Table "
1878 "config entered\n");
1881 ret = rte_eth_dev_rss_reta_update(res->port_id,
1882 reta_conf, dev_info.reta_size);
1884 printf("Bad redirection table parameter, "
1885 "return code = %d \n", ret);
1889 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1890 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1891 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1892 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1893 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1894 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1895 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1896 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1897 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1899 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1902 cmdline_parse_inst_t cmd_config_rss_reta = {
1903 .f = cmd_set_rss_reta_parsed,
1905 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1907 (void *)&cmd_config_rss_reta_port,
1908 (void *)&cmd_config_rss_reta_keyword,
1909 (void *)&cmd_config_rss_reta_port_id,
1910 (void *)&cmd_config_rss_reta_name,
1911 (void *)&cmd_config_rss_reta_list_name,
1912 (void *)&cmd_config_rss_reta_list_of_items,
1917 /* *** SHOW PORT RETA INFO *** */
1918 struct cmd_showport_reta {
1919 cmdline_fixed_string_t show;
1920 cmdline_fixed_string_t port;
1922 cmdline_fixed_string_t rss;
1923 cmdline_fixed_string_t reta;
1925 cmdline_fixed_string_t list_of_items;
1929 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1930 uint16_t nb_entries,
1934 const char *p, *p0 = str;
1938 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1941 p = strchr(p0, '(');
1945 p0 = strchr(p, ')');
1949 if (size >= sizeof(s)) {
1950 printf("The string size exceeds the internal buffer size\n");
1953 snprintf(s, sizeof(s), "%.*s", size, p);
1954 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1955 if (ret <= 0 || ret != num) {
1956 printf("The bits of masks do not match the number of "
1957 "reta entries: %u\n", num);
1960 for (i = 0; i < ret; i++)
1961 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1967 cmd_showport_reta_parsed(void *parsed_result,
1968 __attribute__((unused)) struct cmdline *cl,
1969 __attribute__((unused)) void *data)
1971 struct cmd_showport_reta *res = parsed_result;
1972 struct rte_eth_rss_reta_entry64 reta_conf[8];
1973 struct rte_eth_dev_info dev_info;
1975 memset(&dev_info, 0, sizeof(dev_info));
1976 rte_eth_dev_info_get(res->port_id, &dev_info);
1977 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1978 res->size > ETH_RSS_RETA_SIZE_512) {
1979 printf("Invalid redirection table size: %u\n", res->size);
1983 memset(reta_conf, 0, sizeof(reta_conf));
1984 if (showport_parse_reta_config(reta_conf, res->size,
1985 res->list_of_items) < 0) {
1986 printf("Invalid string: %s for reta masks\n",
1987 res->list_of_items);
1990 port_rss_reta_info(res->port_id, reta_conf, res->size);
1993 cmdline_parse_token_string_t cmd_showport_reta_show =
1994 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1995 cmdline_parse_token_string_t cmd_showport_reta_port =
1996 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1997 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1998 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1999 cmdline_parse_token_string_t cmd_showport_reta_rss =
2000 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2001 cmdline_parse_token_string_t cmd_showport_reta_reta =
2002 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2003 cmdline_parse_token_num_t cmd_showport_reta_size =
2004 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2005 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2006 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2007 list_of_items, NULL);
2009 cmdline_parse_inst_t cmd_showport_reta = {
2010 .f = cmd_showport_reta_parsed,
2012 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
2014 (void *)&cmd_showport_reta_show,
2015 (void *)&cmd_showport_reta_port,
2016 (void *)&cmd_showport_reta_port_id,
2017 (void *)&cmd_showport_reta_rss,
2018 (void *)&cmd_showport_reta_reta,
2019 (void *)&cmd_showport_reta_size,
2020 (void *)&cmd_showport_reta_list_of_items,
2025 /* *** Show RSS hash configuration *** */
2026 struct cmd_showport_rss_hash {
2027 cmdline_fixed_string_t show;
2028 cmdline_fixed_string_t port;
2030 cmdline_fixed_string_t rss_hash;
2031 cmdline_fixed_string_t rss_type;
2032 cmdline_fixed_string_t key; /* optional argument */
2035 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2036 __attribute__((unused)) struct cmdline *cl,
2039 struct cmd_showport_rss_hash *res = parsed_result;
2041 port_rss_hash_conf_show(res->port_id, res->rss_type,
2042 show_rss_key != NULL);
2045 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2046 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2047 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2048 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2049 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2050 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2051 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2052 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2054 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2055 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2056 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2057 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2058 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2059 "ipv6-tcp-ex#ipv6-udp-ex");
2060 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2061 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2063 cmdline_parse_inst_t cmd_showport_rss_hash = {
2064 .f = cmd_showport_rss_hash_parsed,
2067 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2068 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2069 "ipv6-sctp|ipv6-other|l2-payload|"
2070 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2072 (void *)&cmd_showport_rss_hash_show,
2073 (void *)&cmd_showport_rss_hash_port,
2074 (void *)&cmd_showport_rss_hash_port_id,
2075 (void *)&cmd_showport_rss_hash_rss_hash,
2076 (void *)&cmd_showport_rss_hash_rss_hash_info,
2081 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2082 .f = cmd_showport_rss_hash_parsed,
2085 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2086 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2087 "ipv6-sctp|ipv6-other|l2-payload|"
2088 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2090 (void *)&cmd_showport_rss_hash_show,
2091 (void *)&cmd_showport_rss_hash_port,
2092 (void *)&cmd_showport_rss_hash_port_id,
2093 (void *)&cmd_showport_rss_hash_rss_hash,
2094 (void *)&cmd_showport_rss_hash_rss_hash_info,
2095 (void *)&cmd_showport_rss_hash_rss_key,
2100 /* *** Configure DCB *** */
2101 struct cmd_config_dcb {
2102 cmdline_fixed_string_t port;
2103 cmdline_fixed_string_t config;
2105 cmdline_fixed_string_t dcb;
2106 cmdline_fixed_string_t vt;
2107 cmdline_fixed_string_t vt_en;
2109 cmdline_fixed_string_t pfc;
2110 cmdline_fixed_string_t pfc_en;
2114 cmd_config_dcb_parsed(void *parsed_result,
2115 __attribute__((unused)) struct cmdline *cl,
2116 __attribute__((unused)) void *data)
2118 struct cmd_config_dcb *res = parsed_result;
2119 portid_t port_id = res->port_id;
2120 struct rte_port *port;
2124 port = &ports[port_id];
2125 /** Check if the port is not started **/
2126 if (port->port_status != RTE_PORT_STOPPED) {
2127 printf("Please stop port %d first\n", port_id);
2131 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2132 printf("The invalid number of traffic class,"
2133 " only 4 or 8 allowed.\n");
2137 if (nb_fwd_lcores < res->num_tcs) {
2138 printf("nb_cores shouldn't be less than number of TCs.\n");
2141 if (!strncmp(res->pfc_en, "on", 2))
2146 /* DCB in VT mode */
2147 if (!strncmp(res->vt_en, "on", 2))
2148 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2149 (enum rte_eth_nb_tcs)res->num_tcs,
2152 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2153 (enum rte_eth_nb_tcs)res->num_tcs,
2158 printf("Cannot initialize network ports.\n");
2162 cmd_reconfig_device_queue(port_id, 1, 1);
2165 cmdline_parse_token_string_t cmd_config_dcb_port =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2167 cmdline_parse_token_string_t cmd_config_dcb_config =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2169 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2170 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2171 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2173 cmdline_parse_token_string_t cmd_config_dcb_vt =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2175 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2177 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2178 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2179 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2181 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2184 cmdline_parse_inst_t cmd_config_dcb = {
2185 .f = cmd_config_dcb_parsed,
2187 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2189 (void *)&cmd_config_dcb_port,
2190 (void *)&cmd_config_dcb_config,
2191 (void *)&cmd_config_dcb_port_id,
2192 (void *)&cmd_config_dcb_dcb,
2193 (void *)&cmd_config_dcb_vt,
2194 (void *)&cmd_config_dcb_vt_en,
2195 (void *)&cmd_config_dcb_num_tcs,
2196 (void *)&cmd_config_dcb_pfc,
2197 (void *)&cmd_config_dcb_pfc_en,
2202 /* *** configure number of packets per burst *** */
2203 struct cmd_config_burst {
2204 cmdline_fixed_string_t port;
2205 cmdline_fixed_string_t keyword;
2206 cmdline_fixed_string_t all;
2207 cmdline_fixed_string_t name;
2212 cmd_config_burst_parsed(void *parsed_result,
2213 __attribute__((unused)) struct cmdline *cl,
2214 __attribute__((unused)) void *data)
2216 struct cmd_config_burst *res = parsed_result;
2218 if (!all_ports_stopped()) {
2219 printf("Please stop all ports first\n");
2223 if (!strcmp(res->name, "burst")) {
2224 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2225 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2228 nb_pkt_per_burst = res->value;
2230 printf("Unknown parameter\n");
2236 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2239 cmdline_parse_token_string_t cmd_config_burst_port =
2240 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2241 cmdline_parse_token_string_t cmd_config_burst_keyword =
2242 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2243 cmdline_parse_token_string_t cmd_config_burst_all =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2245 cmdline_parse_token_string_t cmd_config_burst_name =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2247 cmdline_parse_token_num_t cmd_config_burst_value =
2248 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2250 cmdline_parse_inst_t cmd_config_burst = {
2251 .f = cmd_config_burst_parsed,
2253 .help_str = "port config all burst value",
2255 (void *)&cmd_config_burst_port,
2256 (void *)&cmd_config_burst_keyword,
2257 (void *)&cmd_config_burst_all,
2258 (void *)&cmd_config_burst_name,
2259 (void *)&cmd_config_burst_value,
2264 /* *** configure rx/tx queues *** */
2265 struct cmd_config_thresh {
2266 cmdline_fixed_string_t port;
2267 cmdline_fixed_string_t keyword;
2268 cmdline_fixed_string_t all;
2269 cmdline_fixed_string_t name;
2274 cmd_config_thresh_parsed(void *parsed_result,
2275 __attribute__((unused)) struct cmdline *cl,
2276 __attribute__((unused)) void *data)
2278 struct cmd_config_thresh *res = parsed_result;
2280 if (!all_ports_stopped()) {
2281 printf("Please stop all ports first\n");
2285 if (!strcmp(res->name, "txpt"))
2286 tx_pthresh = res->value;
2287 else if(!strcmp(res->name, "txht"))
2288 tx_hthresh = res->value;
2289 else if(!strcmp(res->name, "txwt"))
2290 tx_wthresh = res->value;
2291 else if(!strcmp(res->name, "rxpt"))
2292 rx_pthresh = res->value;
2293 else if(!strcmp(res->name, "rxht"))
2294 rx_hthresh = res->value;
2295 else if(!strcmp(res->name, "rxwt"))
2296 rx_wthresh = res->value;
2298 printf("Unknown parameter\n");
2304 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2307 cmdline_parse_token_string_t cmd_config_thresh_port =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2309 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2311 cmdline_parse_token_string_t cmd_config_thresh_all =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2313 cmdline_parse_token_string_t cmd_config_thresh_name =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2315 "txpt#txht#txwt#rxpt#rxht#rxwt");
2316 cmdline_parse_token_num_t cmd_config_thresh_value =
2317 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2319 cmdline_parse_inst_t cmd_config_thresh = {
2320 .f = cmd_config_thresh_parsed,
2322 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2324 (void *)&cmd_config_thresh_port,
2325 (void *)&cmd_config_thresh_keyword,
2326 (void *)&cmd_config_thresh_all,
2327 (void *)&cmd_config_thresh_name,
2328 (void *)&cmd_config_thresh_value,
2333 /* *** configure free/rs threshold *** */
2334 struct cmd_config_threshold {
2335 cmdline_fixed_string_t port;
2336 cmdline_fixed_string_t keyword;
2337 cmdline_fixed_string_t all;
2338 cmdline_fixed_string_t name;
2343 cmd_config_threshold_parsed(void *parsed_result,
2344 __attribute__((unused)) struct cmdline *cl,
2345 __attribute__((unused)) void *data)
2347 struct cmd_config_threshold *res = parsed_result;
2349 if (!all_ports_stopped()) {
2350 printf("Please stop all ports first\n");
2354 if (!strcmp(res->name, "txfreet"))
2355 tx_free_thresh = res->value;
2356 else if (!strcmp(res->name, "txrst"))
2357 tx_rs_thresh = res->value;
2358 else if (!strcmp(res->name, "rxfreet"))
2359 rx_free_thresh = res->value;
2361 printf("Unknown parameter\n");
2367 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2370 cmdline_parse_token_string_t cmd_config_threshold_port =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2372 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2375 cmdline_parse_token_string_t cmd_config_threshold_all =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2377 cmdline_parse_token_string_t cmd_config_threshold_name =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2379 "txfreet#txrst#rxfreet");
2380 cmdline_parse_token_num_t cmd_config_threshold_value =
2381 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2383 cmdline_parse_inst_t cmd_config_threshold = {
2384 .f = cmd_config_threshold_parsed,
2386 .help_str = "port config all txfreet|txrst|rxfreet value",
2388 (void *)&cmd_config_threshold_port,
2389 (void *)&cmd_config_threshold_keyword,
2390 (void *)&cmd_config_threshold_all,
2391 (void *)&cmd_config_threshold_name,
2392 (void *)&cmd_config_threshold_value,
2398 struct cmd_stop_result {
2399 cmdline_fixed_string_t stop;
2402 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2403 __attribute__((unused)) struct cmdline *cl,
2404 __attribute__((unused)) void *data)
2406 stop_packet_forwarding();
2409 cmdline_parse_token_string_t cmd_stop_stop =
2410 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2412 cmdline_parse_inst_t cmd_stop = {
2413 .f = cmd_stop_parsed,
2415 .help_str = "stop - stop packet forwarding",
2417 (void *)&cmd_stop_stop,
2422 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2425 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2426 unsigned int *parsed_items, int check_unique_values)
2428 unsigned int nb_item;
2436 * First parse all items in the list and store their value.
2441 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2443 if ((c >= '0') && (c <= '9')) {
2444 value = (unsigned int) (value * 10 + (c - '0'));
2449 printf("character %c is not a decimal digit\n", c);
2453 printf("No valid value before comma\n");
2456 if (nb_item < max_items) {
2457 parsed_items[nb_item] = value;
2463 if (nb_item >= max_items) {
2464 printf("Number of %s = %u > %u (maximum items)\n",
2465 item_name, nb_item + 1, max_items);
2468 parsed_items[nb_item++] = value;
2469 if (! check_unique_values)
2473 * Then, check that all values in the list are differents.
2474 * No optimization here...
2476 for (i = 0; i < nb_item; i++) {
2477 for (j = i + 1; j < nb_item; j++) {
2478 if (parsed_items[j] == parsed_items[i]) {
2479 printf("duplicated %s %u at index %u and %u\n",
2480 item_name, parsed_items[i], i, j);
2488 struct cmd_set_list_result {
2489 cmdline_fixed_string_t cmd_keyword;
2490 cmdline_fixed_string_t list_name;
2491 cmdline_fixed_string_t list_of_items;
2494 static void cmd_set_list_parsed(void *parsed_result,
2495 __attribute__((unused)) struct cmdline *cl,
2496 __attribute__((unused)) void *data)
2498 struct cmd_set_list_result *res;
2500 unsigned int lcorelist[RTE_MAX_LCORE];
2501 unsigned int portlist[RTE_MAX_ETHPORTS];
2503 unsigned int nb_item;
2505 if (test_done == 0) {
2506 printf("Please stop forwarding first\n");
2510 res = parsed_result;
2511 if (!strcmp(res->list_name, "corelist")) {
2512 nb_item = parse_item_list(res->list_of_items, "core",
2514 parsed_items.lcorelist, 1);
2516 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2519 if (!strcmp(res->list_name, "portlist")) {
2520 nb_item = parse_item_list(res->list_of_items, "port",
2522 parsed_items.portlist, 1);
2524 set_fwd_ports_list(parsed_items.portlist, nb_item);
2528 cmdline_parse_token_string_t cmd_set_list_keyword =
2529 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2531 cmdline_parse_token_string_t cmd_set_list_name =
2532 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2533 "corelist#portlist");
2534 cmdline_parse_token_string_t cmd_set_list_of_items =
2535 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2538 cmdline_parse_inst_t cmd_set_fwd_list = {
2539 .f = cmd_set_list_parsed,
2541 .help_str = "set corelist|portlist x[,y]*",
2543 (void *)&cmd_set_list_keyword,
2544 (void *)&cmd_set_list_name,
2545 (void *)&cmd_set_list_of_items,
2550 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2552 struct cmd_setmask_result {
2553 cmdline_fixed_string_t set;
2554 cmdline_fixed_string_t mask;
2558 static void cmd_set_mask_parsed(void *parsed_result,
2559 __attribute__((unused)) struct cmdline *cl,
2560 __attribute__((unused)) void *data)
2562 struct cmd_setmask_result *res = parsed_result;
2564 if (test_done == 0) {
2565 printf("Please stop forwarding first\n");
2568 if (!strcmp(res->mask, "coremask"))
2569 set_fwd_lcores_mask(res->hexavalue);
2570 else if (!strcmp(res->mask, "portmask"))
2571 set_fwd_ports_mask(res->hexavalue);
2574 cmdline_parse_token_string_t cmd_setmask_set =
2575 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2576 cmdline_parse_token_string_t cmd_setmask_mask =
2577 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2578 "coremask#portmask");
2579 cmdline_parse_token_num_t cmd_setmask_value =
2580 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2582 cmdline_parse_inst_t cmd_set_fwd_mask = {
2583 .f = cmd_set_mask_parsed,
2585 .help_str = "set coremask|portmask hexadecimal value",
2587 (void *)&cmd_setmask_set,
2588 (void *)&cmd_setmask_mask,
2589 (void *)&cmd_setmask_value,
2595 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2597 struct cmd_set_result {
2598 cmdline_fixed_string_t set;
2599 cmdline_fixed_string_t what;
2603 static void cmd_set_parsed(void *parsed_result,
2604 __attribute__((unused)) struct cmdline *cl,
2605 __attribute__((unused)) void *data)
2607 struct cmd_set_result *res = parsed_result;
2608 if (!strcmp(res->what, "nbport"))
2609 set_fwd_ports_number(res->value);
2610 else if (!strcmp(res->what, "nbcore"))
2611 set_fwd_lcores_number(res->value);
2612 else if (!strcmp(res->what, "burst"))
2613 set_nb_pkt_per_burst(res->value);
2614 else if (!strcmp(res->what, "verbose"))
2615 set_verbose_level(res->value);
2618 cmdline_parse_token_string_t cmd_set_set =
2619 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2620 cmdline_parse_token_string_t cmd_set_what =
2621 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2622 "nbport#nbcore#burst#verbose");
2623 cmdline_parse_token_num_t cmd_set_value =
2624 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2626 cmdline_parse_inst_t cmd_set_numbers = {
2627 .f = cmd_set_parsed,
2629 .help_str = "set nbport|nbcore|burst|verbose value",
2631 (void *)&cmd_set_set,
2632 (void *)&cmd_set_what,
2633 (void *)&cmd_set_value,
2638 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2640 struct cmd_set_txpkts_result {
2641 cmdline_fixed_string_t cmd_keyword;
2642 cmdline_fixed_string_t txpkts;
2643 cmdline_fixed_string_t seg_lengths;
2647 cmd_set_txpkts_parsed(void *parsed_result,
2648 __attribute__((unused)) struct cmdline *cl,
2649 __attribute__((unused)) void *data)
2651 struct cmd_set_txpkts_result *res;
2652 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2653 unsigned int nb_segs;
2655 res = parsed_result;
2656 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2657 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2659 set_tx_pkt_segments(seg_lengths, nb_segs);
2662 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2663 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2664 cmd_keyword, "set");
2665 cmdline_parse_token_string_t cmd_set_txpkts_name =
2666 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2668 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2669 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2672 cmdline_parse_inst_t cmd_set_txpkts = {
2673 .f = cmd_set_txpkts_parsed,
2675 .help_str = "set txpkts x[,y]*",
2677 (void *)&cmd_set_txpkts_keyword,
2678 (void *)&cmd_set_txpkts_name,
2679 (void *)&cmd_set_txpkts_lengths,
2684 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2686 struct cmd_set_txsplit_result {
2687 cmdline_fixed_string_t cmd_keyword;
2688 cmdline_fixed_string_t txsplit;
2689 cmdline_fixed_string_t mode;
2693 cmd_set_txsplit_parsed(void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 struct cmd_set_txsplit_result *res;
2699 res = parsed_result;
2700 set_tx_pkt_split(res->mode);
2703 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2704 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2705 cmd_keyword, "set");
2706 cmdline_parse_token_string_t cmd_set_txsplit_name =
2707 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2708 txsplit, "txsplit");
2709 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2710 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2713 cmdline_parse_inst_t cmd_set_txsplit = {
2714 .f = cmd_set_txsplit_parsed,
2716 .help_str = "set txsplit on|off|rand",
2718 (void *)&cmd_set_txsplit_keyword,
2719 (void *)&cmd_set_txsplit_name,
2720 (void *)&cmd_set_txsplit_mode,
2725 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2726 struct cmd_rx_vlan_filter_all_result {
2727 cmdline_fixed_string_t rx_vlan;
2728 cmdline_fixed_string_t what;
2729 cmdline_fixed_string_t all;
2734 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2735 __attribute__((unused)) struct cmdline *cl,
2736 __attribute__((unused)) void *data)
2738 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2740 if (!strcmp(res->what, "add"))
2741 rx_vlan_all_filter_set(res->port_id, 1);
2743 rx_vlan_all_filter_set(res->port_id, 0);
2746 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2747 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2748 rx_vlan, "rx_vlan");
2749 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2750 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2752 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2753 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2755 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2756 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2759 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2760 .f = cmd_rx_vlan_filter_all_parsed,
2762 .help_str = "add/remove all identifiers to/from the set of VLAN "
2763 "Identifiers filtered by a port",
2765 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2766 (void *)&cmd_rx_vlan_filter_all_what,
2767 (void *)&cmd_rx_vlan_filter_all_all,
2768 (void *)&cmd_rx_vlan_filter_all_portid,
2773 /* *** VLAN OFFLOAD SET ON A PORT *** */
2774 struct cmd_vlan_offload_result {
2775 cmdline_fixed_string_t vlan;
2776 cmdline_fixed_string_t set;
2777 cmdline_fixed_string_t vlan_type;
2778 cmdline_fixed_string_t what;
2779 cmdline_fixed_string_t on;
2780 cmdline_fixed_string_t port_id;
2784 cmd_vlan_offload_parsed(void *parsed_result,
2785 __attribute__((unused)) struct cmdline *cl,
2786 __attribute__((unused)) void *data)
2789 struct cmd_vlan_offload_result *res = parsed_result;
2792 portid_t port_id = 0;
2796 len = strnlen(str, STR_TOKEN_SIZE);
2798 /* Get port_id first */
2806 tmp = strtoul(str, NULL, 0);
2807 /* If port_id greater that what portid_t can represent, return */
2808 if(tmp >= RTE_MAX_ETHPORTS)
2810 port_id = (portid_t)tmp;
2812 if (!strcmp(res->on, "on"))
2817 if (!strcmp(res->what, "strip"))
2818 rx_vlan_strip_set(port_id, on);
2819 else if(!strcmp(res->what, "stripq")){
2820 uint16_t queue_id = 0;
2822 /* No queue_id, return */
2824 printf("must specify (port,queue_id)\n");
2827 tmp = strtoul(str + i + 1, NULL, 0);
2828 /* If queue_id greater that what 16-bits can represent, return */
2832 queue_id = (uint16_t)tmp;
2833 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2835 else if (!strcmp(res->what, "filter"))
2836 rx_vlan_filter_set(port_id, on);
2838 vlan_extend_set(port_id, on);
2843 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2844 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2846 cmdline_parse_token_string_t cmd_vlan_offload_set =
2847 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2849 cmdline_parse_token_string_t cmd_vlan_offload_what =
2850 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2851 what, "strip#filter#qinq#stripq");
2852 cmdline_parse_token_string_t cmd_vlan_offload_on =
2853 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2855 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2856 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2859 cmdline_parse_inst_t cmd_vlan_offload = {
2860 .f = cmd_vlan_offload_parsed,
2862 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2863 " qinq(extended) for both rx/tx sides ",
2865 (void *)&cmd_vlan_offload_vlan,
2866 (void *)&cmd_vlan_offload_set,
2867 (void *)&cmd_vlan_offload_what,
2868 (void *)&cmd_vlan_offload_on,
2869 (void *)&cmd_vlan_offload_portid,
2874 /* *** VLAN TPID SET ON A PORT *** */
2875 struct cmd_vlan_tpid_result {
2876 cmdline_fixed_string_t vlan;
2877 cmdline_fixed_string_t set;
2878 cmdline_fixed_string_t vlan_type;
2879 cmdline_fixed_string_t what;
2885 cmd_vlan_tpid_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2889 struct cmd_vlan_tpid_result *res = parsed_result;
2890 enum rte_vlan_type vlan_type;
2892 if (!strcmp(res->vlan_type, "inner"))
2893 vlan_type = ETH_VLAN_TYPE_INNER;
2894 else if (!strcmp(res->vlan_type, "outer"))
2895 vlan_type = ETH_VLAN_TYPE_OUTER;
2897 printf("Unknown vlan type\n");
2900 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
2903 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2904 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2906 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2907 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2909 cmdline_parse_token_string_t cmd_vlan_type =
2910 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2911 vlan_type, "inner#outer");
2912 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2913 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2915 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2916 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2918 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2919 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2922 cmdline_parse_inst_t cmd_vlan_tpid = {
2923 .f = cmd_vlan_tpid_parsed,
2925 .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
2928 (void *)&cmd_vlan_tpid_vlan,
2929 (void *)&cmd_vlan_tpid_set,
2930 (void *)&cmd_vlan_type,
2931 (void *)&cmd_vlan_tpid_what,
2932 (void *)&cmd_vlan_tpid_tpid,
2933 (void *)&cmd_vlan_tpid_portid,
2938 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2939 struct cmd_rx_vlan_filter_result {
2940 cmdline_fixed_string_t rx_vlan;
2941 cmdline_fixed_string_t what;
2947 cmd_rx_vlan_filter_parsed(void *parsed_result,
2948 __attribute__((unused)) struct cmdline *cl,
2949 __attribute__((unused)) void *data)
2951 struct cmd_rx_vlan_filter_result *res = parsed_result;
2953 if (!strcmp(res->what, "add"))
2954 rx_vft_set(res->port_id, res->vlan_id, 1);
2956 rx_vft_set(res->port_id, res->vlan_id, 0);
2959 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2960 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2961 rx_vlan, "rx_vlan");
2962 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2963 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2965 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2966 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2968 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2969 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2972 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2973 .f = cmd_rx_vlan_filter_parsed,
2975 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2976 "Identifiers filtered by a port",
2978 (void *)&cmd_rx_vlan_filter_rx_vlan,
2979 (void *)&cmd_rx_vlan_filter_what,
2980 (void *)&cmd_rx_vlan_filter_vlanid,
2981 (void *)&cmd_rx_vlan_filter_portid,
2986 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2987 struct cmd_tx_vlan_set_result {
2988 cmdline_fixed_string_t tx_vlan;
2989 cmdline_fixed_string_t set;
2995 cmd_tx_vlan_set_parsed(void *parsed_result,
2996 __attribute__((unused)) struct cmdline *cl,
2997 __attribute__((unused)) void *data)
2999 struct cmd_tx_vlan_set_result *res = parsed_result;
3001 tx_vlan_set(res->port_id, res->vlan_id);
3004 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3005 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3006 tx_vlan, "tx_vlan");
3007 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3008 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3010 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3011 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3013 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3014 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3017 cmdline_parse_inst_t cmd_tx_vlan_set = {
3018 .f = cmd_tx_vlan_set_parsed,
3020 .help_str = "enable hardware insertion of a single VLAN header "
3021 "with a given TAG Identifier in packets sent on a port",
3023 (void *)&cmd_tx_vlan_set_tx_vlan,
3024 (void *)&cmd_tx_vlan_set_set,
3025 (void *)&cmd_tx_vlan_set_portid,
3026 (void *)&cmd_tx_vlan_set_vlanid,
3031 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3032 struct cmd_tx_vlan_set_qinq_result {
3033 cmdline_fixed_string_t tx_vlan;
3034 cmdline_fixed_string_t set;
3037 uint16_t vlan_id_outer;
3041 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3042 __attribute__((unused)) struct cmdline *cl,
3043 __attribute__((unused)) void *data)
3045 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3047 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3050 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3051 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3052 tx_vlan, "tx_vlan");
3053 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3054 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3056 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3057 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3059 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3060 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3062 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3063 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3064 vlan_id_outer, UINT16);
3066 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3067 .f = cmd_tx_vlan_set_qinq_parsed,
3069 .help_str = "enable hardware insertion of double VLAN header "
3070 "with given TAG Identifiers in packets sent on a port",
3072 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3073 (void *)&cmd_tx_vlan_set_qinq_set,
3074 (void *)&cmd_tx_vlan_set_qinq_portid,
3075 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3076 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3081 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3082 struct cmd_tx_vlan_set_pvid_result {
3083 cmdline_fixed_string_t tx_vlan;
3084 cmdline_fixed_string_t set;
3085 cmdline_fixed_string_t pvid;
3088 cmdline_fixed_string_t mode;
3092 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3093 __attribute__((unused)) struct cmdline *cl,
3094 __attribute__((unused)) void *data)
3096 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3098 if (strcmp(res->mode, "on") == 0)
3099 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3101 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3104 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3105 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3106 tx_vlan, "tx_vlan");
3107 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3108 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3110 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3111 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3113 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3114 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3116 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3117 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3119 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3120 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3123 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3124 .f = cmd_tx_vlan_set_pvid_parsed,
3126 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3128 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3129 (void *)&cmd_tx_vlan_set_pvid_set,
3130 (void *)&cmd_tx_vlan_set_pvid_pvid,
3131 (void *)&cmd_tx_vlan_set_pvid_port_id,
3132 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3133 (void *)&cmd_tx_vlan_set_pvid_mode,
3138 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3139 struct cmd_tx_vlan_reset_result {
3140 cmdline_fixed_string_t tx_vlan;
3141 cmdline_fixed_string_t reset;
3146 cmd_tx_vlan_reset_parsed(void *parsed_result,
3147 __attribute__((unused)) struct cmdline *cl,
3148 __attribute__((unused)) void *data)
3150 struct cmd_tx_vlan_reset_result *res = parsed_result;
3152 tx_vlan_reset(res->port_id);
3155 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3156 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3157 tx_vlan, "tx_vlan");
3158 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3159 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3161 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3162 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3165 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3166 .f = cmd_tx_vlan_reset_parsed,
3168 .help_str = "disable hardware insertion of a VLAN header in packets "
3171 (void *)&cmd_tx_vlan_reset_tx_vlan,
3172 (void *)&cmd_tx_vlan_reset_reset,
3173 (void *)&cmd_tx_vlan_reset_portid,
3179 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3180 struct cmd_csum_result {
3181 cmdline_fixed_string_t csum;
3182 cmdline_fixed_string_t mode;
3183 cmdline_fixed_string_t proto;
3184 cmdline_fixed_string_t hwsw;
3189 csum_show(int port_id)
3191 struct rte_eth_dev_info dev_info;
3194 ol_flags = ports[port_id].tx_ol_flags;
3195 printf("Parse tunnel is %s\n",
3196 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3197 printf("IP checksum offload is %s\n",
3198 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3199 printf("UDP checksum offload is %s\n",
3200 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3201 printf("TCP checksum offload is %s\n",
3202 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3203 printf("SCTP checksum offload is %s\n",
3204 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3205 printf("Outer-Ip checksum offload is %s\n",
3206 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3208 /* display warnings if configuration is not supported by the NIC */
3209 rte_eth_dev_info_get(port_id, &dev_info);
3210 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3211 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3212 printf("Warning: hardware IP checksum enabled but not "
3213 "supported by port %d\n", port_id);
3215 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3216 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3217 printf("Warning: hardware UDP checksum enabled but not "
3218 "supported by port %d\n", port_id);
3220 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3221 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3222 printf("Warning: hardware TCP checksum enabled but not "
3223 "supported by port %d\n", port_id);
3225 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3226 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3227 printf("Warning: hardware SCTP checksum enabled but not "
3228 "supported by port %d\n", port_id);
3230 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3231 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3232 printf("Warning: hardware outer IP checksum enabled but not "
3233 "supported by port %d\n", port_id);
3238 cmd_csum_parsed(void *parsed_result,
3239 __attribute__((unused)) struct cmdline *cl,
3240 __attribute__((unused)) void *data)
3242 struct cmd_csum_result *res = parsed_result;
3246 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3247 printf("invalid port %d\n", res->port_id);
3251 if (!strcmp(res->mode, "set")) {
3253 if (!strcmp(res->hwsw, "hw"))
3256 if (!strcmp(res->proto, "ip")) {
3257 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3258 } else if (!strcmp(res->proto, "udp")) {
3259 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3260 } else if (!strcmp(res->proto, "tcp")) {
3261 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3262 } else if (!strcmp(res->proto, "sctp")) {
3263 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3264 } else if (!strcmp(res->proto, "outer-ip")) {
3265 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3269 ports[res->port_id].tx_ol_flags |= mask;
3271 ports[res->port_id].tx_ol_flags &= (~mask);
3273 csum_show(res->port_id);
3276 cmdline_parse_token_string_t cmd_csum_csum =
3277 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3279 cmdline_parse_token_string_t cmd_csum_mode =
3280 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3282 cmdline_parse_token_string_t cmd_csum_proto =
3283 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3284 proto, "ip#tcp#udp#sctp#outer-ip");
3285 cmdline_parse_token_string_t cmd_csum_hwsw =
3286 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3288 cmdline_parse_token_num_t cmd_csum_portid =
3289 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3292 cmdline_parse_inst_t cmd_csum_set = {
3293 .f = cmd_csum_parsed,
3295 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3296 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3298 (void *)&cmd_csum_csum,
3299 (void *)&cmd_csum_mode,
3300 (void *)&cmd_csum_proto,
3301 (void *)&cmd_csum_hwsw,
3302 (void *)&cmd_csum_portid,
3307 cmdline_parse_token_string_t cmd_csum_mode_show =
3308 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3311 cmdline_parse_inst_t cmd_csum_show = {
3312 .f = cmd_csum_parsed,
3314 .help_str = "show checksum offload configuration: csum show <port>",
3316 (void *)&cmd_csum_csum,
3317 (void *)&cmd_csum_mode_show,
3318 (void *)&cmd_csum_portid,
3323 /* Enable/disable tunnel parsing */
3324 struct cmd_csum_tunnel_result {
3325 cmdline_fixed_string_t csum;
3326 cmdline_fixed_string_t parse;
3327 cmdline_fixed_string_t onoff;
3332 cmd_csum_tunnel_parsed(void *parsed_result,
3333 __attribute__((unused)) struct cmdline *cl,
3334 __attribute__((unused)) void *data)
3336 struct cmd_csum_tunnel_result *res = parsed_result;
3338 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3341 if (!strcmp(res->onoff, "on"))
3342 ports[res->port_id].tx_ol_flags |=
3343 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3345 ports[res->port_id].tx_ol_flags &=
3346 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3348 csum_show(res->port_id);
3351 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3352 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3354 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3355 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3356 parse, "parse_tunnel");
3357 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3358 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3360 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3361 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3364 cmdline_parse_inst_t cmd_csum_tunnel = {
3365 .f = cmd_csum_tunnel_parsed,
3367 .help_str = "enable/disable parsing of tunnels for csum engine: "
3368 "csum parse_tunnel on|off <tx-port>",
3370 (void *)&cmd_csum_tunnel_csum,
3371 (void *)&cmd_csum_tunnel_parse,
3372 (void *)&cmd_csum_tunnel_onoff,
3373 (void *)&cmd_csum_tunnel_portid,
3378 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3379 struct cmd_tso_set_result {
3380 cmdline_fixed_string_t tso;
3381 cmdline_fixed_string_t mode;
3387 cmd_tso_set_parsed(void *parsed_result,
3388 __attribute__((unused)) struct cmdline *cl,
3389 __attribute__((unused)) void *data)
3391 struct cmd_tso_set_result *res = parsed_result;
3392 struct rte_eth_dev_info dev_info;
3394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3397 if (!strcmp(res->mode, "set"))
3398 ports[res->port_id].tso_segsz = res->tso_segsz;
3400 if (ports[res->port_id].tso_segsz == 0)
3401 printf("TSO is disabled\n");
3403 printf("TSO segment size is %d\n",
3404 ports[res->port_id].tso_segsz);
3406 /* display warnings if configuration is not supported by the NIC */
3407 rte_eth_dev_info_get(res->port_id, &dev_info);
3408 if ((ports[res->port_id].tso_segsz != 0) &&
3409 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3410 printf("Warning: TSO enabled but not "
3411 "supported by port %d\n", res->port_id);
3415 cmdline_parse_token_string_t cmd_tso_set_tso =
3416 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3418 cmdline_parse_token_string_t cmd_tso_set_mode =
3419 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3421 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3422 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3424 cmdline_parse_token_num_t cmd_tso_set_portid =
3425 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3428 cmdline_parse_inst_t cmd_tso_set = {
3429 .f = cmd_tso_set_parsed,
3431 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3432 "tso set <tso_segsz> <port>",
3434 (void *)&cmd_tso_set_tso,
3435 (void *)&cmd_tso_set_mode,
3436 (void *)&cmd_tso_set_tso_segsz,
3437 (void *)&cmd_tso_set_portid,
3442 cmdline_parse_token_string_t cmd_tso_show_mode =
3443 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3447 cmdline_parse_inst_t cmd_tso_show = {
3448 .f = cmd_tso_set_parsed,
3450 .help_str = "Show TSO segment size for csum engine: "
3453 (void *)&cmd_tso_set_tso,
3454 (void *)&cmd_tso_show_mode,
3455 (void *)&cmd_tso_set_portid,
3460 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3461 struct cmd_set_flush_rx {
3462 cmdline_fixed_string_t set;
3463 cmdline_fixed_string_t flush_rx;
3464 cmdline_fixed_string_t mode;
3468 cmd_set_flush_rx_parsed(void *parsed_result,
3469 __attribute__((unused)) struct cmdline *cl,
3470 __attribute__((unused)) void *data)
3472 struct cmd_set_flush_rx *res = parsed_result;
3473 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3476 cmdline_parse_token_string_t cmd_setflushrx_set =
3477 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3479 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3480 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3481 flush_rx, "flush_rx");
3482 cmdline_parse_token_string_t cmd_setflushrx_mode =
3483 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3487 cmdline_parse_inst_t cmd_set_flush_rx = {
3488 .f = cmd_set_flush_rx_parsed,
3489 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3492 (void *)&cmd_setflushrx_set,
3493 (void *)&cmd_setflushrx_flush_rx,
3494 (void *)&cmd_setflushrx_mode,
3499 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3500 struct cmd_set_link_check {
3501 cmdline_fixed_string_t set;
3502 cmdline_fixed_string_t link_check;
3503 cmdline_fixed_string_t mode;
3507 cmd_set_link_check_parsed(void *parsed_result,
3508 __attribute__((unused)) struct cmdline *cl,
3509 __attribute__((unused)) void *data)
3511 struct cmd_set_link_check *res = parsed_result;
3512 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3515 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3516 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3518 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3519 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3520 link_check, "link_check");
3521 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3522 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3526 cmdline_parse_inst_t cmd_set_link_check = {
3527 .f = cmd_set_link_check_parsed,
3528 .help_str = "set link_check on|off: enable/disable link status check "
3529 "when starting/stopping a port",
3532 (void *)&cmd_setlinkcheck_set,
3533 (void *)&cmd_setlinkcheck_link_check,
3534 (void *)&cmd_setlinkcheck_mode,
3539 #ifdef RTE_NIC_BYPASS
3540 /* *** SET NIC BYPASS MODE *** */
3541 struct cmd_set_bypass_mode_result {
3542 cmdline_fixed_string_t set;
3543 cmdline_fixed_string_t bypass;
3544 cmdline_fixed_string_t mode;
3545 cmdline_fixed_string_t value;
3550 cmd_set_bypass_mode_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_set_bypass_mode_result *res = parsed_result;
3555 portid_t port_id = res->port_id;
3556 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3558 if (!bypass_is_supported(port_id))
3561 if (!strcmp(res->value, "bypass"))
3562 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3563 else if (!strcmp(res->value, "isolate"))
3564 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3566 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3568 /* Set the bypass mode for the relevant port. */
3569 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3570 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3574 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3575 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3577 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3578 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3580 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3581 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3583 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3584 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3585 value, "normal#bypass#isolate");
3586 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3587 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3590 cmdline_parse_inst_t cmd_set_bypass_mode = {
3591 .f = cmd_set_bypass_mode_parsed,
3592 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3593 "Set the NIC bypass mode for port_id",
3596 (void *)&cmd_setbypass_mode_set,
3597 (void *)&cmd_setbypass_mode_bypass,
3598 (void *)&cmd_setbypass_mode_mode,
3599 (void *)&cmd_setbypass_mode_value,
3600 (void *)&cmd_setbypass_mode_port,
3605 /* *** SET NIC BYPASS EVENT *** */
3606 struct cmd_set_bypass_event_result {
3607 cmdline_fixed_string_t set;
3608 cmdline_fixed_string_t bypass;
3609 cmdline_fixed_string_t event;
3610 cmdline_fixed_string_t event_value;
3611 cmdline_fixed_string_t mode;
3612 cmdline_fixed_string_t mode_value;
3617 cmd_set_bypass_event_parsed(void *parsed_result,
3618 __attribute__((unused)) struct cmdline *cl,
3619 __attribute__((unused)) void *data)
3622 struct cmd_set_bypass_event_result *res = parsed_result;
3623 portid_t port_id = res->port_id;
3624 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3625 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3627 if (!bypass_is_supported(port_id))
3630 if (!strcmp(res->event_value, "timeout"))
3631 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3632 else if (!strcmp(res->event_value, "os_on"))
3633 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3634 else if (!strcmp(res->event_value, "os_off"))
3635 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3636 else if (!strcmp(res->event_value, "power_on"))
3637 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3638 else if (!strcmp(res->event_value, "power_off"))
3639 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3641 bypass_event = RTE_BYPASS_EVENT_NONE;
3643 if (!strcmp(res->mode_value, "bypass"))
3644 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3645 else if (!strcmp(res->mode_value, "isolate"))
3646 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3648 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3650 /* Set the watchdog timeout. */
3651 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3654 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3655 (rc = rte_eth_dev_wd_timeout_store(port_id,
3656 bypass_timeout)) != 0) {
3657 printf("Failed to set timeout value %u "
3658 "for port %d, errto code: %d.\n",
3659 bypass_timeout, port_id, rc);
3663 /* Set the bypass event to transition to bypass mode. */
3664 if (0 != rte_eth_dev_bypass_event_store(port_id,
3665 bypass_event, bypass_mode)) {
3666 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3671 cmdline_parse_token_string_t cmd_setbypass_event_set =
3672 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3674 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3675 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3677 cmdline_parse_token_string_t cmd_setbypass_event_event =
3678 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3680 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3681 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3682 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3683 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3684 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3686 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3687 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3688 mode_value, "normal#bypass#isolate");
3689 cmdline_parse_token_num_t cmd_setbypass_event_port =
3690 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3693 cmdline_parse_inst_t cmd_set_bypass_event = {
3694 .f = cmd_set_bypass_event_parsed,
3695 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3696 "mode (normal|bypass|isolate) (port_id): "
3697 "Set the NIC bypass event mode for port_id",
3700 (void *)&cmd_setbypass_event_set,
3701 (void *)&cmd_setbypass_event_bypass,
3702 (void *)&cmd_setbypass_event_event,
3703 (void *)&cmd_setbypass_event_event_value,
3704 (void *)&cmd_setbypass_event_mode,
3705 (void *)&cmd_setbypass_event_mode_value,
3706 (void *)&cmd_setbypass_event_port,
3712 /* *** SET NIC BYPASS TIMEOUT *** */
3713 struct cmd_set_bypass_timeout_result {
3714 cmdline_fixed_string_t set;
3715 cmdline_fixed_string_t bypass;
3716 cmdline_fixed_string_t timeout;
3717 cmdline_fixed_string_t value;
3721 cmd_set_bypass_timeout_parsed(void *parsed_result,
3722 __attribute__((unused)) struct cmdline *cl,
3723 __attribute__((unused)) void *data)
3725 struct cmd_set_bypass_timeout_result *res = parsed_result;
3727 if (!strcmp(res->value, "1.5"))
3728 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3729 else if (!strcmp(res->value, "2"))
3730 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3731 else if (!strcmp(res->value, "3"))
3732 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3733 else if (!strcmp(res->value, "4"))
3734 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3735 else if (!strcmp(res->value, "8"))
3736 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3737 else if (!strcmp(res->value, "16"))
3738 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3739 else if (!strcmp(res->value, "32"))
3740 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3742 bypass_timeout = RTE_BYPASS_TMT_OFF;
3745 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3746 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3748 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3751 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3752 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3753 timeout, "timeout");
3754 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3756 value, "0#1.5#2#3#4#8#16#32");
3758 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3759 .f = cmd_set_bypass_timeout_parsed,
3760 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3761 "Set the NIC bypass watchdog timeout",
3764 (void *)&cmd_setbypass_timeout_set,
3765 (void *)&cmd_setbypass_timeout_bypass,
3766 (void *)&cmd_setbypass_timeout_timeout,
3767 (void *)&cmd_setbypass_timeout_value,
3772 /* *** SHOW NIC BYPASS MODE *** */
3773 struct cmd_show_bypass_config_result {
3774 cmdline_fixed_string_t show;
3775 cmdline_fixed_string_t bypass;
3776 cmdline_fixed_string_t config;
3781 cmd_show_bypass_config_parsed(void *parsed_result,
3782 __attribute__((unused)) struct cmdline *cl,
3783 __attribute__((unused)) void *data)
3785 struct cmd_show_bypass_config_result *res = parsed_result;
3786 uint32_t event_mode;
3787 uint32_t bypass_mode;
3788 portid_t port_id = res->port_id;
3789 uint32_t timeout = bypass_timeout;
3792 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3793 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3794 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3795 {"UNKNOWN", "normal", "bypass", "isolate"};
3796 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3803 int num_events = (sizeof events) / (sizeof events[0]);
3805 if (!bypass_is_supported(port_id))
3808 /* Display the bypass mode.*/
3809 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3810 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3814 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3815 bypass_mode = RTE_BYPASS_MODE_NONE;
3817 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3820 /* Display the bypass timeout.*/
3821 if (!RTE_BYPASS_TMT_VALID(timeout))
3822 timeout = RTE_BYPASS_TMT_OFF;
3824 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3826 /* Display the bypass events and associated modes. */
3827 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3829 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3830 printf("\tFailed to get bypass mode for event = %s\n",
3833 if (!RTE_BYPASS_MODE_VALID(event_mode))
3834 event_mode = RTE_BYPASS_MODE_NONE;
3836 printf("\tbypass event: %-16s = %s\n", events[i],
3842 cmdline_parse_token_string_t cmd_showbypass_config_show =
3843 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3845 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3846 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3848 cmdline_parse_token_string_t cmd_showbypass_config_config =
3849 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3851 cmdline_parse_token_num_t cmd_showbypass_config_port =
3852 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3855 cmdline_parse_inst_t cmd_show_bypass_config = {
3856 .f = cmd_show_bypass_config_parsed,
3857 .help_str = "show bypass config (port_id): "
3858 "Show the NIC bypass config for port_id",
3861 (void *)&cmd_showbypass_config_show,
3862 (void *)&cmd_showbypass_config_bypass,
3863 (void *)&cmd_showbypass_config_config,
3864 (void *)&cmd_showbypass_config_port,
3870 #ifdef RTE_LIBRTE_PMD_BOND
3871 /* *** SET BONDING MODE *** */
3872 struct cmd_set_bonding_mode_result {
3873 cmdline_fixed_string_t set;
3874 cmdline_fixed_string_t bonding;
3875 cmdline_fixed_string_t mode;
3880 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3881 __attribute__((unused)) struct cmdline *cl,
3882 __attribute__((unused)) void *data)
3884 struct cmd_set_bonding_mode_result *res = parsed_result;
3885 portid_t port_id = res->port_id;
3887 /* Set the bonding mode for the relevant port. */
3888 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3889 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3892 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3895 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3897 bonding, "bonding");
3898 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3901 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3902 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3904 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3905 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3908 cmdline_parse_inst_t cmd_set_bonding_mode = {
3909 .f = cmd_set_bonding_mode_parsed,
3910 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3913 (void *) &cmd_setbonding_mode_set,
3914 (void *) &cmd_setbonding_mode_bonding,
3915 (void *) &cmd_setbonding_mode_mode,
3916 (void *) &cmd_setbonding_mode_value,
3917 (void *) &cmd_setbonding_mode_port,
3922 /* *** SET BALANCE XMIT POLICY *** */
3923 struct cmd_set_bonding_balance_xmit_policy_result {
3924 cmdline_fixed_string_t set;
3925 cmdline_fixed_string_t bonding;
3926 cmdline_fixed_string_t balance_xmit_policy;
3928 cmdline_fixed_string_t policy;
3931 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3932 __attribute__((unused)) struct cmdline *cl,
3933 __attribute__((unused)) void *data)
3935 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3936 portid_t port_id = res->port_id;
3939 if (!strcmp(res->policy, "l2")) {
3940 policy = BALANCE_XMIT_POLICY_LAYER2;
3941 } else if (!strcmp(res->policy, "l23")) {
3942 policy = BALANCE_XMIT_POLICY_LAYER23;
3943 } else if (!strcmp(res->policy, "l34")) {
3944 policy = BALANCE_XMIT_POLICY_LAYER34;
3946 printf("\t Invalid xmit policy selection");
3950 /* Set the bonding mode for the relevant port. */
3951 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3952 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3957 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3958 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3960 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3962 bonding, "bonding");
3963 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3965 balance_xmit_policy, "balance_xmit_policy");
3966 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3967 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3969 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3970 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3971 policy, "l2#l23#l34");
3973 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3974 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3975 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3978 (void *)&cmd_setbonding_balance_xmit_policy_set,
3979 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3980 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3981 (void *)&cmd_setbonding_balance_xmit_policy_port,
3982 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3987 /* *** SHOW NIC BONDING CONFIGURATION *** */
3988 struct cmd_show_bonding_config_result {
3989 cmdline_fixed_string_t show;
3990 cmdline_fixed_string_t bonding;
3991 cmdline_fixed_string_t config;
3995 static void cmd_show_bonding_config_parsed(void *parsed_result,
3996 __attribute__((unused)) struct cmdline *cl,
3997 __attribute__((unused)) void *data)
3999 struct cmd_show_bonding_config_result *res = parsed_result;
4001 uint8_t slaves[RTE_MAX_ETHPORTS];
4002 int num_slaves, num_active_slaves;
4005 portid_t port_id = res->port_id;
4007 /* Display the bonding mode.*/
4008 bonding_mode = rte_eth_bond_mode_get(port_id);
4009 if (bonding_mode < 0) {
4010 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4013 printf("\tBonding mode: %d\n", bonding_mode);
4015 if (bonding_mode == BONDING_MODE_BALANCE) {
4016 int balance_xmit_policy;
4018 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4019 if (balance_xmit_policy < 0) {
4020 printf("\tFailed to get balance xmit policy for port = %d\n",
4024 printf("\tBalance Xmit Policy: ");
4026 switch (balance_xmit_policy) {
4027 case BALANCE_XMIT_POLICY_LAYER2:
4028 printf("BALANCE_XMIT_POLICY_LAYER2");
4030 case BALANCE_XMIT_POLICY_LAYER23:
4031 printf("BALANCE_XMIT_POLICY_LAYER23");
4033 case BALANCE_XMIT_POLICY_LAYER34:
4034 printf("BALANCE_XMIT_POLICY_LAYER34");
4041 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4043 if (num_slaves < 0) {
4044 printf("\tFailed to get slave list for port = %d\n", port_id);
4047 if (num_slaves > 0) {
4048 printf("\tSlaves (%d): [", num_slaves);
4049 for (i = 0; i < num_slaves - 1; i++)
4050 printf("%d ", slaves[i]);
4052 printf("%d]\n", slaves[num_slaves - 1]);
4054 printf("\tSlaves: []\n");
4058 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4061 if (num_active_slaves < 0) {
4062 printf("\tFailed to get active slave list for port = %d\n", port_id);
4065 if (num_active_slaves > 0) {
4066 printf("\tActive Slaves (%d): [", num_active_slaves);
4067 for (i = 0; i < num_active_slaves - 1; i++)
4068 printf("%d ", slaves[i]);
4070 printf("%d]\n", slaves[num_active_slaves - 1]);
4073 printf("\tActive Slaves: []\n");
4077 primary_id = rte_eth_bond_primary_get(port_id);
4078 if (primary_id < 0) {
4079 printf("\tFailed to get primary slave for port = %d\n", port_id);
4082 printf("\tPrimary: [%d]\n", primary_id);
4086 cmdline_parse_token_string_t cmd_showbonding_config_show =
4087 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4089 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4090 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4091 bonding, "bonding");
4092 cmdline_parse_token_string_t cmd_showbonding_config_config =
4093 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4095 cmdline_parse_token_num_t cmd_showbonding_config_port =
4096 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4099 cmdline_parse_inst_t cmd_show_bonding_config = {
4100 .f = cmd_show_bonding_config_parsed,
4101 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4104 (void *)&cmd_showbonding_config_show,
4105 (void *)&cmd_showbonding_config_bonding,
4106 (void *)&cmd_showbonding_config_config,
4107 (void *)&cmd_showbonding_config_port,
4112 /* *** SET BONDING PRIMARY *** */
4113 struct cmd_set_bonding_primary_result {
4114 cmdline_fixed_string_t set;
4115 cmdline_fixed_string_t bonding;
4116 cmdline_fixed_string_t primary;
4121 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4122 __attribute__((unused)) struct cmdline *cl,
4123 __attribute__((unused)) void *data)
4125 struct cmd_set_bonding_primary_result *res = parsed_result;
4126 portid_t master_port_id = res->port_id;
4127 portid_t slave_port_id = res->slave_id;
4129 /* Set the primary slave for a bonded device. */
4130 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4131 printf("\t Failed to set primary slave for port = %d.\n",
4138 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4139 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4141 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4142 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4143 bonding, "bonding");
4144 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4145 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4146 primary, "primary");
4147 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4148 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4150 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4151 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4154 cmdline_parse_inst_t cmd_set_bonding_primary = {
4155 .f = cmd_set_bonding_primary_parsed,
4156 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4159 (void *)&cmd_setbonding_primary_set,
4160 (void *)&cmd_setbonding_primary_bonding,
4161 (void *)&cmd_setbonding_primary_primary,
4162 (void *)&cmd_setbonding_primary_slave,
4163 (void *)&cmd_setbonding_primary_port,
4168 /* *** ADD SLAVE *** */
4169 struct cmd_add_bonding_slave_result {
4170 cmdline_fixed_string_t add;
4171 cmdline_fixed_string_t bonding;
4172 cmdline_fixed_string_t slave;
4177 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4178 __attribute__((unused)) struct cmdline *cl,
4179 __attribute__((unused)) void *data)
4181 struct cmd_add_bonding_slave_result *res = parsed_result;
4182 portid_t master_port_id = res->port_id;
4183 portid_t slave_port_id = res->slave_id;
4185 /* Set the primary slave for a bonded device. */
4186 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4187 printf("\t Failed to add slave %d to master port = %d.\n",
4188 slave_port_id, master_port_id);
4192 set_port_slave_flag(slave_port_id);
4195 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4196 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4198 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4199 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4200 bonding, "bonding");
4201 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4202 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4204 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4205 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4207 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4208 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4211 cmdline_parse_inst_t cmd_add_bonding_slave = {
4212 .f = cmd_add_bonding_slave_parsed,
4213 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4216 (void *)&cmd_addbonding_slave_add,
4217 (void *)&cmd_addbonding_slave_bonding,
4218 (void *)&cmd_addbonding_slave_slave,
4219 (void *)&cmd_addbonding_slave_slaveid,
4220 (void *)&cmd_addbonding_slave_port,
4225 /* *** REMOVE SLAVE *** */
4226 struct cmd_remove_bonding_slave_result {
4227 cmdline_fixed_string_t remove;
4228 cmdline_fixed_string_t bonding;
4229 cmdline_fixed_string_t slave;
4234 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4235 __attribute__((unused)) struct cmdline *cl,
4236 __attribute__((unused)) void *data)
4238 struct cmd_remove_bonding_slave_result *res = parsed_result;
4239 portid_t master_port_id = res->port_id;
4240 portid_t slave_port_id = res->slave_id;
4242 /* Set the primary slave for a bonded device. */
4243 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4244 printf("\t Failed to remove slave %d from master port = %d.\n",
4245 slave_port_id, master_port_id);
4249 clear_port_slave_flag(slave_port_id);
4252 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4253 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4255 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4256 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4257 bonding, "bonding");
4258 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4259 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4261 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4262 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4264 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4265 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4268 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4269 .f = cmd_remove_bonding_slave_parsed,
4270 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4273 (void *)&cmd_removebonding_slave_remove,
4274 (void *)&cmd_removebonding_slave_bonding,
4275 (void *)&cmd_removebonding_slave_slave,
4276 (void *)&cmd_removebonding_slave_slaveid,
4277 (void *)&cmd_removebonding_slave_port,
4282 /* *** CREATE BONDED DEVICE *** */
4283 struct cmd_create_bonded_device_result {
4284 cmdline_fixed_string_t create;
4285 cmdline_fixed_string_t bonded;
4286 cmdline_fixed_string_t device;
4291 static int bond_dev_num = 0;
4293 static void cmd_create_bonded_device_parsed(void *parsed_result,
4294 __attribute__((unused)) struct cmdline *cl,
4295 __attribute__((unused)) void *data)
4297 struct cmd_create_bonded_device_result *res = parsed_result;
4298 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4301 if (test_done == 0) {
4302 printf("Please stop forwarding first\n");
4306 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4309 /* Create a new bonded device. */
4310 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4312 printf("\t Failed to create bonded device.\n");
4315 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4318 /* Update number of ports */
4319 nb_ports = rte_eth_dev_count();
4320 reconfig(port_id, res->socket);
4321 rte_eth_promiscuous_enable(port_id);
4322 ports[port_id].enabled = 1;
4327 cmdline_parse_token_string_t cmd_createbonded_device_create =
4328 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4330 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4331 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4333 cmdline_parse_token_string_t cmd_createbonded_device_device =
4334 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4336 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4337 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4339 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4340 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4343 cmdline_parse_inst_t cmd_create_bonded_device = {
4344 .f = cmd_create_bonded_device_parsed,
4345 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4348 (void *)&cmd_createbonded_device_create,
4349 (void *)&cmd_createbonded_device_bonded,
4350 (void *)&cmd_createbonded_device_device,
4351 (void *)&cmd_createbonded_device_mode,
4352 (void *)&cmd_createbonded_device_socket,
4357 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4358 struct cmd_set_bond_mac_addr_result {
4359 cmdline_fixed_string_t set;
4360 cmdline_fixed_string_t bonding;
4361 cmdline_fixed_string_t mac_addr;
4363 struct ether_addr address;
4366 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4367 __attribute__((unused)) struct cmdline *cl,
4368 __attribute__((unused)) void *data)
4370 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4373 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4376 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4378 /* check the return value and print it if is < 0 */
4380 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4383 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4384 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4385 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4386 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4388 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4389 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4391 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4392 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4393 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4394 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4396 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4397 .f = cmd_set_bond_mac_addr_parsed,
4399 .help_str = "set bonding mac_addr (port_id) (address): ",
4401 (void *)&cmd_set_bond_mac_addr_set,
4402 (void *)&cmd_set_bond_mac_addr_bonding,
4403 (void *)&cmd_set_bond_mac_addr_mac,
4404 (void *)&cmd_set_bond_mac_addr_portnum,
4405 (void *)&cmd_set_bond_mac_addr_addr,
4411 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4412 struct cmd_set_bond_mon_period_result {
4413 cmdline_fixed_string_t set;
4414 cmdline_fixed_string_t bonding;
4415 cmdline_fixed_string_t mon_period;
4420 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4421 __attribute__((unused)) struct cmdline *cl,
4422 __attribute__((unused)) void *data)
4424 struct cmd_set_bond_mon_period_result *res = parsed_result;
4427 if (res->port_num >= nb_ports) {
4428 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4432 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4434 /* check the return value and print it if is < 0 */
4436 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4439 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4440 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4442 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4443 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4444 bonding, "bonding");
4445 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4446 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4447 mon_period, "mon_period");
4448 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4449 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4451 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4452 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4455 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4456 .f = cmd_set_bond_mon_period_parsed,
4458 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4460 (void *)&cmd_set_bond_mon_period_set,
4461 (void *)&cmd_set_bond_mon_period_bonding,
4462 (void *)&cmd_set_bond_mon_period_mon_period,
4463 (void *)&cmd_set_bond_mon_period_portnum,
4464 (void *)&cmd_set_bond_mon_period_period_ms,
4469 #endif /* RTE_LIBRTE_PMD_BOND */
4471 /* *** SET FORWARDING MODE *** */
4472 struct cmd_set_fwd_mode_result {
4473 cmdline_fixed_string_t set;
4474 cmdline_fixed_string_t fwd;
4475 cmdline_fixed_string_t mode;
4478 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4479 __attribute__((unused)) struct cmdline *cl,
4480 __attribute__((unused)) void *data)
4482 struct cmd_set_fwd_mode_result *res = parsed_result;
4484 set_pkt_forwarding_mode(res->mode);
4487 cmdline_parse_token_string_t cmd_setfwd_set =
4488 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4489 cmdline_parse_token_string_t cmd_setfwd_fwd =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4491 cmdline_parse_token_string_t cmd_setfwd_mode =
4492 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4493 "" /* defined at init */);
4495 cmdline_parse_inst_t cmd_set_fwd_mode = {
4496 .f = cmd_set_fwd_mode_parsed,
4498 .help_str = NULL, /* defined at init */
4500 (void *)&cmd_setfwd_set,
4501 (void *)&cmd_setfwd_fwd,
4502 (void *)&cmd_setfwd_mode,
4507 static void cmd_set_fwd_mode_init(void)
4510 static char token[128];
4511 static char help[256];
4512 cmdline_parse_token_string_t *token_struct;
4514 modes = list_pkt_forwarding_modes();
4515 snprintf(help, sizeof help, "set fwd %s - "
4516 "set packet forwarding mode", modes);
4517 cmd_set_fwd_mode.help_str = help;
4519 /* string token separator is # */
4520 for (c = token; *modes != '\0'; modes++)
4525 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4526 token_struct->string_data.str = token;
4529 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4530 struct cmd_set_burst_tx_retry_result {
4531 cmdline_fixed_string_t set;
4532 cmdline_fixed_string_t burst;
4533 cmdline_fixed_string_t tx;
4534 cmdline_fixed_string_t delay;
4536 cmdline_fixed_string_t retry;
4540 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4541 __attribute__((unused)) struct cmdline *cl,
4542 __attribute__((unused)) void *data)
4544 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4546 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4547 && !strcmp(res->tx, "tx")) {
4548 if (!strcmp(res->delay, "delay"))
4549 burst_tx_delay_time = res->time;
4550 if (!strcmp(res->retry, "retry"))
4551 burst_tx_retry_num = res->retry_num;
4556 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4557 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4558 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4559 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4561 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4562 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4563 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4564 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4565 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4566 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4568 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4569 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4570 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4572 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4573 .f = cmd_set_burst_tx_retry_parsed,
4574 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4576 (void *)&cmd_set_burst_tx_retry_set,
4577 (void *)&cmd_set_burst_tx_retry_burst,
4578 (void *)&cmd_set_burst_tx_retry_tx,
4579 (void *)&cmd_set_burst_tx_retry_delay,
4580 (void *)&cmd_set_burst_tx_retry_time,
4581 (void *)&cmd_set_burst_tx_retry_retry,
4582 (void *)&cmd_set_burst_tx_retry_retry_num,
4587 /* *** SET PROMISC MODE *** */
4588 struct cmd_set_promisc_mode_result {
4589 cmdline_fixed_string_t set;
4590 cmdline_fixed_string_t promisc;
4591 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4592 uint8_t port_num; /* valid if "allports" argument == 0 */
4593 cmdline_fixed_string_t mode;
4596 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4597 __attribute__((unused)) struct cmdline *cl,
4600 struct cmd_set_promisc_mode_result *res = parsed_result;
4604 if (!strcmp(res->mode, "on"))
4611 FOREACH_PORT(i, ports) {
4613 rte_eth_promiscuous_enable(i);
4615 rte_eth_promiscuous_disable(i);
4620 rte_eth_promiscuous_enable(res->port_num);
4622 rte_eth_promiscuous_disable(res->port_num);
4626 cmdline_parse_token_string_t cmd_setpromisc_set =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4628 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4629 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4631 cmdline_parse_token_string_t cmd_setpromisc_portall =
4632 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4634 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4635 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4637 cmdline_parse_token_string_t cmd_setpromisc_mode =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4641 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4642 .f = cmd_set_promisc_mode_parsed,
4644 .help_str = "set promisc all on|off: set promisc mode for all ports",
4646 (void *)&cmd_setpromisc_set,
4647 (void *)&cmd_setpromisc_promisc,
4648 (void *)&cmd_setpromisc_portall,
4649 (void *)&cmd_setpromisc_mode,
4654 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4655 .f = cmd_set_promisc_mode_parsed,
4657 .help_str = "set promisc X on|off: set promisc mode on port X",
4659 (void *)&cmd_setpromisc_set,
4660 (void *)&cmd_setpromisc_promisc,
4661 (void *)&cmd_setpromisc_portnum,
4662 (void *)&cmd_setpromisc_mode,
4667 /* *** SET ALLMULTI MODE *** */
4668 struct cmd_set_allmulti_mode_result {
4669 cmdline_fixed_string_t set;
4670 cmdline_fixed_string_t allmulti;
4671 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4672 uint8_t port_num; /* valid if "allports" argument == 0 */
4673 cmdline_fixed_string_t mode;
4676 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4677 __attribute__((unused)) struct cmdline *cl,
4680 struct cmd_set_allmulti_mode_result *res = parsed_result;
4684 if (!strcmp(res->mode, "on"))
4691 FOREACH_PORT(i, ports) {
4693 rte_eth_allmulticast_enable(i);
4695 rte_eth_allmulticast_disable(i);
4700 rte_eth_allmulticast_enable(res->port_num);
4702 rte_eth_allmulticast_disable(res->port_num);
4706 cmdline_parse_token_string_t cmd_setallmulti_set =
4707 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4708 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4709 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4711 cmdline_parse_token_string_t cmd_setallmulti_portall =
4712 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4714 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4715 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4717 cmdline_parse_token_string_t cmd_setallmulti_mode =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4721 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4722 .f = cmd_set_allmulti_mode_parsed,
4724 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4726 (void *)&cmd_setallmulti_set,
4727 (void *)&cmd_setallmulti_allmulti,
4728 (void *)&cmd_setallmulti_portall,
4729 (void *)&cmd_setallmulti_mode,
4734 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4735 .f = cmd_set_allmulti_mode_parsed,
4737 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4739 (void *)&cmd_setallmulti_set,
4740 (void *)&cmd_setallmulti_allmulti,
4741 (void *)&cmd_setallmulti_portnum,
4742 (void *)&cmd_setallmulti_mode,
4747 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4748 struct cmd_link_flow_ctrl_set_result {
4749 cmdline_fixed_string_t set;
4750 cmdline_fixed_string_t flow_ctrl;
4751 cmdline_fixed_string_t rx;
4752 cmdline_fixed_string_t rx_lfc_mode;
4753 cmdline_fixed_string_t tx;
4754 cmdline_fixed_string_t tx_lfc_mode;
4755 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4756 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4757 cmdline_fixed_string_t autoneg_str;
4758 cmdline_fixed_string_t autoneg;
4759 cmdline_fixed_string_t hw_str;
4760 uint32_t high_water;
4761 cmdline_fixed_string_t lw_str;
4763 cmdline_fixed_string_t pt_str;
4764 uint16_t pause_time;
4765 cmdline_fixed_string_t xon_str;
4770 cmdline_parse_token_string_t cmd_lfc_set_set =
4771 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4773 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4774 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4775 flow_ctrl, "flow_ctrl");
4776 cmdline_parse_token_string_t cmd_lfc_set_rx =
4777 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4779 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4780 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4781 rx_lfc_mode, "on#off");
4782 cmdline_parse_token_string_t cmd_lfc_set_tx =
4783 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4785 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4786 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4787 tx_lfc_mode, "on#off");
4788 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4789 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4790 hw_str, "high_water");
4791 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4792 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4793 high_water, UINT32);
4794 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4795 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4796 lw_str, "low_water");
4797 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4798 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4800 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4801 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4802 pt_str, "pause_time");
4803 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4804 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4805 pause_time, UINT16);
4806 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4807 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4808 xon_str, "send_xon");
4809 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4810 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4812 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4813 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4814 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4815 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4816 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4817 mac_ctrl_frame_fwd_mode, "on#off");
4818 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4819 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4820 autoneg_str, "autoneg");
4821 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4822 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4824 cmdline_parse_token_num_t cmd_lfc_set_portid =
4825 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4828 /* forward declaration */
4830 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4833 cmdline_parse_inst_t cmd_link_flow_control_set = {
4834 .f = cmd_link_flow_ctrl_set_parsed,
4836 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4837 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4838 autoneg on|off port_id",
4840 (void *)&cmd_lfc_set_set,
4841 (void *)&cmd_lfc_set_flow_ctrl,
4842 (void *)&cmd_lfc_set_rx,
4843 (void *)&cmd_lfc_set_rx_mode,
4844 (void *)&cmd_lfc_set_tx,
4845 (void *)&cmd_lfc_set_tx_mode,
4846 (void *)&cmd_lfc_set_high_water,
4847 (void *)&cmd_lfc_set_low_water,
4848 (void *)&cmd_lfc_set_pause_time,
4849 (void *)&cmd_lfc_set_send_xon,
4850 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4851 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4852 (void *)&cmd_lfc_set_autoneg_str,
4853 (void *)&cmd_lfc_set_autoneg,
4854 (void *)&cmd_lfc_set_portid,
4859 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4860 .f = cmd_link_flow_ctrl_set_parsed,
4861 .data = (void *)&cmd_link_flow_control_set_rx,
4862 .help_str = "Change rx flow control parameter: set flow_ctrl "
4863 "rx on|off port_id",
4865 (void *)&cmd_lfc_set_set,
4866 (void *)&cmd_lfc_set_flow_ctrl,
4867 (void *)&cmd_lfc_set_rx,
4868 (void *)&cmd_lfc_set_rx_mode,
4869 (void *)&cmd_lfc_set_portid,
4874 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4875 .f = cmd_link_flow_ctrl_set_parsed,
4876 .data = (void *)&cmd_link_flow_control_set_tx,
4877 .help_str = "Change tx flow control parameter: set flow_ctrl "
4878 "tx on|off port_id",
4880 (void *)&cmd_lfc_set_set,
4881 (void *)&cmd_lfc_set_flow_ctrl,
4882 (void *)&cmd_lfc_set_tx,
4883 (void *)&cmd_lfc_set_tx_mode,
4884 (void *)&cmd_lfc_set_portid,
4889 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4890 .f = cmd_link_flow_ctrl_set_parsed,
4891 .data = (void *)&cmd_link_flow_control_set_hw,
4892 .help_str = "Change high water flow control parameter: set flow_ctrl "
4893 "high_water value port_id",
4895 (void *)&cmd_lfc_set_set,
4896 (void *)&cmd_lfc_set_flow_ctrl,
4897 (void *)&cmd_lfc_set_high_water_str,
4898 (void *)&cmd_lfc_set_high_water,
4899 (void *)&cmd_lfc_set_portid,
4904 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4905 .f = cmd_link_flow_ctrl_set_parsed,
4906 .data = (void *)&cmd_link_flow_control_set_lw,
4907 .help_str = "Change low water flow control parameter: set flow_ctrl "
4908 "low_water value port_id",
4910 (void *)&cmd_lfc_set_set,
4911 (void *)&cmd_lfc_set_flow_ctrl,
4912 (void *)&cmd_lfc_set_low_water_str,
4913 (void *)&cmd_lfc_set_low_water,
4914 (void *)&cmd_lfc_set_portid,
4919 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4920 .f = cmd_link_flow_ctrl_set_parsed,
4921 .data = (void *)&cmd_link_flow_control_set_pt,
4922 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4923 "pause_time value port_id",
4925 (void *)&cmd_lfc_set_set,
4926 (void *)&cmd_lfc_set_flow_ctrl,
4927 (void *)&cmd_lfc_set_pause_time_str,
4928 (void *)&cmd_lfc_set_pause_time,
4929 (void *)&cmd_lfc_set_portid,
4934 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4935 .f = cmd_link_flow_ctrl_set_parsed,
4936 .data = (void *)&cmd_link_flow_control_set_xon,
4937 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4938 "send_xon value port_id",
4940 (void *)&cmd_lfc_set_set,
4941 (void *)&cmd_lfc_set_flow_ctrl,
4942 (void *)&cmd_lfc_set_send_xon_str,
4943 (void *)&cmd_lfc_set_send_xon,
4944 (void *)&cmd_lfc_set_portid,
4949 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4950 .f = cmd_link_flow_ctrl_set_parsed,
4951 .data = (void *)&cmd_link_flow_control_set_macfwd,
4952 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4953 "mac_ctrl_frame_fwd on|off port_id",
4955 (void *)&cmd_lfc_set_set,
4956 (void *)&cmd_lfc_set_flow_ctrl,
4957 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4958 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4959 (void *)&cmd_lfc_set_portid,
4964 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4965 .f = cmd_link_flow_ctrl_set_parsed,
4966 .data = (void *)&cmd_link_flow_control_set_autoneg,
4967 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4968 "autoneg on|off port_id",
4970 (void *)&cmd_lfc_set_set,
4971 (void *)&cmd_lfc_set_flow_ctrl,
4972 (void *)&cmd_lfc_set_autoneg_str,
4973 (void *)&cmd_lfc_set_autoneg,
4974 (void *)&cmd_lfc_set_portid,
4980 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4981 __attribute__((unused)) struct cmdline *cl,
4984 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4985 cmdline_parse_inst_t *cmd = data;
4986 struct rte_eth_fc_conf fc_conf;
4992 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4993 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4994 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4995 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4997 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4998 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5001 /* Partial command line, retrieve current configuration */
5003 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5005 printf("cannot get current flow ctrl parameters, return"
5006 "code = %d\n", ret);
5010 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5011 (fc_conf.mode == RTE_FC_FULL))
5013 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5014 (fc_conf.mode == RTE_FC_FULL))
5018 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5019 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5021 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5022 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5024 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5026 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5027 fc_conf.high_water = res->high_water;
5029 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5030 fc_conf.low_water = res->low_water;
5032 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5033 fc_conf.pause_time = res->pause_time;
5035 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5036 fc_conf.send_xon = res->send_xon;
5038 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5039 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5040 fc_conf.mac_ctrl_frame_fwd = 1;
5042 fc_conf.mac_ctrl_frame_fwd = 0;
5045 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5046 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5048 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5050 printf("bad flow contrl parameter, return code = %d \n", ret);
5053 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5054 struct cmd_priority_flow_ctrl_set_result {
5055 cmdline_fixed_string_t set;
5056 cmdline_fixed_string_t pfc_ctrl;
5057 cmdline_fixed_string_t rx;
5058 cmdline_fixed_string_t rx_pfc_mode;
5059 cmdline_fixed_string_t tx;
5060 cmdline_fixed_string_t tx_pfc_mode;
5061 uint32_t high_water;
5063 uint16_t pause_time;
5069 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5070 __attribute__((unused)) struct cmdline *cl,
5071 __attribute__((unused)) void *data)
5073 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5074 struct rte_eth_pfc_conf pfc_conf;
5075 int rx_fc_enable, tx_fc_enable;
5079 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5080 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5081 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5082 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5084 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5085 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5088 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5089 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5090 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5091 pfc_conf.fc.high_water = res->high_water;
5092 pfc_conf.fc.low_water = res->low_water;
5093 pfc_conf.fc.pause_time = res->pause_time;
5094 pfc_conf.priority = res->priority;
5096 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5098 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5101 cmdline_parse_token_string_t cmd_pfc_set_set =
5102 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5104 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5105 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5106 pfc_ctrl, "pfc_ctrl");
5107 cmdline_parse_token_string_t cmd_pfc_set_rx =
5108 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5110 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5111 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5112 rx_pfc_mode, "on#off");
5113 cmdline_parse_token_string_t cmd_pfc_set_tx =
5114 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5116 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5117 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5118 tx_pfc_mode, "on#off");
5119 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5120 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5121 high_water, UINT32);
5122 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5123 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5125 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5126 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5127 pause_time, UINT16);
5128 cmdline_parse_token_num_t cmd_pfc_set_priority =
5129 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5131 cmdline_parse_token_num_t cmd_pfc_set_portid =
5132 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5135 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5136 .f = cmd_priority_flow_ctrl_set_parsed,
5138 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5139 tx on|off high_water low_water pause_time priority port_id",
5141 (void *)&cmd_pfc_set_set,
5142 (void *)&cmd_pfc_set_flow_ctrl,
5143 (void *)&cmd_pfc_set_rx,
5144 (void *)&cmd_pfc_set_rx_mode,
5145 (void *)&cmd_pfc_set_tx,
5146 (void *)&cmd_pfc_set_tx_mode,
5147 (void *)&cmd_pfc_set_high_water,
5148 (void *)&cmd_pfc_set_low_water,
5149 (void *)&cmd_pfc_set_pause_time,
5150 (void *)&cmd_pfc_set_priority,
5151 (void *)&cmd_pfc_set_portid,
5156 /* *** RESET CONFIGURATION *** */
5157 struct cmd_reset_result {
5158 cmdline_fixed_string_t reset;
5159 cmdline_fixed_string_t def;
5162 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5164 __attribute__((unused)) void *data)
5166 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5167 set_def_fwd_config();
5170 cmdline_parse_token_string_t cmd_reset_set =
5171 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5172 cmdline_parse_token_string_t cmd_reset_def =
5173 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5176 cmdline_parse_inst_t cmd_reset = {
5177 .f = cmd_reset_parsed,
5179 .help_str = "set default: reset default forwarding configuration",
5181 (void *)&cmd_reset_set,
5182 (void *)&cmd_reset_def,
5187 /* *** START FORWARDING *** */
5188 struct cmd_start_result {
5189 cmdline_fixed_string_t start;
5192 cmdline_parse_token_string_t cmd_start_start =
5193 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5195 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5196 __attribute__((unused)) struct cmdline *cl,
5197 __attribute__((unused)) void *data)
5199 start_packet_forwarding(0);
5202 cmdline_parse_inst_t cmd_start = {
5203 .f = cmd_start_parsed,
5205 .help_str = "start packet forwarding",
5207 (void *)&cmd_start_start,
5212 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5213 struct cmd_start_tx_first_result {
5214 cmdline_fixed_string_t start;
5215 cmdline_fixed_string_t tx_first;
5219 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5220 __attribute__((unused)) struct cmdline *cl,
5221 __attribute__((unused)) void *data)
5223 start_packet_forwarding(1);
5226 cmdline_parse_token_string_t cmd_start_tx_first_start =
5227 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5229 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5230 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5231 tx_first, "tx_first");
5233 cmdline_parse_inst_t cmd_start_tx_first = {
5234 .f = cmd_start_tx_first_parsed,
5236 .help_str = "start packet forwarding, after sending 1 burst of packets",
5238 (void *)&cmd_start_tx_first_start,
5239 (void *)&cmd_start_tx_first_tx_first,
5244 /* *** SET LINK UP *** */
5245 struct cmd_set_link_up_result {
5246 cmdline_fixed_string_t set;
5247 cmdline_fixed_string_t link_up;
5248 cmdline_fixed_string_t port;
5252 cmdline_parse_token_string_t cmd_set_link_up_set =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5254 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5257 cmdline_parse_token_string_t cmd_set_link_up_port =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5259 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5260 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5262 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5263 __attribute__((unused)) struct cmdline *cl,
5264 __attribute__((unused)) void *data)
5266 struct cmd_set_link_up_result *res = parsed_result;
5267 dev_set_link_up(res->port_id);
5270 cmdline_parse_inst_t cmd_set_link_up = {
5271 .f = cmd_set_link_up_parsed,
5273 .help_str = "set link-up port (port id)",
5275 (void *)&cmd_set_link_up_set,
5276 (void *)&cmd_set_link_up_link_up,
5277 (void *)&cmd_set_link_up_port,
5278 (void *)&cmd_set_link_up_port_id,
5283 /* *** SET LINK DOWN *** */
5284 struct cmd_set_link_down_result {
5285 cmdline_fixed_string_t set;
5286 cmdline_fixed_string_t link_down;
5287 cmdline_fixed_string_t port;
5291 cmdline_parse_token_string_t cmd_set_link_down_set =
5292 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5293 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5294 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5296 cmdline_parse_token_string_t cmd_set_link_down_port =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5298 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5299 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5301 static void cmd_set_link_down_parsed(
5302 __attribute__((unused)) void *parsed_result,
5303 __attribute__((unused)) struct cmdline *cl,
5304 __attribute__((unused)) void *data)
5306 struct cmd_set_link_down_result *res = parsed_result;
5307 dev_set_link_down(res->port_id);
5310 cmdline_parse_inst_t cmd_set_link_down = {
5311 .f = cmd_set_link_down_parsed,
5313 .help_str = "set link-down port (port id)",
5315 (void *)&cmd_set_link_down_set,
5316 (void *)&cmd_set_link_down_link_down,
5317 (void *)&cmd_set_link_down_port,
5318 (void *)&cmd_set_link_down_port_id,
5323 /* *** SHOW CFG *** */
5324 struct cmd_showcfg_result {
5325 cmdline_fixed_string_t show;
5326 cmdline_fixed_string_t cfg;
5327 cmdline_fixed_string_t what;
5330 static void cmd_showcfg_parsed(void *parsed_result,
5331 __attribute__((unused)) struct cmdline *cl,
5332 __attribute__((unused)) void *data)
5334 struct cmd_showcfg_result *res = parsed_result;
5335 if (!strcmp(res->what, "rxtx"))
5336 rxtx_config_display();
5337 else if (!strcmp(res->what, "cores"))
5338 fwd_lcores_config_display();
5339 else if (!strcmp(res->what, "fwd"))
5340 fwd_config_display();
5341 else if (!strcmp(res->what, "txpkts"))
5342 show_tx_pkt_segments();
5345 cmdline_parse_token_string_t cmd_showcfg_show =
5346 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5347 cmdline_parse_token_string_t cmd_showcfg_port =
5348 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5349 cmdline_parse_token_string_t cmd_showcfg_what =
5350 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5351 "rxtx#cores#fwd#txpkts");
5353 cmdline_parse_inst_t cmd_showcfg = {
5354 .f = cmd_showcfg_parsed,
5356 .help_str = "show config rxtx|cores|fwd|txpkts",
5358 (void *)&cmd_showcfg_show,
5359 (void *)&cmd_showcfg_port,
5360 (void *)&cmd_showcfg_what,
5365 /* *** SHOW ALL PORT INFO *** */
5366 struct cmd_showportall_result {
5367 cmdline_fixed_string_t show;
5368 cmdline_fixed_string_t port;
5369 cmdline_fixed_string_t what;
5370 cmdline_fixed_string_t all;
5373 static void cmd_showportall_parsed(void *parsed_result,
5374 __attribute__((unused)) struct cmdline *cl,
5375 __attribute__((unused)) void *data)
5379 struct cmd_showportall_result *res = parsed_result;
5380 if (!strcmp(res->show, "clear")) {
5381 if (!strcmp(res->what, "stats"))
5382 FOREACH_PORT(i, ports)
5384 else if (!strcmp(res->what, "xstats"))
5385 FOREACH_PORT(i, ports)
5386 nic_xstats_clear(i);
5387 } else if (!strcmp(res->what, "info"))
5388 FOREACH_PORT(i, ports)
5389 port_infos_display(i);
5390 else if (!strcmp(res->what, "stats"))
5391 FOREACH_PORT(i, ports)
5392 nic_stats_display(i);
5393 else if (!strcmp(res->what, "xstats"))
5394 FOREACH_PORT(i, ports)
5395 nic_xstats_display(i);
5396 else if (!strcmp(res->what, "fdir"))
5397 FOREACH_PORT(i, ports)
5399 else if (!strcmp(res->what, "stat_qmap"))
5400 FOREACH_PORT(i, ports)
5401 nic_stats_mapping_display(i);
5402 else if (!strcmp(res->what, "dcb_tc"))
5403 FOREACH_PORT(i, ports)
5404 port_dcb_info_display(i);
5407 cmdline_parse_token_string_t cmd_showportall_show =
5408 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5410 cmdline_parse_token_string_t cmd_showportall_port =
5411 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5412 cmdline_parse_token_string_t cmd_showportall_what =
5413 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5414 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5415 cmdline_parse_token_string_t cmd_showportall_all =
5416 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5417 cmdline_parse_inst_t cmd_showportall = {
5418 .f = cmd_showportall_parsed,
5420 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5422 (void *)&cmd_showportall_show,
5423 (void *)&cmd_showportall_port,
5424 (void *)&cmd_showportall_what,
5425 (void *)&cmd_showportall_all,
5430 /* *** SHOW PORT INFO *** */
5431 struct cmd_showport_result {
5432 cmdline_fixed_string_t show;
5433 cmdline_fixed_string_t port;
5434 cmdline_fixed_string_t what;
5438 static void cmd_showport_parsed(void *parsed_result,
5439 __attribute__((unused)) struct cmdline *cl,
5440 __attribute__((unused)) void *data)
5442 struct cmd_showport_result *res = parsed_result;
5443 if (!strcmp(res->show, "clear")) {
5444 if (!strcmp(res->what, "stats"))
5445 nic_stats_clear(res->portnum);
5446 else if (!strcmp(res->what, "xstats"))
5447 nic_xstats_clear(res->portnum);
5448 } else if (!strcmp(res->what, "info"))
5449 port_infos_display(res->portnum);
5450 else if (!strcmp(res->what, "stats"))
5451 nic_stats_display(res->portnum);
5452 else if (!strcmp(res->what, "xstats"))
5453 nic_xstats_display(res->portnum);
5454 else if (!strcmp(res->what, "fdir"))
5455 fdir_get_infos(res->portnum);
5456 else if (!strcmp(res->what, "stat_qmap"))
5457 nic_stats_mapping_display(res->portnum);
5458 else if (!strcmp(res->what, "dcb_tc"))
5459 port_dcb_info_display(res->portnum);
5462 cmdline_parse_token_string_t cmd_showport_show =
5463 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5465 cmdline_parse_token_string_t cmd_showport_port =
5466 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5467 cmdline_parse_token_string_t cmd_showport_what =
5468 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5469 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5470 cmdline_parse_token_num_t cmd_showport_portnum =
5471 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5473 cmdline_parse_inst_t cmd_showport = {
5474 .f = cmd_showport_parsed,
5476 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5478 (void *)&cmd_showport_show,
5479 (void *)&cmd_showport_port,
5480 (void *)&cmd_showport_what,
5481 (void *)&cmd_showport_portnum,
5486 /* *** SHOW QUEUE INFO *** */
5487 struct cmd_showqueue_result {
5488 cmdline_fixed_string_t show;
5489 cmdline_fixed_string_t type;
5490 cmdline_fixed_string_t what;
5496 cmd_showqueue_parsed(void *parsed_result,
5497 __attribute__((unused)) struct cmdline *cl,
5498 __attribute__((unused)) void *data)
5500 struct cmd_showqueue_result *res = parsed_result;
5502 if (!strcmp(res->type, "rxq"))
5503 rx_queue_infos_display(res->portnum, res->queuenum);
5504 else if (!strcmp(res->type, "txq"))
5505 tx_queue_infos_display(res->portnum, res->queuenum);
5508 cmdline_parse_token_string_t cmd_showqueue_show =
5509 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5510 cmdline_parse_token_string_t cmd_showqueue_type =
5511 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5512 cmdline_parse_token_string_t cmd_showqueue_what =
5513 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5514 cmdline_parse_token_num_t cmd_showqueue_portnum =
5515 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5516 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5517 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5519 cmdline_parse_inst_t cmd_showqueue = {
5520 .f = cmd_showqueue_parsed,
5522 .help_str = "show rxq|txq info <port number> <queue_number>",
5524 (void *)&cmd_showqueue_show,
5525 (void *)&cmd_showqueue_type,
5526 (void *)&cmd_showqueue_what,
5527 (void *)&cmd_showqueue_portnum,
5528 (void *)&cmd_showqueue_queuenum,
5533 /* *** READ PORT REGISTER *** */
5534 struct cmd_read_reg_result {
5535 cmdline_fixed_string_t read;
5536 cmdline_fixed_string_t reg;
5542 cmd_read_reg_parsed(void *parsed_result,
5543 __attribute__((unused)) struct cmdline *cl,
5544 __attribute__((unused)) void *data)
5546 struct cmd_read_reg_result *res = parsed_result;
5547 port_reg_display(res->port_id, res->reg_off);
5550 cmdline_parse_token_string_t cmd_read_reg_read =
5551 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5552 cmdline_parse_token_string_t cmd_read_reg_reg =
5553 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5554 cmdline_parse_token_num_t cmd_read_reg_port_id =
5555 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5556 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5557 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5559 cmdline_parse_inst_t cmd_read_reg = {
5560 .f = cmd_read_reg_parsed,
5562 .help_str = "read reg port_id reg_off",
5564 (void *)&cmd_read_reg_read,
5565 (void *)&cmd_read_reg_reg,
5566 (void *)&cmd_read_reg_port_id,
5567 (void *)&cmd_read_reg_reg_off,
5572 /* *** READ PORT REGISTER BIT FIELD *** */
5573 struct cmd_read_reg_bit_field_result {
5574 cmdline_fixed_string_t read;
5575 cmdline_fixed_string_t regfield;
5583 cmd_read_reg_bit_field_parsed(void *parsed_result,
5584 __attribute__((unused)) struct cmdline *cl,
5585 __attribute__((unused)) void *data)
5587 struct cmd_read_reg_bit_field_result *res = parsed_result;
5588 port_reg_bit_field_display(res->port_id, res->reg_off,
5589 res->bit1_pos, res->bit2_pos);
5592 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5593 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5595 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5596 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5597 regfield, "regfield");
5598 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5599 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5601 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5602 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5604 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5605 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5607 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5611 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5612 .f = cmd_read_reg_bit_field_parsed,
5614 .help_str = "read regfield port_id reg_off bit_x bit_y "
5615 "(read register bit field between bit_x and bit_y included)",
5617 (void *)&cmd_read_reg_bit_field_read,
5618 (void *)&cmd_read_reg_bit_field_regfield,
5619 (void *)&cmd_read_reg_bit_field_port_id,
5620 (void *)&cmd_read_reg_bit_field_reg_off,
5621 (void *)&cmd_read_reg_bit_field_bit1_pos,
5622 (void *)&cmd_read_reg_bit_field_bit2_pos,
5627 /* *** READ PORT REGISTER BIT *** */
5628 struct cmd_read_reg_bit_result {
5629 cmdline_fixed_string_t read;
5630 cmdline_fixed_string_t regbit;
5637 cmd_read_reg_bit_parsed(void *parsed_result,
5638 __attribute__((unused)) struct cmdline *cl,
5639 __attribute__((unused)) void *data)
5641 struct cmd_read_reg_bit_result *res = parsed_result;
5642 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5645 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5646 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5647 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5648 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5650 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5651 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5652 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5653 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5654 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5655 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5657 cmdline_parse_inst_t cmd_read_reg_bit = {
5658 .f = cmd_read_reg_bit_parsed,
5660 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5662 (void *)&cmd_read_reg_bit_read,
5663 (void *)&cmd_read_reg_bit_regbit,
5664 (void *)&cmd_read_reg_bit_port_id,
5665 (void *)&cmd_read_reg_bit_reg_off,
5666 (void *)&cmd_read_reg_bit_bit_pos,
5671 /* *** WRITE PORT REGISTER *** */
5672 struct cmd_write_reg_result {
5673 cmdline_fixed_string_t write;
5674 cmdline_fixed_string_t reg;
5681 cmd_write_reg_parsed(void *parsed_result,
5682 __attribute__((unused)) struct cmdline *cl,
5683 __attribute__((unused)) void *data)
5685 struct cmd_write_reg_result *res = parsed_result;
5686 port_reg_set(res->port_id, res->reg_off, res->value);
5689 cmdline_parse_token_string_t cmd_write_reg_write =
5690 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5691 cmdline_parse_token_string_t cmd_write_reg_reg =
5692 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5693 cmdline_parse_token_num_t cmd_write_reg_port_id =
5694 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5695 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5696 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5697 cmdline_parse_token_num_t cmd_write_reg_value =
5698 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5700 cmdline_parse_inst_t cmd_write_reg = {
5701 .f = cmd_write_reg_parsed,
5703 .help_str = "write reg port_id reg_off reg_value",
5705 (void *)&cmd_write_reg_write,
5706 (void *)&cmd_write_reg_reg,
5707 (void *)&cmd_write_reg_port_id,
5708 (void *)&cmd_write_reg_reg_off,
5709 (void *)&cmd_write_reg_value,
5714 /* *** WRITE PORT REGISTER BIT FIELD *** */
5715 struct cmd_write_reg_bit_field_result {
5716 cmdline_fixed_string_t write;
5717 cmdline_fixed_string_t regfield;
5726 cmd_write_reg_bit_field_parsed(void *parsed_result,
5727 __attribute__((unused)) struct cmdline *cl,
5728 __attribute__((unused)) void *data)
5730 struct cmd_write_reg_bit_field_result *res = parsed_result;
5731 port_reg_bit_field_set(res->port_id, res->reg_off,
5732 res->bit1_pos, res->bit2_pos, res->value);
5735 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5736 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5738 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5739 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5740 regfield, "regfield");
5741 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5742 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5744 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5745 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5747 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5748 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5750 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5753 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5757 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5758 .f = cmd_write_reg_bit_field_parsed,
5760 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5761 "(set register bit field between bit_x and bit_y included)",
5763 (void *)&cmd_write_reg_bit_field_write,
5764 (void *)&cmd_write_reg_bit_field_regfield,
5765 (void *)&cmd_write_reg_bit_field_port_id,
5766 (void *)&cmd_write_reg_bit_field_reg_off,
5767 (void *)&cmd_write_reg_bit_field_bit1_pos,
5768 (void *)&cmd_write_reg_bit_field_bit2_pos,
5769 (void *)&cmd_write_reg_bit_field_value,
5774 /* *** WRITE PORT REGISTER BIT *** */
5775 struct cmd_write_reg_bit_result {
5776 cmdline_fixed_string_t write;
5777 cmdline_fixed_string_t regbit;
5785 cmd_write_reg_bit_parsed(void *parsed_result,
5786 __attribute__((unused)) struct cmdline *cl,
5787 __attribute__((unused)) void *data)
5789 struct cmd_write_reg_bit_result *res = parsed_result;
5790 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5793 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5794 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5796 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5797 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5799 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5800 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5801 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5802 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5803 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5805 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5808 cmdline_parse_inst_t cmd_write_reg_bit = {
5809 .f = cmd_write_reg_bit_parsed,
5811 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5813 (void *)&cmd_write_reg_bit_write,
5814 (void *)&cmd_write_reg_bit_regbit,
5815 (void *)&cmd_write_reg_bit_port_id,
5816 (void *)&cmd_write_reg_bit_reg_off,
5817 (void *)&cmd_write_reg_bit_bit_pos,
5818 (void *)&cmd_write_reg_bit_value,
5823 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5824 struct cmd_read_rxd_txd_result {
5825 cmdline_fixed_string_t read;
5826 cmdline_fixed_string_t rxd_txd;
5833 cmd_read_rxd_txd_parsed(void *parsed_result,
5834 __attribute__((unused)) struct cmdline *cl,
5835 __attribute__((unused)) void *data)
5837 struct cmd_read_rxd_txd_result *res = parsed_result;
5839 if (!strcmp(res->rxd_txd, "rxd"))
5840 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5841 else if (!strcmp(res->rxd_txd, "txd"))
5842 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5845 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5846 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5847 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5848 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5850 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5851 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5852 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5853 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5854 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5855 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5857 cmdline_parse_inst_t cmd_read_rxd_txd = {
5858 .f = cmd_read_rxd_txd_parsed,
5860 .help_str = "read rxd|txd port_id queue_id rxd_id",
5862 (void *)&cmd_read_rxd_txd_read,
5863 (void *)&cmd_read_rxd_txd_rxd_txd,
5864 (void *)&cmd_read_rxd_txd_port_id,
5865 (void *)&cmd_read_rxd_txd_queue_id,
5866 (void *)&cmd_read_rxd_txd_desc_id,
5872 struct cmd_quit_result {
5873 cmdline_fixed_string_t quit;
5876 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5878 __attribute__((unused)) void *data)
5884 cmdline_parse_token_string_t cmd_quit_quit =
5885 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5887 cmdline_parse_inst_t cmd_quit = {
5888 .f = cmd_quit_parsed,
5890 .help_str = "exit application",
5892 (void *)&cmd_quit_quit,
5897 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5898 struct cmd_mac_addr_result {
5899 cmdline_fixed_string_t mac_addr_cmd;
5900 cmdline_fixed_string_t what;
5902 struct ether_addr address;
5905 static void cmd_mac_addr_parsed(void *parsed_result,
5906 __attribute__((unused)) struct cmdline *cl,
5907 __attribute__((unused)) void *data)
5909 struct cmd_mac_addr_result *res = parsed_result;
5912 if (strcmp(res->what, "add") == 0)
5913 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5915 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5917 /* check the return value and print it if is < 0 */
5919 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5923 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5924 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5926 cmdline_parse_token_string_t cmd_mac_addr_what =
5927 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5929 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5930 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5931 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5932 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5934 cmdline_parse_inst_t cmd_mac_addr = {
5935 .f = cmd_mac_addr_parsed,
5937 .help_str = "mac_addr add|remove X <address>: "
5938 "add/remove MAC address on port X",
5940 (void *)&cmd_mac_addr_cmd,
5941 (void *)&cmd_mac_addr_what,
5942 (void *)&cmd_mac_addr_portnum,
5943 (void *)&cmd_mac_addr_addr,
5949 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5950 struct cmd_set_qmap_result {
5951 cmdline_fixed_string_t set;
5952 cmdline_fixed_string_t qmap;
5953 cmdline_fixed_string_t what;
5960 cmd_set_qmap_parsed(void *parsed_result,
5961 __attribute__((unused)) struct cmdline *cl,
5962 __attribute__((unused)) void *data)
5964 struct cmd_set_qmap_result *res = parsed_result;
5965 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5967 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5970 cmdline_parse_token_string_t cmd_setqmap_set =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5973 cmdline_parse_token_string_t cmd_setqmap_qmap =
5974 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5976 cmdline_parse_token_string_t cmd_setqmap_what =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5979 cmdline_parse_token_num_t cmd_setqmap_portid =
5980 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5982 cmdline_parse_token_num_t cmd_setqmap_queueid =
5983 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5985 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5986 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5989 cmdline_parse_inst_t cmd_set_qmap = {
5990 .f = cmd_set_qmap_parsed,
5992 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5994 (void *)&cmd_setqmap_set,
5995 (void *)&cmd_setqmap_qmap,
5996 (void *)&cmd_setqmap_what,
5997 (void *)&cmd_setqmap_portid,
5998 (void *)&cmd_setqmap_queueid,
5999 (void *)&cmd_setqmap_mapvalue,
6004 /* *** CONFIGURE UNICAST HASH TABLE *** */
6005 struct cmd_set_uc_hash_table {
6006 cmdline_fixed_string_t set;
6007 cmdline_fixed_string_t port;
6009 cmdline_fixed_string_t what;
6010 struct ether_addr address;
6011 cmdline_fixed_string_t mode;
6015 cmd_set_uc_hash_parsed(void *parsed_result,
6016 __attribute__((unused)) struct cmdline *cl,
6017 __attribute__((unused)) void *data)
6020 struct cmd_set_uc_hash_table *res = parsed_result;
6022 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6024 if (strcmp(res->what, "uta") == 0)
6025 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6026 &res->address,(uint8_t)is_on);
6028 printf("bad unicast hash table parameter, return code = %d \n", ret);
6032 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6035 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6036 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6038 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6039 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6041 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6042 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6044 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6045 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6047 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6048 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6051 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6052 .f = cmd_set_uc_hash_parsed,
6054 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6056 (void *)&cmd_set_uc_hash_set,
6057 (void *)&cmd_set_uc_hash_port,
6058 (void *)&cmd_set_uc_hash_portid,
6059 (void *)&cmd_set_uc_hash_what,
6060 (void *)&cmd_set_uc_hash_mac,
6061 (void *)&cmd_set_uc_hash_mode,
6066 struct cmd_set_uc_all_hash_table {
6067 cmdline_fixed_string_t set;
6068 cmdline_fixed_string_t port;
6070 cmdline_fixed_string_t what;
6071 cmdline_fixed_string_t value;
6072 cmdline_fixed_string_t mode;
6076 cmd_set_uc_all_hash_parsed(void *parsed_result,
6077 __attribute__((unused)) struct cmdline *cl,
6078 __attribute__((unused)) void *data)
6081 struct cmd_set_uc_all_hash_table *res = parsed_result;
6083 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6085 if ((strcmp(res->what, "uta") == 0) &&
6086 (strcmp(res->value, "all") == 0))
6087 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6089 printf("bad unicast hash table parameter,"
6090 "return code = %d \n", ret);
6093 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6094 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6096 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6097 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6099 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6100 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6102 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6103 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6105 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6106 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6108 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6112 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6113 .f = cmd_set_uc_all_hash_parsed,
6115 .help_str = "set port X uta all on|off (X = port number)",
6117 (void *)&cmd_set_uc_all_hash_set,
6118 (void *)&cmd_set_uc_all_hash_port,
6119 (void *)&cmd_set_uc_all_hash_portid,
6120 (void *)&cmd_set_uc_all_hash_what,
6121 (void *)&cmd_set_uc_all_hash_value,
6122 (void *)&cmd_set_uc_all_hash_mode,
6127 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6128 struct cmd_set_vf_macvlan_filter {
6129 cmdline_fixed_string_t set;
6130 cmdline_fixed_string_t port;
6132 cmdline_fixed_string_t vf;
6134 struct ether_addr address;
6135 cmdline_fixed_string_t filter_type;
6136 cmdline_fixed_string_t mode;
6140 cmd_set_vf_macvlan_parsed(void *parsed_result,
6141 __attribute__((unused)) struct cmdline *cl,
6142 __attribute__((unused)) void *data)
6145 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6146 struct rte_eth_mac_filter filter;
6148 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6150 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6152 /* set VF MAC filter */
6156 filter.dst_id = res->vf_id;
6158 if (!strcmp(res->filter_type, "exact-mac"))
6159 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6160 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6161 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6162 else if (!strcmp(res->filter_type, "hashmac"))
6163 filter.filter_type = RTE_MAC_HASH_MATCH;
6164 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6165 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6167 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6170 ret = rte_eth_dev_filter_ctrl(res->port_id,
6171 RTE_ETH_FILTER_MACVLAN,
6175 ret = rte_eth_dev_filter_ctrl(res->port_id,
6176 RTE_ETH_FILTER_MACVLAN,
6177 RTE_ETH_FILTER_DELETE,
6181 printf("bad set MAC hash parameter, return code = %d\n", ret);
6185 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6186 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6188 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6189 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6191 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6192 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6194 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6195 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6197 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6198 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6200 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6201 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6203 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6204 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6205 filter_type, "exact-mac#exact-mac-vlan"
6206 "#hashmac#hashmac-vlan");
6207 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6211 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6212 .f = cmd_set_vf_macvlan_parsed,
6214 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6215 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6217 "exact match rule:exact match of MAC or MAC and VLAN; "
6218 "hash match rule: hash match of MAC and exact match "
6221 (void *)&cmd_set_vf_macvlan_set,
6222 (void *)&cmd_set_vf_macvlan_port,
6223 (void *)&cmd_set_vf_macvlan_portid,
6224 (void *)&cmd_set_vf_macvlan_vf,
6225 (void *)&cmd_set_vf_macvlan_vf_id,
6226 (void *)&cmd_set_vf_macvlan_mac,
6227 (void *)&cmd_set_vf_macvlan_filter_type,
6228 (void *)&cmd_set_vf_macvlan_mode,
6233 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6234 struct cmd_set_vf_traffic {
6235 cmdline_fixed_string_t set;
6236 cmdline_fixed_string_t port;
6238 cmdline_fixed_string_t vf;
6240 cmdline_fixed_string_t what;
6241 cmdline_fixed_string_t mode;
6245 cmd_set_vf_traffic_parsed(void *parsed_result,
6246 __attribute__((unused)) struct cmdline *cl,
6247 __attribute__((unused)) void *data)
6249 struct cmd_set_vf_traffic *res = parsed_result;
6250 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6251 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6253 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6256 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6257 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6259 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6260 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6262 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6263 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6265 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6268 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6269 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6271 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6274 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6278 cmdline_parse_inst_t cmd_set_vf_traffic = {
6279 .f = cmd_set_vf_traffic_parsed,
6281 .help_str = "set port X vf Y rx|tx on|off"
6282 "(X = port number,Y = vf id)",
6284 (void *)&cmd_setvf_traffic_set,
6285 (void *)&cmd_setvf_traffic_port,
6286 (void *)&cmd_setvf_traffic_portid,
6287 (void *)&cmd_setvf_traffic_vf,
6288 (void *)&cmd_setvf_traffic_vfid,
6289 (void *)&cmd_setvf_traffic_what,
6290 (void *)&cmd_setvf_traffic_mode,
6295 /* *** CONFIGURE VF RECEIVE MODE *** */
6296 struct cmd_set_vf_rxmode {
6297 cmdline_fixed_string_t set;
6298 cmdline_fixed_string_t port;
6300 cmdline_fixed_string_t vf;
6302 cmdline_fixed_string_t what;
6303 cmdline_fixed_string_t mode;
6304 cmdline_fixed_string_t on;
6308 cmd_set_vf_rxmode_parsed(void *parsed_result,
6309 __attribute__((unused)) struct cmdline *cl,
6310 __attribute__((unused)) void *data)
6313 uint16_t rx_mode = 0;
6314 struct cmd_set_vf_rxmode *res = parsed_result;
6316 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6317 if (!strcmp(res->what,"rxmode")) {
6318 if (!strcmp(res->mode, "AUPE"))
6319 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6320 else if (!strcmp(res->mode, "ROPE"))
6321 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6322 else if (!strcmp(res->mode, "BAM"))
6323 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6324 else if (!strncmp(res->mode, "MPE",3))
6325 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6328 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6330 printf("bad VF receive mode parameter, return code = %d \n",
6334 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6337 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6338 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6340 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6341 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6343 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6346 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6347 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6349 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6352 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6354 mode, "AUPE#ROPE#BAM#MPE");
6355 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6356 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6359 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6360 .f = cmd_set_vf_rxmode_parsed,
6362 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6364 (void *)&cmd_set_vf_rxmode_set,
6365 (void *)&cmd_set_vf_rxmode_port,
6366 (void *)&cmd_set_vf_rxmode_portid,
6367 (void *)&cmd_set_vf_rxmode_vf,
6368 (void *)&cmd_set_vf_rxmode_vfid,
6369 (void *)&cmd_set_vf_rxmode_what,
6370 (void *)&cmd_set_vf_rxmode_mode,
6371 (void *)&cmd_set_vf_rxmode_on,
6376 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6377 struct cmd_vf_mac_addr_result {
6378 cmdline_fixed_string_t mac_addr_cmd;
6379 cmdline_fixed_string_t what;
6380 cmdline_fixed_string_t port;
6382 cmdline_fixed_string_t vf;
6384 struct ether_addr address;
6387 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6388 __attribute__((unused)) struct cmdline *cl,
6389 __attribute__((unused)) void *data)
6391 struct cmd_vf_mac_addr_result *res = parsed_result;
6394 if (strcmp(res->what, "add") == 0)
6395 ret = rte_eth_dev_mac_addr_add(res->port_num,
6396 &res->address, res->vf_num);
6398 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6402 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6403 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6404 mac_addr_cmd,"mac_addr");
6405 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6406 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6408 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6409 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6411 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6412 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6414 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6415 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6417 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6418 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6420 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6421 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6424 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6425 .f = cmd_vf_mac_addr_parsed,
6427 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6428 "Y = VF number)add MAC address filtering for a VF on port X",
6430 (void *)&cmd_vf_mac_addr_cmd,
6431 (void *)&cmd_vf_mac_addr_what,
6432 (void *)&cmd_vf_mac_addr_port,
6433 (void *)&cmd_vf_mac_addr_portnum,
6434 (void *)&cmd_vf_mac_addr_vf,
6435 (void *)&cmd_vf_mac_addr_vfnum,
6436 (void *)&cmd_vf_mac_addr_addr,
6441 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6442 struct cmd_vf_rx_vlan_filter {
6443 cmdline_fixed_string_t rx_vlan;
6444 cmdline_fixed_string_t what;
6446 cmdline_fixed_string_t port;
6448 cmdline_fixed_string_t vf;
6453 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6454 __attribute__((unused)) struct cmdline *cl,
6455 __attribute__((unused)) void *data)
6457 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6459 if (!strcmp(res->what, "add"))
6460 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6462 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6465 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6466 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6467 rx_vlan, "rx_vlan");
6468 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6469 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6471 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6472 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6474 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6475 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6477 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6478 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6480 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6481 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6483 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6484 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6487 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6488 .f = cmd_vf_rx_vlan_filter_parsed,
6490 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6491 "Y = port number,Z = hexadecimal VF mask)",
6493 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6494 (void *)&cmd_vf_rx_vlan_filter_what,
6495 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6496 (void *)&cmd_vf_rx_vlan_filter_port,
6497 (void *)&cmd_vf_rx_vlan_filter_portid,
6498 (void *)&cmd_vf_rx_vlan_filter_vf,
6499 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6504 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6505 struct cmd_queue_rate_limit_result {
6506 cmdline_fixed_string_t set;
6507 cmdline_fixed_string_t port;
6509 cmdline_fixed_string_t queue;
6511 cmdline_fixed_string_t rate;
6515 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6516 __attribute__((unused)) struct cmdline *cl,
6517 __attribute__((unused)) void *data)
6519 struct cmd_queue_rate_limit_result *res = parsed_result;
6522 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6523 && (strcmp(res->queue, "queue") == 0)
6524 && (strcmp(res->rate, "rate") == 0))
6525 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6528 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6532 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6533 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6535 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6536 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6538 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6539 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6541 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6542 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6544 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6545 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6547 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6548 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6550 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6551 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6554 cmdline_parse_inst_t cmd_queue_rate_limit = {
6555 .f = cmd_queue_rate_limit_parsed,
6557 .help_str = "set port X queue Y rate Z:(X = port number,"
6558 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6560 (void *)&cmd_queue_rate_limit_set,
6561 (void *)&cmd_queue_rate_limit_port,
6562 (void *)&cmd_queue_rate_limit_portnum,
6563 (void *)&cmd_queue_rate_limit_queue,
6564 (void *)&cmd_queue_rate_limit_queuenum,
6565 (void *)&cmd_queue_rate_limit_rate,
6566 (void *)&cmd_queue_rate_limit_ratenum,
6571 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6572 struct cmd_vf_rate_limit_result {
6573 cmdline_fixed_string_t set;
6574 cmdline_fixed_string_t port;
6576 cmdline_fixed_string_t vf;
6578 cmdline_fixed_string_t rate;
6580 cmdline_fixed_string_t q_msk;
6584 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6585 __attribute__((unused)) struct cmdline *cl,
6586 __attribute__((unused)) void *data)
6588 struct cmd_vf_rate_limit_result *res = parsed_result;
6591 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6592 && (strcmp(res->vf, "vf") == 0)
6593 && (strcmp(res->rate, "rate") == 0)
6594 && (strcmp(res->q_msk, "queue_mask") == 0))
6595 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6596 res->rate_num, res->q_msk_val);
6598 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6602 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6603 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6605 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6606 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6608 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6609 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6611 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6612 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6614 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6615 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6617 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6618 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6620 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6621 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6623 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6624 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6625 q_msk, "queue_mask");
6626 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6627 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6630 cmdline_parse_inst_t cmd_vf_rate_limit = {
6631 .f = cmd_vf_rate_limit_parsed,
6633 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6634 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6635 "for queues of VF on port X",
6637 (void *)&cmd_vf_rate_limit_set,
6638 (void *)&cmd_vf_rate_limit_port,
6639 (void *)&cmd_vf_rate_limit_portnum,
6640 (void *)&cmd_vf_rate_limit_vf,
6641 (void *)&cmd_vf_rate_limit_vfnum,
6642 (void *)&cmd_vf_rate_limit_rate,
6643 (void *)&cmd_vf_rate_limit_ratenum,
6644 (void *)&cmd_vf_rate_limit_q_msk,
6645 (void *)&cmd_vf_rate_limit_q_msk_val,
6650 /* *** ADD TUNNEL FILTER OF A PORT *** */
6651 struct cmd_tunnel_filter_result {
6652 cmdline_fixed_string_t cmd;
6653 cmdline_fixed_string_t what;
6655 struct ether_addr outer_mac;
6656 struct ether_addr inner_mac;
6657 cmdline_ipaddr_t ip_value;
6658 uint16_t inner_vlan;
6659 cmdline_fixed_string_t tunnel_type;
6660 cmdline_fixed_string_t filter_type;
6666 cmd_tunnel_filter_parsed(void *parsed_result,
6667 __attribute__((unused)) struct cmdline *cl,
6668 __attribute__((unused)) void *data)
6670 struct cmd_tunnel_filter_result *res = parsed_result;
6671 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6674 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
6676 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
6677 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
6678 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6680 if (res->ip_value.family == AF_INET) {
6681 tunnel_filter_conf.ip_addr.ipv4_addr =
6682 rte_be_to_cpu_32(res->ip_value.addr.ipv4.s_addr);
6683 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6686 for (i = 0; i < 4; i++) {
6687 tunnel_filter_conf.ip_addr.ipv6_addr[i] =
6688 rte_be_to_cpu_32(res->ip_value.addr.ipv6.s6_addr32[i]);
6690 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6693 if (!strcmp(res->filter_type, "imac-ivlan"))
6694 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6695 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6696 tunnel_filter_conf.filter_type =
6697 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6698 else if (!strcmp(res->filter_type, "imac-tenid"))
6699 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6700 else if (!strcmp(res->filter_type, "imac"))
6701 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6702 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6703 tunnel_filter_conf.filter_type =
6704 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6705 else if (!strcmp(res->filter_type, "oip"))
6706 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
6707 else if (!strcmp(res->filter_type, "iip"))
6708 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
6710 printf("The filter type is not supported");
6714 if (!strcmp(res->tunnel_type, "vxlan"))
6715 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6716 else if (!strcmp(res->tunnel_type, "nvgre"))
6717 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6718 else if (!strcmp(res->tunnel_type, "ipingre"))
6719 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
6721 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6725 tunnel_filter_conf.tenant_id = res->tenant_id;
6726 tunnel_filter_conf.queue_id = res->queue_num;
6727 if (!strcmp(res->what, "add"))
6728 ret = rte_eth_dev_filter_ctrl(res->port_id,
6729 RTE_ETH_FILTER_TUNNEL,
6731 &tunnel_filter_conf);
6733 ret = rte_eth_dev_filter_ctrl(res->port_id,
6734 RTE_ETH_FILTER_TUNNEL,
6735 RTE_ETH_FILTER_DELETE,
6736 &tunnel_filter_conf);
6738 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6742 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6743 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6744 cmd, "tunnel_filter");
6745 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6746 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6748 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6749 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6751 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6752 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6754 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6757 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6758 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6759 inner_vlan, UINT16);
6760 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6761 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6763 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6764 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6765 tunnel_type, "vxlan#nvgre#ipingre");
6767 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6768 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6769 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6770 "imac#omac-imac-tenid");
6771 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6772 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6774 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6775 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6778 cmdline_parse_inst_t cmd_tunnel_filter = {
6779 .f = cmd_tunnel_filter_parsed,
6781 .help_str = "add/rm tunnel filter of a port: "
6782 "tunnel_filter add port_id outer_mac inner_mac ip "
6783 "inner_vlan tunnel_type(vxlan|nvgre|ipingre) filter_type "
6784 "(oip|iip|imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6785 "imac|omac-imac-tenid) "
6786 "tenant_id queue_num",
6788 (void *)&cmd_tunnel_filter_cmd,
6789 (void *)&cmd_tunnel_filter_what,
6790 (void *)&cmd_tunnel_filter_port_id,
6791 (void *)&cmd_tunnel_filter_outer_mac,
6792 (void *)&cmd_tunnel_filter_inner_mac,
6793 (void *)&cmd_tunnel_filter_ip_value,
6794 (void *)&cmd_tunnel_filter_innner_vlan,
6795 (void *)&cmd_tunnel_filter_tunnel_type,
6796 (void *)&cmd_tunnel_filter_filter_type,
6797 (void *)&cmd_tunnel_filter_tenant_id,
6798 (void *)&cmd_tunnel_filter_queue_num,
6803 /* *** CONFIGURE TUNNEL UDP PORT *** */
6804 struct cmd_tunnel_udp_config {
6805 cmdline_fixed_string_t cmd;
6806 cmdline_fixed_string_t what;
6812 cmd_tunnel_udp_config_parsed(void *parsed_result,
6813 __attribute__((unused)) struct cmdline *cl,
6814 __attribute__((unused)) void *data)
6816 struct cmd_tunnel_udp_config *res = parsed_result;
6817 struct rte_eth_udp_tunnel tunnel_udp;
6820 tunnel_udp.udp_port = res->udp_port;
6822 if (!strcmp(res->cmd, "rx_vxlan_port"))
6823 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6825 if (!strcmp(res->what, "add"))
6826 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
6829 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
6833 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6836 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6837 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6838 cmd, "rx_vxlan_port");
6839 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6840 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6842 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6843 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6845 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6846 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6849 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6850 .f = cmd_tunnel_udp_config_parsed,
6852 .help_str = "add/rm an tunneling UDP port filter: "
6853 "rx_vxlan_port add udp_port port_id",
6855 (void *)&cmd_tunnel_udp_config_cmd,
6856 (void *)&cmd_tunnel_udp_config_what,
6857 (void *)&cmd_tunnel_udp_config_udp_port,
6858 (void *)&cmd_tunnel_udp_config_port_id,
6863 /* *** GLOBAL CONFIG *** */
6864 struct cmd_global_config_result {
6865 cmdline_fixed_string_t cmd;
6867 cmdline_fixed_string_t cfg_type;
6872 cmd_global_config_parsed(void *parsed_result,
6873 __attribute__((unused)) struct cmdline *cl,
6874 __attribute__((unused)) void *data)
6876 struct cmd_global_config_result *res = parsed_result;
6877 struct rte_eth_global_cfg conf;
6880 memset(&conf, 0, sizeof(conf));
6881 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6882 conf.cfg.gre_key_len = res->len;
6883 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6884 RTE_ETH_FILTER_SET, &conf);
6886 printf("Global config error\n");
6889 cmdline_parse_token_string_t cmd_global_config_cmd =
6890 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6892 cmdline_parse_token_num_t cmd_global_config_port_id =
6893 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6894 cmdline_parse_token_string_t cmd_global_config_type =
6895 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6896 cfg_type, "gre-key-len");
6897 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6898 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6901 cmdline_parse_inst_t cmd_global_config = {
6902 .f = cmd_global_config_parsed,
6903 .data = (void *)NULL,
6904 .help_str = "global_config <port_id> gre-key-len <number>",
6906 (void *)&cmd_global_config_cmd,
6907 (void *)&cmd_global_config_port_id,
6908 (void *)&cmd_global_config_type,
6909 (void *)&cmd_global_config_gre_key_len,
6914 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6915 struct cmd_set_mirror_mask_result {
6916 cmdline_fixed_string_t set;
6917 cmdline_fixed_string_t port;
6919 cmdline_fixed_string_t mirror;
6921 cmdline_fixed_string_t what;
6922 cmdline_fixed_string_t value;
6923 cmdline_fixed_string_t dstpool;
6925 cmdline_fixed_string_t on;
6928 cmdline_parse_token_string_t cmd_mirror_mask_set =
6929 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6931 cmdline_parse_token_string_t cmd_mirror_mask_port =
6932 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6934 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6935 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6937 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6939 mirror, "mirror-rule");
6940 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6941 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6943 cmdline_parse_token_string_t cmd_mirror_mask_what =
6944 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6945 what, "pool-mirror-up#pool-mirror-down"
6947 cmdline_parse_token_string_t cmd_mirror_mask_value =
6948 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6950 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6952 dstpool, "dst-pool");
6953 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6954 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6956 cmdline_parse_token_string_t cmd_mirror_mask_on =
6957 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6961 cmd_set_mirror_mask_parsed(void *parsed_result,
6962 __attribute__((unused)) struct cmdline *cl,
6963 __attribute__((unused)) void *data)
6966 struct cmd_set_mirror_mask_result *res = parsed_result;
6967 struct rte_eth_mirror_conf mr_conf;
6969 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6971 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6973 mr_conf.dst_pool = res->dstpool_id;
6975 if (!strcmp(res->what, "pool-mirror-up")) {
6976 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6977 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6978 } else if (!strcmp(res->what, "pool-mirror-down")) {
6979 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6980 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6981 } else if (!strcmp(res->what, "vlan-mirror")) {
6982 mr_conf.rule_type = ETH_MIRROR_VLAN;
6983 nb_item = parse_item_list(res->value, "vlan",
6984 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6988 for (i = 0; i < nb_item; i++) {
6989 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6990 printf("Invalid vlan_id: must be < 4096\n");
6994 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6995 mr_conf.vlan.vlan_mask |= 1ULL << i;
6999 if (!strcmp(res->on, "on"))
7000 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7003 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7006 printf("mirror rule add error: (%s)\n", strerror(-ret));
7009 cmdline_parse_inst_t cmd_set_mirror_mask = {
7010 .f = cmd_set_mirror_mask_parsed,
7012 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
7013 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
7015 (void *)&cmd_mirror_mask_set,
7016 (void *)&cmd_mirror_mask_port,
7017 (void *)&cmd_mirror_mask_portid,
7018 (void *)&cmd_mirror_mask_mirror,
7019 (void *)&cmd_mirror_mask_ruleid,
7020 (void *)&cmd_mirror_mask_what,
7021 (void *)&cmd_mirror_mask_value,
7022 (void *)&cmd_mirror_mask_dstpool,
7023 (void *)&cmd_mirror_mask_poolid,
7024 (void *)&cmd_mirror_mask_on,
7029 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
7030 struct cmd_set_mirror_link_result {
7031 cmdline_fixed_string_t set;
7032 cmdline_fixed_string_t port;
7034 cmdline_fixed_string_t mirror;
7036 cmdline_fixed_string_t what;
7037 cmdline_fixed_string_t dstpool;
7039 cmdline_fixed_string_t on;
7042 cmdline_parse_token_string_t cmd_mirror_link_set =
7043 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7045 cmdline_parse_token_string_t cmd_mirror_link_port =
7046 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7048 cmdline_parse_token_num_t cmd_mirror_link_portid =
7049 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7051 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7052 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7053 mirror, "mirror-rule");
7054 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7055 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7057 cmdline_parse_token_string_t cmd_mirror_link_what =
7058 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7059 what, "uplink-mirror#downlink-mirror");
7060 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7061 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7062 dstpool, "dst-pool");
7063 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7064 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7066 cmdline_parse_token_string_t cmd_mirror_link_on =
7067 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7071 cmd_set_mirror_link_parsed(void *parsed_result,
7072 __attribute__((unused)) struct cmdline *cl,
7073 __attribute__((unused)) void *data)
7076 struct cmd_set_mirror_link_result *res = parsed_result;
7077 struct rte_eth_mirror_conf mr_conf;
7079 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7080 if (!strcmp(res->what, "uplink-mirror"))
7081 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7083 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7085 mr_conf.dst_pool = res->dstpool_id;
7087 if (!strcmp(res->on, "on"))
7088 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7091 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7094 /* check the return value and print it if is < 0 */
7096 printf("mirror rule add error: (%s)\n", strerror(-ret));
7100 cmdline_parse_inst_t cmd_set_mirror_link = {
7101 .f = cmd_set_mirror_link_parsed,
7103 .help_str = "set port X mirror-rule Y uplink-mirror|"
7104 "downlink-mirror dst-pool Z on|off",
7106 (void *)&cmd_mirror_link_set,
7107 (void *)&cmd_mirror_link_port,
7108 (void *)&cmd_mirror_link_portid,
7109 (void *)&cmd_mirror_link_mirror,
7110 (void *)&cmd_mirror_link_ruleid,
7111 (void *)&cmd_mirror_link_what,
7112 (void *)&cmd_mirror_link_dstpool,
7113 (void *)&cmd_mirror_link_poolid,
7114 (void *)&cmd_mirror_link_on,
7119 /* *** RESET VM MIRROR RULE *** */
7120 struct cmd_rm_mirror_rule_result {
7121 cmdline_fixed_string_t reset;
7122 cmdline_fixed_string_t port;
7124 cmdline_fixed_string_t mirror;
7128 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7129 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7131 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7132 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7134 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7135 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7137 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7138 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7139 mirror, "mirror-rule");
7140 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7141 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7145 cmd_reset_mirror_rule_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;
7152 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7154 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7157 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7158 .f = cmd_reset_mirror_rule_parsed,
7160 .help_str = "reset port X mirror-rule Y",
7162 (void *)&cmd_rm_mirror_rule_reset,
7163 (void *)&cmd_rm_mirror_rule_port,
7164 (void *)&cmd_rm_mirror_rule_portid,
7165 (void *)&cmd_rm_mirror_rule_mirror,
7166 (void *)&cmd_rm_mirror_rule_ruleid,
7171 /* ******************************************************************************** */
7173 struct cmd_dump_result {
7174 cmdline_fixed_string_t dump;
7178 dump_struct_sizes(void)
7180 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7181 DUMP_SIZE(struct rte_mbuf);
7182 DUMP_SIZE(struct rte_mempool);
7183 DUMP_SIZE(struct rte_ring);
7187 static void cmd_dump_parsed(void *parsed_result,
7188 __attribute__((unused)) struct cmdline *cl,
7189 __attribute__((unused)) void *data)
7191 struct cmd_dump_result *res = parsed_result;
7193 if (!strcmp(res->dump, "dump_physmem"))
7194 rte_dump_physmem_layout(stdout);
7195 else if (!strcmp(res->dump, "dump_memzone"))
7196 rte_memzone_dump(stdout);
7197 else if (!strcmp(res->dump, "dump_log_history"))
7198 rte_log_dump_history(stdout);
7199 else if (!strcmp(res->dump, "dump_struct_sizes"))
7200 dump_struct_sizes();
7201 else if (!strcmp(res->dump, "dump_ring"))
7202 rte_ring_list_dump(stdout);
7203 else if (!strcmp(res->dump, "dump_mempool"))
7204 rte_mempool_list_dump(stdout);
7205 else if (!strcmp(res->dump, "dump_devargs"))
7206 rte_eal_devargs_dump(stdout);
7209 cmdline_parse_token_string_t cmd_dump_dump =
7210 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7214 "dump_struct_sizes#"
7219 cmdline_parse_inst_t cmd_dump = {
7220 .f = cmd_dump_parsed, /* function to call */
7221 .data = NULL, /* 2nd arg of func */
7222 .help_str = "dump status",
7223 .tokens = { /* token list, NULL terminated */
7224 (void *)&cmd_dump_dump,
7229 /* ******************************************************************************** */
7231 struct cmd_dump_one_result {
7232 cmdline_fixed_string_t dump;
7233 cmdline_fixed_string_t name;
7236 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7237 __attribute__((unused)) void *data)
7239 struct cmd_dump_one_result *res = parsed_result;
7241 if (!strcmp(res->dump, "dump_ring")) {
7243 r = rte_ring_lookup(res->name);
7245 cmdline_printf(cl, "Cannot find ring\n");
7248 rte_ring_dump(stdout, r);
7249 } else if (!strcmp(res->dump, "dump_mempool")) {
7250 struct rte_mempool *mp;
7251 mp = rte_mempool_lookup(res->name);
7253 cmdline_printf(cl, "Cannot find mempool\n");
7256 rte_mempool_dump(stdout, mp);
7260 cmdline_parse_token_string_t cmd_dump_one_dump =
7261 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7262 "dump_ring#dump_mempool");
7264 cmdline_parse_token_string_t cmd_dump_one_name =
7265 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7267 cmdline_parse_inst_t cmd_dump_one = {
7268 .f = cmd_dump_one_parsed, /* function to call */
7269 .data = NULL, /* 2nd arg of func */
7270 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7271 .tokens = { /* token list, NULL terminated */
7272 (void *)&cmd_dump_one_dump,
7273 (void *)&cmd_dump_one_name,
7278 /* *** Add/Del syn filter *** */
7279 struct cmd_syn_filter_result {
7280 cmdline_fixed_string_t filter;
7282 cmdline_fixed_string_t ops;
7283 cmdline_fixed_string_t priority;
7284 cmdline_fixed_string_t high;
7285 cmdline_fixed_string_t queue;
7290 cmd_syn_filter_parsed(void *parsed_result,
7291 __attribute__((unused)) struct cmdline *cl,
7292 __attribute__((unused)) void *data)
7294 struct cmd_syn_filter_result *res = parsed_result;
7295 struct rte_eth_syn_filter syn_filter;
7298 ret = rte_eth_dev_filter_supported(res->port_id,
7299 RTE_ETH_FILTER_SYN);
7301 printf("syn filter is not supported on port %u.\n",
7306 memset(&syn_filter, 0, sizeof(syn_filter));
7308 if (!strcmp(res->ops, "add")) {
7309 if (!strcmp(res->high, "high"))
7310 syn_filter.hig_pri = 1;
7312 syn_filter.hig_pri = 0;
7314 syn_filter.queue = res->queue_id;
7315 ret = rte_eth_dev_filter_ctrl(res->port_id,
7320 ret = rte_eth_dev_filter_ctrl(res->port_id,
7322 RTE_ETH_FILTER_DELETE,
7326 printf("syn filter programming error: (%s)\n",
7330 cmdline_parse_token_string_t cmd_syn_filter_filter =
7331 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7332 filter, "syn_filter");
7333 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7334 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7336 cmdline_parse_token_string_t cmd_syn_filter_ops =
7337 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7339 cmdline_parse_token_string_t cmd_syn_filter_priority =
7340 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7341 priority, "priority");
7342 cmdline_parse_token_string_t cmd_syn_filter_high =
7343 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7345 cmdline_parse_token_string_t cmd_syn_filter_queue =
7346 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7348 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7349 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7352 cmdline_parse_inst_t cmd_syn_filter = {
7353 .f = cmd_syn_filter_parsed,
7355 .help_str = "add/delete syn filter",
7357 (void *)&cmd_syn_filter_filter,
7358 (void *)&cmd_syn_filter_port_id,
7359 (void *)&cmd_syn_filter_ops,
7360 (void *)&cmd_syn_filter_priority,
7361 (void *)&cmd_syn_filter_high,
7362 (void *)&cmd_syn_filter_queue,
7363 (void *)&cmd_syn_filter_queue_id,
7368 /* *** ADD/REMOVE A 2tuple FILTER *** */
7369 struct cmd_2tuple_filter_result {
7370 cmdline_fixed_string_t filter;
7372 cmdline_fixed_string_t ops;
7373 cmdline_fixed_string_t dst_port;
7374 uint16_t dst_port_value;
7375 cmdline_fixed_string_t protocol;
7376 uint8_t protocol_value;
7377 cmdline_fixed_string_t mask;
7379 cmdline_fixed_string_t tcp_flags;
7380 uint8_t tcp_flags_value;
7381 cmdline_fixed_string_t priority;
7382 uint8_t priority_value;
7383 cmdline_fixed_string_t queue;
7388 cmd_2tuple_filter_parsed(void *parsed_result,
7389 __attribute__((unused)) struct cmdline *cl,
7390 __attribute__((unused)) void *data)
7392 struct rte_eth_ntuple_filter filter;
7393 struct cmd_2tuple_filter_result *res = parsed_result;
7396 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7398 printf("ntuple filter is not supported on port %u.\n",
7403 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7405 filter.flags = RTE_2TUPLE_FLAGS;
7406 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7407 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7408 filter.proto = res->protocol_value;
7409 filter.priority = res->priority_value;
7410 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7411 printf("nonzero tcp_flags is only meaningful"
7412 " when protocol is TCP.\n");
7415 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7416 printf("invalid TCP flags.\n");
7420 if (res->tcp_flags_value != 0) {
7421 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7422 filter.tcp_flags = res->tcp_flags_value;
7425 /* need convert to big endian. */
7426 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7427 filter.queue = res->queue_id;
7429 if (!strcmp(res->ops, "add"))
7430 ret = rte_eth_dev_filter_ctrl(res->port_id,
7431 RTE_ETH_FILTER_NTUPLE,
7435 ret = rte_eth_dev_filter_ctrl(res->port_id,
7436 RTE_ETH_FILTER_NTUPLE,
7437 RTE_ETH_FILTER_DELETE,
7440 printf("2tuple filter programming error: (%s)\n",
7445 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7446 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7447 filter, "2tuple_filter");
7448 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7449 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7451 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7452 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7454 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7455 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7456 dst_port, "dst_port");
7457 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7458 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7459 dst_port_value, UINT16);
7460 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7461 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7462 protocol, "protocol");
7463 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7464 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7465 protocol_value, UINT8);
7466 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7467 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7469 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7470 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7472 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7473 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7474 tcp_flags, "tcp_flags");
7475 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7476 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7477 tcp_flags_value, UINT8);
7478 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7479 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7480 priority, "priority");
7481 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7482 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7483 priority_value, UINT8);
7484 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7485 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7487 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7488 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7491 cmdline_parse_inst_t cmd_2tuple_filter = {
7492 .f = cmd_2tuple_filter_parsed,
7494 .help_str = "add a 2tuple filter",
7496 (void *)&cmd_2tuple_filter_filter,
7497 (void *)&cmd_2tuple_filter_port_id,
7498 (void *)&cmd_2tuple_filter_ops,
7499 (void *)&cmd_2tuple_filter_dst_port,
7500 (void *)&cmd_2tuple_filter_dst_port_value,
7501 (void *)&cmd_2tuple_filter_protocol,
7502 (void *)&cmd_2tuple_filter_protocol_value,
7503 (void *)&cmd_2tuple_filter_mask,
7504 (void *)&cmd_2tuple_filter_mask_value,
7505 (void *)&cmd_2tuple_filter_tcp_flags,
7506 (void *)&cmd_2tuple_filter_tcp_flags_value,
7507 (void *)&cmd_2tuple_filter_priority,
7508 (void *)&cmd_2tuple_filter_priority_value,
7509 (void *)&cmd_2tuple_filter_queue,
7510 (void *)&cmd_2tuple_filter_queue_id,
7515 /* *** ADD/REMOVE A 5tuple FILTER *** */
7516 struct cmd_5tuple_filter_result {
7517 cmdline_fixed_string_t filter;
7519 cmdline_fixed_string_t ops;
7520 cmdline_fixed_string_t dst_ip;
7521 cmdline_ipaddr_t dst_ip_value;
7522 cmdline_fixed_string_t src_ip;
7523 cmdline_ipaddr_t src_ip_value;
7524 cmdline_fixed_string_t dst_port;
7525 uint16_t dst_port_value;
7526 cmdline_fixed_string_t src_port;
7527 uint16_t src_port_value;
7528 cmdline_fixed_string_t protocol;
7529 uint8_t protocol_value;
7530 cmdline_fixed_string_t mask;
7532 cmdline_fixed_string_t tcp_flags;
7533 uint8_t tcp_flags_value;
7534 cmdline_fixed_string_t priority;
7535 uint8_t priority_value;
7536 cmdline_fixed_string_t queue;
7541 cmd_5tuple_filter_parsed(void *parsed_result,
7542 __attribute__((unused)) struct cmdline *cl,
7543 __attribute__((unused)) void *data)
7545 struct rte_eth_ntuple_filter filter;
7546 struct cmd_5tuple_filter_result *res = parsed_result;
7549 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7551 printf("ntuple filter is not supported on port %u.\n",
7556 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7558 filter.flags = RTE_5TUPLE_FLAGS;
7559 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7560 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7561 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7562 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7563 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7564 filter.proto = res->protocol_value;
7565 filter.priority = res->priority_value;
7566 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7567 printf("nonzero tcp_flags is only meaningful"
7568 " when protocol is TCP.\n");
7571 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7572 printf("invalid TCP flags.\n");
7576 if (res->tcp_flags_value != 0) {
7577 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7578 filter.tcp_flags = res->tcp_flags_value;
7581 if (res->dst_ip_value.family == AF_INET)
7582 /* no need to convert, already big endian. */
7583 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7585 if (filter.dst_ip_mask == 0) {
7586 printf("can not support ipv6 involved compare.\n");
7592 if (res->src_ip_value.family == AF_INET)
7593 /* no need to convert, already big endian. */
7594 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7596 if (filter.src_ip_mask == 0) {
7597 printf("can not support ipv6 involved compare.\n");
7602 /* need convert to big endian. */
7603 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7604 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7605 filter.queue = res->queue_id;
7607 if (!strcmp(res->ops, "add"))
7608 ret = rte_eth_dev_filter_ctrl(res->port_id,
7609 RTE_ETH_FILTER_NTUPLE,
7613 ret = rte_eth_dev_filter_ctrl(res->port_id,
7614 RTE_ETH_FILTER_NTUPLE,
7615 RTE_ETH_FILTER_DELETE,
7618 printf("5tuple filter programming error: (%s)\n",
7622 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7623 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7624 filter, "5tuple_filter");
7625 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7626 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7628 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7629 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7631 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7632 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7634 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7635 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7637 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7638 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7640 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7641 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7643 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7644 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7645 dst_port, "dst_port");
7646 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7647 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7648 dst_port_value, UINT16);
7649 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7650 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7651 src_port, "src_port");
7652 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7653 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7654 src_port_value, UINT16);
7655 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7656 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7657 protocol, "protocol");
7658 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7659 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7660 protocol_value, UINT8);
7661 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7662 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7664 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7665 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7667 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7668 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7669 tcp_flags, "tcp_flags");
7670 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7671 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7672 tcp_flags_value, UINT8);
7673 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7674 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7675 priority, "priority");
7676 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7677 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7678 priority_value, UINT8);
7679 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7680 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7682 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7683 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7686 cmdline_parse_inst_t cmd_5tuple_filter = {
7687 .f = cmd_5tuple_filter_parsed,
7689 .help_str = "add/del a 5tuple filter",
7691 (void *)&cmd_5tuple_filter_filter,
7692 (void *)&cmd_5tuple_filter_port_id,
7693 (void *)&cmd_5tuple_filter_ops,
7694 (void *)&cmd_5tuple_filter_dst_ip,
7695 (void *)&cmd_5tuple_filter_dst_ip_value,
7696 (void *)&cmd_5tuple_filter_src_ip,
7697 (void *)&cmd_5tuple_filter_src_ip_value,
7698 (void *)&cmd_5tuple_filter_dst_port,
7699 (void *)&cmd_5tuple_filter_dst_port_value,
7700 (void *)&cmd_5tuple_filter_src_port,
7701 (void *)&cmd_5tuple_filter_src_port_value,
7702 (void *)&cmd_5tuple_filter_protocol,
7703 (void *)&cmd_5tuple_filter_protocol_value,
7704 (void *)&cmd_5tuple_filter_mask,
7705 (void *)&cmd_5tuple_filter_mask_value,
7706 (void *)&cmd_5tuple_filter_tcp_flags,
7707 (void *)&cmd_5tuple_filter_tcp_flags_value,
7708 (void *)&cmd_5tuple_filter_priority,
7709 (void *)&cmd_5tuple_filter_priority_value,
7710 (void *)&cmd_5tuple_filter_queue,
7711 (void *)&cmd_5tuple_filter_queue_id,
7716 /* *** ADD/REMOVE A flex FILTER *** */
7717 struct cmd_flex_filter_result {
7718 cmdline_fixed_string_t filter;
7719 cmdline_fixed_string_t ops;
7721 cmdline_fixed_string_t len;
7723 cmdline_fixed_string_t bytes;
7724 cmdline_fixed_string_t bytes_value;
7725 cmdline_fixed_string_t mask;
7726 cmdline_fixed_string_t mask_value;
7727 cmdline_fixed_string_t priority;
7728 uint8_t priority_value;
7729 cmdline_fixed_string_t queue;
7733 static int xdigit2val(unsigned char c)
7738 else if (isupper(c))
7746 cmd_flex_filter_parsed(void *parsed_result,
7747 __attribute__((unused)) struct cmdline *cl,
7748 __attribute__((unused)) void *data)
7751 struct rte_eth_flex_filter filter;
7752 struct cmd_flex_filter_result *res = parsed_result;
7753 char *bytes_ptr, *mask_ptr;
7754 uint16_t len, i, j = 0;
7759 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7760 printf("the len exceed the max length 128\n");
7763 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7764 filter.len = res->len_value;
7765 filter.priority = res->priority_value;
7766 filter.queue = res->queue_id;
7767 bytes_ptr = res->bytes_value;
7768 mask_ptr = res->mask_value;
7770 /* translate bytes string to array. */
7771 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7772 (bytes_ptr[1] == 'X')))
7774 len = strnlen(bytes_ptr, res->len_value * 2);
7775 if (len == 0 || (len % 8 != 0)) {
7776 printf("please check len and bytes input\n");
7779 for (i = 0; i < len; i++) {
7781 if (isxdigit(c) == 0) {
7782 /* invalid characters. */
7783 printf("invalid input\n");
7786 val = xdigit2val(c);
7789 filter.bytes[j] = byte;
7790 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7797 /* translate mask string to uint8_t array. */
7798 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7799 (mask_ptr[1] == 'X')))
7801 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7803 printf("invalid input\n");
7808 for (i = 0; i < len; i++) {
7810 if (isxdigit(c) == 0) {
7811 /* invalid characters. */
7812 printf("invalid input\n");
7815 val = xdigit2val(c);
7818 filter.mask[j] = byte;
7819 printf("mask[%d]:%02x ", j, filter.mask[j]);
7827 if (!strcmp(res->ops, "add"))
7828 ret = rte_eth_dev_filter_ctrl(res->port_id,
7829 RTE_ETH_FILTER_FLEXIBLE,
7833 ret = rte_eth_dev_filter_ctrl(res->port_id,
7834 RTE_ETH_FILTER_FLEXIBLE,
7835 RTE_ETH_FILTER_DELETE,
7839 printf("flex filter setting error: (%s)\n", strerror(-ret));
7842 cmdline_parse_token_string_t cmd_flex_filter_filter =
7843 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7844 filter, "flex_filter");
7845 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7846 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7848 cmdline_parse_token_string_t cmd_flex_filter_ops =
7849 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7851 cmdline_parse_token_string_t cmd_flex_filter_len =
7852 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7854 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7855 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7857 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7858 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7860 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7861 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7863 cmdline_parse_token_string_t cmd_flex_filter_mask =
7864 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7866 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7867 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7869 cmdline_parse_token_string_t cmd_flex_filter_priority =
7870 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7871 priority, "priority");
7872 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7873 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7874 priority_value, UINT8);
7875 cmdline_parse_token_string_t cmd_flex_filter_queue =
7876 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7878 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7879 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7881 cmdline_parse_inst_t cmd_flex_filter = {
7882 .f = cmd_flex_filter_parsed,
7884 .help_str = "add/del a flex filter",
7886 (void *)&cmd_flex_filter_filter,
7887 (void *)&cmd_flex_filter_port_id,
7888 (void *)&cmd_flex_filter_ops,
7889 (void *)&cmd_flex_filter_len,
7890 (void *)&cmd_flex_filter_len_value,
7891 (void *)&cmd_flex_filter_bytes,
7892 (void *)&cmd_flex_filter_bytes_value,
7893 (void *)&cmd_flex_filter_mask,
7894 (void *)&cmd_flex_filter_mask_value,
7895 (void *)&cmd_flex_filter_priority,
7896 (void *)&cmd_flex_filter_priority_value,
7897 (void *)&cmd_flex_filter_queue,
7898 (void *)&cmd_flex_filter_queue_id,
7903 /* *** Filters Control *** */
7905 /* *** deal with ethertype filter *** */
7906 struct cmd_ethertype_filter_result {
7907 cmdline_fixed_string_t filter;
7909 cmdline_fixed_string_t ops;
7910 cmdline_fixed_string_t mac;
7911 struct ether_addr mac_addr;
7912 cmdline_fixed_string_t ethertype;
7913 uint16_t ethertype_value;
7914 cmdline_fixed_string_t drop;
7915 cmdline_fixed_string_t queue;
7919 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7920 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7921 filter, "ethertype_filter");
7922 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7923 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7925 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7926 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7928 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7929 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7930 mac, "mac_addr#mac_ignr");
7931 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7932 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7934 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7935 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7936 ethertype, "ethertype");
7937 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7938 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7939 ethertype_value, UINT16);
7940 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7941 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7943 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7944 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7946 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7947 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7951 cmd_ethertype_filter_parsed(void *parsed_result,
7952 __attribute__((unused)) struct cmdline *cl,
7953 __attribute__((unused)) void *data)
7955 struct cmd_ethertype_filter_result *res = parsed_result;
7956 struct rte_eth_ethertype_filter filter;
7959 ret = rte_eth_dev_filter_supported(res->port_id,
7960 RTE_ETH_FILTER_ETHERTYPE);
7962 printf("ethertype filter is not supported on port %u.\n",
7967 memset(&filter, 0, sizeof(filter));
7968 if (!strcmp(res->mac, "mac_addr")) {
7969 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7970 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7971 sizeof(struct ether_addr));
7973 if (!strcmp(res->drop, "drop"))
7974 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7975 filter.ether_type = res->ethertype_value;
7976 filter.queue = res->queue_id;
7978 if (!strcmp(res->ops, "add"))
7979 ret = rte_eth_dev_filter_ctrl(res->port_id,
7980 RTE_ETH_FILTER_ETHERTYPE,
7984 ret = rte_eth_dev_filter_ctrl(res->port_id,
7985 RTE_ETH_FILTER_ETHERTYPE,
7986 RTE_ETH_FILTER_DELETE,
7989 printf("ethertype filter programming error: (%s)\n",
7993 cmdline_parse_inst_t cmd_ethertype_filter = {
7994 .f = cmd_ethertype_filter_parsed,
7996 .help_str = "add or delete an ethertype filter entry",
7998 (void *)&cmd_ethertype_filter_filter,
7999 (void *)&cmd_ethertype_filter_port_id,
8000 (void *)&cmd_ethertype_filter_ops,
8001 (void *)&cmd_ethertype_filter_mac,
8002 (void *)&cmd_ethertype_filter_mac_addr,
8003 (void *)&cmd_ethertype_filter_ethertype,
8004 (void *)&cmd_ethertype_filter_ethertype_value,
8005 (void *)&cmd_ethertype_filter_drop,
8006 (void *)&cmd_ethertype_filter_queue,
8007 (void *)&cmd_ethertype_filter_queue_id,
8012 /* *** deal with flow director filter *** */
8013 struct cmd_flow_director_result {
8014 cmdline_fixed_string_t flow_director_filter;
8016 cmdline_fixed_string_t mode;
8017 cmdline_fixed_string_t mode_value;
8018 cmdline_fixed_string_t ops;
8019 cmdline_fixed_string_t flow;
8020 cmdline_fixed_string_t flow_type;
8021 cmdline_fixed_string_t ether;
8022 uint16_t ether_type;
8023 cmdline_fixed_string_t src;
8024 cmdline_ipaddr_t ip_src;
8026 cmdline_fixed_string_t dst;
8027 cmdline_ipaddr_t ip_dst;
8029 cmdline_fixed_string_t verify_tag;
8030 uint32_t verify_tag_value;
8031 cmdline_fixed_string_t vlan;
8032 uint16_t vlan_value;
8033 cmdline_fixed_string_t flexbytes;
8034 cmdline_fixed_string_t flexbytes_value;
8035 cmdline_fixed_string_t pf_vf;
8036 cmdline_fixed_string_t drop;
8037 cmdline_fixed_string_t queue;
8039 cmdline_fixed_string_t fd_id;
8040 uint32_t fd_id_value;
8041 cmdline_fixed_string_t mac;
8042 struct ether_addr mac_addr;
8043 cmdline_fixed_string_t tunnel;
8044 cmdline_fixed_string_t tunnel_type;
8045 cmdline_fixed_string_t tunnel_id;
8046 uint32_t tunnel_id_value;
8050 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8053 const char *p, *p0 = q_arg;
8055 unsigned long int_fld;
8056 char *str_fld[max_num];
8061 p = strchr(p0, '(');
8065 p0 = strchr(p, ')');
8070 if (size >= sizeof(s))
8073 snprintf(s, sizeof(s), "%.*s", size, p);
8074 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8075 if (ret < 0 || ret > max_num)
8077 for (i = 0; i < ret; i++) {
8079 int_fld = strtoul(str_fld[i], &end, 0);
8080 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8082 flexbytes[i] = (uint8_t)int_fld;
8088 str2flowtype(char *string)
8091 static const struct {
8094 } flowtype_str[] = {
8095 {"raw", RTE_ETH_FLOW_RAW},
8096 {"ipv4", RTE_ETH_FLOW_IPV4},
8097 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8098 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8099 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8100 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8101 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8102 {"ipv6", RTE_ETH_FLOW_IPV6},
8103 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8104 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8105 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8106 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8107 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8108 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8111 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8112 if (!strcmp(flowtype_str[i].str, string))
8113 return flowtype_str[i].type;
8115 return RTE_ETH_FLOW_UNKNOWN;
8118 static enum rte_eth_fdir_tunnel_type
8119 str2fdir_tunneltype(char *string)
8123 static const struct {
8125 enum rte_eth_fdir_tunnel_type type;
8126 } tunneltype_str[] = {
8127 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8128 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8131 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8132 if (!strcmp(tunneltype_str[i].str, string))
8133 return tunneltype_str[i].type;
8135 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8138 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8140 if ((ip_addr).family == AF_INET) \
8141 (ip) = (ip_addr).addr.ipv4.s_addr; \
8143 printf("invalid parameter.\n"); \
8148 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8150 if ((ip_addr).family == AF_INET6) \
8151 (void)rte_memcpy(&(ip), \
8152 &((ip_addr).addr.ipv6), \
8153 sizeof(struct in6_addr)); \
8155 printf("invalid parameter.\n"); \
8161 cmd_flow_director_filter_parsed(void *parsed_result,
8162 __attribute__((unused)) struct cmdline *cl,
8163 __attribute__((unused)) void *data)
8165 struct cmd_flow_director_result *res = parsed_result;
8166 struct rte_eth_fdir_filter entry;
8167 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8169 unsigned long vf_id;
8172 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8174 printf("flow director is not supported on port %u.\n",
8178 memset(flexbytes, 0, sizeof(flexbytes));
8179 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8181 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8182 if (strcmp(res->mode_value, "MAC-VLAN")) {
8183 printf("Please set mode to MAC-VLAN.\n");
8186 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8187 if (strcmp(res->mode_value, "Tunnel")) {
8188 printf("Please set mode to Tunnel.\n");
8192 if (strcmp(res->mode_value, "IP")) {
8193 printf("Please set mode to IP.\n");
8196 entry.input.flow_type = str2flowtype(res->flow_type);
8199 ret = parse_flexbytes(res->flexbytes_value,
8201 RTE_ETH_FDIR_MAX_FLEXLEN);
8203 printf("error: Cannot parse flexbytes input.\n");
8207 switch (entry.input.flow_type) {
8208 case RTE_ETH_FLOW_FRAG_IPV4:
8209 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8210 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8211 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8212 IPV4_ADDR_TO_UINT(res->ip_dst,
8213 entry.input.flow.ip4_flow.dst_ip);
8214 IPV4_ADDR_TO_UINT(res->ip_src,
8215 entry.input.flow.ip4_flow.src_ip);
8216 /* need convert to big endian. */
8217 entry.input.flow.udp4_flow.dst_port =
8218 rte_cpu_to_be_16(res->port_dst);
8219 entry.input.flow.udp4_flow.src_port =
8220 rte_cpu_to_be_16(res->port_src);
8222 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8223 IPV4_ADDR_TO_UINT(res->ip_dst,
8224 entry.input.flow.sctp4_flow.ip.dst_ip);
8225 IPV4_ADDR_TO_UINT(res->ip_src,
8226 entry.input.flow.sctp4_flow.ip.src_ip);
8227 /* need convert to big endian. */
8228 entry.input.flow.sctp4_flow.dst_port =
8229 rte_cpu_to_be_16(res->port_dst);
8230 entry.input.flow.sctp4_flow.src_port =
8231 rte_cpu_to_be_16(res->port_src);
8232 entry.input.flow.sctp4_flow.verify_tag =
8233 rte_cpu_to_be_32(res->verify_tag_value);
8235 case RTE_ETH_FLOW_FRAG_IPV6:
8236 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8237 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8238 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8239 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8240 entry.input.flow.ipv6_flow.dst_ip);
8241 IPV6_ADDR_TO_ARRAY(res->ip_src,
8242 entry.input.flow.ipv6_flow.src_ip);
8243 /* need convert to big endian. */
8244 entry.input.flow.udp6_flow.dst_port =
8245 rte_cpu_to_be_16(res->port_dst);
8246 entry.input.flow.udp6_flow.src_port =
8247 rte_cpu_to_be_16(res->port_src);
8249 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8250 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8251 entry.input.flow.sctp6_flow.ip.dst_ip);
8252 IPV6_ADDR_TO_ARRAY(res->ip_src,
8253 entry.input.flow.sctp6_flow.ip.src_ip);
8254 /* need convert to big endian. */
8255 entry.input.flow.sctp6_flow.dst_port =
8256 rte_cpu_to_be_16(res->port_dst);
8257 entry.input.flow.sctp6_flow.src_port =
8258 rte_cpu_to_be_16(res->port_src);
8259 entry.input.flow.sctp6_flow.verify_tag =
8260 rte_cpu_to_be_32(res->verify_tag_value);
8262 case RTE_ETH_FLOW_L2_PAYLOAD:
8263 entry.input.flow.l2_flow.ether_type =
8264 rte_cpu_to_be_16(res->ether_type);
8270 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8271 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8273 sizeof(struct ether_addr));
8275 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8276 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8278 sizeof(struct ether_addr));
8279 entry.input.flow.tunnel_flow.tunnel_type =
8280 str2fdir_tunneltype(res->tunnel_type);
8281 entry.input.flow.tunnel_flow.tunnel_id =
8282 rte_cpu_to_be_32(res->tunnel_id_value);
8285 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8287 RTE_ETH_FDIR_MAX_FLEXLEN);
8289 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8291 entry.action.flex_off = 0; /*use 0 by default */
8292 if (!strcmp(res->drop, "drop"))
8293 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8295 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8297 if (!strcmp(res->pf_vf, "pf"))
8298 entry.input.flow_ext.is_vf = 0;
8299 else if (!strncmp(res->pf_vf, "vf", 2)) {
8300 struct rte_eth_dev_info dev_info;
8302 memset(&dev_info, 0, sizeof(dev_info));
8303 rte_eth_dev_info_get(res->port_id, &dev_info);
8305 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8306 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8307 printf("invalid parameter %s.\n", res->pf_vf);
8310 entry.input.flow_ext.is_vf = 1;
8311 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8313 printf("invalid parameter %s.\n", res->pf_vf);
8317 /* set to report FD ID by default */
8318 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8319 entry.action.rx_queue = res->queue_id;
8320 entry.soft_id = res->fd_id_value;
8321 if (!strcmp(res->ops, "add"))
8322 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8323 RTE_ETH_FILTER_ADD, &entry);
8324 else if (!strcmp(res->ops, "del"))
8325 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8326 RTE_ETH_FILTER_DELETE, &entry);
8328 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8329 RTE_ETH_FILTER_UPDATE, &entry);
8331 printf("flow director programming error: (%s)\n",
8335 cmdline_parse_token_string_t cmd_flow_director_filter =
8336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8337 flow_director_filter, "flow_director_filter");
8338 cmdline_parse_token_num_t cmd_flow_director_port_id =
8339 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8341 cmdline_parse_token_string_t cmd_flow_director_ops =
8342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8343 ops, "add#del#update");
8344 cmdline_parse_token_string_t cmd_flow_director_flow =
8345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8347 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8349 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8350 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8351 cmdline_parse_token_string_t cmd_flow_director_ether =
8352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8354 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8356 ether_type, UINT16);
8357 cmdline_parse_token_string_t cmd_flow_director_src =
8358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8360 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8361 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8363 cmdline_parse_token_num_t cmd_flow_director_port_src =
8364 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8366 cmdline_parse_token_string_t cmd_flow_director_dst =
8367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8369 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8370 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8372 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8375 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8377 verify_tag, "verify_tag");
8378 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8380 verify_tag_value, UINT32);
8381 cmdline_parse_token_string_t cmd_flow_director_vlan =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8384 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8386 vlan_value, UINT16);
8387 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8389 flexbytes, "flexbytes");
8390 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8392 flexbytes_value, NULL);
8393 cmdline_parse_token_string_t cmd_flow_director_drop =
8394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8396 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8399 cmdline_parse_token_string_t cmd_flow_director_queue =
8400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8402 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8403 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8405 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8408 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8410 fd_id_value, UINT32);
8412 cmdline_parse_token_string_t cmd_flow_director_mode =
8413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8415 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8418 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8420 mode_value, "MAC-VLAN");
8421 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8423 mode_value, "Tunnel");
8424 cmdline_parse_token_string_t cmd_flow_director_mac =
8425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8427 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8428 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8430 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8433 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8435 tunnel_type, "NVGRE#VxLAN");
8436 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8438 tunnel_id, "tunnel-id");
8439 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8440 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8441 tunnel_id_value, UINT32);
8443 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8444 .f = cmd_flow_director_filter_parsed,
8446 .help_str = "add or delete an ip flow director entry on NIC",
8448 (void *)&cmd_flow_director_filter,
8449 (void *)&cmd_flow_director_port_id,
8450 (void *)&cmd_flow_director_mode,
8451 (void *)&cmd_flow_director_mode_ip,
8452 (void *)&cmd_flow_director_ops,
8453 (void *)&cmd_flow_director_flow,
8454 (void *)&cmd_flow_director_flow_type,
8455 (void *)&cmd_flow_director_src,
8456 (void *)&cmd_flow_director_ip_src,
8457 (void *)&cmd_flow_director_dst,
8458 (void *)&cmd_flow_director_ip_dst,
8459 (void *)&cmd_flow_director_vlan,
8460 (void *)&cmd_flow_director_vlan_value,
8461 (void *)&cmd_flow_director_flexbytes,
8462 (void *)&cmd_flow_director_flexbytes_value,
8463 (void *)&cmd_flow_director_drop,
8464 (void *)&cmd_flow_director_pf_vf,
8465 (void *)&cmd_flow_director_queue,
8466 (void *)&cmd_flow_director_queue_id,
8467 (void *)&cmd_flow_director_fd_id,
8468 (void *)&cmd_flow_director_fd_id_value,
8473 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8474 .f = cmd_flow_director_filter_parsed,
8476 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8478 (void *)&cmd_flow_director_filter,
8479 (void *)&cmd_flow_director_port_id,
8480 (void *)&cmd_flow_director_mode,
8481 (void *)&cmd_flow_director_mode_ip,
8482 (void *)&cmd_flow_director_ops,
8483 (void *)&cmd_flow_director_flow,
8484 (void *)&cmd_flow_director_flow_type,
8485 (void *)&cmd_flow_director_src,
8486 (void *)&cmd_flow_director_ip_src,
8487 (void *)&cmd_flow_director_port_src,
8488 (void *)&cmd_flow_director_dst,
8489 (void *)&cmd_flow_director_ip_dst,
8490 (void *)&cmd_flow_director_port_dst,
8491 (void *)&cmd_flow_director_vlan,
8492 (void *)&cmd_flow_director_vlan_value,
8493 (void *)&cmd_flow_director_flexbytes,
8494 (void *)&cmd_flow_director_flexbytes_value,
8495 (void *)&cmd_flow_director_drop,
8496 (void *)&cmd_flow_director_pf_vf,
8497 (void *)&cmd_flow_director_queue,
8498 (void *)&cmd_flow_director_queue_id,
8499 (void *)&cmd_flow_director_fd_id,
8500 (void *)&cmd_flow_director_fd_id_value,
8505 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8506 .f = cmd_flow_director_filter_parsed,
8508 .help_str = "add or delete a sctp flow director entry on NIC",
8510 (void *)&cmd_flow_director_filter,
8511 (void *)&cmd_flow_director_port_id,
8512 (void *)&cmd_flow_director_mode,
8513 (void *)&cmd_flow_director_mode_ip,
8514 (void *)&cmd_flow_director_ops,
8515 (void *)&cmd_flow_director_flow,
8516 (void *)&cmd_flow_director_flow_type,
8517 (void *)&cmd_flow_director_src,
8518 (void *)&cmd_flow_director_ip_src,
8519 (void *)&cmd_flow_director_port_dst,
8520 (void *)&cmd_flow_director_dst,
8521 (void *)&cmd_flow_director_ip_dst,
8522 (void *)&cmd_flow_director_port_dst,
8523 (void *)&cmd_flow_director_verify_tag,
8524 (void *)&cmd_flow_director_verify_tag_value,
8525 (void *)&cmd_flow_director_vlan,
8526 (void *)&cmd_flow_director_vlan_value,
8527 (void *)&cmd_flow_director_flexbytes,
8528 (void *)&cmd_flow_director_flexbytes_value,
8529 (void *)&cmd_flow_director_drop,
8530 (void *)&cmd_flow_director_pf_vf,
8531 (void *)&cmd_flow_director_queue,
8532 (void *)&cmd_flow_director_queue_id,
8533 (void *)&cmd_flow_director_fd_id,
8534 (void *)&cmd_flow_director_fd_id_value,
8539 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8540 .f = cmd_flow_director_filter_parsed,
8542 .help_str = "add or delete a L2 flow director entry on NIC",
8544 (void *)&cmd_flow_director_filter,
8545 (void *)&cmd_flow_director_port_id,
8546 (void *)&cmd_flow_director_mode,
8547 (void *)&cmd_flow_director_mode_ip,
8548 (void *)&cmd_flow_director_ops,
8549 (void *)&cmd_flow_director_flow,
8550 (void *)&cmd_flow_director_flow_type,
8551 (void *)&cmd_flow_director_ether,
8552 (void *)&cmd_flow_director_ether_type,
8553 (void *)&cmd_flow_director_flexbytes,
8554 (void *)&cmd_flow_director_flexbytes_value,
8555 (void *)&cmd_flow_director_drop,
8556 (void *)&cmd_flow_director_pf_vf,
8557 (void *)&cmd_flow_director_queue,
8558 (void *)&cmd_flow_director_queue_id,
8559 (void *)&cmd_flow_director_fd_id,
8560 (void *)&cmd_flow_director_fd_id_value,
8565 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8566 .f = cmd_flow_director_filter_parsed,
8568 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8570 (void *)&cmd_flow_director_filter,
8571 (void *)&cmd_flow_director_port_id,
8572 (void *)&cmd_flow_director_mode,
8573 (void *)&cmd_flow_director_mode_mac_vlan,
8574 (void *)&cmd_flow_director_ops,
8575 (void *)&cmd_flow_director_mac,
8576 (void *)&cmd_flow_director_mac_addr,
8577 (void *)&cmd_flow_director_vlan,
8578 (void *)&cmd_flow_director_vlan_value,
8579 (void *)&cmd_flow_director_flexbytes,
8580 (void *)&cmd_flow_director_flexbytes_value,
8581 (void *)&cmd_flow_director_drop,
8582 (void *)&cmd_flow_director_queue,
8583 (void *)&cmd_flow_director_queue_id,
8584 (void *)&cmd_flow_director_fd_id,
8585 (void *)&cmd_flow_director_fd_id_value,
8590 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8591 .f = cmd_flow_director_filter_parsed,
8593 .help_str = "add or delete a tunnel flow director entry on NIC",
8595 (void *)&cmd_flow_director_filter,
8596 (void *)&cmd_flow_director_port_id,
8597 (void *)&cmd_flow_director_mode,
8598 (void *)&cmd_flow_director_mode_tunnel,
8599 (void *)&cmd_flow_director_ops,
8600 (void *)&cmd_flow_director_mac,
8601 (void *)&cmd_flow_director_mac_addr,
8602 (void *)&cmd_flow_director_vlan,
8603 (void *)&cmd_flow_director_vlan_value,
8604 (void *)&cmd_flow_director_tunnel,
8605 (void *)&cmd_flow_director_tunnel_type,
8606 (void *)&cmd_flow_director_tunnel_id,
8607 (void *)&cmd_flow_director_tunnel_id_value,
8608 (void *)&cmd_flow_director_flexbytes,
8609 (void *)&cmd_flow_director_flexbytes_value,
8610 (void *)&cmd_flow_director_drop,
8611 (void *)&cmd_flow_director_queue,
8612 (void *)&cmd_flow_director_queue_id,
8613 (void *)&cmd_flow_director_fd_id,
8614 (void *)&cmd_flow_director_fd_id_value,
8619 struct cmd_flush_flow_director_result {
8620 cmdline_fixed_string_t flush_flow_director;
8624 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8625 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8626 flush_flow_director, "flush_flow_director");
8627 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8628 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8632 cmd_flush_flow_director_parsed(void *parsed_result,
8633 __attribute__((unused)) struct cmdline *cl,
8634 __attribute__((unused)) void *data)
8636 struct cmd_flow_director_result *res = parsed_result;
8639 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8641 printf("flow director is not supported on port %u.\n",
8646 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8647 RTE_ETH_FILTER_FLUSH, NULL);
8649 printf("flow director table flushing error: (%s)\n",
8653 cmdline_parse_inst_t cmd_flush_flow_director = {
8654 .f = cmd_flush_flow_director_parsed,
8656 .help_str = "flush all flow director entries of a device on NIC",
8658 (void *)&cmd_flush_flow_director_flush,
8659 (void *)&cmd_flush_flow_director_port_id,
8664 /* *** deal with flow director mask *** */
8665 struct cmd_flow_director_mask_result {
8666 cmdline_fixed_string_t flow_director_mask;
8668 cmdline_fixed_string_t mode;
8669 cmdline_fixed_string_t mode_value;
8670 cmdline_fixed_string_t vlan;
8672 cmdline_fixed_string_t src_mask;
8673 cmdline_ipaddr_t ipv4_src;
8674 cmdline_ipaddr_t ipv6_src;
8676 cmdline_fixed_string_t dst_mask;
8677 cmdline_ipaddr_t ipv4_dst;
8678 cmdline_ipaddr_t ipv6_dst;
8680 cmdline_fixed_string_t mac;
8681 uint8_t mac_addr_byte_mask;
8682 cmdline_fixed_string_t tunnel_id;
8683 uint32_t tunnel_id_mask;
8684 cmdline_fixed_string_t tunnel_type;
8685 uint8_t tunnel_type_mask;
8689 cmd_flow_director_mask_parsed(void *parsed_result,
8690 __attribute__((unused)) struct cmdline *cl,
8691 __attribute__((unused)) void *data)
8693 struct cmd_flow_director_mask_result *res = parsed_result;
8694 struct rte_eth_fdir_masks *mask;
8695 struct rte_port *port;
8697 if (res->port_id > nb_ports) {
8698 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8702 port = &ports[res->port_id];
8703 /** Check if the port is not started **/
8704 if (port->port_status != RTE_PORT_STOPPED) {
8705 printf("Please stop port %d first\n", res->port_id);
8709 mask = &port->dev_conf.fdir_conf.mask;
8711 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8712 if (strcmp(res->mode_value, "MAC-VLAN")) {
8713 printf("Please set mode to MAC-VLAN.\n");
8717 mask->vlan_tci_mask = res->vlan_mask;
8718 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8719 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8720 if (strcmp(res->mode_value, "Tunnel")) {
8721 printf("Please set mode to Tunnel.\n");
8725 mask->vlan_tci_mask = res->vlan_mask;
8726 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8727 mask->tunnel_id_mask = res->tunnel_id_mask;
8728 mask->tunnel_type_mask = res->tunnel_type_mask;
8730 if (strcmp(res->mode_value, "IP")) {
8731 printf("Please set mode to IP.\n");
8735 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8736 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8737 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8738 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8739 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8740 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8741 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8744 cmd_reconfig_device_queue(res->port_id, 1, 1);
8747 cmdline_parse_token_string_t cmd_flow_director_mask =
8748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8749 flow_director_mask, "flow_director_mask");
8750 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8753 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8756 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8759 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8761 src_mask, "src_mask");
8762 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8763 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8765 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8766 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8768 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8771 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8773 dst_mask, "dst_mask");
8774 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8775 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8777 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8778 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8780 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8784 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8787 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8790 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8792 mode_value, "MAC-VLAN");
8793 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8795 mode_value, "Tunnel");
8796 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8799 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8801 mac_addr_byte_mask, UINT8);
8802 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8804 tunnel_type, "tunnel-type");
8805 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8806 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8807 tunnel_type_mask, UINT8);
8808 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8810 tunnel_id, "tunnel-id");
8811 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8812 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8813 tunnel_id_mask, UINT32);
8815 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8816 .f = cmd_flow_director_mask_parsed,
8818 .help_str = "set IP mode flow director's mask on NIC",
8820 (void *)&cmd_flow_director_mask,
8821 (void *)&cmd_flow_director_mask_port_id,
8822 (void *)&cmd_flow_director_mask_mode,
8823 (void *)&cmd_flow_director_mask_mode_ip,
8824 (void *)&cmd_flow_director_mask_vlan,
8825 (void *)&cmd_flow_director_mask_vlan_value,
8826 (void *)&cmd_flow_director_mask_src,
8827 (void *)&cmd_flow_director_mask_ipv4_src,
8828 (void *)&cmd_flow_director_mask_ipv6_src,
8829 (void *)&cmd_flow_director_mask_port_src,
8830 (void *)&cmd_flow_director_mask_dst,
8831 (void *)&cmd_flow_director_mask_ipv4_dst,
8832 (void *)&cmd_flow_director_mask_ipv6_dst,
8833 (void *)&cmd_flow_director_mask_port_dst,
8838 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8839 .f = cmd_flow_director_mask_parsed,
8841 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8843 (void *)&cmd_flow_director_mask,
8844 (void *)&cmd_flow_director_mask_port_id,
8845 (void *)&cmd_flow_director_mask_mode,
8846 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8847 (void *)&cmd_flow_director_mask_vlan,
8848 (void *)&cmd_flow_director_mask_vlan_value,
8849 (void *)&cmd_flow_director_mask_mac,
8850 (void *)&cmd_flow_director_mask_mac_value,
8855 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8856 .f = cmd_flow_director_mask_parsed,
8858 .help_str = "set tunnel mode flow director's mask on NIC",
8860 (void *)&cmd_flow_director_mask,
8861 (void *)&cmd_flow_director_mask_port_id,
8862 (void *)&cmd_flow_director_mask_mode,
8863 (void *)&cmd_flow_director_mask_mode_tunnel,
8864 (void *)&cmd_flow_director_mask_vlan,
8865 (void *)&cmd_flow_director_mask_vlan_value,
8866 (void *)&cmd_flow_director_mask_mac,
8867 (void *)&cmd_flow_director_mask_mac_value,
8868 (void *)&cmd_flow_director_mask_tunnel_type,
8869 (void *)&cmd_flow_director_mask_tunnel_type_value,
8870 (void *)&cmd_flow_director_mask_tunnel_id,
8871 (void *)&cmd_flow_director_mask_tunnel_id_value,
8876 /* *** deal with flow director mask on flexible payload *** */
8877 struct cmd_flow_director_flex_mask_result {
8878 cmdline_fixed_string_t flow_director_flexmask;
8880 cmdline_fixed_string_t flow;
8881 cmdline_fixed_string_t flow_type;
8882 cmdline_fixed_string_t mask;
8886 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8887 __attribute__((unused)) struct cmdline *cl,
8888 __attribute__((unused)) void *data)
8890 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8891 struct rte_eth_fdir_info fdir_info;
8892 struct rte_eth_fdir_flex_mask flex_mask;
8893 struct rte_port *port;
8894 uint32_t flow_type_mask;
8898 if (res->port_id > nb_ports) {
8899 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8903 port = &ports[res->port_id];
8904 /** Check if the port is not started **/
8905 if (port->port_status != RTE_PORT_STOPPED) {
8906 printf("Please stop port %d first\n", res->port_id);
8910 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8911 ret = parse_flexbytes(res->mask,
8913 RTE_ETH_FDIR_MAX_FLEXLEN);
8915 printf("error: Cannot parse mask input.\n");
8919 memset(&fdir_info, 0, sizeof(fdir_info));
8920 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8921 RTE_ETH_FILTER_INFO, &fdir_info);
8923 printf("Cannot get FDir filter info\n");
8927 if (!strcmp(res->flow_type, "none")) {
8928 /* means don't specify the flow type */
8929 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8930 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8931 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8932 0, sizeof(struct rte_eth_fdir_flex_mask));
8933 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8934 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8936 sizeof(struct rte_eth_fdir_flex_mask));
8937 cmd_reconfig_device_queue(res->port_id, 1, 1);
8940 flow_type_mask = fdir_info.flow_types_mask[0];
8941 if (!strcmp(res->flow_type, "all")) {
8942 if (!flow_type_mask) {
8943 printf("No flow type supported\n");
8946 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8947 if (flow_type_mask & (1 << i)) {
8948 flex_mask.flow_type = i;
8949 fdir_set_flex_mask(res->port_id, &flex_mask);
8952 cmd_reconfig_device_queue(res->port_id, 1, 1);
8955 flex_mask.flow_type = str2flowtype(res->flow_type);
8956 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8957 printf("Flow type %s not supported on port %d\n",
8958 res->flow_type, res->port_id);
8961 fdir_set_flex_mask(res->port_id, &flex_mask);
8962 cmd_reconfig_device_queue(res->port_id, 1, 1);
8965 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8967 flow_director_flexmask,
8968 "flow_director_flex_mask");
8969 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8970 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8972 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8975 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8977 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8978 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8979 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8983 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8984 .f = cmd_flow_director_flex_mask_parsed,
8986 .help_str = "set flow director's flex mask on NIC",
8988 (void *)&cmd_flow_director_flexmask,
8989 (void *)&cmd_flow_director_flexmask_port_id,
8990 (void *)&cmd_flow_director_flexmask_flow,
8991 (void *)&cmd_flow_director_flexmask_flow_type,
8992 (void *)&cmd_flow_director_flexmask_mask,
8997 /* *** deal with flow director flexible payload configuration *** */
8998 struct cmd_flow_director_flexpayload_result {
8999 cmdline_fixed_string_t flow_director_flexpayload;
9001 cmdline_fixed_string_t payload_layer;
9002 cmdline_fixed_string_t payload_cfg;
9006 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9009 const char *p, *p0 = q_arg;
9011 unsigned long int_fld;
9012 char *str_fld[max_num];
9017 p = strchr(p0, '(');
9021 p0 = strchr(p, ')');
9026 if (size >= sizeof(s))
9029 snprintf(s, sizeof(s), "%.*s", size, p);
9030 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9031 if (ret < 0 || ret > max_num)
9033 for (i = 0; i < ret; i++) {
9035 int_fld = strtoul(str_fld[i], &end, 0);
9036 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9038 offsets[i] = (uint16_t)int_fld;
9044 cmd_flow_director_flxpld_parsed(void *parsed_result,
9045 __attribute__((unused)) struct cmdline *cl,
9046 __attribute__((unused)) void *data)
9048 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9049 struct rte_eth_flex_payload_cfg flex_cfg;
9050 struct rte_port *port;
9053 if (res->port_id > nb_ports) {
9054 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9058 port = &ports[res->port_id];
9059 /** Check if the port is not started **/
9060 if (port->port_status != RTE_PORT_STOPPED) {
9061 printf("Please stop port %d first\n", res->port_id);
9065 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9067 if (!strcmp(res->payload_layer, "raw"))
9068 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9069 else if (!strcmp(res->payload_layer, "l2"))
9070 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9071 else if (!strcmp(res->payload_layer, "l3"))
9072 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9073 else if (!strcmp(res->payload_layer, "l4"))
9074 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9076 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9077 RTE_ETH_FDIR_MAX_FLEXLEN);
9079 printf("error: Cannot parse flex payload input.\n");
9083 fdir_set_flex_payload(res->port_id, &flex_cfg);
9084 cmd_reconfig_device_queue(res->port_id, 1, 1);
9087 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9089 flow_director_flexpayload,
9090 "flow_director_flex_payload");
9091 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9092 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9094 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9096 payload_layer, "raw#l2#l3#l4");
9097 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9101 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9102 .f = cmd_flow_director_flxpld_parsed,
9104 .help_str = "set flow director's flex payload on NIC",
9106 (void *)&cmd_flow_director_flexpayload,
9107 (void *)&cmd_flow_director_flexpayload_port_id,
9108 (void *)&cmd_flow_director_flexpayload_payload_layer,
9109 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9114 /* *** Classification Filters Control *** */
9115 /* *** Get symmetric hash enable per port *** */
9116 struct cmd_get_sym_hash_ena_per_port_result {
9117 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9122 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9123 __rte_unused struct cmdline *cl,
9124 __rte_unused void *data)
9126 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9127 struct rte_eth_hash_filter_info info;
9130 if (rte_eth_dev_filter_supported(res->port_id,
9131 RTE_ETH_FILTER_HASH) < 0) {
9132 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9137 memset(&info, 0, sizeof(info));
9138 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9139 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9140 RTE_ETH_FILTER_GET, &info);
9143 printf("Cannot get symmetric hash enable per port "
9144 "on port %u\n", res->port_id);
9148 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9149 "enabled" : "disabled", res->port_id);
9152 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9153 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9154 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9155 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9156 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9159 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9160 .f = cmd_get_sym_hash_per_port_parsed,
9162 .help_str = "get_sym_hash_ena_per_port port_id",
9164 (void *)&cmd_get_sym_hash_ena_per_port_all,
9165 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9170 /* *** Set symmetric hash enable per port *** */
9171 struct cmd_set_sym_hash_ena_per_port_result {
9172 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9173 cmdline_fixed_string_t enable;
9178 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9179 __rte_unused struct cmdline *cl,
9180 __rte_unused void *data)
9182 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9183 struct rte_eth_hash_filter_info info;
9186 if (rte_eth_dev_filter_supported(res->port_id,
9187 RTE_ETH_FILTER_HASH) < 0) {
9188 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9193 memset(&info, 0, sizeof(info));
9194 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9195 if (!strcmp(res->enable, "enable"))
9196 info.info.enable = 1;
9197 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9198 RTE_ETH_FILTER_SET, &info);
9200 printf("Cannot set symmetric hash enable per port on "
9201 "port %u\n", res->port_id);
9204 printf("Symmetric hash has been set to %s on port %u\n",
9205 res->enable, res->port_id);
9208 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9209 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9210 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9211 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9212 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9214 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9215 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9216 enable, "enable#disable");
9218 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9219 .f = cmd_set_sym_hash_per_port_parsed,
9221 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9223 (void *)&cmd_set_sym_hash_ena_per_port_all,
9224 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9225 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9230 /* Get global config of hash function */
9231 struct cmd_get_hash_global_config_result {
9232 cmdline_fixed_string_t get_hash_global_config;
9237 flowtype_to_str(uint16_t ftype)
9244 {"ipv4", RTE_ETH_FLOW_IPV4},
9245 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9246 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9247 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9248 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9249 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9250 {"ipv6", RTE_ETH_FLOW_IPV6},
9251 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9252 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9253 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9254 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9255 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9256 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9259 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9260 if (ftype_table[i].ftype == ftype)
9261 return ftype_table[i].str;
9268 cmd_get_hash_global_config_parsed(void *parsed_result,
9269 __rte_unused struct cmdline *cl,
9270 __rte_unused void *data)
9272 struct cmd_get_hash_global_config_result *res = parsed_result;
9273 struct rte_eth_hash_filter_info info;
9274 uint32_t idx, offset;
9279 if (rte_eth_dev_filter_supported(res->port_id,
9280 RTE_ETH_FILTER_HASH) < 0) {
9281 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9286 memset(&info, 0, sizeof(info));
9287 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9288 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9289 RTE_ETH_FILTER_GET, &info);
9291 printf("Cannot get hash global configurations by port %d\n",
9296 switch (info.info.global_conf.hash_func) {
9297 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9298 printf("Hash function is Toeplitz\n");
9300 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9301 printf("Hash function is Simple XOR\n");
9304 printf("Unknown hash function\n");
9308 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9309 idx = i / UINT32_BIT;
9310 offset = i % UINT32_BIT;
9311 if (!(info.info.global_conf.valid_bit_mask[idx] &
9314 str = flowtype_to_str(i);
9317 printf("Symmetric hash is %s globally for flow type %s "
9319 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9320 (1UL << offset)) ? "enabled" : "disabled"), str,
9325 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9326 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9327 get_hash_global_config, "get_hash_global_config");
9328 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9329 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9332 cmdline_parse_inst_t cmd_get_hash_global_config = {
9333 .f = cmd_get_hash_global_config_parsed,
9335 .help_str = "get_hash_global_config port_id",
9337 (void *)&cmd_get_hash_global_config_all,
9338 (void *)&cmd_get_hash_global_config_port_id,
9343 /* Set global config of hash function */
9344 struct cmd_set_hash_global_config_result {
9345 cmdline_fixed_string_t set_hash_global_config;
9347 cmdline_fixed_string_t hash_func;
9348 cmdline_fixed_string_t flow_type;
9349 cmdline_fixed_string_t enable;
9353 cmd_set_hash_global_config_parsed(void *parsed_result,
9354 __rte_unused struct cmdline *cl,
9355 __rte_unused void *data)
9357 struct cmd_set_hash_global_config_result *res = parsed_result;
9358 struct rte_eth_hash_filter_info info;
9359 uint32_t ftype, idx, offset;
9362 if (rte_eth_dev_filter_supported(res->port_id,
9363 RTE_ETH_FILTER_HASH) < 0) {
9364 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9368 memset(&info, 0, sizeof(info));
9369 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9370 if (!strcmp(res->hash_func, "toeplitz"))
9371 info.info.global_conf.hash_func =
9372 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9373 else if (!strcmp(res->hash_func, "simple_xor"))
9374 info.info.global_conf.hash_func =
9375 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9376 else if (!strcmp(res->hash_func, "default"))
9377 info.info.global_conf.hash_func =
9378 RTE_ETH_HASH_FUNCTION_DEFAULT;
9380 ftype = str2flowtype(res->flow_type);
9381 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9382 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9383 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9384 if (!strcmp(res->enable, "enable"))
9385 info.info.global_conf.sym_hash_enable_mask[idx] |=
9387 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9388 RTE_ETH_FILTER_SET, &info);
9390 printf("Cannot set global hash configurations by port %d\n",
9393 printf("Global hash configurations have been set "
9394 "succcessfully by port %d\n", res->port_id);
9397 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9399 set_hash_global_config, "set_hash_global_config");
9400 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9401 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9403 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9404 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9405 hash_func, "toeplitz#simple_xor#default");
9406 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9407 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9409 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9410 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9411 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9412 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9413 enable, "enable#disable");
9415 cmdline_parse_inst_t cmd_set_hash_global_config = {
9416 .f = cmd_set_hash_global_config_parsed,
9418 .help_str = "set_hash_global_config port_id "
9419 "toeplitz|simple_xor|default "
9420 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9421 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9424 (void *)&cmd_set_hash_global_config_all,
9425 (void *)&cmd_set_hash_global_config_port_id,
9426 (void *)&cmd_set_hash_global_config_hash_func,
9427 (void *)&cmd_set_hash_global_config_flow_type,
9428 (void *)&cmd_set_hash_global_config_enable,
9433 /* Set hash input set */
9434 struct cmd_set_hash_input_set_result {
9435 cmdline_fixed_string_t set_hash_input_set;
9437 cmdline_fixed_string_t flow_type;
9438 cmdline_fixed_string_t inset_field;
9439 cmdline_fixed_string_t select;
9442 static enum rte_eth_input_set_field
9443 str2inset(char *string)
9447 static const struct {
9449 enum rte_eth_input_set_field inset;
9451 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9452 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9453 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9454 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9455 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9456 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9457 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9458 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9459 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9460 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9461 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9462 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9463 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9464 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9465 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9466 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9467 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9468 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9469 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9470 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9471 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9472 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9473 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9474 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9475 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9476 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9477 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9478 {"none", RTE_ETH_INPUT_SET_NONE},
9481 for (i = 0; i < RTE_DIM(inset_table); i++) {
9482 if (!strcmp(string, inset_table[i].str))
9483 return inset_table[i].inset;
9486 return RTE_ETH_INPUT_SET_UNKNOWN;
9490 cmd_set_hash_input_set_parsed(void *parsed_result,
9491 __rte_unused struct cmdline *cl,
9492 __rte_unused void *data)
9494 struct cmd_set_hash_input_set_result *res = parsed_result;
9495 struct rte_eth_hash_filter_info info;
9497 memset(&info, 0, sizeof(info));
9498 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9499 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9500 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9501 info.info.input_set_conf.inset_size = 1;
9502 if (!strcmp(res->select, "select"))
9503 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9504 else if (!strcmp(res->select, "add"))
9505 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9506 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9507 RTE_ETH_FILTER_SET, &info);
9510 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9511 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9512 set_hash_input_set, "set_hash_input_set");
9513 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9514 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9516 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9517 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9519 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9520 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9521 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9522 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9524 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9525 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9526 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9527 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9528 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9530 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9531 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9532 select, "select#add");
9534 cmdline_parse_inst_t cmd_set_hash_input_set = {
9535 .f = cmd_set_hash_input_set_parsed,
9537 .help_str = "set_hash_input_set <port_id> "
9538 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9539 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9540 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9541 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9542 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9543 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9544 "fld-7th|fld-8th|none select|add",
9546 (void *)&cmd_set_hash_input_set_cmd,
9547 (void *)&cmd_set_hash_input_set_port_id,
9548 (void *)&cmd_set_hash_input_set_flow_type,
9549 (void *)&cmd_set_hash_input_set_field,
9550 (void *)&cmd_set_hash_input_set_select,
9555 /* Set flow director input set */
9556 struct cmd_set_fdir_input_set_result {
9557 cmdline_fixed_string_t set_fdir_input_set;
9559 cmdline_fixed_string_t flow_type;
9560 cmdline_fixed_string_t inset_field;
9561 cmdline_fixed_string_t select;
9565 cmd_set_fdir_input_set_parsed(void *parsed_result,
9566 __rte_unused struct cmdline *cl,
9567 __rte_unused void *data)
9569 struct cmd_set_fdir_input_set_result *res = parsed_result;
9570 struct rte_eth_fdir_filter_info info;
9572 memset(&info, 0, sizeof(info));
9573 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9574 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9575 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9576 info.info.input_set_conf.inset_size = 1;
9577 if (!strcmp(res->select, "select"))
9578 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9579 else if (!strcmp(res->select, "add"))
9580 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9581 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9582 RTE_ETH_FILTER_SET, &info);
9585 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9586 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9587 set_fdir_input_set, "set_fdir_input_set");
9588 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9589 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9591 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9592 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9594 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9595 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9596 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9597 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9599 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9600 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9601 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9602 "fld-7th#fld-8th#none");
9603 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9604 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9605 select, "select#add");
9607 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9608 .f = cmd_set_fdir_input_set_parsed,
9610 .help_str = "set_fdir_input_set <port_id> "
9611 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9612 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9613 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9614 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9615 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9616 "fld-7th|fld-8th|none select|add",
9618 (void *)&cmd_set_fdir_input_set_cmd,
9619 (void *)&cmd_set_fdir_input_set_port_id,
9620 (void *)&cmd_set_fdir_input_set_flow_type,
9621 (void *)&cmd_set_fdir_input_set_field,
9622 (void *)&cmd_set_fdir_input_set_select,
9627 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9628 struct cmd_mcast_addr_result {
9629 cmdline_fixed_string_t mcast_addr_cmd;
9630 cmdline_fixed_string_t what;
9632 struct ether_addr mc_addr;
9635 static void cmd_mcast_addr_parsed(void *parsed_result,
9636 __attribute__((unused)) struct cmdline *cl,
9637 __attribute__((unused)) void *data)
9639 struct cmd_mcast_addr_result *res = parsed_result;
9641 if (!is_multicast_ether_addr(&res->mc_addr)) {
9642 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9643 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9644 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9645 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9648 if (strcmp(res->what, "add") == 0)
9649 mcast_addr_add(res->port_num, &res->mc_addr);
9651 mcast_addr_remove(res->port_num, &res->mc_addr);
9654 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9655 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9656 mcast_addr_cmd, "mcast_addr");
9657 cmdline_parse_token_string_t cmd_mcast_addr_what =
9658 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9660 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9661 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9662 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9665 cmdline_parse_inst_t cmd_mcast_addr = {
9666 .f = cmd_mcast_addr_parsed,
9668 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9670 (void *)&cmd_mcast_addr_cmd,
9671 (void *)&cmd_mcast_addr_what,
9672 (void *)&cmd_mcast_addr_portnum,
9673 (void *)&cmd_mcast_addr_addr,
9679 * only support E-tag now.
9682 /* Ether type config */
9683 struct cmd_config_l2_tunnel_eth_type_result {
9684 cmdline_fixed_string_t port;
9685 cmdline_fixed_string_t config;
9686 cmdline_fixed_string_t all;
9688 cmdline_fixed_string_t l2_tunnel;
9689 cmdline_fixed_string_t l2_tunnel_type;
9690 cmdline_fixed_string_t eth_type;
9691 uint16_t eth_type_val;
9694 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
9695 TOKEN_STRING_INITIALIZER
9696 (struct cmd_config_l2_tunnel_eth_type_result,
9698 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
9699 TOKEN_STRING_INITIALIZER
9700 (struct cmd_config_l2_tunnel_eth_type_result,
9702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
9703 TOKEN_STRING_INITIALIZER
9704 (struct cmd_config_l2_tunnel_eth_type_result,
9706 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
9707 TOKEN_NUM_INITIALIZER
9708 (struct cmd_config_l2_tunnel_eth_type_result,
9710 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
9711 TOKEN_STRING_INITIALIZER
9712 (struct cmd_config_l2_tunnel_eth_type_result,
9713 l2_tunnel, "l2-tunnel");
9714 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
9715 TOKEN_STRING_INITIALIZER
9716 (struct cmd_config_l2_tunnel_eth_type_result,
9717 l2_tunnel_type, "E-tag");
9718 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
9719 TOKEN_STRING_INITIALIZER
9720 (struct cmd_config_l2_tunnel_eth_type_result,
9721 eth_type, "ether-type");
9722 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
9723 TOKEN_NUM_INITIALIZER
9724 (struct cmd_config_l2_tunnel_eth_type_result,
9725 eth_type_val, UINT16);
9728 str2fdir_l2_tunnel_type(char *string)
9732 static const struct {
9735 } l2_tunnel_type_str[] = {
9736 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
9739 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
9740 if (!strcmp(l2_tunnel_type_str[i].str, string))
9741 return l2_tunnel_type_str[i].type;
9743 return RTE_TUNNEL_TYPE_NONE;
9746 /* ether type config for all ports */
9748 cmd_config_l2_tunnel_eth_type_all_parsed
9749 (void *parsed_result,
9750 __attribute__((unused)) struct cmdline *cl,
9751 __attribute__((unused)) void *data)
9753 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
9754 struct rte_eth_l2_tunnel_conf entry;
9757 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9758 entry.ether_type = res->eth_type_val;
9760 FOREACH_PORT(pid, ports) {
9761 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
9765 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
9766 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
9768 .help_str = "port config all l2-tunnel ether-type",
9770 (void *)&cmd_config_l2_tunnel_eth_type_port,
9771 (void *)&cmd_config_l2_tunnel_eth_type_config,
9772 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
9773 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9774 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9775 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9776 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9781 /* ether type config for a specific port */
9783 cmd_config_l2_tunnel_eth_type_specific_parsed(
9784 void *parsed_result,
9785 __attribute__((unused)) struct cmdline *cl,
9786 __attribute__((unused)) void *data)
9788 struct cmd_config_l2_tunnel_eth_type_result *res =
9790 struct rte_eth_l2_tunnel_conf entry;
9792 if (port_id_is_invalid(res->id, ENABLED_WARN))
9795 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9796 entry.ether_type = res->eth_type_val;
9798 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
9801 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
9802 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
9804 .help_str = "port config l2-tunnel ether-type",
9806 (void *)&cmd_config_l2_tunnel_eth_type_port,
9807 (void *)&cmd_config_l2_tunnel_eth_type_config,
9808 (void *)&cmd_config_l2_tunnel_eth_type_id,
9809 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
9810 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
9811 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
9812 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
9817 /* Enable/disable l2 tunnel */
9818 struct cmd_config_l2_tunnel_en_dis_result {
9819 cmdline_fixed_string_t port;
9820 cmdline_fixed_string_t config;
9821 cmdline_fixed_string_t all;
9823 cmdline_fixed_string_t l2_tunnel;
9824 cmdline_fixed_string_t l2_tunnel_type;
9825 cmdline_fixed_string_t en_dis;
9828 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
9829 TOKEN_STRING_INITIALIZER
9830 (struct cmd_config_l2_tunnel_en_dis_result,
9832 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
9833 TOKEN_STRING_INITIALIZER
9834 (struct cmd_config_l2_tunnel_en_dis_result,
9836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
9837 TOKEN_STRING_INITIALIZER
9838 (struct cmd_config_l2_tunnel_en_dis_result,
9840 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
9841 TOKEN_NUM_INITIALIZER
9842 (struct cmd_config_l2_tunnel_en_dis_result,
9844 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
9845 TOKEN_STRING_INITIALIZER
9846 (struct cmd_config_l2_tunnel_en_dis_result,
9847 l2_tunnel, "l2-tunnel");
9848 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
9849 TOKEN_STRING_INITIALIZER
9850 (struct cmd_config_l2_tunnel_en_dis_result,
9851 l2_tunnel_type, "E-tag");
9852 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
9853 TOKEN_STRING_INITIALIZER
9854 (struct cmd_config_l2_tunnel_en_dis_result,
9855 en_dis, "enable#disable");
9857 /* enable/disable l2 tunnel for all ports */
9859 cmd_config_l2_tunnel_en_dis_all_parsed(
9860 void *parsed_result,
9861 __attribute__((unused)) struct cmdline *cl,
9862 __attribute__((unused)) void *data)
9864 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
9865 struct rte_eth_l2_tunnel_conf entry;
9869 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9871 if (!strcmp("enable", res->en_dis))
9876 FOREACH_PORT(pid, ports) {
9877 rte_eth_dev_l2_tunnel_offload_set(pid,
9879 ETH_L2_TUNNEL_ENABLE_MASK,
9884 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
9885 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
9887 .help_str = "port config all l2-tunnel enable/disable",
9889 (void *)&cmd_config_l2_tunnel_en_dis_port,
9890 (void *)&cmd_config_l2_tunnel_en_dis_config,
9891 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
9892 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9893 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9894 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9899 /* enable/disable l2 tunnel for a port */
9901 cmd_config_l2_tunnel_en_dis_specific_parsed(
9902 void *parsed_result,
9903 __attribute__((unused)) struct cmdline *cl,
9904 __attribute__((unused)) void *data)
9906 struct cmd_config_l2_tunnel_en_dis_result *res =
9908 struct rte_eth_l2_tunnel_conf entry;
9910 if (port_id_is_invalid(res->id, ENABLED_WARN))
9913 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
9915 if (!strcmp("enable", res->en_dis))
9916 rte_eth_dev_l2_tunnel_offload_set(res->id,
9918 ETH_L2_TUNNEL_ENABLE_MASK,
9921 rte_eth_dev_l2_tunnel_offload_set(res->id,
9923 ETH_L2_TUNNEL_ENABLE_MASK,
9927 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
9928 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
9930 .help_str = "port config l2-tunnel enable/disable",
9932 (void *)&cmd_config_l2_tunnel_en_dis_port,
9933 (void *)&cmd_config_l2_tunnel_en_dis_config,
9934 (void *)&cmd_config_l2_tunnel_en_dis_id,
9935 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
9936 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
9937 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
9942 /* E-tag configuration */
9944 /* Common result structure for all E-tag configuration */
9945 struct cmd_config_e_tag_result {
9946 cmdline_fixed_string_t e_tag;
9947 cmdline_fixed_string_t set;
9948 cmdline_fixed_string_t insertion;
9949 cmdline_fixed_string_t stripping;
9950 cmdline_fixed_string_t forwarding;
9951 cmdline_fixed_string_t filter;
9952 cmdline_fixed_string_t add;
9953 cmdline_fixed_string_t del;
9954 cmdline_fixed_string_t on;
9955 cmdline_fixed_string_t off;
9956 cmdline_fixed_string_t on_off;
9957 cmdline_fixed_string_t port_tag_id;
9958 uint32_t port_tag_id_val;
9959 cmdline_fixed_string_t e_tag_id;
9960 uint16_t e_tag_id_val;
9961 cmdline_fixed_string_t dst_pool;
9962 uint8_t dst_pool_val;
9963 cmdline_fixed_string_t port;
9965 cmdline_fixed_string_t vf;
9969 /* Common CLI fields for all E-tag configuration */
9970 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
9971 TOKEN_STRING_INITIALIZER
9972 (struct cmd_config_e_tag_result,
9974 cmdline_parse_token_string_t cmd_config_e_tag_set =
9975 TOKEN_STRING_INITIALIZER
9976 (struct cmd_config_e_tag_result,
9978 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
9979 TOKEN_STRING_INITIALIZER
9980 (struct cmd_config_e_tag_result,
9981 insertion, "insertion");
9982 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
9983 TOKEN_STRING_INITIALIZER
9984 (struct cmd_config_e_tag_result,
9985 stripping, "stripping");
9986 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
9987 TOKEN_STRING_INITIALIZER
9988 (struct cmd_config_e_tag_result,
9989 forwarding, "forwarding");
9990 cmdline_parse_token_string_t cmd_config_e_tag_filter =
9991 TOKEN_STRING_INITIALIZER
9992 (struct cmd_config_e_tag_result,
9994 cmdline_parse_token_string_t cmd_config_e_tag_add =
9995 TOKEN_STRING_INITIALIZER
9996 (struct cmd_config_e_tag_result,
9998 cmdline_parse_token_string_t cmd_config_e_tag_del =
9999 TOKEN_STRING_INITIALIZER
10000 (struct cmd_config_e_tag_result,
10002 cmdline_parse_token_string_t cmd_config_e_tag_on =
10003 TOKEN_STRING_INITIALIZER
10004 (struct cmd_config_e_tag_result,
10006 cmdline_parse_token_string_t cmd_config_e_tag_off =
10007 TOKEN_STRING_INITIALIZER
10008 (struct cmd_config_e_tag_result,
10010 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10011 TOKEN_STRING_INITIALIZER
10012 (struct cmd_config_e_tag_result,
10014 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10015 TOKEN_STRING_INITIALIZER
10016 (struct cmd_config_e_tag_result,
10017 port_tag_id, "port-tag-id");
10018 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10019 TOKEN_NUM_INITIALIZER
10020 (struct cmd_config_e_tag_result,
10021 port_tag_id_val, UINT32);
10022 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10023 TOKEN_STRING_INITIALIZER
10024 (struct cmd_config_e_tag_result,
10025 e_tag_id, "e-tag-id");
10026 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10027 TOKEN_NUM_INITIALIZER
10028 (struct cmd_config_e_tag_result,
10029 e_tag_id_val, UINT16);
10030 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10031 TOKEN_STRING_INITIALIZER
10032 (struct cmd_config_e_tag_result,
10033 dst_pool, "dst-pool");
10034 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10035 TOKEN_NUM_INITIALIZER
10036 (struct cmd_config_e_tag_result,
10037 dst_pool_val, UINT8);
10038 cmdline_parse_token_string_t cmd_config_e_tag_port =
10039 TOKEN_STRING_INITIALIZER
10040 (struct cmd_config_e_tag_result,
10042 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10043 TOKEN_NUM_INITIALIZER
10044 (struct cmd_config_e_tag_result,
10046 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10047 TOKEN_STRING_INITIALIZER
10048 (struct cmd_config_e_tag_result,
10050 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10051 TOKEN_NUM_INITIALIZER
10052 (struct cmd_config_e_tag_result,
10055 /* E-tag insertion configuration */
10057 cmd_config_e_tag_insertion_en_parsed(
10058 void *parsed_result,
10059 __attribute__((unused)) struct cmdline *cl,
10060 __attribute__((unused)) void *data)
10062 struct cmd_config_e_tag_result *res =
10064 struct rte_eth_l2_tunnel_conf entry;
10066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10069 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10070 entry.tunnel_id = res->port_tag_id_val;
10071 entry.vf_id = res->vf_id;
10072 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10074 ETH_L2_TUNNEL_INSERTION_MASK,
10079 cmd_config_e_tag_insertion_dis_parsed(
10080 void *parsed_result,
10081 __attribute__((unused)) struct cmdline *cl,
10082 __attribute__((unused)) void *data)
10084 struct cmd_config_e_tag_result *res =
10086 struct rte_eth_l2_tunnel_conf entry;
10088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10091 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10092 entry.vf_id = res->vf_id;
10094 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10096 ETH_L2_TUNNEL_INSERTION_MASK,
10100 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10101 .f = cmd_config_e_tag_insertion_en_parsed,
10103 .help_str = "E-tag insertion enable",
10105 (void *)&cmd_config_e_tag_e_tag,
10106 (void *)&cmd_config_e_tag_set,
10107 (void *)&cmd_config_e_tag_insertion,
10108 (void *)&cmd_config_e_tag_on,
10109 (void *)&cmd_config_e_tag_port_tag_id,
10110 (void *)&cmd_config_e_tag_port_tag_id_val,
10111 (void *)&cmd_config_e_tag_port,
10112 (void *)&cmd_config_e_tag_port_id,
10113 (void *)&cmd_config_e_tag_vf,
10114 (void *)&cmd_config_e_tag_vf_id,
10119 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10120 .f = cmd_config_e_tag_insertion_dis_parsed,
10122 .help_str = "E-tag insertion disable",
10124 (void *)&cmd_config_e_tag_e_tag,
10125 (void *)&cmd_config_e_tag_set,
10126 (void *)&cmd_config_e_tag_insertion,
10127 (void *)&cmd_config_e_tag_off,
10128 (void *)&cmd_config_e_tag_port,
10129 (void *)&cmd_config_e_tag_port_id,
10130 (void *)&cmd_config_e_tag_vf,
10131 (void *)&cmd_config_e_tag_vf_id,
10136 /* E-tag stripping configuration */
10138 cmd_config_e_tag_stripping_parsed(
10139 void *parsed_result,
10140 __attribute__((unused)) struct cmdline *cl,
10141 __attribute__((unused)) void *data)
10143 struct cmd_config_e_tag_result *res =
10145 struct rte_eth_l2_tunnel_conf entry;
10147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10150 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10152 if (!strcmp(res->on_off, "on"))
10153 rte_eth_dev_l2_tunnel_offload_set
10156 ETH_L2_TUNNEL_STRIPPING_MASK,
10159 rte_eth_dev_l2_tunnel_offload_set
10162 ETH_L2_TUNNEL_STRIPPING_MASK,
10166 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10167 .f = cmd_config_e_tag_stripping_parsed,
10169 .help_str = "E-tag stripping enable/disable",
10171 (void *)&cmd_config_e_tag_e_tag,
10172 (void *)&cmd_config_e_tag_set,
10173 (void *)&cmd_config_e_tag_stripping,
10174 (void *)&cmd_config_e_tag_on_off,
10175 (void *)&cmd_config_e_tag_port,
10176 (void *)&cmd_config_e_tag_port_id,
10181 /* E-tag forwarding configuration */
10183 cmd_config_e_tag_forwarding_parsed(
10184 void *parsed_result,
10185 __attribute__((unused)) struct cmdline *cl,
10186 __attribute__((unused)) void *data)
10188 struct cmd_config_e_tag_result *res = parsed_result;
10189 struct rte_eth_l2_tunnel_conf entry;
10191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10194 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10196 if (!strcmp(res->on_off, "on"))
10197 rte_eth_dev_l2_tunnel_offload_set
10200 ETH_L2_TUNNEL_FORWARDING_MASK,
10203 rte_eth_dev_l2_tunnel_offload_set
10206 ETH_L2_TUNNEL_FORWARDING_MASK,
10210 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10211 .f = cmd_config_e_tag_forwarding_parsed,
10213 .help_str = "E-tag forwarding enable/disable",
10215 (void *)&cmd_config_e_tag_e_tag,
10216 (void *)&cmd_config_e_tag_set,
10217 (void *)&cmd_config_e_tag_forwarding,
10218 (void *)&cmd_config_e_tag_on_off,
10219 (void *)&cmd_config_e_tag_port,
10220 (void *)&cmd_config_e_tag_port_id,
10225 /* E-tag filter configuration */
10227 cmd_config_e_tag_filter_add_parsed(
10228 void *parsed_result,
10229 __attribute__((unused)) struct cmdline *cl,
10230 __attribute__((unused)) void *data)
10232 struct cmd_config_e_tag_result *res = parsed_result;
10233 struct rte_eth_l2_tunnel_conf entry;
10236 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10239 if (res->e_tag_id_val > 0x3fff) {
10240 printf("e-tag-id must be equal or less than 0x3fff.\n");
10244 ret = rte_eth_dev_filter_supported(res->port_id,
10245 RTE_ETH_FILTER_L2_TUNNEL);
10247 printf("E-tag filter is not supported on port %u.\n",
10252 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10253 entry.tunnel_id = res->e_tag_id_val;
10254 entry.pool = res->dst_pool_val;
10256 ret = rte_eth_dev_filter_ctrl(res->port_id,
10257 RTE_ETH_FILTER_L2_TUNNEL,
10258 RTE_ETH_FILTER_ADD,
10261 printf("E-tag filter programming error: (%s)\n",
10265 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10266 .f = cmd_config_e_tag_filter_add_parsed,
10268 .help_str = "E-tag filter add",
10270 (void *)&cmd_config_e_tag_e_tag,
10271 (void *)&cmd_config_e_tag_set,
10272 (void *)&cmd_config_e_tag_filter,
10273 (void *)&cmd_config_e_tag_add,
10274 (void *)&cmd_config_e_tag_e_tag_id,
10275 (void *)&cmd_config_e_tag_e_tag_id_val,
10276 (void *)&cmd_config_e_tag_dst_pool,
10277 (void *)&cmd_config_e_tag_dst_pool_val,
10278 (void *)&cmd_config_e_tag_port,
10279 (void *)&cmd_config_e_tag_port_id,
10285 cmd_config_e_tag_filter_del_parsed(
10286 void *parsed_result,
10287 __attribute__((unused)) struct cmdline *cl,
10288 __attribute__((unused)) void *data)
10290 struct cmd_config_e_tag_result *res = parsed_result;
10291 struct rte_eth_l2_tunnel_conf entry;
10294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10297 if (res->e_tag_id_val > 0x3fff) {
10298 printf("e-tag-id must be less than 0x3fff.\n");
10302 ret = rte_eth_dev_filter_supported(res->port_id,
10303 RTE_ETH_FILTER_L2_TUNNEL);
10305 printf("E-tag filter is not supported on port %u.\n",
10310 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10311 entry.tunnel_id = res->e_tag_id_val;
10313 ret = rte_eth_dev_filter_ctrl(res->port_id,
10314 RTE_ETH_FILTER_L2_TUNNEL,
10315 RTE_ETH_FILTER_DELETE,
10318 printf("E-tag filter programming error: (%s)\n",
10322 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10323 .f = cmd_config_e_tag_filter_del_parsed,
10325 .help_str = "E-tag filter delete",
10327 (void *)&cmd_config_e_tag_e_tag,
10328 (void *)&cmd_config_e_tag_set,
10329 (void *)&cmd_config_e_tag_filter,
10330 (void *)&cmd_config_e_tag_del,
10331 (void *)&cmd_config_e_tag_e_tag_id,
10332 (void *)&cmd_config_e_tag_e_tag_id_val,
10333 (void *)&cmd_config_e_tag_port,
10334 (void *)&cmd_config_e_tag_port_id,
10339 /* ******************************************************************************** */
10341 /* list of instructions */
10342 cmdline_parse_ctx_t main_ctx[] = {
10343 (cmdline_parse_inst_t *)&cmd_help_brief,
10344 (cmdline_parse_inst_t *)&cmd_help_long,
10345 (cmdline_parse_inst_t *)&cmd_quit,
10346 (cmdline_parse_inst_t *)&cmd_showport,
10347 (cmdline_parse_inst_t *)&cmd_showqueue,
10348 (cmdline_parse_inst_t *)&cmd_showportall,
10349 (cmdline_parse_inst_t *)&cmd_showcfg,
10350 (cmdline_parse_inst_t *)&cmd_start,
10351 (cmdline_parse_inst_t *)&cmd_start_tx_first,
10352 (cmdline_parse_inst_t *)&cmd_set_link_up,
10353 (cmdline_parse_inst_t *)&cmd_set_link_down,
10354 (cmdline_parse_inst_t *)&cmd_reset,
10355 (cmdline_parse_inst_t *)&cmd_set_numbers,
10356 (cmdline_parse_inst_t *)&cmd_set_txpkts,
10357 (cmdline_parse_inst_t *)&cmd_set_txsplit,
10358 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
10359 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
10360 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
10361 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
10362 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
10363 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
10364 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
10365 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
10366 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
10367 (cmdline_parse_inst_t *)&cmd_set_link_check,
10368 #ifdef RTE_NIC_BYPASS
10369 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
10370 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
10371 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
10372 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
10374 #ifdef RTE_LIBRTE_PMD_BOND
10375 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
10376 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
10377 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
10378 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
10379 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
10380 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
10381 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
10382 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
10383 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
10385 (cmdline_parse_inst_t *)&cmd_vlan_offload,
10386 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
10387 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
10388 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
10389 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
10390 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
10391 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
10392 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
10393 (cmdline_parse_inst_t *)&cmd_csum_set,
10394 (cmdline_parse_inst_t *)&cmd_csum_show,
10395 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
10396 (cmdline_parse_inst_t *)&cmd_tso_set,
10397 (cmdline_parse_inst_t *)&cmd_tso_show,
10398 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
10399 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
10400 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
10401 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
10402 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
10403 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
10404 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
10405 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
10406 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
10407 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
10408 (cmdline_parse_inst_t *)&cmd_config_dcb,
10409 (cmdline_parse_inst_t *)&cmd_read_reg,
10410 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
10411 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
10412 (cmdline_parse_inst_t *)&cmd_write_reg,
10413 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
10414 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
10415 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
10416 (cmdline_parse_inst_t *)&cmd_stop,
10417 (cmdline_parse_inst_t *)&cmd_mac_addr,
10418 (cmdline_parse_inst_t *)&cmd_set_qmap,
10419 (cmdline_parse_inst_t *)&cmd_operate_port,
10420 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
10421 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
10422 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
10423 (cmdline_parse_inst_t *)&cmd_config_speed_all,
10424 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
10425 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
10426 (cmdline_parse_inst_t *)&cmd_config_mtu,
10427 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
10428 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
10429 (cmdline_parse_inst_t *)&cmd_config_rss,
10430 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
10431 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
10432 (cmdline_parse_inst_t *)&cmd_showport_reta,
10433 (cmdline_parse_inst_t *)&cmd_config_burst,
10434 (cmdline_parse_inst_t *)&cmd_config_thresh,
10435 (cmdline_parse_inst_t *)&cmd_config_threshold,
10436 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
10437 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
10438 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
10439 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
10440 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
10441 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
10442 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
10443 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
10444 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
10445 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
10446 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
10447 (cmdline_parse_inst_t *)&cmd_global_config,
10448 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
10449 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
10450 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
10451 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
10452 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
10453 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
10454 (cmdline_parse_inst_t *)&cmd_dump,
10455 (cmdline_parse_inst_t *)&cmd_dump_one,
10456 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
10457 (cmdline_parse_inst_t *)&cmd_syn_filter,
10458 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
10459 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
10460 (cmdline_parse_inst_t *)&cmd_flex_filter,
10461 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
10462 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
10463 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
10464 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
10465 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
10466 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
10467 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
10468 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
10469 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
10470 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
10471 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
10472 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
10473 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
10474 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
10475 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
10476 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
10477 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
10478 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
10479 (cmdline_parse_inst_t *)&cmd_mcast_addr,
10480 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
10481 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
10482 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
10483 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
10484 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
10485 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
10486 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
10487 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
10488 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
10489 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
10493 /* prompt function, called from main on MASTER lcore */
10497 /* initialize non-constant commands */
10498 cmd_set_fwd_mode_init();
10500 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
10501 if (testpmd_cl == NULL)
10503 cmdline_interact(testpmd_cl);
10504 cmdline_stdin_exit(testpmd_cl);
10510 if (testpmd_cl != NULL)
10511 cmdline_quit(testpmd_cl);
10515 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
10517 if (id == (portid_t)RTE_PORT_ALL) {
10520 FOREACH_PORT(pid, ports) {
10521 /* check if need_reconfig has been set to 1 */
10522 if (ports[pid].need_reconfig == 0)
10523 ports[pid].need_reconfig = dev;
10524 /* check if need_reconfig_queues has been set to 1 */
10525 if (ports[pid].need_reconfig_queues == 0)
10526 ports[pid].need_reconfig_queues = queue;
10528 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
10529 /* check if need_reconfig has been set to 1 */
10530 if (ports[id].need_reconfig == 0)
10531 ports[id].need_reconfig = dev;
10532 /* check if need_reconfig_queues has been set to 1 */
10533 if (ports[id].need_reconfig_queues == 0)
10534 ports[id].need_reconfig_queues = queue;
10538 #ifdef RTE_NIC_BYPASS
10539 #include <rte_pci_dev_ids.h>
10541 bypass_is_supported(portid_t port_id)
10543 struct rte_port *port;
10544 struct rte_pci_id *pci_id;
10546 if (port_id_is_invalid(port_id, ENABLED_WARN))
10549 /* Get the device id. */
10550 port = &ports[port_id];
10551 pci_id = &port->dev_info.pci_dev->id;
10553 /* Check if NIC supports bypass. */
10554 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
10558 printf("\tBypass not supported for port_id = %d.\n", port_id);