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 tpid (value) (port_id)\n"
281 " Set the outer 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 "rx_vlan set tpid (value) (port_id)\n"
301 " Set the outer VLAN TPID for Packet Filtering on"
304 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
305 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
306 " add a tunnel filter of a port.\n\n"
308 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
309 "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n"
310 " remove a tunnel filter of a port.\n\n"
312 "rx_vxlan_port add (udp_port) (port_id)\n"
313 " Add an UDP port for VXLAN packet filter on a port\n\n"
315 "rx_vxlan_port rm (udp_port) (port_id)\n"
316 " Remove an UDP port for VXLAN packet filter on a port\n\n"
318 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
319 " Set hardware insertion of VLAN IDs (single or double VLAN "
320 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
322 "tx_vlan set pvid port_id vlan_id (on|off)\n"
323 " Set port based TX VLAN insertion.\n\n"
325 "tx_vlan reset (port_id)\n"
326 " Disable hardware insertion of a VLAN header in"
327 " packets sent on a port.\n\n"
329 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
330 " Select hardware or software calculation of the"
331 " checksum when transmitting a packet using the"
332 " csum forward engine.\n"
333 " ip|udp|tcp|sctp always concern the inner layer.\n"
334 " outer-ip concerns the outer IP layer in"
335 " case the packet is recognized as a tunnel packet by"
336 " the forward engine (vxlan, gre and ipip are supported)\n"
337 " Please check the NIC datasheet for HW limits.\n\n"
339 "csum parse-tunnel (on|off) (tx_port_id)\n"
340 " If disabled, treat tunnel packets as non-tunneled"
341 " packets (treat inner headers as payload). The port\n"
342 " argument is the port used for TX in csum forward"
345 "csum show (port_id)\n"
346 " Display tx checksum offload configuration\n\n"
348 "tso set (segsize) (portid)\n"
349 " Enable TCP Segmentation Offload in csum forward"
351 " Please check the NIC datasheet for HW limits.\n\n"
354 " Display the status of TCP Segmentation Offload.\n\n"
357 " Set packet forwarding mode.\n\n"
359 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
360 " Add a MAC address on port_id.\n\n"
362 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
363 " Remove a MAC address from port_id.\n\n"
365 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
366 " Add a MAC address for a VF on the port.\n\n"
368 "set port (port_id) uta (mac_address|all) (on|off)\n"
369 " Add/Remove a or all unicast hash filter(s)"
372 "set promisc (port_id|all) (on|off)\n"
373 " Set the promiscuous mode on port_id, or all.\n\n"
375 "set allmulti (port_id|all) (on|off)\n"
376 " Set the allmulti mode on port_id, or all.\n\n"
378 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
379 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
380 " (on|off) autoneg (on|off) (port_id)\n"
381 "set flow_ctrl rx (on|off) (portid)\n"
382 "set flow_ctrl tx (on|off) (portid)\n"
383 "set flow_ctrl high_water (high_water) (portid)\n"
384 "set flow_ctrl low_water (low_water) (portid)\n"
385 "set flow_ctrl pause_time (pause_time) (portid)\n"
386 "set flow_ctrl send_xon (send_xon) (portid)\n"
387 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
388 "set flow_ctrl autoneg (on|off) (port_id)\n"
389 " Set the link flow control parameter on a port.\n\n"
391 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
392 " (low_water) (pause_time) (priority) (port_id)\n"
393 " Set the priority flow control parameter on a"
396 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
397 " Set statistics mapping (qmapping 0..15) for RX/TX"
399 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
400 " on port 0 to mapping 5.\n\n"
402 "set port (port_id) vf (vf_id) rx|tx on|off\n"
403 " Enable/Disable a VF receive/tranmit from a port\n\n"
405 "set port (port_id) vf (vf_id) (mac_addr)"
406 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
407 " Add/Remove unicast or multicast MAC addr filter"
410 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
412 " AUPE:accepts untagged VLAN;"
413 "ROPE:accept unicast hash\n\n"
414 " BAM:accepts broadcast packets;"
415 "MPE:accepts all multicast packets\n\n"
416 " Enable/Disable a VF receive mode of a port\n\n"
418 "set port (port_id) queue (queue_id) rate (rate_num)\n"
419 " Set rate limit for a queue of a port\n\n"
421 "set port (port_id) vf (vf_id) rate (rate_num) "
422 "queue_mask (queue_mask_value)\n"
423 " Set rate limit for queues in VF of a port\n\n"
425 "set port (port_id) mirror-rule (rule_id)"
426 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
427 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
428 " Set pool or vlan type mirror rule on a port.\n"
429 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
430 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
433 "set port (port_id) mirror-rule (rule_id)"
434 " (uplink-mirror|downlink-mirror) dst-pool"
435 " (pool_id) (on|off)\n"
436 " Set uplink or downlink type mirror rule on a port.\n"
437 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
438 " 0 on' enable mirror income traffic to pool 0.\n\n"
440 "reset port (port_id) mirror-rule (rule_id)\n"
441 " Reset a mirror rule.\n\n"
443 "set flush_rx (on|off)\n"
444 " Flush (default) or don't flush RX streams before"
445 " forwarding. Mainly used with PCAP drivers.\n\n"
447 #ifdef RTE_NIC_BYPASS
448 "set bypass mode (normal|bypass|isolate) (port_id)\n"
449 " Set the bypass mode for the lowest port on bypass enabled"
452 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
453 "mode (normal|bypass|isolate) (port_id)\n"
454 " Set the event required to initiate specified bypass mode for"
455 " the lowest port on a bypass enabled NIC where:\n"
456 " timeout = enable bypass after watchdog timeout.\n"
457 " os_on = enable bypass when OS/board is powered on.\n"
458 " os_off = enable bypass when OS/board is powered off.\n"
459 " power_on = enable bypass when power supply is turned on.\n"
460 " power_off = enable bypass when power supply is turned off."
463 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
464 " Set the bypass watchdog timeout to 'n' seconds"
465 " where 0 = instant.\n\n"
467 "show bypass config (port_id)\n"
468 " Show the bypass configuration for a bypass enabled NIC"
469 " using the lowest port on the NIC.\n\n"
471 #ifdef RTE_LIBRTE_PMD_BOND
472 "create bonded device (mode) (socket)\n"
473 " Create a new bonded device with specific bonding mode and socket.\n\n"
475 "add bonding slave (slave_id) (port_id)\n"
476 " Add a slave device to a bonded device.\n\n"
478 "remove bonding slave (slave_id) (port_id)\n"
479 " Remove a slave device from a bonded device.\n\n"
481 "set bonding mode (value) (port_id)\n"
482 " Set the bonding mode on a bonded device.\n\n"
484 "set bonding primary (slave_id) (port_id)\n"
485 " Set the primary slave for a bonded device.\n\n"
487 "show bonding config (port_id)\n"
488 " Show the bonding config for port_id.\n\n"
490 "set bonding mac_addr (port_id) (address)\n"
491 " Set the MAC address of a bonded device.\n\n"
493 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
494 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
496 "set bonding mon_period (port_id) (value)\n"
497 " Set the bonding link status monitoring polling period in ms.\n\n"
499 "set link-up port (port_id)\n"
500 " Set link up for a port.\n\n"
502 "set link-down port (port_id)\n"
503 " Set link down for a port.\n\n"
505 , list_pkt_forwarding_modes()
509 if (show_all || !strcmp(res->section, "ports")) {
515 "----------------\n\n"
517 "port start (port_id|all)\n"
518 " Start all ports or port_id.\n\n"
520 "port stop (port_id|all)\n"
521 " Stop all ports or port_id.\n\n"
523 "port close (port_id|all)\n"
524 " Close all ports or port_id.\n\n"
526 "port attach (ident)\n"
527 " Attach physical or virtual dev by pci address or virtual device name\n\n"
529 "port detach (port_id)\n"
530 " Detach physical or virtual dev by port_id\n\n"
532 "port config (port_id|all)"
533 " speed (10|100|1000|10000|40000|auto)"
534 " duplex (half|full|auto)\n"
535 " Set speed and duplex for all ports or port_id\n\n"
537 "port config all (rxq|txq|rxd|txd) (value)\n"
538 " Set number for rxq/txq/rxd/txd.\n\n"
540 "port config all max-pkt-len (value)\n"
541 " Set the max packet length.\n\n"
543 "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
544 "hw-vlan-strip|hw-vlan-extend|drop-en)"
546 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
549 "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
550 " Set the RSS mode.\n\n"
552 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
553 " Set the RSS redirection table.\n\n"
555 "port config (port_id) dcb vt (on|off) (traffic_class)"
557 " Set the DCB mode.\n\n"
559 "port config all burst (value)\n"
560 " Set the number of packets per burst.\n\n"
562 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
564 " Set the ring prefetch/host/writeback threshold"
565 " for tx/rx queue.\n\n"
567 "port config all (txfreet|txrst|rxfreet) (value)\n"
568 " Set free threshold for rx/tx, or set"
569 " tx rs bit threshold.\n\n"
570 "port config mtu X value\n"
571 " Set the MTU of port X to a given value\n\n"
573 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
574 " Start/stop a rx/tx queue of port X. Only take effect"
575 " when port X is started\n"
579 if (show_all || !strcmp(res->section, "registers")) {
587 "read reg (port_id) (address)\n"
588 " Display value of a port register.\n\n"
590 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
591 " Display a port register bit field.\n\n"
593 "read regbit (port_id) (address) (bit_x)\n"
594 " Display a single port register bit.\n\n"
596 "write reg (port_id) (address) (value)\n"
597 " Set value of a port register.\n\n"
599 "write regfield (port_id) (address) (bit_x) (bit_y)"
601 " Set bit field of a port register.\n\n"
603 "write regbit (port_id) (address) (bit_x) (value)\n"
604 " Set single bit value of a port register.\n\n"
607 if (show_all || !strcmp(res->section, "filters")) {
615 "ethertype_filter (port_id) (add|del)"
616 " (mac_addr|mac_ignr) (mac_address) ethertype"
617 " (ether_type) (drop|fwd) queue (queue_id)\n"
618 " Add/Del an ethertype filter.\n\n"
620 "2tuple_filter (port_id) (add|del)"
621 " dst_port (dst_port_value) protocol (protocol_value)"
622 " mask (mask_value) tcp_flags (tcp_flags_value)"
623 " priority (prio_value) queue (queue_id)\n"
624 " Add/Del a 2tuple filter.\n\n"
626 "5tuple_filter (port_id) (add|del)"
627 " dst_ip (dst_address) src_ip (src_address)"
628 " dst_port (dst_port_value) src_port (src_port_value)"
629 " protocol (protocol_value)"
630 " mask (mask_value) tcp_flags (tcp_flags_value)"
631 " priority (prio_value) queue (queue_id)\n"
632 " Add/Del a 5tuple filter.\n\n"
634 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
635 " Add/Del syn filter.\n\n"
637 "flex_filter (port_id) (add|del) len (len_value)"
638 " bytes (bytes_value) mask (mask_value)"
639 " priority (prio_value) queue (queue_id)\n"
640 " Add/Del a flex filter.\n\n"
642 "flow_director_filter (port_id) mode IP (add|del|update)"
643 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
644 " src (src_ip_address) dst (dst_ip_address)"
645 " vlan (vlan_value) flexbytes (flexbytes_value)"
646 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
647 " fd_id (fd_id_value)\n"
648 " Add/Del an IP type flow director filter.\n\n"
650 "flow_director_filter (port_id) mode IP (add|del|update)"
651 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
652 " src (src_ip_address) (src_port)"
653 " dst (dst_ip_address) (dst_port)"
654 " vlan (vlan_value) flexbytes (flexbytes_value)"
655 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
656 " fd_id (fd_id_value)\n"
657 " Add/Del an UDP/TCP type flow director filter.\n\n"
659 "flow_director_filter (port_id) mode IP (add|del|update)"
660 " flow (ipv4-sctp|ipv6-sctp)"
661 " src (src_ip_address) (src_port)"
662 " dst (dst_ip_address) (dst_port)"
663 " tag (verification_tag) vlan (vlan_value)"
664 " flexbytes (flexbytes_value) (drop|fwd)"
665 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
666 " Add/Del a SCTP type flow director filter.\n\n"
668 "flow_director_filter (port_id) mode IP (add|del|update)"
669 " flow l2_payload ether (ethertype)"
670 " flexbytes (flexbytes_value) (drop|fwd)"
671 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
672 " Add/Del a l2 payload type flow director filter.\n\n"
674 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
675 " mac (mac_address) vlan (vlan_value)"
676 " flexbytes (flexbytes_value) (drop|fwd)"
677 " queue (queue_id) fd_id (fd_id_value)\n"
678 " Add/Del a MAC-VLAN flow director filter.\n\n"
680 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
681 " mac (mac_address) vlan (vlan_value)"
682 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
683 " flexbytes (flexbytes_value) (drop|fwd)"
684 " queue (queue_id) fd_id (fd_id_value)\n"
685 " Add/Del a Tunnel flow director filter.\n\n"
687 "flush_flow_director (port_id)\n"
688 " Flush all flow director entries of a device.\n\n"
690 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
691 " src_mask (ipv4_src) (ipv6_src) (src_port)"
692 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
693 " Set flow director IP mask.\n\n"
695 "flow_director_mask (port_id) mode MAC-VLAN"
696 " vlan (vlan_value) mac (mac_value)\n"
697 " Set flow director MAC-VLAN mask.\n\n"
699 "flow_director_mask (port_id) mode Tunnel"
700 " vlan (vlan_value) mac (mac_value)"
701 " tunnel-type (tunnel_type_value)"
702 " tunnel-id (tunnel_id_value)\n"
703 " Set flow director Tunnel mask.\n\n"
705 "flow_director_flex_mask (port_id)"
706 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
707 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
709 " Configure mask of flex payload.\n\n"
711 "flow_director_flex_payload (port_id)"
712 " (raw|l2|l3|l4) (config)\n"
713 " Configure flex payload selection.\n\n"
715 "get_sym_hash_ena_per_port (port_id)\n"
716 " get symmetric hash enable configuration per port.\n\n"
718 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
719 " set symmetric hash enable configuration per port"
720 " to enable or disable.\n\n"
722 "get_hash_global_config (port_id)\n"
723 " Get the global configurations of hash filters.\n\n"
725 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
726 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
727 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
728 " (enable|disable)\n"
729 " Set the global configurations of hash filters.\n\n"
731 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
732 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
733 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
734 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
735 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
736 "ipv6-next-header|udp-src-port|udp-dst-port|"
737 "tcp-src-port|tcp-dst-port|sctp-src-port|"
738 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
739 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
740 "fld-8th|none) (select|add)\n"
741 " Set the input set for hash.\n\n"
743 "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
744 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
745 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
746 "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
747 "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
748 "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
749 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
750 "fld-8th|none) (select|add)\n"
751 " Set the input set for FDir.\n\n"
756 cmdline_parse_token_string_t cmd_help_long_help =
757 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
759 cmdline_parse_token_string_t cmd_help_long_section =
760 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
761 "all#control#display#config#"
762 "ports#registers#filters");
764 cmdline_parse_inst_t cmd_help_long = {
765 .f = cmd_help_long_parsed,
767 .help_str = "show help",
769 (void *)&cmd_help_long_help,
770 (void *)&cmd_help_long_section,
776 /* *** start/stop/close all ports *** */
777 struct cmd_operate_port_result {
778 cmdline_fixed_string_t keyword;
779 cmdline_fixed_string_t name;
780 cmdline_fixed_string_t value;
783 static void cmd_operate_port_parsed(void *parsed_result,
784 __attribute__((unused)) struct cmdline *cl,
785 __attribute__((unused)) void *data)
787 struct cmd_operate_port_result *res = parsed_result;
789 if (!strcmp(res->name, "start"))
790 start_port(RTE_PORT_ALL);
791 else if (!strcmp(res->name, "stop"))
792 stop_port(RTE_PORT_ALL);
793 else if (!strcmp(res->name, "close"))
794 close_port(RTE_PORT_ALL);
796 printf("Unknown parameter\n");
799 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
800 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
802 cmdline_parse_token_string_t cmd_operate_port_all_port =
803 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
805 cmdline_parse_token_string_t cmd_operate_port_all_all =
806 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
808 cmdline_parse_inst_t cmd_operate_port = {
809 .f = cmd_operate_port_parsed,
811 .help_str = "port start|stop|close all: start/stop/close all ports",
813 (void *)&cmd_operate_port_all_cmd,
814 (void *)&cmd_operate_port_all_port,
815 (void *)&cmd_operate_port_all_all,
820 /* *** start/stop/close specific port *** */
821 struct cmd_operate_specific_port_result {
822 cmdline_fixed_string_t keyword;
823 cmdline_fixed_string_t name;
827 static void cmd_operate_specific_port_parsed(void *parsed_result,
828 __attribute__((unused)) struct cmdline *cl,
829 __attribute__((unused)) void *data)
831 struct cmd_operate_specific_port_result *res = parsed_result;
833 if (!strcmp(res->name, "start"))
834 start_port(res->value);
835 else if (!strcmp(res->name, "stop"))
836 stop_port(res->value);
837 else if (!strcmp(res->name, "close"))
838 close_port(res->value);
840 printf("Unknown parameter\n");
843 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
844 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
846 cmdline_parse_token_string_t cmd_operate_specific_port_port =
847 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
848 name, "start#stop#close");
849 cmdline_parse_token_num_t cmd_operate_specific_port_id =
850 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
853 cmdline_parse_inst_t cmd_operate_specific_port = {
854 .f = cmd_operate_specific_port_parsed,
856 .help_str = "port start|stop|close X: start/stop/close port X",
858 (void *)&cmd_operate_specific_port_cmd,
859 (void *)&cmd_operate_specific_port_port,
860 (void *)&cmd_operate_specific_port_id,
865 /* *** attach a specified port *** */
866 struct cmd_operate_attach_port_result {
867 cmdline_fixed_string_t port;
868 cmdline_fixed_string_t keyword;
869 cmdline_fixed_string_t identifier;
872 static void cmd_operate_attach_port_parsed(void *parsed_result,
873 __attribute__((unused)) struct cmdline *cl,
874 __attribute__((unused)) void *data)
876 struct cmd_operate_attach_port_result *res = parsed_result;
878 if (!strcmp(res->keyword, "attach"))
879 attach_port(res->identifier);
881 printf("Unknown parameter\n");
884 cmdline_parse_token_string_t cmd_operate_attach_port_port =
885 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
887 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
888 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
890 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
891 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
894 cmdline_parse_inst_t cmd_operate_attach_port = {
895 .f = cmd_operate_attach_port_parsed,
897 .help_str = "port attach identifier, "
898 "identifier: pci address or virtual dev name",
900 (void *)&cmd_operate_attach_port_port,
901 (void *)&cmd_operate_attach_port_keyword,
902 (void *)&cmd_operate_attach_port_identifier,
907 /* *** detach a specified port *** */
908 struct cmd_operate_detach_port_result {
909 cmdline_fixed_string_t port;
910 cmdline_fixed_string_t keyword;
914 static void cmd_operate_detach_port_parsed(void *parsed_result,
915 __attribute__((unused)) struct cmdline *cl,
916 __attribute__((unused)) void *data)
918 struct cmd_operate_detach_port_result *res = parsed_result;
920 if (!strcmp(res->keyword, "detach"))
921 detach_port(res->port_id);
923 printf("Unknown parameter\n");
926 cmdline_parse_token_string_t cmd_operate_detach_port_port =
927 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
929 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
930 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
932 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
933 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
936 cmdline_parse_inst_t cmd_operate_detach_port = {
937 .f = cmd_operate_detach_port_parsed,
939 .help_str = "port detach port_id",
941 (void *)&cmd_operate_detach_port_port,
942 (void *)&cmd_operate_detach_port_keyword,
943 (void *)&cmd_operate_detach_port_port_id,
948 /* *** configure speed for all ports *** */
949 struct cmd_config_speed_all {
950 cmdline_fixed_string_t port;
951 cmdline_fixed_string_t keyword;
952 cmdline_fixed_string_t all;
953 cmdline_fixed_string_t item1;
954 cmdline_fixed_string_t item2;
955 cmdline_fixed_string_t value1;
956 cmdline_fixed_string_t value2;
960 cmd_config_speed_all_parsed(void *parsed_result,
961 __attribute__((unused)) struct cmdline *cl,
962 __attribute__((unused)) void *data)
964 struct cmd_config_speed_all *res = parsed_result;
965 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
966 uint16_t link_duplex = 0;
969 if (!all_ports_stopped()) {
970 printf("Please stop all ports first\n");
974 if (!strcmp(res->value1, "10"))
975 link_speed = ETH_LINK_SPEED_10;
976 else if (!strcmp(res->value1, "100"))
977 link_speed = ETH_LINK_SPEED_100;
978 else if (!strcmp(res->value1, "1000"))
979 link_speed = ETH_LINK_SPEED_1000;
980 else if (!strcmp(res->value1, "10000"))
981 link_speed = ETH_LINK_SPEED_10G;
982 else if (!strcmp(res->value1, "40000"))
983 link_speed = ETH_LINK_SPEED_40G;
984 else if (!strcmp(res->value1, "auto"))
985 link_speed = ETH_LINK_SPEED_AUTONEG;
987 printf("Unknown parameter\n");
991 if (!strcmp(res->value2, "half"))
992 link_duplex = ETH_LINK_HALF_DUPLEX;
993 else if (!strcmp(res->value2, "full"))
994 link_duplex = ETH_LINK_FULL_DUPLEX;
995 else if (!strcmp(res->value2, "auto"))
996 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
998 printf("Unknown parameter\n");
1002 FOREACH_PORT(pid, ports) {
1003 ports[pid].dev_conf.link_speed = link_speed;
1004 ports[pid].dev_conf.link_duplex = link_duplex;
1007 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1010 cmdline_parse_token_string_t cmd_config_speed_all_port =
1011 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1012 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1013 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1015 cmdline_parse_token_string_t cmd_config_speed_all_all =
1016 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1017 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1018 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1019 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1020 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1021 "10#100#1000#10000#40000#auto");
1022 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1023 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1024 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1025 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1028 cmdline_parse_inst_t cmd_config_speed_all = {
1029 .f = cmd_config_speed_all_parsed,
1031 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
1034 (void *)&cmd_config_speed_all_port,
1035 (void *)&cmd_config_speed_all_keyword,
1036 (void *)&cmd_config_speed_all_all,
1037 (void *)&cmd_config_speed_all_item1,
1038 (void *)&cmd_config_speed_all_value1,
1039 (void *)&cmd_config_speed_all_item2,
1040 (void *)&cmd_config_speed_all_value2,
1045 /* *** configure speed for specific port *** */
1046 struct cmd_config_speed_specific {
1047 cmdline_fixed_string_t port;
1048 cmdline_fixed_string_t keyword;
1050 cmdline_fixed_string_t item1;
1051 cmdline_fixed_string_t item2;
1052 cmdline_fixed_string_t value1;
1053 cmdline_fixed_string_t value2;
1057 cmd_config_speed_specific_parsed(void *parsed_result,
1058 __attribute__((unused)) struct cmdline *cl,
1059 __attribute__((unused)) void *data)
1061 struct cmd_config_speed_specific *res = parsed_result;
1062 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
1063 uint16_t link_duplex = 0;
1065 if (!all_ports_stopped()) {
1066 printf("Please stop all ports first\n");
1070 if (port_id_is_invalid(res->id, ENABLED_WARN))
1073 if (!strcmp(res->value1, "10"))
1074 link_speed = ETH_LINK_SPEED_10;
1075 else if (!strcmp(res->value1, "100"))
1076 link_speed = ETH_LINK_SPEED_100;
1077 else if (!strcmp(res->value1, "1000"))
1078 link_speed = ETH_LINK_SPEED_1000;
1079 else if (!strcmp(res->value1, "10000"))
1080 link_speed = ETH_LINK_SPEED_10000;
1081 else if (!strcmp(res->value1, "40000"))
1082 link_speed = ETH_LINK_SPEED_40G;
1083 else if (!strcmp(res->value1, "auto"))
1084 link_speed = ETH_LINK_SPEED_AUTONEG;
1086 printf("Unknown parameter\n");
1090 if (!strcmp(res->value2, "half"))
1091 link_duplex = ETH_LINK_HALF_DUPLEX;
1092 else if (!strcmp(res->value2, "full"))
1093 link_duplex = ETH_LINK_FULL_DUPLEX;
1094 else if (!strcmp(res->value2, "auto"))
1095 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
1097 printf("Unknown parameter\n");
1101 ports[res->id].dev_conf.link_speed = link_speed;
1102 ports[res->id].dev_conf.link_duplex = link_duplex;
1104 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1108 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1109 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1111 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1114 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1115 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1116 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1117 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1119 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1120 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1121 "10#100#1000#10000#40000#auto");
1122 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1123 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1125 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1126 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1129 cmdline_parse_inst_t cmd_config_speed_specific = {
1130 .f = cmd_config_speed_specific_parsed,
1132 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1135 (void *)&cmd_config_speed_specific_port,
1136 (void *)&cmd_config_speed_specific_keyword,
1137 (void *)&cmd_config_speed_specific_id,
1138 (void *)&cmd_config_speed_specific_item1,
1139 (void *)&cmd_config_speed_specific_value1,
1140 (void *)&cmd_config_speed_specific_item2,
1141 (void *)&cmd_config_speed_specific_value2,
1146 /* *** configure txq/rxq, txd/rxd *** */
1147 struct cmd_config_rx_tx {
1148 cmdline_fixed_string_t port;
1149 cmdline_fixed_string_t keyword;
1150 cmdline_fixed_string_t all;
1151 cmdline_fixed_string_t name;
1156 cmd_config_rx_tx_parsed(void *parsed_result,
1157 __attribute__((unused)) struct cmdline *cl,
1158 __attribute__((unused)) void *data)
1160 struct cmd_config_rx_tx *res = parsed_result;
1162 if (!all_ports_stopped()) {
1163 printf("Please stop all ports first\n");
1167 if (!strcmp(res->name, "rxq")) {
1168 if (res->value <= 0) {
1169 printf("rxq %d invalid - must be > 0\n", res->value);
1172 nb_rxq = res->value;
1174 else if (!strcmp(res->name, "txq")) {
1175 if (res->value <= 0) {
1176 printf("txq %d invalid - must be > 0\n", res->value);
1179 nb_txq = res->value;
1181 else if (!strcmp(res->name, "rxd")) {
1182 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1183 printf("rxd %d invalid - must be > 0 && <= %d\n",
1184 res->value, RTE_TEST_RX_DESC_MAX);
1187 nb_rxd = res->value;
1188 } else if (!strcmp(res->name, "txd")) {
1189 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1190 printf("txd %d invalid - must be > 0 && <= %d\n",
1191 res->value, RTE_TEST_TX_DESC_MAX);
1194 nb_txd = res->value;
1196 printf("Unknown parameter\n");
1202 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1205 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1206 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1207 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1208 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1209 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1210 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1211 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1212 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1214 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1215 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1217 cmdline_parse_inst_t cmd_config_rx_tx = {
1218 .f = cmd_config_rx_tx_parsed,
1220 .help_str = "port config all rxq|txq|rxd|txd value",
1222 (void *)&cmd_config_rx_tx_port,
1223 (void *)&cmd_config_rx_tx_keyword,
1224 (void *)&cmd_config_rx_tx_all,
1225 (void *)&cmd_config_rx_tx_name,
1226 (void *)&cmd_config_rx_tx_value,
1231 /* *** config max packet length *** */
1232 struct cmd_config_max_pkt_len_result {
1233 cmdline_fixed_string_t port;
1234 cmdline_fixed_string_t keyword;
1235 cmdline_fixed_string_t all;
1236 cmdline_fixed_string_t name;
1241 cmd_config_max_pkt_len_parsed(void *parsed_result,
1242 __attribute__((unused)) struct cmdline *cl,
1243 __attribute__((unused)) void *data)
1245 struct cmd_config_max_pkt_len_result *res = parsed_result;
1247 if (!all_ports_stopped()) {
1248 printf("Please stop all ports first\n");
1252 if (!strcmp(res->name, "max-pkt-len")) {
1253 if (res->value < ETHER_MIN_LEN) {
1254 printf("max-pkt-len can not be less than %d\n",
1258 if (res->value == rx_mode.max_rx_pkt_len)
1261 rx_mode.max_rx_pkt_len = res->value;
1262 if (res->value > ETHER_MAX_LEN)
1263 rx_mode.jumbo_frame = 1;
1265 rx_mode.jumbo_frame = 0;
1267 printf("Unknown parameter\n");
1273 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1276 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1279 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1280 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1282 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1285 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1286 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1288 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1289 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1292 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1293 .f = cmd_config_max_pkt_len_parsed,
1295 .help_str = "port config all max-pkt-len value",
1297 (void *)&cmd_config_max_pkt_len_port,
1298 (void *)&cmd_config_max_pkt_len_keyword,
1299 (void *)&cmd_config_max_pkt_len_all,
1300 (void *)&cmd_config_max_pkt_len_name,
1301 (void *)&cmd_config_max_pkt_len_value,
1306 /* *** configure port MTU *** */
1307 struct cmd_config_mtu_result {
1308 cmdline_fixed_string_t port;
1309 cmdline_fixed_string_t keyword;
1310 cmdline_fixed_string_t mtu;
1316 cmd_config_mtu_parsed(void *parsed_result,
1317 __attribute__((unused)) struct cmdline *cl,
1318 __attribute__((unused)) void *data)
1320 struct cmd_config_mtu_result *res = parsed_result;
1322 if (res->value < ETHER_MIN_LEN) {
1323 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1326 port_mtu_set(res->port_id, res->value);
1329 cmdline_parse_token_string_t cmd_config_mtu_port =
1330 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1332 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1333 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1335 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1338 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1339 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1340 cmdline_parse_token_num_t cmd_config_mtu_value =
1341 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1343 cmdline_parse_inst_t cmd_config_mtu = {
1344 .f = cmd_config_mtu_parsed,
1346 .help_str = "port config mtu value",
1348 (void *)&cmd_config_mtu_port,
1349 (void *)&cmd_config_mtu_keyword,
1350 (void *)&cmd_config_mtu_mtu,
1351 (void *)&cmd_config_mtu_port_id,
1352 (void *)&cmd_config_mtu_value,
1357 /* *** configure rx mode *** */
1358 struct cmd_config_rx_mode_flag {
1359 cmdline_fixed_string_t port;
1360 cmdline_fixed_string_t keyword;
1361 cmdline_fixed_string_t all;
1362 cmdline_fixed_string_t name;
1363 cmdline_fixed_string_t value;
1367 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1368 __attribute__((unused)) struct cmdline *cl,
1369 __attribute__((unused)) void *data)
1371 struct cmd_config_rx_mode_flag *res = parsed_result;
1373 if (!all_ports_stopped()) {
1374 printf("Please stop all ports first\n");
1378 if (!strcmp(res->name, "crc-strip")) {
1379 if (!strcmp(res->value, "on"))
1380 rx_mode.hw_strip_crc = 1;
1381 else if (!strcmp(res->value, "off"))
1382 rx_mode.hw_strip_crc = 0;
1384 printf("Unknown parameter\n");
1387 } else if (!strcmp(res->name, "rx-cksum")) {
1388 if (!strcmp(res->value, "on"))
1389 rx_mode.hw_ip_checksum = 1;
1390 else if (!strcmp(res->value, "off"))
1391 rx_mode.hw_ip_checksum = 0;
1393 printf("Unknown parameter\n");
1396 } else if (!strcmp(res->name, "hw-vlan")) {
1397 if (!strcmp(res->value, "on")) {
1398 rx_mode.hw_vlan_filter = 1;
1399 rx_mode.hw_vlan_strip = 1;
1401 else if (!strcmp(res->value, "off")) {
1402 rx_mode.hw_vlan_filter = 0;
1403 rx_mode.hw_vlan_strip = 0;
1406 printf("Unknown parameter\n");
1409 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1410 if (!strcmp(res->value, "on"))
1411 rx_mode.hw_vlan_filter = 1;
1412 else if (!strcmp(res->value, "off"))
1413 rx_mode.hw_vlan_filter = 0;
1415 printf("Unknown parameter\n");
1418 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1419 if (!strcmp(res->value, "on"))
1420 rx_mode.hw_vlan_strip = 1;
1421 else if (!strcmp(res->value, "off"))
1422 rx_mode.hw_vlan_strip = 0;
1424 printf("Unknown parameter\n");
1427 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1428 if (!strcmp(res->value, "on"))
1429 rx_mode.hw_vlan_extend = 1;
1430 else if (!strcmp(res->value, "off"))
1431 rx_mode.hw_vlan_extend = 0;
1433 printf("Unknown parameter\n");
1436 } else if (!strcmp(res->name, "drop-en")) {
1437 if (!strcmp(res->value, "on"))
1439 else if (!strcmp(res->value, "off"))
1442 printf("Unknown parameter\n");
1446 printf("Unknown parameter\n");
1452 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1455 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1456 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1457 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1460 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1462 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1464 "crc-strip#rx-cksum#hw-vlan#"
1465 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1466 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1467 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1470 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1471 .f = cmd_config_rx_mode_flag_parsed,
1473 .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
1474 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1476 (void *)&cmd_config_rx_mode_flag_port,
1477 (void *)&cmd_config_rx_mode_flag_keyword,
1478 (void *)&cmd_config_rx_mode_flag_all,
1479 (void *)&cmd_config_rx_mode_flag_name,
1480 (void *)&cmd_config_rx_mode_flag_value,
1485 /* *** configure rss *** */
1486 struct cmd_config_rss {
1487 cmdline_fixed_string_t port;
1488 cmdline_fixed_string_t keyword;
1489 cmdline_fixed_string_t all;
1490 cmdline_fixed_string_t name;
1491 cmdline_fixed_string_t value;
1495 cmd_config_rss_parsed(void *parsed_result,
1496 __attribute__((unused)) struct cmdline *cl,
1497 __attribute__((unused)) void *data)
1499 struct cmd_config_rss *res = parsed_result;
1500 struct rte_eth_rss_conf rss_conf;
1503 if (!strcmp(res->value, "all"))
1504 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1505 ETH_RSS_UDP | ETH_RSS_SCTP |
1507 else if (!strcmp(res->value, "ip"))
1508 rss_conf.rss_hf = ETH_RSS_IP;
1509 else if (!strcmp(res->value, "udp"))
1510 rss_conf.rss_hf = ETH_RSS_UDP;
1511 else if (!strcmp(res->value, "tcp"))
1512 rss_conf.rss_hf = ETH_RSS_TCP;
1513 else if (!strcmp(res->value, "sctp"))
1514 rss_conf.rss_hf = ETH_RSS_SCTP;
1515 else if (!strcmp(res->value, "ether"))
1516 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1517 else if (!strcmp(res->value, "none"))
1518 rss_conf.rss_hf = 0;
1520 printf("Unknown parameter\n");
1523 rss_conf.rss_key = NULL;
1524 for (i = 0; i < rte_eth_dev_count(); i++)
1525 rte_eth_dev_rss_hash_update(i, &rss_conf);
1528 cmdline_parse_token_string_t cmd_config_rss_port =
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1530 cmdline_parse_token_string_t cmd_config_rss_keyword =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1532 cmdline_parse_token_string_t cmd_config_rss_all =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1534 cmdline_parse_token_string_t cmd_config_rss_name =
1535 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1536 cmdline_parse_token_string_t cmd_config_rss_value =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1538 "all#ip#tcp#udp#sctp#ether#none");
1540 cmdline_parse_inst_t cmd_config_rss = {
1541 .f = cmd_config_rss_parsed,
1543 .help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
1545 (void *)&cmd_config_rss_port,
1546 (void *)&cmd_config_rss_keyword,
1547 (void *)&cmd_config_rss_all,
1548 (void *)&cmd_config_rss_name,
1549 (void *)&cmd_config_rss_value,
1554 /* *** configure rss hash key *** */
1555 struct cmd_config_rss_hash_key {
1556 cmdline_fixed_string_t port;
1557 cmdline_fixed_string_t config;
1559 cmdline_fixed_string_t rss_hash_key;
1560 cmdline_fixed_string_t rss_type;
1561 cmdline_fixed_string_t key;
1564 #define RSS_HASH_KEY_LENGTH 40
1566 hexa_digit_to_value(char hexa_digit)
1568 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1569 return (uint8_t) (hexa_digit - '0');
1570 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1571 return (uint8_t) ((hexa_digit - 'a') + 10);
1572 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1573 return (uint8_t) ((hexa_digit - 'A') + 10);
1574 /* Invalid hexa digit */
1579 parse_and_check_key_hexa_digit(char *key, int idx)
1583 hexa_v = hexa_digit_to_value(key[idx]);
1585 printf("invalid key: character %c at position %d is not a "
1586 "valid hexa digit\n", key[idx], idx);
1591 cmd_config_rss_hash_key_parsed(void *parsed_result,
1592 __attribute__((unused)) struct cmdline *cl,
1593 __attribute__((unused)) void *data)
1595 struct cmd_config_rss_hash_key *res = parsed_result;
1596 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1601 /* Check the length of the RSS hash key */
1602 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1603 printf("key length: %d invalid - key must be a string of %d"
1604 "hexa-decimal numbers\n", (int) strlen(res->key),
1605 RSS_HASH_KEY_LENGTH * 2);
1608 /* Translate RSS hash key into binary representation */
1609 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1610 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1613 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1616 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1618 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1619 RSS_HASH_KEY_LENGTH);
1622 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1624 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1627 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1628 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1629 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1630 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1631 rss_hash_key, "rss-hash-key");
1632 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1634 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1635 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1636 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1637 "ipv6-tcp-ex#ipv6-udp-ex");
1638 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1641 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1642 .f = cmd_config_rss_hash_key_parsed,
1645 "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
1646 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
1647 "ipv6-sctp|ipv6-other|l2-payload|"
1648 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
1650 (void *)&cmd_config_rss_hash_key_port,
1651 (void *)&cmd_config_rss_hash_key_config,
1652 (void *)&cmd_config_rss_hash_key_port_id,
1653 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1654 (void *)&cmd_config_rss_hash_key_rss_type,
1655 (void *)&cmd_config_rss_hash_key_value,
1660 /* *** configure port rxq/txq start/stop *** */
1661 struct cmd_config_rxtx_queue {
1662 cmdline_fixed_string_t port;
1664 cmdline_fixed_string_t rxtxq;
1666 cmdline_fixed_string_t opname;
1670 cmd_config_rxtx_queue_parsed(void *parsed_result,
1671 __attribute__((unused)) struct cmdline *cl,
1672 __attribute__((unused)) void *data)
1674 struct cmd_config_rxtx_queue *res = parsed_result;
1679 if (test_done == 0) {
1680 printf("Please stop forwarding first\n");
1684 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1687 if (port_is_started(res->portid) != 1) {
1688 printf("Please start port %u first\n", res->portid);
1692 if (!strcmp(res->rxtxq, "rxq"))
1694 else if (!strcmp(res->rxtxq, "txq"))
1697 printf("Unknown parameter\n");
1701 if (isrx && rx_queue_id_is_invalid(res->qid))
1703 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1706 if (!strcmp(res->opname, "start"))
1708 else if (!strcmp(res->opname, "stop"))
1711 printf("Unknown parameter\n");
1715 if (isstart && isrx)
1716 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1717 else if (!isstart && isrx)
1718 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1719 else if (isstart && !isrx)
1720 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1722 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1724 if (ret == -ENOTSUP)
1725 printf("Function not supported in PMD driver\n");
1728 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1730 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1731 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1732 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1734 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1735 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1736 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1740 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1741 .f = cmd_config_rxtx_queue_parsed,
1743 .help_str = "port X rxq|txq ID start|stop",
1745 (void *)&cmd_config_speed_all_port,
1746 (void *)&cmd_config_rxtx_queue_portid,
1747 (void *)&cmd_config_rxtx_queue_rxtxq,
1748 (void *)&cmd_config_rxtx_queue_qid,
1749 (void *)&cmd_config_rxtx_queue_opname,
1754 /* *** Configure RSS RETA *** */
1755 struct cmd_config_rss_reta {
1756 cmdline_fixed_string_t port;
1757 cmdline_fixed_string_t keyword;
1759 cmdline_fixed_string_t name;
1760 cmdline_fixed_string_t list_name;
1761 cmdline_fixed_string_t list_of_items;
1765 parse_reta_config(const char *str,
1766 struct rte_eth_rss_reta_entry64 *reta_conf,
1767 uint16_t nb_entries)
1771 uint16_t hash_index, idx, shift;
1774 const char *p, *p0 = str;
1781 unsigned long int_fld[_NUM_FLD];
1782 char *str_fld[_NUM_FLD];
1784 while ((p = strchr(p0,'(')) != NULL) {
1786 if((p0 = strchr(p,')')) == NULL)
1790 if(size >= sizeof(s))
1793 snprintf(s, sizeof(s), "%.*s", size, p);
1794 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1796 for (i = 0; i < _NUM_FLD; i++) {
1798 int_fld[i] = strtoul(str_fld[i], &end, 0);
1799 if (errno != 0 || end == str_fld[i] ||
1804 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1805 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1807 if (hash_index >= nb_entries) {
1808 printf("Invalid RETA hash index=%d\n", hash_index);
1812 idx = hash_index / RTE_RETA_GROUP_SIZE;
1813 shift = hash_index % RTE_RETA_GROUP_SIZE;
1814 reta_conf[idx].mask |= (1ULL << shift);
1815 reta_conf[idx].reta[shift] = nb_queue;
1822 cmd_set_rss_reta_parsed(void *parsed_result,
1823 __attribute__((unused)) struct cmdline *cl,
1824 __attribute__((unused)) void *data)
1827 struct rte_eth_dev_info dev_info;
1828 struct rte_eth_rss_reta_entry64 reta_conf[8];
1829 struct cmd_config_rss_reta *res = parsed_result;
1831 memset(&dev_info, 0, sizeof(dev_info));
1832 rte_eth_dev_info_get(res->port_id, &dev_info);
1833 if (dev_info.reta_size == 0) {
1834 printf("Redirection table size is 0 which is "
1835 "invalid for RSS\n");
1838 printf("The reta size of port %d is %u\n",
1839 res->port_id, dev_info.reta_size);
1840 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1841 printf("Currently do not support more than %u entries of "
1842 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1846 memset(reta_conf, 0, sizeof(reta_conf));
1847 if (!strcmp(res->list_name, "reta")) {
1848 if (parse_reta_config(res->list_of_items, reta_conf,
1849 dev_info.reta_size)) {
1850 printf("Invalid RSS Redirection Table "
1851 "config entered\n");
1854 ret = rte_eth_dev_rss_reta_update(res->port_id,
1855 reta_conf, dev_info.reta_size);
1857 printf("Bad redirection table parameter, "
1858 "return code = %d \n", ret);
1862 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1864 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1866 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1867 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1868 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1870 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1871 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1872 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1875 cmdline_parse_inst_t cmd_config_rss_reta = {
1876 .f = cmd_set_rss_reta_parsed,
1878 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1880 (void *)&cmd_config_rss_reta_port,
1881 (void *)&cmd_config_rss_reta_keyword,
1882 (void *)&cmd_config_rss_reta_port_id,
1883 (void *)&cmd_config_rss_reta_name,
1884 (void *)&cmd_config_rss_reta_list_name,
1885 (void *)&cmd_config_rss_reta_list_of_items,
1890 /* *** SHOW PORT RETA INFO *** */
1891 struct cmd_showport_reta {
1892 cmdline_fixed_string_t show;
1893 cmdline_fixed_string_t port;
1895 cmdline_fixed_string_t rss;
1896 cmdline_fixed_string_t reta;
1898 cmdline_fixed_string_t list_of_items;
1902 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1903 uint16_t nb_entries,
1907 const char *p, *p0 = str;
1911 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1914 p = strchr(p0, '(');
1918 p0 = strchr(p, ')');
1922 if (size >= sizeof(s)) {
1923 printf("The string size exceeds the internal buffer size\n");
1926 snprintf(s, sizeof(s), "%.*s", size, p);
1927 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1928 if (ret <= 0 || ret != num) {
1929 printf("The bits of masks do not match the number of "
1930 "reta entries: %u\n", num);
1933 for (i = 0; i < ret; i++)
1934 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1940 cmd_showport_reta_parsed(void *parsed_result,
1941 __attribute__((unused)) struct cmdline *cl,
1942 __attribute__((unused)) void *data)
1944 struct cmd_showport_reta *res = parsed_result;
1945 struct rte_eth_rss_reta_entry64 reta_conf[8];
1946 struct rte_eth_dev_info dev_info;
1948 memset(&dev_info, 0, sizeof(dev_info));
1949 rte_eth_dev_info_get(res->port_id, &dev_info);
1950 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1951 res->size > ETH_RSS_RETA_SIZE_512) {
1952 printf("Invalid redirection table size: %u\n", res->size);
1956 memset(reta_conf, 0, sizeof(reta_conf));
1957 if (showport_parse_reta_config(reta_conf, res->size,
1958 res->list_of_items) < 0) {
1959 printf("Invalid string: %s for reta masks\n",
1960 res->list_of_items);
1963 port_rss_reta_info(res->port_id, reta_conf, res->size);
1966 cmdline_parse_token_string_t cmd_showport_reta_show =
1967 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1968 cmdline_parse_token_string_t cmd_showport_reta_port =
1969 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1970 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1971 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1972 cmdline_parse_token_string_t cmd_showport_reta_rss =
1973 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1974 cmdline_parse_token_string_t cmd_showport_reta_reta =
1975 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1976 cmdline_parse_token_num_t cmd_showport_reta_size =
1977 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1978 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1979 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1980 list_of_items, NULL);
1982 cmdline_parse_inst_t cmd_showport_reta = {
1983 .f = cmd_showport_reta_parsed,
1985 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1987 (void *)&cmd_showport_reta_show,
1988 (void *)&cmd_showport_reta_port,
1989 (void *)&cmd_showport_reta_port_id,
1990 (void *)&cmd_showport_reta_rss,
1991 (void *)&cmd_showport_reta_reta,
1992 (void *)&cmd_showport_reta_size,
1993 (void *)&cmd_showport_reta_list_of_items,
1998 /* *** Show RSS hash configuration *** */
1999 struct cmd_showport_rss_hash {
2000 cmdline_fixed_string_t show;
2001 cmdline_fixed_string_t port;
2003 cmdline_fixed_string_t rss_hash;
2004 cmdline_fixed_string_t rss_type;
2005 cmdline_fixed_string_t key; /* optional argument */
2008 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2009 __attribute__((unused)) struct cmdline *cl,
2012 struct cmd_showport_rss_hash *res = parsed_result;
2014 port_rss_hash_conf_show(res->port_id, res->rss_type,
2015 show_rss_key != NULL);
2018 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2019 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2020 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2021 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2022 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2023 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2024 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2025 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2027 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2028 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2029 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2030 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2031 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2032 "ipv6-tcp-ex#ipv6-udp-ex");
2033 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2034 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2036 cmdline_parse_inst_t cmd_showport_rss_hash = {
2037 .f = cmd_showport_rss_hash_parsed,
2040 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2041 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2042 "ipv6-sctp|ipv6-other|l2-payload|"
2043 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex (X = port number)\n",
2045 (void *)&cmd_showport_rss_hash_show,
2046 (void *)&cmd_showport_rss_hash_port,
2047 (void *)&cmd_showport_rss_hash_port_id,
2048 (void *)&cmd_showport_rss_hash_rss_hash,
2049 (void *)&cmd_showport_rss_hash_rss_hash_info,
2054 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2055 .f = cmd_showport_rss_hash_parsed,
2058 "show port X rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
2059 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
2060 "ipv6-sctp|ipv6-other|l2-payload|"
2061 "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key (X = port number)\n",
2063 (void *)&cmd_showport_rss_hash_show,
2064 (void *)&cmd_showport_rss_hash_port,
2065 (void *)&cmd_showport_rss_hash_port_id,
2066 (void *)&cmd_showport_rss_hash_rss_hash,
2067 (void *)&cmd_showport_rss_hash_rss_hash_info,
2068 (void *)&cmd_showport_rss_hash_rss_key,
2073 /* *** Configure DCB *** */
2074 struct cmd_config_dcb {
2075 cmdline_fixed_string_t port;
2076 cmdline_fixed_string_t config;
2078 cmdline_fixed_string_t dcb;
2079 cmdline_fixed_string_t vt;
2080 cmdline_fixed_string_t vt_en;
2082 cmdline_fixed_string_t pfc;
2083 cmdline_fixed_string_t pfc_en;
2087 cmd_config_dcb_parsed(void *parsed_result,
2088 __attribute__((unused)) struct cmdline *cl,
2089 __attribute__((unused)) void *data)
2091 struct cmd_config_dcb *res = parsed_result;
2092 portid_t port_id = res->port_id;
2093 struct rte_port *port;
2097 port = &ports[port_id];
2098 /** Check if the port is not started **/
2099 if (port->port_status != RTE_PORT_STOPPED) {
2100 printf("Please stop port %d first\n", port_id);
2104 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2105 printf("The invalid number of traffic class,"
2106 " only 4 or 8 allowed.\n");
2110 if (nb_fwd_lcores < res->num_tcs) {
2111 printf("nb_cores shouldn't be less than number of TCs.\n");
2114 if (!strncmp(res->pfc_en, "on", 2))
2119 /* DCB in VT mode */
2120 if (!strncmp(res->vt_en, "on", 2))
2121 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2122 (enum rte_eth_nb_tcs)res->num_tcs,
2125 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2126 (enum rte_eth_nb_tcs)res->num_tcs,
2131 printf("Cannot initialize network ports.\n");
2135 cmd_reconfig_device_queue(port_id, 1, 1);
2138 cmdline_parse_token_string_t cmd_config_dcb_port =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2140 cmdline_parse_token_string_t cmd_config_dcb_config =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2142 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2143 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2144 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2146 cmdline_parse_token_string_t cmd_config_dcb_vt =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2148 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2150 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2151 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2152 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2154 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2157 cmdline_parse_inst_t cmd_config_dcb = {
2158 .f = cmd_config_dcb_parsed,
2160 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
2162 (void *)&cmd_config_dcb_port,
2163 (void *)&cmd_config_dcb_config,
2164 (void *)&cmd_config_dcb_port_id,
2165 (void *)&cmd_config_dcb_dcb,
2166 (void *)&cmd_config_dcb_vt,
2167 (void *)&cmd_config_dcb_vt_en,
2168 (void *)&cmd_config_dcb_num_tcs,
2169 (void *)&cmd_config_dcb_pfc,
2170 (void *)&cmd_config_dcb_pfc_en,
2175 /* *** configure number of packets per burst *** */
2176 struct cmd_config_burst {
2177 cmdline_fixed_string_t port;
2178 cmdline_fixed_string_t keyword;
2179 cmdline_fixed_string_t all;
2180 cmdline_fixed_string_t name;
2185 cmd_config_burst_parsed(void *parsed_result,
2186 __attribute__((unused)) struct cmdline *cl,
2187 __attribute__((unused)) void *data)
2189 struct cmd_config_burst *res = parsed_result;
2191 if (!all_ports_stopped()) {
2192 printf("Please stop all ports first\n");
2196 if (!strcmp(res->name, "burst")) {
2197 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2198 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2201 nb_pkt_per_burst = res->value;
2203 printf("Unknown parameter\n");
2209 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2212 cmdline_parse_token_string_t cmd_config_burst_port =
2213 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2214 cmdline_parse_token_string_t cmd_config_burst_keyword =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2216 cmdline_parse_token_string_t cmd_config_burst_all =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2218 cmdline_parse_token_string_t cmd_config_burst_name =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2220 cmdline_parse_token_num_t cmd_config_burst_value =
2221 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2223 cmdline_parse_inst_t cmd_config_burst = {
2224 .f = cmd_config_burst_parsed,
2226 .help_str = "port config all burst value",
2228 (void *)&cmd_config_burst_port,
2229 (void *)&cmd_config_burst_keyword,
2230 (void *)&cmd_config_burst_all,
2231 (void *)&cmd_config_burst_name,
2232 (void *)&cmd_config_burst_value,
2237 /* *** configure rx/tx queues *** */
2238 struct cmd_config_thresh {
2239 cmdline_fixed_string_t port;
2240 cmdline_fixed_string_t keyword;
2241 cmdline_fixed_string_t all;
2242 cmdline_fixed_string_t name;
2247 cmd_config_thresh_parsed(void *parsed_result,
2248 __attribute__((unused)) struct cmdline *cl,
2249 __attribute__((unused)) void *data)
2251 struct cmd_config_thresh *res = parsed_result;
2253 if (!all_ports_stopped()) {
2254 printf("Please stop all ports first\n");
2258 if (!strcmp(res->name, "txpt"))
2259 tx_pthresh = res->value;
2260 else if(!strcmp(res->name, "txht"))
2261 tx_hthresh = res->value;
2262 else if(!strcmp(res->name, "txwt"))
2263 tx_wthresh = res->value;
2264 else if(!strcmp(res->name, "rxpt"))
2265 rx_pthresh = res->value;
2266 else if(!strcmp(res->name, "rxht"))
2267 rx_hthresh = res->value;
2268 else if(!strcmp(res->name, "rxwt"))
2269 rx_wthresh = res->value;
2271 printf("Unknown parameter\n");
2277 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2280 cmdline_parse_token_string_t cmd_config_thresh_port =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2282 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2284 cmdline_parse_token_string_t cmd_config_thresh_all =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2286 cmdline_parse_token_string_t cmd_config_thresh_name =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2288 "txpt#txht#txwt#rxpt#rxht#rxwt");
2289 cmdline_parse_token_num_t cmd_config_thresh_value =
2290 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2292 cmdline_parse_inst_t cmd_config_thresh = {
2293 .f = cmd_config_thresh_parsed,
2295 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2297 (void *)&cmd_config_thresh_port,
2298 (void *)&cmd_config_thresh_keyword,
2299 (void *)&cmd_config_thresh_all,
2300 (void *)&cmd_config_thresh_name,
2301 (void *)&cmd_config_thresh_value,
2306 /* *** configure free/rs threshold *** */
2307 struct cmd_config_threshold {
2308 cmdline_fixed_string_t port;
2309 cmdline_fixed_string_t keyword;
2310 cmdline_fixed_string_t all;
2311 cmdline_fixed_string_t name;
2316 cmd_config_threshold_parsed(void *parsed_result,
2317 __attribute__((unused)) struct cmdline *cl,
2318 __attribute__((unused)) void *data)
2320 struct cmd_config_threshold *res = parsed_result;
2322 if (!all_ports_stopped()) {
2323 printf("Please stop all ports first\n");
2327 if (!strcmp(res->name, "txfreet"))
2328 tx_free_thresh = res->value;
2329 else if (!strcmp(res->name, "txrst"))
2330 tx_rs_thresh = res->value;
2331 else if (!strcmp(res->name, "rxfreet"))
2332 rx_free_thresh = res->value;
2334 printf("Unknown parameter\n");
2340 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2343 cmdline_parse_token_string_t cmd_config_threshold_port =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2345 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2348 cmdline_parse_token_string_t cmd_config_threshold_all =
2349 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2350 cmdline_parse_token_string_t cmd_config_threshold_name =
2351 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2352 "txfreet#txrst#rxfreet");
2353 cmdline_parse_token_num_t cmd_config_threshold_value =
2354 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2356 cmdline_parse_inst_t cmd_config_threshold = {
2357 .f = cmd_config_threshold_parsed,
2359 .help_str = "port config all txfreet|txrst|rxfreet value",
2361 (void *)&cmd_config_threshold_port,
2362 (void *)&cmd_config_threshold_keyword,
2363 (void *)&cmd_config_threshold_all,
2364 (void *)&cmd_config_threshold_name,
2365 (void *)&cmd_config_threshold_value,
2371 struct cmd_stop_result {
2372 cmdline_fixed_string_t stop;
2375 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2376 __attribute__((unused)) struct cmdline *cl,
2377 __attribute__((unused)) void *data)
2379 stop_packet_forwarding();
2382 cmdline_parse_token_string_t cmd_stop_stop =
2383 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2385 cmdline_parse_inst_t cmd_stop = {
2386 .f = cmd_stop_parsed,
2388 .help_str = "stop - stop packet forwarding",
2390 (void *)&cmd_stop_stop,
2395 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2398 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2399 unsigned int *parsed_items, int check_unique_values)
2401 unsigned int nb_item;
2409 * First parse all items in the list and store their value.
2414 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2416 if ((c >= '0') && (c <= '9')) {
2417 value = (unsigned int) (value * 10 + (c - '0'));
2422 printf("character %c is not a decimal digit\n", c);
2426 printf("No valid value before comma\n");
2429 if (nb_item < max_items) {
2430 parsed_items[nb_item] = value;
2436 if (nb_item >= max_items) {
2437 printf("Number of %s = %u > %u (maximum items)\n",
2438 item_name, nb_item + 1, max_items);
2441 parsed_items[nb_item++] = value;
2442 if (! check_unique_values)
2446 * Then, check that all values in the list are differents.
2447 * No optimization here...
2449 for (i = 0; i < nb_item; i++) {
2450 for (j = i + 1; j < nb_item; j++) {
2451 if (parsed_items[j] == parsed_items[i]) {
2452 printf("duplicated %s %u at index %u and %u\n",
2453 item_name, parsed_items[i], i, j);
2461 struct cmd_set_list_result {
2462 cmdline_fixed_string_t cmd_keyword;
2463 cmdline_fixed_string_t list_name;
2464 cmdline_fixed_string_t list_of_items;
2467 static void cmd_set_list_parsed(void *parsed_result,
2468 __attribute__((unused)) struct cmdline *cl,
2469 __attribute__((unused)) void *data)
2471 struct cmd_set_list_result *res;
2473 unsigned int lcorelist[RTE_MAX_LCORE];
2474 unsigned int portlist[RTE_MAX_ETHPORTS];
2476 unsigned int nb_item;
2478 if (test_done == 0) {
2479 printf("Please stop forwarding first\n");
2483 res = parsed_result;
2484 if (!strcmp(res->list_name, "corelist")) {
2485 nb_item = parse_item_list(res->list_of_items, "core",
2487 parsed_items.lcorelist, 1);
2489 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2492 if (!strcmp(res->list_name, "portlist")) {
2493 nb_item = parse_item_list(res->list_of_items, "port",
2495 parsed_items.portlist, 1);
2497 set_fwd_ports_list(parsed_items.portlist, nb_item);
2501 cmdline_parse_token_string_t cmd_set_list_keyword =
2502 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2504 cmdline_parse_token_string_t cmd_set_list_name =
2505 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2506 "corelist#portlist");
2507 cmdline_parse_token_string_t cmd_set_list_of_items =
2508 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2511 cmdline_parse_inst_t cmd_set_fwd_list = {
2512 .f = cmd_set_list_parsed,
2514 .help_str = "set corelist|portlist x[,y]*",
2516 (void *)&cmd_set_list_keyword,
2517 (void *)&cmd_set_list_name,
2518 (void *)&cmd_set_list_of_items,
2523 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2525 struct cmd_setmask_result {
2526 cmdline_fixed_string_t set;
2527 cmdline_fixed_string_t mask;
2531 static void cmd_set_mask_parsed(void *parsed_result,
2532 __attribute__((unused)) struct cmdline *cl,
2533 __attribute__((unused)) void *data)
2535 struct cmd_setmask_result *res = parsed_result;
2537 if (test_done == 0) {
2538 printf("Please stop forwarding first\n");
2541 if (!strcmp(res->mask, "coremask"))
2542 set_fwd_lcores_mask(res->hexavalue);
2543 else if (!strcmp(res->mask, "portmask"))
2544 set_fwd_ports_mask(res->hexavalue);
2547 cmdline_parse_token_string_t cmd_setmask_set =
2548 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2549 cmdline_parse_token_string_t cmd_setmask_mask =
2550 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2551 "coremask#portmask");
2552 cmdline_parse_token_num_t cmd_setmask_value =
2553 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2555 cmdline_parse_inst_t cmd_set_fwd_mask = {
2556 .f = cmd_set_mask_parsed,
2558 .help_str = "set coremask|portmask hexadecimal value",
2560 (void *)&cmd_setmask_set,
2561 (void *)&cmd_setmask_mask,
2562 (void *)&cmd_setmask_value,
2568 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2570 struct cmd_set_result {
2571 cmdline_fixed_string_t set;
2572 cmdline_fixed_string_t what;
2576 static void cmd_set_parsed(void *parsed_result,
2577 __attribute__((unused)) struct cmdline *cl,
2578 __attribute__((unused)) void *data)
2580 struct cmd_set_result *res = parsed_result;
2581 if (!strcmp(res->what, "nbport"))
2582 set_fwd_ports_number(res->value);
2583 else if (!strcmp(res->what, "nbcore"))
2584 set_fwd_lcores_number(res->value);
2585 else if (!strcmp(res->what, "burst"))
2586 set_nb_pkt_per_burst(res->value);
2587 else if (!strcmp(res->what, "verbose"))
2588 set_verbose_level(res->value);
2591 cmdline_parse_token_string_t cmd_set_set =
2592 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2593 cmdline_parse_token_string_t cmd_set_what =
2594 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2595 "nbport#nbcore#burst#verbose");
2596 cmdline_parse_token_num_t cmd_set_value =
2597 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2599 cmdline_parse_inst_t cmd_set_numbers = {
2600 .f = cmd_set_parsed,
2602 .help_str = "set nbport|nbcore|burst|verbose value",
2604 (void *)&cmd_set_set,
2605 (void *)&cmd_set_what,
2606 (void *)&cmd_set_value,
2611 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2613 struct cmd_set_txpkts_result {
2614 cmdline_fixed_string_t cmd_keyword;
2615 cmdline_fixed_string_t txpkts;
2616 cmdline_fixed_string_t seg_lengths;
2620 cmd_set_txpkts_parsed(void *parsed_result,
2621 __attribute__((unused)) struct cmdline *cl,
2622 __attribute__((unused)) void *data)
2624 struct cmd_set_txpkts_result *res;
2625 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2626 unsigned int nb_segs;
2628 res = parsed_result;
2629 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2630 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2632 set_tx_pkt_segments(seg_lengths, nb_segs);
2635 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2636 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2637 cmd_keyword, "set");
2638 cmdline_parse_token_string_t cmd_set_txpkts_name =
2639 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2641 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2642 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2645 cmdline_parse_inst_t cmd_set_txpkts = {
2646 .f = cmd_set_txpkts_parsed,
2648 .help_str = "set txpkts x[,y]*",
2650 (void *)&cmd_set_txpkts_keyword,
2651 (void *)&cmd_set_txpkts_name,
2652 (void *)&cmd_set_txpkts_lengths,
2657 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2659 struct cmd_set_txsplit_result {
2660 cmdline_fixed_string_t cmd_keyword;
2661 cmdline_fixed_string_t txsplit;
2662 cmdline_fixed_string_t mode;
2666 cmd_set_txsplit_parsed(void *parsed_result,
2667 __attribute__((unused)) struct cmdline *cl,
2668 __attribute__((unused)) void *data)
2670 struct cmd_set_txsplit_result *res;
2672 res = parsed_result;
2673 set_tx_pkt_split(res->mode);
2676 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2677 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2678 cmd_keyword, "set");
2679 cmdline_parse_token_string_t cmd_set_txsplit_name =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2681 txsplit, "txsplit");
2682 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2683 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2686 cmdline_parse_inst_t cmd_set_txsplit = {
2687 .f = cmd_set_txsplit_parsed,
2689 .help_str = "set txsplit on|off|rand",
2691 (void *)&cmd_set_txsplit_keyword,
2692 (void *)&cmd_set_txsplit_name,
2693 (void *)&cmd_set_txsplit_mode,
2698 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2699 struct cmd_rx_vlan_filter_all_result {
2700 cmdline_fixed_string_t rx_vlan;
2701 cmdline_fixed_string_t what;
2702 cmdline_fixed_string_t all;
2707 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2708 __attribute__((unused)) struct cmdline *cl,
2709 __attribute__((unused)) void *data)
2711 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2713 if (!strcmp(res->what, "add"))
2714 rx_vlan_all_filter_set(res->port_id, 1);
2716 rx_vlan_all_filter_set(res->port_id, 0);
2719 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2720 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2721 rx_vlan, "rx_vlan");
2722 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2723 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2725 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2726 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2728 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2729 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2732 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2733 .f = cmd_rx_vlan_filter_all_parsed,
2735 .help_str = "add/remove all identifiers to/from the set of VLAN "
2736 "Identifiers filtered by a port",
2738 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2739 (void *)&cmd_rx_vlan_filter_all_what,
2740 (void *)&cmd_rx_vlan_filter_all_all,
2741 (void *)&cmd_rx_vlan_filter_all_portid,
2746 /* *** VLAN OFFLOAD SET ON A PORT *** */
2747 struct cmd_vlan_offload_result {
2748 cmdline_fixed_string_t vlan;
2749 cmdline_fixed_string_t set;
2750 cmdline_fixed_string_t what;
2751 cmdline_fixed_string_t on;
2752 cmdline_fixed_string_t port_id;
2756 cmd_vlan_offload_parsed(void *parsed_result,
2757 __attribute__((unused)) struct cmdline *cl,
2758 __attribute__((unused)) void *data)
2761 struct cmd_vlan_offload_result *res = parsed_result;
2764 portid_t port_id = 0;
2768 len = strnlen(str, STR_TOKEN_SIZE);
2770 /* Get port_id first */
2778 tmp = strtoul(str, NULL, 0);
2779 /* If port_id greater that what portid_t can represent, return */
2780 if(tmp >= RTE_MAX_ETHPORTS)
2782 port_id = (portid_t)tmp;
2784 if (!strcmp(res->on, "on"))
2789 if (!strcmp(res->what, "strip"))
2790 rx_vlan_strip_set(port_id, on);
2791 else if(!strcmp(res->what, "stripq")){
2792 uint16_t queue_id = 0;
2794 /* No queue_id, return */
2796 printf("must specify (port,queue_id)\n");
2799 tmp = strtoul(str + i + 1, NULL, 0);
2800 /* If queue_id greater that what 16-bits can represent, return */
2804 queue_id = (uint16_t)tmp;
2805 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2807 else if (!strcmp(res->what, "filter"))
2808 rx_vlan_filter_set(port_id, on);
2810 vlan_extend_set(port_id, on);
2815 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2816 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2818 cmdline_parse_token_string_t cmd_vlan_offload_set =
2819 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2821 cmdline_parse_token_string_t cmd_vlan_offload_what =
2822 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2823 what, "strip#filter#qinq#stripq");
2824 cmdline_parse_token_string_t cmd_vlan_offload_on =
2825 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2827 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2828 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2831 cmdline_parse_inst_t cmd_vlan_offload = {
2832 .f = cmd_vlan_offload_parsed,
2834 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2835 " qinq(extended) for both rx/tx sides ",
2837 (void *)&cmd_vlan_offload_vlan,
2838 (void *)&cmd_vlan_offload_set,
2839 (void *)&cmd_vlan_offload_what,
2840 (void *)&cmd_vlan_offload_on,
2841 (void *)&cmd_vlan_offload_portid,
2846 /* *** VLAN TPID SET ON A PORT *** */
2847 struct cmd_vlan_tpid_result {
2848 cmdline_fixed_string_t vlan;
2849 cmdline_fixed_string_t set;
2850 cmdline_fixed_string_t what;
2856 cmd_vlan_tpid_parsed(void *parsed_result,
2857 __attribute__((unused)) struct cmdline *cl,
2858 __attribute__((unused)) void *data)
2860 struct cmd_vlan_tpid_result *res = parsed_result;
2861 vlan_tpid_set(res->port_id, res->tp_id);
2865 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2866 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2868 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2869 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2871 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2872 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2874 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2875 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2877 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2878 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2881 cmdline_parse_inst_t cmd_vlan_tpid = {
2882 .f = cmd_vlan_tpid_parsed,
2884 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2886 (void *)&cmd_vlan_tpid_vlan,
2887 (void *)&cmd_vlan_tpid_set,
2888 (void *)&cmd_vlan_tpid_what,
2889 (void *)&cmd_vlan_tpid_tpid,
2890 (void *)&cmd_vlan_tpid_portid,
2895 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2896 struct cmd_rx_vlan_filter_result {
2897 cmdline_fixed_string_t rx_vlan;
2898 cmdline_fixed_string_t what;
2904 cmd_rx_vlan_filter_parsed(void *parsed_result,
2905 __attribute__((unused)) struct cmdline *cl,
2906 __attribute__((unused)) void *data)
2908 struct cmd_rx_vlan_filter_result *res = parsed_result;
2910 if (!strcmp(res->what, "add"))
2911 rx_vft_set(res->port_id, res->vlan_id, 1);
2913 rx_vft_set(res->port_id, res->vlan_id, 0);
2916 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2917 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2918 rx_vlan, "rx_vlan");
2919 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2920 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2922 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2923 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2925 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2926 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2929 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2930 .f = cmd_rx_vlan_filter_parsed,
2932 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2933 "Identifiers filtered by a port",
2935 (void *)&cmd_rx_vlan_filter_rx_vlan,
2936 (void *)&cmd_rx_vlan_filter_what,
2937 (void *)&cmd_rx_vlan_filter_vlanid,
2938 (void *)&cmd_rx_vlan_filter_portid,
2943 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2944 struct cmd_tx_vlan_set_result {
2945 cmdline_fixed_string_t tx_vlan;
2946 cmdline_fixed_string_t set;
2952 cmd_tx_vlan_set_parsed(void *parsed_result,
2953 __attribute__((unused)) struct cmdline *cl,
2954 __attribute__((unused)) void *data)
2956 struct cmd_tx_vlan_set_result *res = parsed_result;
2957 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
2959 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) {
2960 printf("Error, as QinQ has been enabled.\n");
2964 tx_vlan_set(res->port_id, res->vlan_id);
2967 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2968 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2969 tx_vlan, "tx_vlan");
2970 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2971 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2973 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2974 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2976 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2977 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2980 cmdline_parse_inst_t cmd_tx_vlan_set = {
2981 .f = cmd_tx_vlan_set_parsed,
2983 .help_str = "enable hardware insertion of a single VLAN header "
2984 "with a given TAG Identifier in packets sent on a port",
2986 (void *)&cmd_tx_vlan_set_tx_vlan,
2987 (void *)&cmd_tx_vlan_set_set,
2988 (void *)&cmd_tx_vlan_set_portid,
2989 (void *)&cmd_tx_vlan_set_vlanid,
2994 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2995 struct cmd_tx_vlan_set_qinq_result {
2996 cmdline_fixed_string_t tx_vlan;
2997 cmdline_fixed_string_t set;
3000 uint16_t vlan_id_outer;
3004 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3005 __attribute__((unused)) struct cmdline *cl,
3006 __attribute__((unused)) void *data)
3008 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3009 int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id);
3011 if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) {
3012 printf("Error, as QinQ hasn't been enabled.\n");
3016 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3019 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3020 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3021 tx_vlan, "tx_vlan");
3022 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3023 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3025 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3026 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3028 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3029 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3031 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3032 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3033 vlan_id_outer, UINT16);
3035 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3036 .f = cmd_tx_vlan_set_qinq_parsed,
3038 .help_str = "enable hardware insertion of double VLAN header "
3039 "with given TAG Identifiers in packets sent on a port",
3041 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3042 (void *)&cmd_tx_vlan_set_qinq_set,
3043 (void *)&cmd_tx_vlan_set_qinq_portid,
3044 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3045 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3050 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3051 struct cmd_tx_vlan_set_pvid_result {
3052 cmdline_fixed_string_t tx_vlan;
3053 cmdline_fixed_string_t set;
3054 cmdline_fixed_string_t pvid;
3057 cmdline_fixed_string_t mode;
3061 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3062 __attribute__((unused)) struct cmdline *cl,
3063 __attribute__((unused)) void *data)
3065 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3067 if (strcmp(res->mode, "on") == 0)
3068 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3070 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3073 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3074 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3075 tx_vlan, "tx_vlan");
3076 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3077 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3079 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3080 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3082 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3083 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3085 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3086 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3088 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3089 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3092 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3093 .f = cmd_tx_vlan_set_pvid_parsed,
3095 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3097 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3098 (void *)&cmd_tx_vlan_set_pvid_set,
3099 (void *)&cmd_tx_vlan_set_pvid_pvid,
3100 (void *)&cmd_tx_vlan_set_pvid_port_id,
3101 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3102 (void *)&cmd_tx_vlan_set_pvid_mode,
3107 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3108 struct cmd_tx_vlan_reset_result {
3109 cmdline_fixed_string_t tx_vlan;
3110 cmdline_fixed_string_t reset;
3115 cmd_tx_vlan_reset_parsed(void *parsed_result,
3116 __attribute__((unused)) struct cmdline *cl,
3117 __attribute__((unused)) void *data)
3119 struct cmd_tx_vlan_reset_result *res = parsed_result;
3121 tx_vlan_reset(res->port_id);
3124 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3125 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3126 tx_vlan, "tx_vlan");
3127 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3128 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3130 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3131 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3134 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3135 .f = cmd_tx_vlan_reset_parsed,
3137 .help_str = "disable hardware insertion of a VLAN header in packets "
3140 (void *)&cmd_tx_vlan_reset_tx_vlan,
3141 (void *)&cmd_tx_vlan_reset_reset,
3142 (void *)&cmd_tx_vlan_reset_portid,
3148 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3149 struct cmd_csum_result {
3150 cmdline_fixed_string_t csum;
3151 cmdline_fixed_string_t mode;
3152 cmdline_fixed_string_t proto;
3153 cmdline_fixed_string_t hwsw;
3158 csum_show(int port_id)
3160 struct rte_eth_dev_info dev_info;
3163 ol_flags = ports[port_id].tx_ol_flags;
3164 printf("Parse tunnel is %s\n",
3165 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3166 printf("IP checksum offload is %s\n",
3167 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3168 printf("UDP checksum offload is %s\n",
3169 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3170 printf("TCP checksum offload is %s\n",
3171 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3172 printf("SCTP checksum offload is %s\n",
3173 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3174 printf("Outer-Ip checksum offload is %s\n",
3175 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3177 /* display warnings if configuration is not supported by the NIC */
3178 rte_eth_dev_info_get(port_id, &dev_info);
3179 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3180 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3181 printf("Warning: hardware IP checksum enabled but not "
3182 "supported by port %d\n", port_id);
3184 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3185 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3186 printf("Warning: hardware UDP checksum enabled but not "
3187 "supported by port %d\n", port_id);
3189 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3190 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3191 printf("Warning: hardware TCP checksum enabled but not "
3192 "supported by port %d\n", port_id);
3194 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3195 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3196 printf("Warning: hardware SCTP checksum enabled but not "
3197 "supported by port %d\n", port_id);
3199 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3200 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3201 printf("Warning: hardware outer IP checksum enabled but not "
3202 "supported by port %d\n", port_id);
3207 cmd_csum_parsed(void *parsed_result,
3208 __attribute__((unused)) struct cmdline *cl,
3209 __attribute__((unused)) void *data)
3211 struct cmd_csum_result *res = parsed_result;
3215 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3216 printf("invalid port %d\n", res->port_id);
3220 if (!strcmp(res->mode, "set")) {
3222 if (!strcmp(res->hwsw, "hw"))
3225 if (!strcmp(res->proto, "ip")) {
3226 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3227 } else if (!strcmp(res->proto, "udp")) {
3228 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3229 } else if (!strcmp(res->proto, "tcp")) {
3230 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3231 } else if (!strcmp(res->proto, "sctp")) {
3232 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3233 } else if (!strcmp(res->proto, "outer-ip")) {
3234 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3238 ports[res->port_id].tx_ol_flags |= mask;
3240 ports[res->port_id].tx_ol_flags &= (~mask);
3242 csum_show(res->port_id);
3245 cmdline_parse_token_string_t cmd_csum_csum =
3246 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3248 cmdline_parse_token_string_t cmd_csum_mode =
3249 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3251 cmdline_parse_token_string_t cmd_csum_proto =
3252 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3253 proto, "ip#tcp#udp#sctp#outer-ip");
3254 cmdline_parse_token_string_t cmd_csum_hwsw =
3255 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3257 cmdline_parse_token_num_t cmd_csum_portid =
3258 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3261 cmdline_parse_inst_t cmd_csum_set = {
3262 .f = cmd_csum_parsed,
3264 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3265 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3267 (void *)&cmd_csum_csum,
3268 (void *)&cmd_csum_mode,
3269 (void *)&cmd_csum_proto,
3270 (void *)&cmd_csum_hwsw,
3271 (void *)&cmd_csum_portid,
3276 cmdline_parse_token_string_t cmd_csum_mode_show =
3277 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3280 cmdline_parse_inst_t cmd_csum_show = {
3281 .f = cmd_csum_parsed,
3283 .help_str = "show checksum offload configuration: csum show <port>",
3285 (void *)&cmd_csum_csum,
3286 (void *)&cmd_csum_mode_show,
3287 (void *)&cmd_csum_portid,
3292 /* Enable/disable tunnel parsing */
3293 struct cmd_csum_tunnel_result {
3294 cmdline_fixed_string_t csum;
3295 cmdline_fixed_string_t parse;
3296 cmdline_fixed_string_t onoff;
3301 cmd_csum_tunnel_parsed(void *parsed_result,
3302 __attribute__((unused)) struct cmdline *cl,
3303 __attribute__((unused)) void *data)
3305 struct cmd_csum_tunnel_result *res = parsed_result;
3307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3310 if (!strcmp(res->onoff, "on"))
3311 ports[res->port_id].tx_ol_flags |=
3312 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3314 ports[res->port_id].tx_ol_flags &=
3315 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3317 csum_show(res->port_id);
3320 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3321 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3323 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3324 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3325 parse, "parse_tunnel");
3326 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3327 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3329 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3330 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3333 cmdline_parse_inst_t cmd_csum_tunnel = {
3334 .f = cmd_csum_tunnel_parsed,
3336 .help_str = "enable/disable parsing of tunnels for csum engine: "
3337 "csum parse_tunnel on|off <tx-port>",
3339 (void *)&cmd_csum_tunnel_csum,
3340 (void *)&cmd_csum_tunnel_parse,
3341 (void *)&cmd_csum_tunnel_onoff,
3342 (void *)&cmd_csum_tunnel_portid,
3347 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3348 struct cmd_tso_set_result {
3349 cmdline_fixed_string_t tso;
3350 cmdline_fixed_string_t mode;
3356 cmd_tso_set_parsed(void *parsed_result,
3357 __attribute__((unused)) struct cmdline *cl,
3358 __attribute__((unused)) void *data)
3360 struct cmd_tso_set_result *res = parsed_result;
3361 struct rte_eth_dev_info dev_info;
3363 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3366 if (!strcmp(res->mode, "set"))
3367 ports[res->port_id].tso_segsz = res->tso_segsz;
3369 if (ports[res->port_id].tso_segsz == 0)
3370 printf("TSO is disabled\n");
3372 printf("TSO segment size is %d\n",
3373 ports[res->port_id].tso_segsz);
3375 /* display warnings if configuration is not supported by the NIC */
3376 rte_eth_dev_info_get(res->port_id, &dev_info);
3377 if ((ports[res->port_id].tso_segsz != 0) &&
3378 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3379 printf("Warning: TSO enabled but not "
3380 "supported by port %d\n", res->port_id);
3384 cmdline_parse_token_string_t cmd_tso_set_tso =
3385 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3387 cmdline_parse_token_string_t cmd_tso_set_mode =
3388 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3390 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3391 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3393 cmdline_parse_token_num_t cmd_tso_set_portid =
3394 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3397 cmdline_parse_inst_t cmd_tso_set = {
3398 .f = cmd_tso_set_parsed,
3400 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3401 "tso set <tso_segsz> <port>",
3403 (void *)&cmd_tso_set_tso,
3404 (void *)&cmd_tso_set_mode,
3405 (void *)&cmd_tso_set_tso_segsz,
3406 (void *)&cmd_tso_set_portid,
3411 cmdline_parse_token_string_t cmd_tso_show_mode =
3412 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3416 cmdline_parse_inst_t cmd_tso_show = {
3417 .f = cmd_tso_set_parsed,
3419 .help_str = "Show TSO segment size for csum engine: "
3422 (void *)&cmd_tso_set_tso,
3423 (void *)&cmd_tso_show_mode,
3424 (void *)&cmd_tso_set_portid,
3429 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3430 struct cmd_set_flush_rx {
3431 cmdline_fixed_string_t set;
3432 cmdline_fixed_string_t flush_rx;
3433 cmdline_fixed_string_t mode;
3437 cmd_set_flush_rx_parsed(void *parsed_result,
3438 __attribute__((unused)) struct cmdline *cl,
3439 __attribute__((unused)) void *data)
3441 struct cmd_set_flush_rx *res = parsed_result;
3442 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3445 cmdline_parse_token_string_t cmd_setflushrx_set =
3446 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3448 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3449 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3450 flush_rx, "flush_rx");
3451 cmdline_parse_token_string_t cmd_setflushrx_mode =
3452 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3456 cmdline_parse_inst_t cmd_set_flush_rx = {
3457 .f = cmd_set_flush_rx_parsed,
3458 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3461 (void *)&cmd_setflushrx_set,
3462 (void *)&cmd_setflushrx_flush_rx,
3463 (void *)&cmd_setflushrx_mode,
3468 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3469 struct cmd_set_link_check {
3470 cmdline_fixed_string_t set;
3471 cmdline_fixed_string_t link_check;
3472 cmdline_fixed_string_t mode;
3476 cmd_set_link_check_parsed(void *parsed_result,
3477 __attribute__((unused)) struct cmdline *cl,
3478 __attribute__((unused)) void *data)
3480 struct cmd_set_link_check *res = parsed_result;
3481 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3484 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3485 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3487 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3488 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3489 link_check, "link_check");
3490 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3491 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3495 cmdline_parse_inst_t cmd_set_link_check = {
3496 .f = cmd_set_link_check_parsed,
3497 .help_str = "set link_check on|off: enable/disable link status check "
3498 "when starting/stopping a port",
3501 (void *)&cmd_setlinkcheck_set,
3502 (void *)&cmd_setlinkcheck_link_check,
3503 (void *)&cmd_setlinkcheck_mode,
3508 #ifdef RTE_NIC_BYPASS
3509 /* *** SET NIC BYPASS MODE *** */
3510 struct cmd_set_bypass_mode_result {
3511 cmdline_fixed_string_t set;
3512 cmdline_fixed_string_t bypass;
3513 cmdline_fixed_string_t mode;
3514 cmdline_fixed_string_t value;
3519 cmd_set_bypass_mode_parsed(void *parsed_result,
3520 __attribute__((unused)) struct cmdline *cl,
3521 __attribute__((unused)) void *data)
3523 struct cmd_set_bypass_mode_result *res = parsed_result;
3524 portid_t port_id = res->port_id;
3525 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3527 if (!bypass_is_supported(port_id))
3530 if (!strcmp(res->value, "bypass"))
3531 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3532 else if (!strcmp(res->value, "isolate"))
3533 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3535 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3537 /* Set the bypass mode for the relevant port. */
3538 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3539 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3543 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3546 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3547 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3549 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3552 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3553 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3554 value, "normal#bypass#isolate");
3555 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3556 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3559 cmdline_parse_inst_t cmd_set_bypass_mode = {
3560 .f = cmd_set_bypass_mode_parsed,
3561 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3562 "Set the NIC bypass mode for port_id",
3565 (void *)&cmd_setbypass_mode_set,
3566 (void *)&cmd_setbypass_mode_bypass,
3567 (void *)&cmd_setbypass_mode_mode,
3568 (void *)&cmd_setbypass_mode_value,
3569 (void *)&cmd_setbypass_mode_port,
3574 /* *** SET NIC BYPASS EVENT *** */
3575 struct cmd_set_bypass_event_result {
3576 cmdline_fixed_string_t set;
3577 cmdline_fixed_string_t bypass;
3578 cmdline_fixed_string_t event;
3579 cmdline_fixed_string_t event_value;
3580 cmdline_fixed_string_t mode;
3581 cmdline_fixed_string_t mode_value;
3586 cmd_set_bypass_event_parsed(void *parsed_result,
3587 __attribute__((unused)) struct cmdline *cl,
3588 __attribute__((unused)) void *data)
3591 struct cmd_set_bypass_event_result *res = parsed_result;
3592 portid_t port_id = res->port_id;
3593 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3594 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3596 if (!bypass_is_supported(port_id))
3599 if (!strcmp(res->event_value, "timeout"))
3600 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3601 else if (!strcmp(res->event_value, "os_on"))
3602 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3603 else if (!strcmp(res->event_value, "os_off"))
3604 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3605 else if (!strcmp(res->event_value, "power_on"))
3606 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3607 else if (!strcmp(res->event_value, "power_off"))
3608 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3610 bypass_event = RTE_BYPASS_EVENT_NONE;
3612 if (!strcmp(res->mode_value, "bypass"))
3613 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3614 else if (!strcmp(res->mode_value, "isolate"))
3615 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3617 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3619 /* Set the watchdog timeout. */
3620 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3623 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3624 (rc = rte_eth_dev_wd_timeout_store(port_id,
3625 bypass_timeout)) != 0) {
3626 printf("Failed to set timeout value %u "
3627 "for port %d, errto code: %d.\n",
3628 bypass_timeout, port_id, rc);
3632 /* Set the bypass event to transition to bypass mode. */
3633 if (0 != rte_eth_dev_bypass_event_store(port_id,
3634 bypass_event, bypass_mode)) {
3635 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3640 cmdline_parse_token_string_t cmd_setbypass_event_set =
3641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3643 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3646 cmdline_parse_token_string_t cmd_setbypass_event_event =
3647 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3649 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3650 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3651 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3652 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3653 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3655 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3656 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3657 mode_value, "normal#bypass#isolate");
3658 cmdline_parse_token_num_t cmd_setbypass_event_port =
3659 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3662 cmdline_parse_inst_t cmd_set_bypass_event = {
3663 .f = cmd_set_bypass_event_parsed,
3664 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3665 "mode (normal|bypass|isolate) (port_id): "
3666 "Set the NIC bypass event mode for port_id",
3669 (void *)&cmd_setbypass_event_set,
3670 (void *)&cmd_setbypass_event_bypass,
3671 (void *)&cmd_setbypass_event_event,
3672 (void *)&cmd_setbypass_event_event_value,
3673 (void *)&cmd_setbypass_event_mode,
3674 (void *)&cmd_setbypass_event_mode_value,
3675 (void *)&cmd_setbypass_event_port,
3681 /* *** SET NIC BYPASS TIMEOUT *** */
3682 struct cmd_set_bypass_timeout_result {
3683 cmdline_fixed_string_t set;
3684 cmdline_fixed_string_t bypass;
3685 cmdline_fixed_string_t timeout;
3686 cmdline_fixed_string_t value;
3690 cmd_set_bypass_timeout_parsed(void *parsed_result,
3691 __attribute__((unused)) struct cmdline *cl,
3692 __attribute__((unused)) void *data)
3694 struct cmd_set_bypass_timeout_result *res = parsed_result;
3696 if (!strcmp(res->value, "1.5"))
3697 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3698 else if (!strcmp(res->value, "2"))
3699 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3700 else if (!strcmp(res->value, "3"))
3701 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3702 else if (!strcmp(res->value, "4"))
3703 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3704 else if (!strcmp(res->value, "8"))
3705 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3706 else if (!strcmp(res->value, "16"))
3707 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3708 else if (!strcmp(res->value, "32"))
3709 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3711 bypass_timeout = RTE_BYPASS_TMT_OFF;
3714 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3717 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3718 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3720 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3721 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3722 timeout, "timeout");
3723 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3725 value, "0#1.5#2#3#4#8#16#32");
3727 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3728 .f = cmd_set_bypass_timeout_parsed,
3729 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3730 "Set the NIC bypass watchdog timeout",
3733 (void *)&cmd_setbypass_timeout_set,
3734 (void *)&cmd_setbypass_timeout_bypass,
3735 (void *)&cmd_setbypass_timeout_timeout,
3736 (void *)&cmd_setbypass_timeout_value,
3741 /* *** SHOW NIC BYPASS MODE *** */
3742 struct cmd_show_bypass_config_result {
3743 cmdline_fixed_string_t show;
3744 cmdline_fixed_string_t bypass;
3745 cmdline_fixed_string_t config;
3750 cmd_show_bypass_config_parsed(void *parsed_result,
3751 __attribute__((unused)) struct cmdline *cl,
3752 __attribute__((unused)) void *data)
3754 struct cmd_show_bypass_config_result *res = parsed_result;
3755 uint32_t event_mode;
3756 uint32_t bypass_mode;
3757 portid_t port_id = res->port_id;
3758 uint32_t timeout = bypass_timeout;
3761 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3762 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3763 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3764 {"UNKNOWN", "normal", "bypass", "isolate"};
3765 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3772 int num_events = (sizeof events) / (sizeof events[0]);
3774 if (!bypass_is_supported(port_id))
3777 /* Display the bypass mode.*/
3778 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3779 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3783 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3784 bypass_mode = RTE_BYPASS_MODE_NONE;
3786 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3789 /* Display the bypass timeout.*/
3790 if (!RTE_BYPASS_TMT_VALID(timeout))
3791 timeout = RTE_BYPASS_TMT_OFF;
3793 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3795 /* Display the bypass events and associated modes. */
3796 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3798 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3799 printf("\tFailed to get bypass mode for event = %s\n",
3802 if (!RTE_BYPASS_MODE_VALID(event_mode))
3803 event_mode = RTE_BYPASS_MODE_NONE;
3805 printf("\tbypass event: %-16s = %s\n", events[i],
3811 cmdline_parse_token_string_t cmd_showbypass_config_show =
3812 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3814 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3815 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3817 cmdline_parse_token_string_t cmd_showbypass_config_config =
3818 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3820 cmdline_parse_token_num_t cmd_showbypass_config_port =
3821 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3824 cmdline_parse_inst_t cmd_show_bypass_config = {
3825 .f = cmd_show_bypass_config_parsed,
3826 .help_str = "show bypass config (port_id): "
3827 "Show the NIC bypass config for port_id",
3830 (void *)&cmd_showbypass_config_show,
3831 (void *)&cmd_showbypass_config_bypass,
3832 (void *)&cmd_showbypass_config_config,
3833 (void *)&cmd_showbypass_config_port,
3839 #ifdef RTE_LIBRTE_PMD_BOND
3840 /* *** SET BONDING MODE *** */
3841 struct cmd_set_bonding_mode_result {
3842 cmdline_fixed_string_t set;
3843 cmdline_fixed_string_t bonding;
3844 cmdline_fixed_string_t mode;
3849 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3850 __attribute__((unused)) struct cmdline *cl,
3851 __attribute__((unused)) void *data)
3853 struct cmd_set_bonding_mode_result *res = parsed_result;
3854 portid_t port_id = res->port_id;
3856 /* Set the bonding mode for the relevant port. */
3857 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3858 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3861 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3862 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3864 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3866 bonding, "bonding");
3867 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3868 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3870 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3871 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3873 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3874 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3877 cmdline_parse_inst_t cmd_set_bonding_mode = {
3878 .f = cmd_set_bonding_mode_parsed,
3879 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3882 (void *) &cmd_setbonding_mode_set,
3883 (void *) &cmd_setbonding_mode_bonding,
3884 (void *) &cmd_setbonding_mode_mode,
3885 (void *) &cmd_setbonding_mode_value,
3886 (void *) &cmd_setbonding_mode_port,
3891 /* *** SET BALANCE XMIT POLICY *** */
3892 struct cmd_set_bonding_balance_xmit_policy_result {
3893 cmdline_fixed_string_t set;
3894 cmdline_fixed_string_t bonding;
3895 cmdline_fixed_string_t balance_xmit_policy;
3897 cmdline_fixed_string_t policy;
3900 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3901 __attribute__((unused)) struct cmdline *cl,
3902 __attribute__((unused)) void *data)
3904 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3905 portid_t port_id = res->port_id;
3908 if (!strcmp(res->policy, "l2")) {
3909 policy = BALANCE_XMIT_POLICY_LAYER2;
3910 } else if (!strcmp(res->policy, "l23")) {
3911 policy = BALANCE_XMIT_POLICY_LAYER23;
3912 } else if (!strcmp(res->policy, "l34")) {
3913 policy = BALANCE_XMIT_POLICY_LAYER34;
3915 printf("\t Invalid xmit policy selection");
3919 /* Set the bonding mode for the relevant port. */
3920 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3921 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3926 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3929 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3930 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3931 bonding, "bonding");
3932 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3933 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3934 balance_xmit_policy, "balance_xmit_policy");
3935 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3936 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3938 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3939 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3940 policy, "l2#l23#l34");
3942 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3943 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3944 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3947 (void *)&cmd_setbonding_balance_xmit_policy_set,
3948 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3949 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3950 (void *)&cmd_setbonding_balance_xmit_policy_port,
3951 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3956 /* *** SHOW NIC BONDING CONFIGURATION *** */
3957 struct cmd_show_bonding_config_result {
3958 cmdline_fixed_string_t show;
3959 cmdline_fixed_string_t bonding;
3960 cmdline_fixed_string_t config;
3964 static void cmd_show_bonding_config_parsed(void *parsed_result,
3965 __attribute__((unused)) struct cmdline *cl,
3966 __attribute__((unused)) void *data)
3968 struct cmd_show_bonding_config_result *res = parsed_result;
3970 uint8_t slaves[RTE_MAX_ETHPORTS];
3971 int num_slaves, num_active_slaves;
3974 portid_t port_id = res->port_id;
3976 /* Display the bonding mode.*/
3977 bonding_mode = rte_eth_bond_mode_get(port_id);
3978 if (bonding_mode < 0) {
3979 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3982 printf("\tBonding mode: %d\n", bonding_mode);
3984 if (bonding_mode == BONDING_MODE_BALANCE) {
3985 int balance_xmit_policy;
3987 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3988 if (balance_xmit_policy < 0) {
3989 printf("\tFailed to get balance xmit policy for port = %d\n",
3993 printf("\tBalance Xmit Policy: ");
3995 switch (balance_xmit_policy) {
3996 case BALANCE_XMIT_POLICY_LAYER2:
3997 printf("BALANCE_XMIT_POLICY_LAYER2");
3999 case BALANCE_XMIT_POLICY_LAYER23:
4000 printf("BALANCE_XMIT_POLICY_LAYER23");
4002 case BALANCE_XMIT_POLICY_LAYER34:
4003 printf("BALANCE_XMIT_POLICY_LAYER34");
4010 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4012 if (num_slaves < 0) {
4013 printf("\tFailed to get slave list for port = %d\n", port_id);
4016 if (num_slaves > 0) {
4017 printf("\tSlaves (%d): [", num_slaves);
4018 for (i = 0; i < num_slaves - 1; i++)
4019 printf("%d ", slaves[i]);
4021 printf("%d]\n", slaves[num_slaves - 1]);
4023 printf("\tSlaves: []\n");
4027 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4030 if (num_active_slaves < 0) {
4031 printf("\tFailed to get active slave list for port = %d\n", port_id);
4034 if (num_active_slaves > 0) {
4035 printf("\tActive Slaves (%d): [", num_active_slaves);
4036 for (i = 0; i < num_active_slaves - 1; i++)
4037 printf("%d ", slaves[i]);
4039 printf("%d]\n", slaves[num_active_slaves - 1]);
4042 printf("\tActive Slaves: []\n");
4046 primary_id = rte_eth_bond_primary_get(port_id);
4047 if (primary_id < 0) {
4048 printf("\tFailed to get primary slave for port = %d\n", port_id);
4051 printf("\tPrimary: [%d]\n", primary_id);
4055 cmdline_parse_token_string_t cmd_showbonding_config_show =
4056 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4058 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4059 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4060 bonding, "bonding");
4061 cmdline_parse_token_string_t cmd_showbonding_config_config =
4062 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4064 cmdline_parse_token_num_t cmd_showbonding_config_port =
4065 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4068 cmdline_parse_inst_t cmd_show_bonding_config = {
4069 .f = cmd_show_bonding_config_parsed,
4070 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4073 (void *)&cmd_showbonding_config_show,
4074 (void *)&cmd_showbonding_config_bonding,
4075 (void *)&cmd_showbonding_config_config,
4076 (void *)&cmd_showbonding_config_port,
4081 /* *** SET BONDING PRIMARY *** */
4082 struct cmd_set_bonding_primary_result {
4083 cmdline_fixed_string_t set;
4084 cmdline_fixed_string_t bonding;
4085 cmdline_fixed_string_t primary;
4090 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4091 __attribute__((unused)) struct cmdline *cl,
4092 __attribute__((unused)) void *data)
4094 struct cmd_set_bonding_primary_result *res = parsed_result;
4095 portid_t master_port_id = res->port_id;
4096 portid_t slave_port_id = res->slave_id;
4098 /* Set the primary slave for a bonded device. */
4099 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4100 printf("\t Failed to set primary slave for port = %d.\n",
4107 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4108 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4110 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4111 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4112 bonding, "bonding");
4113 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4114 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4115 primary, "primary");
4116 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4117 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4119 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4120 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4123 cmdline_parse_inst_t cmd_set_bonding_primary = {
4124 .f = cmd_set_bonding_primary_parsed,
4125 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4128 (void *)&cmd_setbonding_primary_set,
4129 (void *)&cmd_setbonding_primary_bonding,
4130 (void *)&cmd_setbonding_primary_primary,
4131 (void *)&cmd_setbonding_primary_slave,
4132 (void *)&cmd_setbonding_primary_port,
4137 /* *** ADD SLAVE *** */
4138 struct cmd_add_bonding_slave_result {
4139 cmdline_fixed_string_t add;
4140 cmdline_fixed_string_t bonding;
4141 cmdline_fixed_string_t slave;
4146 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4147 __attribute__((unused)) struct cmdline *cl,
4148 __attribute__((unused)) void *data)
4150 struct cmd_add_bonding_slave_result *res = parsed_result;
4151 portid_t master_port_id = res->port_id;
4152 portid_t slave_port_id = res->slave_id;
4154 /* Set the primary slave for a bonded device. */
4155 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4156 printf("\t Failed to add slave %d to master port = %d.\n",
4157 slave_port_id, master_port_id);
4161 set_port_slave_flag(slave_port_id);
4164 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4167 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4169 bonding, "bonding");
4170 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4173 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4176 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4177 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4180 cmdline_parse_inst_t cmd_add_bonding_slave = {
4181 .f = cmd_add_bonding_slave_parsed,
4182 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4185 (void *)&cmd_addbonding_slave_add,
4186 (void *)&cmd_addbonding_slave_bonding,
4187 (void *)&cmd_addbonding_slave_slave,
4188 (void *)&cmd_addbonding_slave_slaveid,
4189 (void *)&cmd_addbonding_slave_port,
4194 /* *** REMOVE SLAVE *** */
4195 struct cmd_remove_bonding_slave_result {
4196 cmdline_fixed_string_t remove;
4197 cmdline_fixed_string_t bonding;
4198 cmdline_fixed_string_t slave;
4203 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4204 __attribute__((unused)) struct cmdline *cl,
4205 __attribute__((unused)) void *data)
4207 struct cmd_remove_bonding_slave_result *res = parsed_result;
4208 portid_t master_port_id = res->port_id;
4209 portid_t slave_port_id = res->slave_id;
4211 /* Set the primary slave for a bonded device. */
4212 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4213 printf("\t Failed to remove slave %d from master port = %d.\n",
4214 slave_port_id, master_port_id);
4218 clear_port_slave_flag(slave_port_id);
4221 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4222 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4224 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4225 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4226 bonding, "bonding");
4227 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4228 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4230 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4231 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4233 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4234 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4237 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4238 .f = cmd_remove_bonding_slave_parsed,
4239 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4242 (void *)&cmd_removebonding_slave_remove,
4243 (void *)&cmd_removebonding_slave_bonding,
4244 (void *)&cmd_removebonding_slave_slave,
4245 (void *)&cmd_removebonding_slave_slaveid,
4246 (void *)&cmd_removebonding_slave_port,
4251 /* *** CREATE BONDED DEVICE *** */
4252 struct cmd_create_bonded_device_result {
4253 cmdline_fixed_string_t create;
4254 cmdline_fixed_string_t bonded;
4255 cmdline_fixed_string_t device;
4260 static int bond_dev_num = 0;
4262 static void cmd_create_bonded_device_parsed(void *parsed_result,
4263 __attribute__((unused)) struct cmdline *cl,
4264 __attribute__((unused)) void *data)
4266 struct cmd_create_bonded_device_result *res = parsed_result;
4267 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4270 if (test_done == 0) {
4271 printf("Please stop forwarding first\n");
4275 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4278 /* Create a new bonded device. */
4279 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4281 printf("\t Failed to create bonded device.\n");
4284 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4287 /* Update number of ports */
4288 nb_ports = rte_eth_dev_count();
4289 reconfig(port_id, res->socket);
4290 rte_eth_promiscuous_enable(port_id);
4291 ports[port_id].enabled = 1;
4296 cmdline_parse_token_string_t cmd_createbonded_device_create =
4297 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4299 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4300 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4302 cmdline_parse_token_string_t cmd_createbonded_device_device =
4303 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4305 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4306 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4308 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4309 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4312 cmdline_parse_inst_t cmd_create_bonded_device = {
4313 .f = cmd_create_bonded_device_parsed,
4314 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4317 (void *)&cmd_createbonded_device_create,
4318 (void *)&cmd_createbonded_device_bonded,
4319 (void *)&cmd_createbonded_device_device,
4320 (void *)&cmd_createbonded_device_mode,
4321 (void *)&cmd_createbonded_device_socket,
4326 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4327 struct cmd_set_bond_mac_addr_result {
4328 cmdline_fixed_string_t set;
4329 cmdline_fixed_string_t bonding;
4330 cmdline_fixed_string_t mac_addr;
4332 struct ether_addr address;
4335 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4336 __attribute__((unused)) struct cmdline *cl,
4337 __attribute__((unused)) void *data)
4339 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4342 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4345 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4347 /* check the return value and print it if is < 0 */
4349 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4352 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4353 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4354 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4355 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4357 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4358 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4360 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4361 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4362 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4363 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4365 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4366 .f = cmd_set_bond_mac_addr_parsed,
4368 .help_str = "set bonding mac_addr (port_id) (address): ",
4370 (void *)&cmd_set_bond_mac_addr_set,
4371 (void *)&cmd_set_bond_mac_addr_bonding,
4372 (void *)&cmd_set_bond_mac_addr_mac,
4373 (void *)&cmd_set_bond_mac_addr_portnum,
4374 (void *)&cmd_set_bond_mac_addr_addr,
4380 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4381 struct cmd_set_bond_mon_period_result {
4382 cmdline_fixed_string_t set;
4383 cmdline_fixed_string_t bonding;
4384 cmdline_fixed_string_t mon_period;
4389 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4390 __attribute__((unused)) struct cmdline *cl,
4391 __attribute__((unused)) void *data)
4393 struct cmd_set_bond_mon_period_result *res = parsed_result;
4396 if (res->port_num >= nb_ports) {
4397 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4401 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4403 /* check the return value and print it if is < 0 */
4405 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4408 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4409 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4411 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4412 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4413 bonding, "bonding");
4414 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4415 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4416 mon_period, "mon_period");
4417 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4418 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4420 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4421 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4424 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4425 .f = cmd_set_bond_mon_period_parsed,
4427 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4429 (void *)&cmd_set_bond_mon_period_set,
4430 (void *)&cmd_set_bond_mon_period_bonding,
4431 (void *)&cmd_set_bond_mon_period_mon_period,
4432 (void *)&cmd_set_bond_mon_period_portnum,
4433 (void *)&cmd_set_bond_mon_period_period_ms,
4438 #endif /* RTE_LIBRTE_PMD_BOND */
4440 /* *** SET FORWARDING MODE *** */
4441 struct cmd_set_fwd_mode_result {
4442 cmdline_fixed_string_t set;
4443 cmdline_fixed_string_t fwd;
4444 cmdline_fixed_string_t mode;
4447 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4448 __attribute__((unused)) struct cmdline *cl,
4449 __attribute__((unused)) void *data)
4451 struct cmd_set_fwd_mode_result *res = parsed_result;
4453 set_pkt_forwarding_mode(res->mode);
4456 cmdline_parse_token_string_t cmd_setfwd_set =
4457 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4458 cmdline_parse_token_string_t cmd_setfwd_fwd =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4460 cmdline_parse_token_string_t cmd_setfwd_mode =
4461 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4462 "" /* defined at init */);
4464 cmdline_parse_inst_t cmd_set_fwd_mode = {
4465 .f = cmd_set_fwd_mode_parsed,
4467 .help_str = NULL, /* defined at init */
4469 (void *)&cmd_setfwd_set,
4470 (void *)&cmd_setfwd_fwd,
4471 (void *)&cmd_setfwd_mode,
4476 static void cmd_set_fwd_mode_init(void)
4479 static char token[128];
4480 static char help[256];
4481 cmdline_parse_token_string_t *token_struct;
4483 modes = list_pkt_forwarding_modes();
4484 snprintf(help, sizeof help, "set fwd %s - "
4485 "set packet forwarding mode", modes);
4486 cmd_set_fwd_mode.help_str = help;
4488 /* string token separator is # */
4489 for (c = token; *modes != '\0'; modes++)
4494 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4495 token_struct->string_data.str = token;
4498 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4499 struct cmd_set_burst_tx_retry_result {
4500 cmdline_fixed_string_t set;
4501 cmdline_fixed_string_t burst;
4502 cmdline_fixed_string_t tx;
4503 cmdline_fixed_string_t delay;
4505 cmdline_fixed_string_t retry;
4509 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4510 __attribute__((unused)) struct cmdline *cl,
4511 __attribute__((unused)) void *data)
4513 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4515 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4516 && !strcmp(res->tx, "tx")) {
4517 if (!strcmp(res->delay, "delay"))
4518 burst_tx_delay_time = res->time;
4519 if (!strcmp(res->retry, "retry"))
4520 burst_tx_retry_num = res->retry_num;
4525 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4527 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4528 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4530 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4531 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4532 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4533 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4534 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4535 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4536 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4537 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4538 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4539 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4541 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4542 .f = cmd_set_burst_tx_retry_parsed,
4543 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4545 (void *)&cmd_set_burst_tx_retry_set,
4546 (void *)&cmd_set_burst_tx_retry_burst,
4547 (void *)&cmd_set_burst_tx_retry_tx,
4548 (void *)&cmd_set_burst_tx_retry_delay,
4549 (void *)&cmd_set_burst_tx_retry_time,
4550 (void *)&cmd_set_burst_tx_retry_retry,
4551 (void *)&cmd_set_burst_tx_retry_retry_num,
4556 /* *** SET PROMISC MODE *** */
4557 struct cmd_set_promisc_mode_result {
4558 cmdline_fixed_string_t set;
4559 cmdline_fixed_string_t promisc;
4560 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4561 uint8_t port_num; /* valid if "allports" argument == 0 */
4562 cmdline_fixed_string_t mode;
4565 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4566 __attribute__((unused)) struct cmdline *cl,
4569 struct cmd_set_promisc_mode_result *res = parsed_result;
4573 if (!strcmp(res->mode, "on"))
4580 FOREACH_PORT(i, ports) {
4582 rte_eth_promiscuous_enable(i);
4584 rte_eth_promiscuous_disable(i);
4589 rte_eth_promiscuous_enable(res->port_num);
4591 rte_eth_promiscuous_disable(res->port_num);
4595 cmdline_parse_token_string_t cmd_setpromisc_set =
4596 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4597 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4598 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4600 cmdline_parse_token_string_t cmd_setpromisc_portall =
4601 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4603 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4604 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4606 cmdline_parse_token_string_t cmd_setpromisc_mode =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4610 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4611 .f = cmd_set_promisc_mode_parsed,
4613 .help_str = "set promisc all on|off: set promisc mode for all ports",
4615 (void *)&cmd_setpromisc_set,
4616 (void *)&cmd_setpromisc_promisc,
4617 (void *)&cmd_setpromisc_portall,
4618 (void *)&cmd_setpromisc_mode,
4623 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4624 .f = cmd_set_promisc_mode_parsed,
4626 .help_str = "set promisc X on|off: set promisc mode on port X",
4628 (void *)&cmd_setpromisc_set,
4629 (void *)&cmd_setpromisc_promisc,
4630 (void *)&cmd_setpromisc_portnum,
4631 (void *)&cmd_setpromisc_mode,
4636 /* *** SET ALLMULTI MODE *** */
4637 struct cmd_set_allmulti_mode_result {
4638 cmdline_fixed_string_t set;
4639 cmdline_fixed_string_t allmulti;
4640 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4641 uint8_t port_num; /* valid if "allports" argument == 0 */
4642 cmdline_fixed_string_t mode;
4645 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4646 __attribute__((unused)) struct cmdline *cl,
4649 struct cmd_set_allmulti_mode_result *res = parsed_result;
4653 if (!strcmp(res->mode, "on"))
4660 FOREACH_PORT(i, ports) {
4662 rte_eth_allmulticast_enable(i);
4664 rte_eth_allmulticast_disable(i);
4669 rte_eth_allmulticast_enable(res->port_num);
4671 rte_eth_allmulticast_disable(res->port_num);
4675 cmdline_parse_token_string_t cmd_setallmulti_set =
4676 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4677 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4678 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4680 cmdline_parse_token_string_t cmd_setallmulti_portall =
4681 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4683 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4684 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4686 cmdline_parse_token_string_t cmd_setallmulti_mode =
4687 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4690 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4691 .f = cmd_set_allmulti_mode_parsed,
4693 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4695 (void *)&cmd_setallmulti_set,
4696 (void *)&cmd_setallmulti_allmulti,
4697 (void *)&cmd_setallmulti_portall,
4698 (void *)&cmd_setallmulti_mode,
4703 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4704 .f = cmd_set_allmulti_mode_parsed,
4706 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4708 (void *)&cmd_setallmulti_set,
4709 (void *)&cmd_setallmulti_allmulti,
4710 (void *)&cmd_setallmulti_portnum,
4711 (void *)&cmd_setallmulti_mode,
4716 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4717 struct cmd_link_flow_ctrl_set_result {
4718 cmdline_fixed_string_t set;
4719 cmdline_fixed_string_t flow_ctrl;
4720 cmdline_fixed_string_t rx;
4721 cmdline_fixed_string_t rx_lfc_mode;
4722 cmdline_fixed_string_t tx;
4723 cmdline_fixed_string_t tx_lfc_mode;
4724 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4725 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4726 cmdline_fixed_string_t autoneg_str;
4727 cmdline_fixed_string_t autoneg;
4728 cmdline_fixed_string_t hw_str;
4729 uint32_t high_water;
4730 cmdline_fixed_string_t lw_str;
4732 cmdline_fixed_string_t pt_str;
4733 uint16_t pause_time;
4734 cmdline_fixed_string_t xon_str;
4739 cmdline_parse_token_string_t cmd_lfc_set_set =
4740 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4742 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4743 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4744 flow_ctrl, "flow_ctrl");
4745 cmdline_parse_token_string_t cmd_lfc_set_rx =
4746 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4748 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4749 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4750 rx_lfc_mode, "on#off");
4751 cmdline_parse_token_string_t cmd_lfc_set_tx =
4752 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4754 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4755 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4756 tx_lfc_mode, "on#off");
4757 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4758 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4759 hw_str, "high_water");
4760 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4761 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4762 high_water, UINT32);
4763 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4764 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4765 lw_str, "low_water");
4766 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4767 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4769 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4770 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4771 pt_str, "pause_time");
4772 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4773 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4774 pause_time, UINT16);
4775 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4776 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4777 xon_str, "send_xon");
4778 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4779 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4781 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4782 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4783 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4784 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4785 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4786 mac_ctrl_frame_fwd_mode, "on#off");
4787 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4788 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4789 autoneg_str, "autoneg");
4790 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4791 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4793 cmdline_parse_token_num_t cmd_lfc_set_portid =
4794 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4797 /* forward declaration */
4799 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4802 cmdline_parse_inst_t cmd_link_flow_control_set = {
4803 .f = cmd_link_flow_ctrl_set_parsed,
4805 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4806 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4807 autoneg on|off port_id",
4809 (void *)&cmd_lfc_set_set,
4810 (void *)&cmd_lfc_set_flow_ctrl,
4811 (void *)&cmd_lfc_set_rx,
4812 (void *)&cmd_lfc_set_rx_mode,
4813 (void *)&cmd_lfc_set_tx,
4814 (void *)&cmd_lfc_set_tx_mode,
4815 (void *)&cmd_lfc_set_high_water,
4816 (void *)&cmd_lfc_set_low_water,
4817 (void *)&cmd_lfc_set_pause_time,
4818 (void *)&cmd_lfc_set_send_xon,
4819 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4820 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4821 (void *)&cmd_lfc_set_autoneg_str,
4822 (void *)&cmd_lfc_set_autoneg,
4823 (void *)&cmd_lfc_set_portid,
4828 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4829 .f = cmd_link_flow_ctrl_set_parsed,
4830 .data = (void *)&cmd_link_flow_control_set_rx,
4831 .help_str = "Change rx flow control parameter: set flow_ctrl "
4832 "rx on|off port_id",
4834 (void *)&cmd_lfc_set_set,
4835 (void *)&cmd_lfc_set_flow_ctrl,
4836 (void *)&cmd_lfc_set_rx,
4837 (void *)&cmd_lfc_set_rx_mode,
4838 (void *)&cmd_lfc_set_portid,
4843 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4844 .f = cmd_link_flow_ctrl_set_parsed,
4845 .data = (void *)&cmd_link_flow_control_set_tx,
4846 .help_str = "Change tx flow control parameter: set flow_ctrl "
4847 "tx on|off port_id",
4849 (void *)&cmd_lfc_set_set,
4850 (void *)&cmd_lfc_set_flow_ctrl,
4851 (void *)&cmd_lfc_set_tx,
4852 (void *)&cmd_lfc_set_tx_mode,
4853 (void *)&cmd_lfc_set_portid,
4858 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4859 .f = cmd_link_flow_ctrl_set_parsed,
4860 .data = (void *)&cmd_link_flow_control_set_hw,
4861 .help_str = "Change high water flow control parameter: set flow_ctrl "
4862 "high_water value port_id",
4864 (void *)&cmd_lfc_set_set,
4865 (void *)&cmd_lfc_set_flow_ctrl,
4866 (void *)&cmd_lfc_set_high_water_str,
4867 (void *)&cmd_lfc_set_high_water,
4868 (void *)&cmd_lfc_set_portid,
4873 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4874 .f = cmd_link_flow_ctrl_set_parsed,
4875 .data = (void *)&cmd_link_flow_control_set_lw,
4876 .help_str = "Change low water flow control parameter: set flow_ctrl "
4877 "low_water value port_id",
4879 (void *)&cmd_lfc_set_set,
4880 (void *)&cmd_lfc_set_flow_ctrl,
4881 (void *)&cmd_lfc_set_low_water_str,
4882 (void *)&cmd_lfc_set_low_water,
4883 (void *)&cmd_lfc_set_portid,
4888 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4889 .f = cmd_link_flow_ctrl_set_parsed,
4890 .data = (void *)&cmd_link_flow_control_set_pt,
4891 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4892 "pause_time value port_id",
4894 (void *)&cmd_lfc_set_set,
4895 (void *)&cmd_lfc_set_flow_ctrl,
4896 (void *)&cmd_lfc_set_pause_time_str,
4897 (void *)&cmd_lfc_set_pause_time,
4898 (void *)&cmd_lfc_set_portid,
4903 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4904 .f = cmd_link_flow_ctrl_set_parsed,
4905 .data = (void *)&cmd_link_flow_control_set_xon,
4906 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4907 "send_xon value port_id",
4909 (void *)&cmd_lfc_set_set,
4910 (void *)&cmd_lfc_set_flow_ctrl,
4911 (void *)&cmd_lfc_set_send_xon_str,
4912 (void *)&cmd_lfc_set_send_xon,
4913 (void *)&cmd_lfc_set_portid,
4918 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4919 .f = cmd_link_flow_ctrl_set_parsed,
4920 .data = (void *)&cmd_link_flow_control_set_macfwd,
4921 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4922 "mac_ctrl_frame_fwd on|off port_id",
4924 (void *)&cmd_lfc_set_set,
4925 (void *)&cmd_lfc_set_flow_ctrl,
4926 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4927 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4928 (void *)&cmd_lfc_set_portid,
4933 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4934 .f = cmd_link_flow_ctrl_set_parsed,
4935 .data = (void *)&cmd_link_flow_control_set_autoneg,
4936 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4937 "autoneg on|off port_id",
4939 (void *)&cmd_lfc_set_set,
4940 (void *)&cmd_lfc_set_flow_ctrl,
4941 (void *)&cmd_lfc_set_autoneg_str,
4942 (void *)&cmd_lfc_set_autoneg,
4943 (void *)&cmd_lfc_set_portid,
4949 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4950 __attribute__((unused)) struct cmdline *cl,
4953 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4954 cmdline_parse_inst_t *cmd = data;
4955 struct rte_eth_fc_conf fc_conf;
4961 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4962 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4963 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4964 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4966 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4967 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4970 /* Partial command line, retrieve current configuration */
4972 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4974 printf("cannot get current flow ctrl parameters, return"
4975 "code = %d\n", ret);
4979 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4980 (fc_conf.mode == RTE_FC_FULL))
4982 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4983 (fc_conf.mode == RTE_FC_FULL))
4987 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4988 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4990 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4991 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4993 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4995 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4996 fc_conf.high_water = res->high_water;
4998 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4999 fc_conf.low_water = res->low_water;
5001 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5002 fc_conf.pause_time = res->pause_time;
5004 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5005 fc_conf.send_xon = res->send_xon;
5007 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5008 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5009 fc_conf.mac_ctrl_frame_fwd = 1;
5011 fc_conf.mac_ctrl_frame_fwd = 0;
5014 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5015 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5017 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5019 printf("bad flow contrl parameter, return code = %d \n", ret);
5022 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5023 struct cmd_priority_flow_ctrl_set_result {
5024 cmdline_fixed_string_t set;
5025 cmdline_fixed_string_t pfc_ctrl;
5026 cmdline_fixed_string_t rx;
5027 cmdline_fixed_string_t rx_pfc_mode;
5028 cmdline_fixed_string_t tx;
5029 cmdline_fixed_string_t tx_pfc_mode;
5030 uint32_t high_water;
5032 uint16_t pause_time;
5038 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5039 __attribute__((unused)) struct cmdline *cl,
5040 __attribute__((unused)) void *data)
5042 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5043 struct rte_eth_pfc_conf pfc_conf;
5044 int rx_fc_enable, tx_fc_enable;
5048 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5049 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5050 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5051 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5053 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5054 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5057 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5058 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5059 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5060 pfc_conf.fc.high_water = res->high_water;
5061 pfc_conf.fc.low_water = res->low_water;
5062 pfc_conf.fc.pause_time = res->pause_time;
5063 pfc_conf.priority = res->priority;
5065 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5067 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5070 cmdline_parse_token_string_t cmd_pfc_set_set =
5071 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5073 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5074 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5075 pfc_ctrl, "pfc_ctrl");
5076 cmdline_parse_token_string_t cmd_pfc_set_rx =
5077 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5079 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5080 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5081 rx_pfc_mode, "on#off");
5082 cmdline_parse_token_string_t cmd_pfc_set_tx =
5083 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5085 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5086 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5087 tx_pfc_mode, "on#off");
5088 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5089 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5090 high_water, UINT32);
5091 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5092 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5094 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5095 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5096 pause_time, UINT16);
5097 cmdline_parse_token_num_t cmd_pfc_set_priority =
5098 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5100 cmdline_parse_token_num_t cmd_pfc_set_portid =
5101 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5104 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5105 .f = cmd_priority_flow_ctrl_set_parsed,
5107 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5108 tx on|off high_water low_water pause_time priority port_id",
5110 (void *)&cmd_pfc_set_set,
5111 (void *)&cmd_pfc_set_flow_ctrl,
5112 (void *)&cmd_pfc_set_rx,
5113 (void *)&cmd_pfc_set_rx_mode,
5114 (void *)&cmd_pfc_set_tx,
5115 (void *)&cmd_pfc_set_tx_mode,
5116 (void *)&cmd_pfc_set_high_water,
5117 (void *)&cmd_pfc_set_low_water,
5118 (void *)&cmd_pfc_set_pause_time,
5119 (void *)&cmd_pfc_set_priority,
5120 (void *)&cmd_pfc_set_portid,
5125 /* *** RESET CONFIGURATION *** */
5126 struct cmd_reset_result {
5127 cmdline_fixed_string_t reset;
5128 cmdline_fixed_string_t def;
5131 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5133 __attribute__((unused)) void *data)
5135 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5136 set_def_fwd_config();
5139 cmdline_parse_token_string_t cmd_reset_set =
5140 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5141 cmdline_parse_token_string_t cmd_reset_def =
5142 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5145 cmdline_parse_inst_t cmd_reset = {
5146 .f = cmd_reset_parsed,
5148 .help_str = "set default: reset default forwarding configuration",
5150 (void *)&cmd_reset_set,
5151 (void *)&cmd_reset_def,
5156 /* *** START FORWARDING *** */
5157 struct cmd_start_result {
5158 cmdline_fixed_string_t start;
5161 cmdline_parse_token_string_t cmd_start_start =
5162 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5164 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5165 __attribute__((unused)) struct cmdline *cl,
5166 __attribute__((unused)) void *data)
5168 start_packet_forwarding(0);
5171 cmdline_parse_inst_t cmd_start = {
5172 .f = cmd_start_parsed,
5174 .help_str = "start packet forwarding",
5176 (void *)&cmd_start_start,
5181 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5182 struct cmd_start_tx_first_result {
5183 cmdline_fixed_string_t start;
5184 cmdline_fixed_string_t tx_first;
5188 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5189 __attribute__((unused)) struct cmdline *cl,
5190 __attribute__((unused)) void *data)
5192 start_packet_forwarding(1);
5195 cmdline_parse_token_string_t cmd_start_tx_first_start =
5196 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5198 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5199 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5200 tx_first, "tx_first");
5202 cmdline_parse_inst_t cmd_start_tx_first = {
5203 .f = cmd_start_tx_first_parsed,
5205 .help_str = "start packet forwarding, after sending 1 burst of packets",
5207 (void *)&cmd_start_tx_first_start,
5208 (void *)&cmd_start_tx_first_tx_first,
5213 /* *** SET LINK UP *** */
5214 struct cmd_set_link_up_result {
5215 cmdline_fixed_string_t set;
5216 cmdline_fixed_string_t link_up;
5217 cmdline_fixed_string_t port;
5221 cmdline_parse_token_string_t cmd_set_link_up_set =
5222 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5223 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5226 cmdline_parse_token_string_t cmd_set_link_up_port =
5227 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5228 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5229 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5231 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5232 __attribute__((unused)) struct cmdline *cl,
5233 __attribute__((unused)) void *data)
5235 struct cmd_set_link_up_result *res = parsed_result;
5236 dev_set_link_up(res->port_id);
5239 cmdline_parse_inst_t cmd_set_link_up = {
5240 .f = cmd_set_link_up_parsed,
5242 .help_str = "set link-up port (port id)",
5244 (void *)&cmd_set_link_up_set,
5245 (void *)&cmd_set_link_up_link_up,
5246 (void *)&cmd_set_link_up_port,
5247 (void *)&cmd_set_link_up_port_id,
5252 /* *** SET LINK DOWN *** */
5253 struct cmd_set_link_down_result {
5254 cmdline_fixed_string_t set;
5255 cmdline_fixed_string_t link_down;
5256 cmdline_fixed_string_t port;
5260 cmdline_parse_token_string_t cmd_set_link_down_set =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5262 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5263 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5265 cmdline_parse_token_string_t cmd_set_link_down_port =
5266 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5267 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5268 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5270 static void cmd_set_link_down_parsed(
5271 __attribute__((unused)) void *parsed_result,
5272 __attribute__((unused)) struct cmdline *cl,
5273 __attribute__((unused)) void *data)
5275 struct cmd_set_link_down_result *res = parsed_result;
5276 dev_set_link_down(res->port_id);
5279 cmdline_parse_inst_t cmd_set_link_down = {
5280 .f = cmd_set_link_down_parsed,
5282 .help_str = "set link-down port (port id)",
5284 (void *)&cmd_set_link_down_set,
5285 (void *)&cmd_set_link_down_link_down,
5286 (void *)&cmd_set_link_down_port,
5287 (void *)&cmd_set_link_down_port_id,
5292 /* *** SHOW CFG *** */
5293 struct cmd_showcfg_result {
5294 cmdline_fixed_string_t show;
5295 cmdline_fixed_string_t cfg;
5296 cmdline_fixed_string_t what;
5299 static void cmd_showcfg_parsed(void *parsed_result,
5300 __attribute__((unused)) struct cmdline *cl,
5301 __attribute__((unused)) void *data)
5303 struct cmd_showcfg_result *res = parsed_result;
5304 if (!strcmp(res->what, "rxtx"))
5305 rxtx_config_display();
5306 else if (!strcmp(res->what, "cores"))
5307 fwd_lcores_config_display();
5308 else if (!strcmp(res->what, "fwd"))
5309 fwd_config_display();
5310 else if (!strcmp(res->what, "txpkts"))
5311 show_tx_pkt_segments();
5314 cmdline_parse_token_string_t cmd_showcfg_show =
5315 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5316 cmdline_parse_token_string_t cmd_showcfg_port =
5317 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5318 cmdline_parse_token_string_t cmd_showcfg_what =
5319 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5320 "rxtx#cores#fwd#txpkts");
5322 cmdline_parse_inst_t cmd_showcfg = {
5323 .f = cmd_showcfg_parsed,
5325 .help_str = "show config rxtx|cores|fwd|txpkts",
5327 (void *)&cmd_showcfg_show,
5328 (void *)&cmd_showcfg_port,
5329 (void *)&cmd_showcfg_what,
5334 /* *** SHOW ALL PORT INFO *** */
5335 struct cmd_showportall_result {
5336 cmdline_fixed_string_t show;
5337 cmdline_fixed_string_t port;
5338 cmdline_fixed_string_t what;
5339 cmdline_fixed_string_t all;
5342 static void cmd_showportall_parsed(void *parsed_result,
5343 __attribute__((unused)) struct cmdline *cl,
5344 __attribute__((unused)) void *data)
5348 struct cmd_showportall_result *res = parsed_result;
5349 if (!strcmp(res->show, "clear")) {
5350 if (!strcmp(res->what, "stats"))
5351 FOREACH_PORT(i, ports)
5353 else if (!strcmp(res->what, "xstats"))
5354 FOREACH_PORT(i, ports)
5355 nic_xstats_clear(i);
5356 } else if (!strcmp(res->what, "info"))
5357 FOREACH_PORT(i, ports)
5358 port_infos_display(i);
5359 else if (!strcmp(res->what, "stats"))
5360 FOREACH_PORT(i, ports)
5361 nic_stats_display(i);
5362 else if (!strcmp(res->what, "xstats"))
5363 FOREACH_PORT(i, ports)
5364 nic_xstats_display(i);
5365 else if (!strcmp(res->what, "fdir"))
5366 FOREACH_PORT(i, ports)
5368 else if (!strcmp(res->what, "stat_qmap"))
5369 FOREACH_PORT(i, ports)
5370 nic_stats_mapping_display(i);
5371 else if (!strcmp(res->what, "dcb_tc"))
5372 FOREACH_PORT(i, ports)
5373 port_dcb_info_display(i);
5376 cmdline_parse_token_string_t cmd_showportall_show =
5377 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5379 cmdline_parse_token_string_t cmd_showportall_port =
5380 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5381 cmdline_parse_token_string_t cmd_showportall_what =
5382 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5383 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5384 cmdline_parse_token_string_t cmd_showportall_all =
5385 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5386 cmdline_parse_inst_t cmd_showportall = {
5387 .f = cmd_showportall_parsed,
5389 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5391 (void *)&cmd_showportall_show,
5392 (void *)&cmd_showportall_port,
5393 (void *)&cmd_showportall_what,
5394 (void *)&cmd_showportall_all,
5399 /* *** SHOW PORT INFO *** */
5400 struct cmd_showport_result {
5401 cmdline_fixed_string_t show;
5402 cmdline_fixed_string_t port;
5403 cmdline_fixed_string_t what;
5407 static void cmd_showport_parsed(void *parsed_result,
5408 __attribute__((unused)) struct cmdline *cl,
5409 __attribute__((unused)) void *data)
5411 struct cmd_showport_result *res = parsed_result;
5412 if (!strcmp(res->show, "clear")) {
5413 if (!strcmp(res->what, "stats"))
5414 nic_stats_clear(res->portnum);
5415 else if (!strcmp(res->what, "xstats"))
5416 nic_xstats_clear(res->portnum);
5417 } else if (!strcmp(res->what, "info"))
5418 port_infos_display(res->portnum);
5419 else if (!strcmp(res->what, "stats"))
5420 nic_stats_display(res->portnum);
5421 else if (!strcmp(res->what, "xstats"))
5422 nic_xstats_display(res->portnum);
5423 else if (!strcmp(res->what, "fdir"))
5424 fdir_get_infos(res->portnum);
5425 else if (!strcmp(res->what, "stat_qmap"))
5426 nic_stats_mapping_display(res->portnum);
5427 else if (!strcmp(res->what, "dcb_tc"))
5428 port_dcb_info_display(res->portnum);
5431 cmdline_parse_token_string_t cmd_showport_show =
5432 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5434 cmdline_parse_token_string_t cmd_showport_port =
5435 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5436 cmdline_parse_token_string_t cmd_showport_what =
5437 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5438 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5439 cmdline_parse_token_num_t cmd_showport_portnum =
5440 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5442 cmdline_parse_inst_t cmd_showport = {
5443 .f = cmd_showport_parsed,
5445 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5447 (void *)&cmd_showport_show,
5448 (void *)&cmd_showport_port,
5449 (void *)&cmd_showport_what,
5450 (void *)&cmd_showport_portnum,
5455 /* *** SHOW QUEUE INFO *** */
5456 struct cmd_showqueue_result {
5457 cmdline_fixed_string_t show;
5458 cmdline_fixed_string_t type;
5459 cmdline_fixed_string_t what;
5465 cmd_showqueue_parsed(void *parsed_result,
5466 __attribute__((unused)) struct cmdline *cl,
5467 __attribute__((unused)) void *data)
5469 struct cmd_showqueue_result *res = parsed_result;
5471 if (!strcmp(res->type, "rxq"))
5472 rx_queue_infos_display(res->portnum, res->queuenum);
5473 else if (!strcmp(res->type, "txq"))
5474 tx_queue_infos_display(res->portnum, res->queuenum);
5477 cmdline_parse_token_string_t cmd_showqueue_show =
5478 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5479 cmdline_parse_token_string_t cmd_showqueue_type =
5480 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5481 cmdline_parse_token_string_t cmd_showqueue_what =
5482 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5483 cmdline_parse_token_num_t cmd_showqueue_portnum =
5484 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5485 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5486 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5488 cmdline_parse_inst_t cmd_showqueue = {
5489 .f = cmd_showqueue_parsed,
5491 .help_str = "show rxq|txq info <port number> <queue_number>",
5493 (void *)&cmd_showqueue_show,
5494 (void *)&cmd_showqueue_type,
5495 (void *)&cmd_showqueue_what,
5496 (void *)&cmd_showqueue_portnum,
5497 (void *)&cmd_showqueue_queuenum,
5502 /* *** READ PORT REGISTER *** */
5503 struct cmd_read_reg_result {
5504 cmdline_fixed_string_t read;
5505 cmdline_fixed_string_t reg;
5511 cmd_read_reg_parsed(void *parsed_result,
5512 __attribute__((unused)) struct cmdline *cl,
5513 __attribute__((unused)) void *data)
5515 struct cmd_read_reg_result *res = parsed_result;
5516 port_reg_display(res->port_id, res->reg_off);
5519 cmdline_parse_token_string_t cmd_read_reg_read =
5520 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5521 cmdline_parse_token_string_t cmd_read_reg_reg =
5522 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5523 cmdline_parse_token_num_t cmd_read_reg_port_id =
5524 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5525 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5526 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5528 cmdline_parse_inst_t cmd_read_reg = {
5529 .f = cmd_read_reg_parsed,
5531 .help_str = "read reg port_id reg_off",
5533 (void *)&cmd_read_reg_read,
5534 (void *)&cmd_read_reg_reg,
5535 (void *)&cmd_read_reg_port_id,
5536 (void *)&cmd_read_reg_reg_off,
5541 /* *** READ PORT REGISTER BIT FIELD *** */
5542 struct cmd_read_reg_bit_field_result {
5543 cmdline_fixed_string_t read;
5544 cmdline_fixed_string_t regfield;
5552 cmd_read_reg_bit_field_parsed(void *parsed_result,
5553 __attribute__((unused)) struct cmdline *cl,
5554 __attribute__((unused)) void *data)
5556 struct cmd_read_reg_bit_field_result *res = parsed_result;
5557 port_reg_bit_field_display(res->port_id, res->reg_off,
5558 res->bit1_pos, res->bit2_pos);
5561 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5562 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5564 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5565 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5566 regfield, "regfield");
5567 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5568 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5570 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5571 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5573 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5574 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5576 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5577 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5580 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5581 .f = cmd_read_reg_bit_field_parsed,
5583 .help_str = "read regfield port_id reg_off bit_x bit_y "
5584 "(read register bit field between bit_x and bit_y included)",
5586 (void *)&cmd_read_reg_bit_field_read,
5587 (void *)&cmd_read_reg_bit_field_regfield,
5588 (void *)&cmd_read_reg_bit_field_port_id,
5589 (void *)&cmd_read_reg_bit_field_reg_off,
5590 (void *)&cmd_read_reg_bit_field_bit1_pos,
5591 (void *)&cmd_read_reg_bit_field_bit2_pos,
5596 /* *** READ PORT REGISTER BIT *** */
5597 struct cmd_read_reg_bit_result {
5598 cmdline_fixed_string_t read;
5599 cmdline_fixed_string_t regbit;
5606 cmd_read_reg_bit_parsed(void *parsed_result,
5607 __attribute__((unused)) struct cmdline *cl,
5608 __attribute__((unused)) void *data)
5610 struct cmd_read_reg_bit_result *res = parsed_result;
5611 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5614 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5615 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5616 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5617 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5619 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5620 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5621 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5622 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5623 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5624 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5626 cmdline_parse_inst_t cmd_read_reg_bit = {
5627 .f = cmd_read_reg_bit_parsed,
5629 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5631 (void *)&cmd_read_reg_bit_read,
5632 (void *)&cmd_read_reg_bit_regbit,
5633 (void *)&cmd_read_reg_bit_port_id,
5634 (void *)&cmd_read_reg_bit_reg_off,
5635 (void *)&cmd_read_reg_bit_bit_pos,
5640 /* *** WRITE PORT REGISTER *** */
5641 struct cmd_write_reg_result {
5642 cmdline_fixed_string_t write;
5643 cmdline_fixed_string_t reg;
5650 cmd_write_reg_parsed(void *parsed_result,
5651 __attribute__((unused)) struct cmdline *cl,
5652 __attribute__((unused)) void *data)
5654 struct cmd_write_reg_result *res = parsed_result;
5655 port_reg_set(res->port_id, res->reg_off, res->value);
5658 cmdline_parse_token_string_t cmd_write_reg_write =
5659 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5660 cmdline_parse_token_string_t cmd_write_reg_reg =
5661 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5662 cmdline_parse_token_num_t cmd_write_reg_port_id =
5663 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5664 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5665 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5666 cmdline_parse_token_num_t cmd_write_reg_value =
5667 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5669 cmdline_parse_inst_t cmd_write_reg = {
5670 .f = cmd_write_reg_parsed,
5672 .help_str = "write reg port_id reg_off reg_value",
5674 (void *)&cmd_write_reg_write,
5675 (void *)&cmd_write_reg_reg,
5676 (void *)&cmd_write_reg_port_id,
5677 (void *)&cmd_write_reg_reg_off,
5678 (void *)&cmd_write_reg_value,
5683 /* *** WRITE PORT REGISTER BIT FIELD *** */
5684 struct cmd_write_reg_bit_field_result {
5685 cmdline_fixed_string_t write;
5686 cmdline_fixed_string_t regfield;
5695 cmd_write_reg_bit_field_parsed(void *parsed_result,
5696 __attribute__((unused)) struct cmdline *cl,
5697 __attribute__((unused)) void *data)
5699 struct cmd_write_reg_bit_field_result *res = parsed_result;
5700 port_reg_bit_field_set(res->port_id, res->reg_off,
5701 res->bit1_pos, res->bit2_pos, res->value);
5704 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5705 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5707 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5708 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5709 regfield, "regfield");
5710 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5711 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5713 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5714 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5716 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5717 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5719 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5720 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5722 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5723 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5726 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5727 .f = cmd_write_reg_bit_field_parsed,
5729 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5730 "(set register bit field between bit_x and bit_y included)",
5732 (void *)&cmd_write_reg_bit_field_write,
5733 (void *)&cmd_write_reg_bit_field_regfield,
5734 (void *)&cmd_write_reg_bit_field_port_id,
5735 (void *)&cmd_write_reg_bit_field_reg_off,
5736 (void *)&cmd_write_reg_bit_field_bit1_pos,
5737 (void *)&cmd_write_reg_bit_field_bit2_pos,
5738 (void *)&cmd_write_reg_bit_field_value,
5743 /* *** WRITE PORT REGISTER BIT *** */
5744 struct cmd_write_reg_bit_result {
5745 cmdline_fixed_string_t write;
5746 cmdline_fixed_string_t regbit;
5754 cmd_write_reg_bit_parsed(void *parsed_result,
5755 __attribute__((unused)) struct cmdline *cl,
5756 __attribute__((unused)) void *data)
5758 struct cmd_write_reg_bit_result *res = parsed_result;
5759 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5762 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5763 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5765 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5766 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5768 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5769 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5770 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5771 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5772 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5773 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5774 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5775 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5777 cmdline_parse_inst_t cmd_write_reg_bit = {
5778 .f = cmd_write_reg_bit_parsed,
5780 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5782 (void *)&cmd_write_reg_bit_write,
5783 (void *)&cmd_write_reg_bit_regbit,
5784 (void *)&cmd_write_reg_bit_port_id,
5785 (void *)&cmd_write_reg_bit_reg_off,
5786 (void *)&cmd_write_reg_bit_bit_pos,
5787 (void *)&cmd_write_reg_bit_value,
5792 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5793 struct cmd_read_rxd_txd_result {
5794 cmdline_fixed_string_t read;
5795 cmdline_fixed_string_t rxd_txd;
5802 cmd_read_rxd_txd_parsed(void *parsed_result,
5803 __attribute__((unused)) struct cmdline *cl,
5804 __attribute__((unused)) void *data)
5806 struct cmd_read_rxd_txd_result *res = parsed_result;
5808 if (!strcmp(res->rxd_txd, "rxd"))
5809 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5810 else if (!strcmp(res->rxd_txd, "txd"))
5811 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5814 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5815 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5816 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5817 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5819 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5820 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5821 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5822 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5823 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5824 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5826 cmdline_parse_inst_t cmd_read_rxd_txd = {
5827 .f = cmd_read_rxd_txd_parsed,
5829 .help_str = "read rxd|txd port_id queue_id rxd_id",
5831 (void *)&cmd_read_rxd_txd_read,
5832 (void *)&cmd_read_rxd_txd_rxd_txd,
5833 (void *)&cmd_read_rxd_txd_port_id,
5834 (void *)&cmd_read_rxd_txd_queue_id,
5835 (void *)&cmd_read_rxd_txd_desc_id,
5841 struct cmd_quit_result {
5842 cmdline_fixed_string_t quit;
5845 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5847 __attribute__((unused)) void *data)
5853 cmdline_parse_token_string_t cmd_quit_quit =
5854 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5856 cmdline_parse_inst_t cmd_quit = {
5857 .f = cmd_quit_parsed,
5859 .help_str = "exit application",
5861 (void *)&cmd_quit_quit,
5866 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5867 struct cmd_mac_addr_result {
5868 cmdline_fixed_string_t mac_addr_cmd;
5869 cmdline_fixed_string_t what;
5871 struct ether_addr address;
5874 static void cmd_mac_addr_parsed(void *parsed_result,
5875 __attribute__((unused)) struct cmdline *cl,
5876 __attribute__((unused)) void *data)
5878 struct cmd_mac_addr_result *res = parsed_result;
5881 if (strcmp(res->what, "add") == 0)
5882 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5884 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5886 /* check the return value and print it if is < 0 */
5888 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5892 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5893 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5895 cmdline_parse_token_string_t cmd_mac_addr_what =
5896 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5898 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5899 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5900 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5903 cmdline_parse_inst_t cmd_mac_addr = {
5904 .f = cmd_mac_addr_parsed,
5906 .help_str = "mac_addr add|remove X <address>: "
5907 "add/remove MAC address on port X",
5909 (void *)&cmd_mac_addr_cmd,
5910 (void *)&cmd_mac_addr_what,
5911 (void *)&cmd_mac_addr_portnum,
5912 (void *)&cmd_mac_addr_addr,
5918 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5919 struct cmd_set_qmap_result {
5920 cmdline_fixed_string_t set;
5921 cmdline_fixed_string_t qmap;
5922 cmdline_fixed_string_t what;
5929 cmd_set_qmap_parsed(void *parsed_result,
5930 __attribute__((unused)) struct cmdline *cl,
5931 __attribute__((unused)) void *data)
5933 struct cmd_set_qmap_result *res = parsed_result;
5934 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5936 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5939 cmdline_parse_token_string_t cmd_setqmap_set =
5940 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5942 cmdline_parse_token_string_t cmd_setqmap_qmap =
5943 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5945 cmdline_parse_token_string_t cmd_setqmap_what =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5948 cmdline_parse_token_num_t cmd_setqmap_portid =
5949 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5951 cmdline_parse_token_num_t cmd_setqmap_queueid =
5952 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5954 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5955 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5958 cmdline_parse_inst_t cmd_set_qmap = {
5959 .f = cmd_set_qmap_parsed,
5961 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5963 (void *)&cmd_setqmap_set,
5964 (void *)&cmd_setqmap_qmap,
5965 (void *)&cmd_setqmap_what,
5966 (void *)&cmd_setqmap_portid,
5967 (void *)&cmd_setqmap_queueid,
5968 (void *)&cmd_setqmap_mapvalue,
5973 /* *** CONFIGURE UNICAST HASH TABLE *** */
5974 struct cmd_set_uc_hash_table {
5975 cmdline_fixed_string_t set;
5976 cmdline_fixed_string_t port;
5978 cmdline_fixed_string_t what;
5979 struct ether_addr address;
5980 cmdline_fixed_string_t mode;
5984 cmd_set_uc_hash_parsed(void *parsed_result,
5985 __attribute__((unused)) struct cmdline *cl,
5986 __attribute__((unused)) void *data)
5989 struct cmd_set_uc_hash_table *res = parsed_result;
5991 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5993 if (strcmp(res->what, "uta") == 0)
5994 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5995 &res->address,(uint8_t)is_on);
5997 printf("bad unicast hash table parameter, return code = %d \n", ret);
6001 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6002 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6004 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6005 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6007 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6008 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6010 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6011 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6013 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6014 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6016 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6017 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6020 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6021 .f = cmd_set_uc_hash_parsed,
6023 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6025 (void *)&cmd_set_uc_hash_set,
6026 (void *)&cmd_set_uc_hash_port,
6027 (void *)&cmd_set_uc_hash_portid,
6028 (void *)&cmd_set_uc_hash_what,
6029 (void *)&cmd_set_uc_hash_mac,
6030 (void *)&cmd_set_uc_hash_mode,
6035 struct cmd_set_uc_all_hash_table {
6036 cmdline_fixed_string_t set;
6037 cmdline_fixed_string_t port;
6039 cmdline_fixed_string_t what;
6040 cmdline_fixed_string_t value;
6041 cmdline_fixed_string_t mode;
6045 cmd_set_uc_all_hash_parsed(void *parsed_result,
6046 __attribute__((unused)) struct cmdline *cl,
6047 __attribute__((unused)) void *data)
6050 struct cmd_set_uc_all_hash_table *res = parsed_result;
6052 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6054 if ((strcmp(res->what, "uta") == 0) &&
6055 (strcmp(res->value, "all") == 0))
6056 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6058 printf("bad unicast hash table parameter,"
6059 "return code = %d \n", ret);
6062 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6065 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6066 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6068 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6069 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6071 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6074 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6077 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6081 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6082 .f = cmd_set_uc_all_hash_parsed,
6084 .help_str = "set port X uta all on|off (X = port number)",
6086 (void *)&cmd_set_uc_all_hash_set,
6087 (void *)&cmd_set_uc_all_hash_port,
6088 (void *)&cmd_set_uc_all_hash_portid,
6089 (void *)&cmd_set_uc_all_hash_what,
6090 (void *)&cmd_set_uc_all_hash_value,
6091 (void *)&cmd_set_uc_all_hash_mode,
6096 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6097 struct cmd_set_vf_macvlan_filter {
6098 cmdline_fixed_string_t set;
6099 cmdline_fixed_string_t port;
6101 cmdline_fixed_string_t vf;
6103 struct ether_addr address;
6104 cmdline_fixed_string_t filter_type;
6105 cmdline_fixed_string_t mode;
6109 cmd_set_vf_macvlan_parsed(void *parsed_result,
6110 __attribute__((unused)) struct cmdline *cl,
6111 __attribute__((unused)) void *data)
6114 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6115 struct rte_eth_mac_filter filter;
6117 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6119 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6121 /* set VF MAC filter */
6125 filter.dst_id = res->vf_id;
6127 if (!strcmp(res->filter_type, "exact-mac"))
6128 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6129 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6130 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6131 else if (!strcmp(res->filter_type, "hashmac"))
6132 filter.filter_type = RTE_MAC_HASH_MATCH;
6133 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6134 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6136 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6139 ret = rte_eth_dev_filter_ctrl(res->port_id,
6140 RTE_ETH_FILTER_MACVLAN,
6144 ret = rte_eth_dev_filter_ctrl(res->port_id,
6145 RTE_ETH_FILTER_MACVLAN,
6146 RTE_ETH_FILTER_DELETE,
6150 printf("bad set MAC hash parameter, return code = %d\n", ret);
6154 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6155 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6157 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6158 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6160 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6161 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6163 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6164 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6166 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6167 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6169 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6170 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6172 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6174 filter_type, "exact-mac#exact-mac-vlan"
6175 "#hashmac#hashmac-vlan");
6176 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6177 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6180 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6181 .f = cmd_set_vf_macvlan_parsed,
6183 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6184 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6186 "exact match rule:exact match of MAC or MAC and VLAN; "
6187 "hash match rule: hash match of MAC and exact match "
6190 (void *)&cmd_set_vf_macvlan_set,
6191 (void *)&cmd_set_vf_macvlan_port,
6192 (void *)&cmd_set_vf_macvlan_portid,
6193 (void *)&cmd_set_vf_macvlan_vf,
6194 (void *)&cmd_set_vf_macvlan_vf_id,
6195 (void *)&cmd_set_vf_macvlan_mac,
6196 (void *)&cmd_set_vf_macvlan_filter_type,
6197 (void *)&cmd_set_vf_macvlan_mode,
6202 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6203 struct cmd_set_vf_traffic {
6204 cmdline_fixed_string_t set;
6205 cmdline_fixed_string_t port;
6207 cmdline_fixed_string_t vf;
6209 cmdline_fixed_string_t what;
6210 cmdline_fixed_string_t mode;
6214 cmd_set_vf_traffic_parsed(void *parsed_result,
6215 __attribute__((unused)) struct cmdline *cl,
6216 __attribute__((unused)) void *data)
6218 struct cmd_set_vf_traffic *res = parsed_result;
6219 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6220 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6222 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6225 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6228 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6231 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6232 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6234 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6237 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6240 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6241 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6243 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6247 cmdline_parse_inst_t cmd_set_vf_traffic = {
6248 .f = cmd_set_vf_traffic_parsed,
6250 .help_str = "set port X vf Y rx|tx on|off"
6251 "(X = port number,Y = vf id)",
6253 (void *)&cmd_setvf_traffic_set,
6254 (void *)&cmd_setvf_traffic_port,
6255 (void *)&cmd_setvf_traffic_portid,
6256 (void *)&cmd_setvf_traffic_vf,
6257 (void *)&cmd_setvf_traffic_vfid,
6258 (void *)&cmd_setvf_traffic_what,
6259 (void *)&cmd_setvf_traffic_mode,
6264 /* *** CONFIGURE VF RECEIVE MODE *** */
6265 struct cmd_set_vf_rxmode {
6266 cmdline_fixed_string_t set;
6267 cmdline_fixed_string_t port;
6269 cmdline_fixed_string_t vf;
6271 cmdline_fixed_string_t what;
6272 cmdline_fixed_string_t mode;
6273 cmdline_fixed_string_t on;
6277 cmd_set_vf_rxmode_parsed(void *parsed_result,
6278 __attribute__((unused)) struct cmdline *cl,
6279 __attribute__((unused)) void *data)
6282 uint16_t rx_mode = 0;
6283 struct cmd_set_vf_rxmode *res = parsed_result;
6285 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6286 if (!strcmp(res->what,"rxmode")) {
6287 if (!strcmp(res->mode, "AUPE"))
6288 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6289 else if (!strcmp(res->mode, "ROPE"))
6290 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6291 else if (!strcmp(res->mode, "BAM"))
6292 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6293 else if (!strncmp(res->mode, "MPE",3))
6294 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6297 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6299 printf("bad VF receive mode parameter, return code = %d \n",
6303 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6304 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6306 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6307 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6309 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6310 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6312 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6315 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6316 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6318 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6319 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6321 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6322 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6323 mode, "AUPE#ROPE#BAM#MPE");
6324 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6325 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6328 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6329 .f = cmd_set_vf_rxmode_parsed,
6331 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6333 (void *)&cmd_set_vf_rxmode_set,
6334 (void *)&cmd_set_vf_rxmode_port,
6335 (void *)&cmd_set_vf_rxmode_portid,
6336 (void *)&cmd_set_vf_rxmode_vf,
6337 (void *)&cmd_set_vf_rxmode_vfid,
6338 (void *)&cmd_set_vf_rxmode_what,
6339 (void *)&cmd_set_vf_rxmode_mode,
6340 (void *)&cmd_set_vf_rxmode_on,
6345 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6346 struct cmd_vf_mac_addr_result {
6347 cmdline_fixed_string_t mac_addr_cmd;
6348 cmdline_fixed_string_t what;
6349 cmdline_fixed_string_t port;
6351 cmdline_fixed_string_t vf;
6353 struct ether_addr address;
6356 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6357 __attribute__((unused)) struct cmdline *cl,
6358 __attribute__((unused)) void *data)
6360 struct cmd_vf_mac_addr_result *res = parsed_result;
6363 if (strcmp(res->what, "add") == 0)
6364 ret = rte_eth_dev_mac_addr_add(res->port_num,
6365 &res->address, res->vf_num);
6367 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6371 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6372 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6373 mac_addr_cmd,"mac_addr");
6374 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6375 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6377 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6378 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6380 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6381 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6383 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6384 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6386 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6387 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6389 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6390 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6393 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6394 .f = cmd_vf_mac_addr_parsed,
6396 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6397 "Y = VF number)add MAC address filtering for a VF on port X",
6399 (void *)&cmd_vf_mac_addr_cmd,
6400 (void *)&cmd_vf_mac_addr_what,
6401 (void *)&cmd_vf_mac_addr_port,
6402 (void *)&cmd_vf_mac_addr_portnum,
6403 (void *)&cmd_vf_mac_addr_vf,
6404 (void *)&cmd_vf_mac_addr_vfnum,
6405 (void *)&cmd_vf_mac_addr_addr,
6410 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6411 struct cmd_vf_rx_vlan_filter {
6412 cmdline_fixed_string_t rx_vlan;
6413 cmdline_fixed_string_t what;
6415 cmdline_fixed_string_t port;
6417 cmdline_fixed_string_t vf;
6422 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6423 __attribute__((unused)) struct cmdline *cl,
6424 __attribute__((unused)) void *data)
6426 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6428 if (!strcmp(res->what, "add"))
6429 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6431 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6434 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6435 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6436 rx_vlan, "rx_vlan");
6437 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6438 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6440 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6441 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6443 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6444 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6446 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6447 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6449 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6450 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6452 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6453 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6456 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6457 .f = cmd_vf_rx_vlan_filter_parsed,
6459 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6460 "Y = port number,Z = hexadecimal VF mask)",
6462 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6463 (void *)&cmd_vf_rx_vlan_filter_what,
6464 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6465 (void *)&cmd_vf_rx_vlan_filter_port,
6466 (void *)&cmd_vf_rx_vlan_filter_portid,
6467 (void *)&cmd_vf_rx_vlan_filter_vf,
6468 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6473 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6474 struct cmd_queue_rate_limit_result {
6475 cmdline_fixed_string_t set;
6476 cmdline_fixed_string_t port;
6478 cmdline_fixed_string_t queue;
6480 cmdline_fixed_string_t rate;
6484 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6485 __attribute__((unused)) struct cmdline *cl,
6486 __attribute__((unused)) void *data)
6488 struct cmd_queue_rate_limit_result *res = parsed_result;
6491 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6492 && (strcmp(res->queue, "queue") == 0)
6493 && (strcmp(res->rate, "rate") == 0))
6494 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6497 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6501 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6502 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6504 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6505 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6507 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6508 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6510 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6511 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6513 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6514 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6516 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6517 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6519 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6520 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6523 cmdline_parse_inst_t cmd_queue_rate_limit = {
6524 .f = cmd_queue_rate_limit_parsed,
6526 .help_str = "set port X queue Y rate Z:(X = port number,"
6527 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6529 (void *)&cmd_queue_rate_limit_set,
6530 (void *)&cmd_queue_rate_limit_port,
6531 (void *)&cmd_queue_rate_limit_portnum,
6532 (void *)&cmd_queue_rate_limit_queue,
6533 (void *)&cmd_queue_rate_limit_queuenum,
6534 (void *)&cmd_queue_rate_limit_rate,
6535 (void *)&cmd_queue_rate_limit_ratenum,
6540 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6541 struct cmd_vf_rate_limit_result {
6542 cmdline_fixed_string_t set;
6543 cmdline_fixed_string_t port;
6545 cmdline_fixed_string_t vf;
6547 cmdline_fixed_string_t rate;
6549 cmdline_fixed_string_t q_msk;
6553 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6554 __attribute__((unused)) struct cmdline *cl,
6555 __attribute__((unused)) void *data)
6557 struct cmd_vf_rate_limit_result *res = parsed_result;
6560 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6561 && (strcmp(res->vf, "vf") == 0)
6562 && (strcmp(res->rate, "rate") == 0)
6563 && (strcmp(res->q_msk, "queue_mask") == 0))
6564 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6565 res->rate_num, res->q_msk_val);
6567 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6571 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6572 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6574 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6575 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6577 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6578 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6580 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6581 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6583 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6584 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6586 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6587 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6589 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6590 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6592 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6593 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6594 q_msk, "queue_mask");
6595 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6596 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6599 cmdline_parse_inst_t cmd_vf_rate_limit = {
6600 .f = cmd_vf_rate_limit_parsed,
6602 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6603 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6604 "for queues of VF on port X",
6606 (void *)&cmd_vf_rate_limit_set,
6607 (void *)&cmd_vf_rate_limit_port,
6608 (void *)&cmd_vf_rate_limit_portnum,
6609 (void *)&cmd_vf_rate_limit_vf,
6610 (void *)&cmd_vf_rate_limit_vfnum,
6611 (void *)&cmd_vf_rate_limit_rate,
6612 (void *)&cmd_vf_rate_limit_ratenum,
6613 (void *)&cmd_vf_rate_limit_q_msk,
6614 (void *)&cmd_vf_rate_limit_q_msk_val,
6619 /* *** ADD TUNNEL FILTER OF A PORT *** */
6620 struct cmd_tunnel_filter_result {
6621 cmdline_fixed_string_t cmd;
6622 cmdline_fixed_string_t what;
6624 struct ether_addr outer_mac;
6625 struct ether_addr inner_mac;
6626 cmdline_ipaddr_t ip_value;
6627 uint16_t inner_vlan;
6628 cmdline_fixed_string_t tunnel_type;
6629 cmdline_fixed_string_t filter_type;
6635 cmd_tunnel_filter_parsed(void *parsed_result,
6636 __attribute__((unused)) struct cmdline *cl,
6637 __attribute__((unused)) void *data)
6639 struct cmd_tunnel_filter_result *res = parsed_result;
6640 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6643 tunnel_filter_conf.outer_mac = &res->outer_mac;
6644 tunnel_filter_conf.inner_mac = &res->inner_mac;
6645 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6647 if (res->ip_value.family == AF_INET) {
6648 tunnel_filter_conf.ip_addr.ipv4_addr =
6649 res->ip_value.addr.ipv4.s_addr;
6650 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6652 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6653 &(res->ip_value.addr.ipv6),
6654 sizeof(struct in6_addr));
6655 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6658 if (!strcmp(res->filter_type, "imac-ivlan"))
6659 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6660 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6661 tunnel_filter_conf.filter_type =
6662 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6663 else if (!strcmp(res->filter_type, "imac-tenid"))
6664 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6665 else if (!strcmp(res->filter_type, "imac"))
6666 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6667 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6668 tunnel_filter_conf.filter_type =
6669 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6671 printf("The filter type is not supported");
6675 if (!strcmp(res->tunnel_type, "vxlan"))
6676 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6677 else if (!strcmp(res->tunnel_type, "nvgre"))
6678 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6680 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6684 tunnel_filter_conf.tenant_id = res->tenant_id;
6685 tunnel_filter_conf.queue_id = res->queue_num;
6686 if (!strcmp(res->what, "add"))
6687 ret = rte_eth_dev_filter_ctrl(res->port_id,
6688 RTE_ETH_FILTER_TUNNEL,
6690 &tunnel_filter_conf);
6692 ret = rte_eth_dev_filter_ctrl(res->port_id,
6693 RTE_ETH_FILTER_TUNNEL,
6694 RTE_ETH_FILTER_DELETE,
6695 &tunnel_filter_conf);
6697 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6701 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6702 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6703 cmd, "tunnel_filter");
6704 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6705 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6707 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6708 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6710 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6713 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6714 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6716 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6717 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6718 inner_vlan, UINT16);
6719 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6720 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6722 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6723 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6724 tunnel_type, "vxlan#nvgre");
6726 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6727 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6728 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6729 "imac#omac-imac-tenid");
6730 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6731 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6733 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6734 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6737 cmdline_parse_inst_t cmd_tunnel_filter = {
6738 .f = cmd_tunnel_filter_parsed,
6740 .help_str = "add/rm tunnel filter of a port: "
6741 "tunnel_filter add port_id outer_mac inner_mac ip "
6742 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6743 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6744 "imac|omac-imac-tenid) "
6745 "tenant_id queue_num",
6747 (void *)&cmd_tunnel_filter_cmd,
6748 (void *)&cmd_tunnel_filter_what,
6749 (void *)&cmd_tunnel_filter_port_id,
6750 (void *)&cmd_tunnel_filter_outer_mac,
6751 (void *)&cmd_tunnel_filter_inner_mac,
6752 (void *)&cmd_tunnel_filter_ip_value,
6753 (void *)&cmd_tunnel_filter_innner_vlan,
6754 (void *)&cmd_tunnel_filter_tunnel_type,
6755 (void *)&cmd_tunnel_filter_filter_type,
6756 (void *)&cmd_tunnel_filter_tenant_id,
6757 (void *)&cmd_tunnel_filter_queue_num,
6762 /* *** CONFIGURE TUNNEL UDP PORT *** */
6763 struct cmd_tunnel_udp_config {
6764 cmdline_fixed_string_t cmd;
6765 cmdline_fixed_string_t what;
6771 cmd_tunnel_udp_config_parsed(void *parsed_result,
6772 __attribute__((unused)) struct cmdline *cl,
6773 __attribute__((unused)) void *data)
6775 struct cmd_tunnel_udp_config *res = parsed_result;
6776 struct rte_eth_udp_tunnel tunnel_udp;
6779 tunnel_udp.udp_port = res->udp_port;
6781 if (!strcmp(res->cmd, "rx_vxlan_port"))
6782 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6784 if (!strcmp(res->what, "add"))
6785 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6787 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6790 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6793 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6794 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6795 cmd, "rx_vxlan_port");
6796 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6797 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6799 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6800 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6802 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6803 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6806 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6807 .f = cmd_tunnel_udp_config_parsed,
6809 .help_str = "add/rm an tunneling UDP port filter: "
6810 "rx_vxlan_port add udp_port port_id",
6812 (void *)&cmd_tunnel_udp_config_cmd,
6813 (void *)&cmd_tunnel_udp_config_what,
6814 (void *)&cmd_tunnel_udp_config_udp_port,
6815 (void *)&cmd_tunnel_udp_config_port_id,
6820 /* *** GLOBAL CONFIG *** */
6821 struct cmd_global_config_result {
6822 cmdline_fixed_string_t cmd;
6824 cmdline_fixed_string_t cfg_type;
6829 cmd_global_config_parsed(void *parsed_result,
6830 __attribute__((unused)) struct cmdline *cl,
6831 __attribute__((unused)) void *data)
6833 struct cmd_global_config_result *res = parsed_result;
6834 struct rte_eth_global_cfg conf;
6837 memset(&conf, 0, sizeof(conf));
6838 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6839 conf.cfg.gre_key_len = res->len;
6840 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6841 RTE_ETH_FILTER_SET, &conf);
6843 printf("Global config error\n");
6846 cmdline_parse_token_string_t cmd_global_config_cmd =
6847 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6849 cmdline_parse_token_num_t cmd_global_config_port_id =
6850 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6851 cmdline_parse_token_string_t cmd_global_config_type =
6852 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6853 cfg_type, "gre-key-len");
6854 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6855 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6858 cmdline_parse_inst_t cmd_global_config = {
6859 .f = cmd_global_config_parsed,
6860 .data = (void *)NULL,
6861 .help_str = "global_config <port_id> gre-key-len <number>",
6863 (void *)&cmd_global_config_cmd,
6864 (void *)&cmd_global_config_port_id,
6865 (void *)&cmd_global_config_type,
6866 (void *)&cmd_global_config_gre_key_len,
6871 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6872 struct cmd_set_mirror_mask_result {
6873 cmdline_fixed_string_t set;
6874 cmdline_fixed_string_t port;
6876 cmdline_fixed_string_t mirror;
6878 cmdline_fixed_string_t what;
6879 cmdline_fixed_string_t value;
6880 cmdline_fixed_string_t dstpool;
6882 cmdline_fixed_string_t on;
6885 cmdline_parse_token_string_t cmd_mirror_mask_set =
6886 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6888 cmdline_parse_token_string_t cmd_mirror_mask_port =
6889 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6891 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6892 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6894 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6895 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6896 mirror, "mirror-rule");
6897 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6898 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6900 cmdline_parse_token_string_t cmd_mirror_mask_what =
6901 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6902 what, "pool-mirror-up#pool-mirror-down"
6904 cmdline_parse_token_string_t cmd_mirror_mask_value =
6905 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6907 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6908 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6909 dstpool, "dst-pool");
6910 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6911 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6913 cmdline_parse_token_string_t cmd_mirror_mask_on =
6914 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6918 cmd_set_mirror_mask_parsed(void *parsed_result,
6919 __attribute__((unused)) struct cmdline *cl,
6920 __attribute__((unused)) void *data)
6923 struct cmd_set_mirror_mask_result *res = parsed_result;
6924 struct rte_eth_mirror_conf mr_conf;
6926 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6928 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6930 mr_conf.dst_pool = res->dstpool_id;
6932 if (!strcmp(res->what, "pool-mirror-up")) {
6933 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6934 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6935 } else if (!strcmp(res->what, "pool-mirror-down")) {
6936 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6937 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6938 } else if (!strcmp(res->what, "vlan-mirror")) {
6939 mr_conf.rule_type = ETH_MIRROR_VLAN;
6940 nb_item = parse_item_list(res->value, "vlan",
6941 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6945 for (i = 0; i < nb_item; i++) {
6946 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6947 printf("Invalid vlan_id: must be < 4096\n");
6951 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6952 mr_conf.vlan.vlan_mask |= 1ULL << i;
6956 if (!strcmp(res->on, "on"))
6957 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6960 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6963 printf("mirror rule add error: (%s)\n", strerror(-ret));
6966 cmdline_parse_inst_t cmd_set_mirror_mask = {
6967 .f = cmd_set_mirror_mask_parsed,
6969 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6970 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6972 (void *)&cmd_mirror_mask_set,
6973 (void *)&cmd_mirror_mask_port,
6974 (void *)&cmd_mirror_mask_portid,
6975 (void *)&cmd_mirror_mask_mirror,
6976 (void *)&cmd_mirror_mask_ruleid,
6977 (void *)&cmd_mirror_mask_what,
6978 (void *)&cmd_mirror_mask_value,
6979 (void *)&cmd_mirror_mask_dstpool,
6980 (void *)&cmd_mirror_mask_poolid,
6981 (void *)&cmd_mirror_mask_on,
6986 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6987 struct cmd_set_mirror_link_result {
6988 cmdline_fixed_string_t set;
6989 cmdline_fixed_string_t port;
6991 cmdline_fixed_string_t mirror;
6993 cmdline_fixed_string_t what;
6994 cmdline_fixed_string_t dstpool;
6996 cmdline_fixed_string_t on;
6999 cmdline_parse_token_string_t cmd_mirror_link_set =
7000 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7002 cmdline_parse_token_string_t cmd_mirror_link_port =
7003 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7005 cmdline_parse_token_num_t cmd_mirror_link_portid =
7006 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7008 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7009 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7010 mirror, "mirror-rule");
7011 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7012 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7014 cmdline_parse_token_string_t cmd_mirror_link_what =
7015 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7016 what, "uplink-mirror#downlink-mirror");
7017 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7018 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7019 dstpool, "dst-pool");
7020 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7021 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7023 cmdline_parse_token_string_t cmd_mirror_link_on =
7024 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7028 cmd_set_mirror_link_parsed(void *parsed_result,
7029 __attribute__((unused)) struct cmdline *cl,
7030 __attribute__((unused)) void *data)
7033 struct cmd_set_mirror_link_result *res = parsed_result;
7034 struct rte_eth_mirror_conf mr_conf;
7036 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7037 if (!strcmp(res->what, "uplink-mirror"))
7038 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7040 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7042 mr_conf.dst_pool = res->dstpool_id;
7044 if (!strcmp(res->on, "on"))
7045 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7048 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7051 /* check the return value and print it if is < 0 */
7053 printf("mirror rule add error: (%s)\n", strerror(-ret));
7057 cmdline_parse_inst_t cmd_set_mirror_link = {
7058 .f = cmd_set_mirror_link_parsed,
7060 .help_str = "set port X mirror-rule Y uplink-mirror|"
7061 "downlink-mirror dst-pool Z on|off",
7063 (void *)&cmd_mirror_link_set,
7064 (void *)&cmd_mirror_link_port,
7065 (void *)&cmd_mirror_link_portid,
7066 (void *)&cmd_mirror_link_mirror,
7067 (void *)&cmd_mirror_link_ruleid,
7068 (void *)&cmd_mirror_link_what,
7069 (void *)&cmd_mirror_link_dstpool,
7070 (void *)&cmd_mirror_link_poolid,
7071 (void *)&cmd_mirror_link_on,
7076 /* *** RESET VM MIRROR RULE *** */
7077 struct cmd_rm_mirror_rule_result {
7078 cmdline_fixed_string_t reset;
7079 cmdline_fixed_string_t port;
7081 cmdline_fixed_string_t mirror;
7085 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7086 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7088 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7089 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7091 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7092 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7094 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7095 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7096 mirror, "mirror-rule");
7097 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7098 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7102 cmd_reset_mirror_rule_parsed(void *parsed_result,
7103 __attribute__((unused)) struct cmdline *cl,
7104 __attribute__((unused)) void *data)
7107 struct cmd_set_mirror_link_result *res = parsed_result;
7109 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7111 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7114 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7115 .f = cmd_reset_mirror_rule_parsed,
7117 .help_str = "reset port X mirror-rule Y",
7119 (void *)&cmd_rm_mirror_rule_reset,
7120 (void *)&cmd_rm_mirror_rule_port,
7121 (void *)&cmd_rm_mirror_rule_portid,
7122 (void *)&cmd_rm_mirror_rule_mirror,
7123 (void *)&cmd_rm_mirror_rule_ruleid,
7128 /* ******************************************************************************** */
7130 struct cmd_dump_result {
7131 cmdline_fixed_string_t dump;
7135 dump_struct_sizes(void)
7137 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7138 DUMP_SIZE(struct rte_mbuf);
7139 DUMP_SIZE(struct rte_mempool);
7140 DUMP_SIZE(struct rte_ring);
7144 static void cmd_dump_parsed(void *parsed_result,
7145 __attribute__((unused)) struct cmdline *cl,
7146 __attribute__((unused)) void *data)
7148 struct cmd_dump_result *res = parsed_result;
7150 if (!strcmp(res->dump, "dump_physmem"))
7151 rte_dump_physmem_layout(stdout);
7152 else if (!strcmp(res->dump, "dump_memzone"))
7153 rte_memzone_dump(stdout);
7154 else if (!strcmp(res->dump, "dump_log_history"))
7155 rte_log_dump_history(stdout);
7156 else if (!strcmp(res->dump, "dump_struct_sizes"))
7157 dump_struct_sizes();
7158 else if (!strcmp(res->dump, "dump_ring"))
7159 rte_ring_list_dump(stdout);
7160 else if (!strcmp(res->dump, "dump_mempool"))
7161 rte_mempool_list_dump(stdout);
7162 else if (!strcmp(res->dump, "dump_devargs"))
7163 rte_eal_devargs_dump(stdout);
7166 cmdline_parse_token_string_t cmd_dump_dump =
7167 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7171 "dump_struct_sizes#"
7176 cmdline_parse_inst_t cmd_dump = {
7177 .f = cmd_dump_parsed, /* function to call */
7178 .data = NULL, /* 2nd arg of func */
7179 .help_str = "dump status",
7180 .tokens = { /* token list, NULL terminated */
7181 (void *)&cmd_dump_dump,
7186 /* ******************************************************************************** */
7188 struct cmd_dump_one_result {
7189 cmdline_fixed_string_t dump;
7190 cmdline_fixed_string_t name;
7193 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7194 __attribute__((unused)) void *data)
7196 struct cmd_dump_one_result *res = parsed_result;
7198 if (!strcmp(res->dump, "dump_ring")) {
7200 r = rte_ring_lookup(res->name);
7202 cmdline_printf(cl, "Cannot find ring\n");
7205 rte_ring_dump(stdout, r);
7206 } else if (!strcmp(res->dump, "dump_mempool")) {
7207 struct rte_mempool *mp;
7208 mp = rte_mempool_lookup(res->name);
7210 cmdline_printf(cl, "Cannot find mempool\n");
7213 rte_mempool_dump(stdout, mp);
7217 cmdline_parse_token_string_t cmd_dump_one_dump =
7218 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7219 "dump_ring#dump_mempool");
7221 cmdline_parse_token_string_t cmd_dump_one_name =
7222 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7224 cmdline_parse_inst_t cmd_dump_one = {
7225 .f = cmd_dump_one_parsed, /* function to call */
7226 .data = NULL, /* 2nd arg of func */
7227 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7228 .tokens = { /* token list, NULL terminated */
7229 (void *)&cmd_dump_one_dump,
7230 (void *)&cmd_dump_one_name,
7235 /* *** Add/Del syn filter *** */
7236 struct cmd_syn_filter_result {
7237 cmdline_fixed_string_t filter;
7239 cmdline_fixed_string_t ops;
7240 cmdline_fixed_string_t priority;
7241 cmdline_fixed_string_t high;
7242 cmdline_fixed_string_t queue;
7247 cmd_syn_filter_parsed(void *parsed_result,
7248 __attribute__((unused)) struct cmdline *cl,
7249 __attribute__((unused)) void *data)
7251 struct cmd_syn_filter_result *res = parsed_result;
7252 struct rte_eth_syn_filter syn_filter;
7255 ret = rte_eth_dev_filter_supported(res->port_id,
7256 RTE_ETH_FILTER_SYN);
7258 printf("syn filter is not supported on port %u.\n",
7263 memset(&syn_filter, 0, sizeof(syn_filter));
7265 if (!strcmp(res->ops, "add")) {
7266 if (!strcmp(res->high, "high"))
7267 syn_filter.hig_pri = 1;
7269 syn_filter.hig_pri = 0;
7271 syn_filter.queue = res->queue_id;
7272 ret = rte_eth_dev_filter_ctrl(res->port_id,
7277 ret = rte_eth_dev_filter_ctrl(res->port_id,
7279 RTE_ETH_FILTER_DELETE,
7283 printf("syn filter programming error: (%s)\n",
7287 cmdline_parse_token_string_t cmd_syn_filter_filter =
7288 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7289 filter, "syn_filter");
7290 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7291 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7293 cmdline_parse_token_string_t cmd_syn_filter_ops =
7294 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7296 cmdline_parse_token_string_t cmd_syn_filter_priority =
7297 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7298 priority, "priority");
7299 cmdline_parse_token_string_t cmd_syn_filter_high =
7300 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7302 cmdline_parse_token_string_t cmd_syn_filter_queue =
7303 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7305 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7306 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7309 cmdline_parse_inst_t cmd_syn_filter = {
7310 .f = cmd_syn_filter_parsed,
7312 .help_str = "add/delete syn filter",
7314 (void *)&cmd_syn_filter_filter,
7315 (void *)&cmd_syn_filter_port_id,
7316 (void *)&cmd_syn_filter_ops,
7317 (void *)&cmd_syn_filter_priority,
7318 (void *)&cmd_syn_filter_high,
7319 (void *)&cmd_syn_filter_queue,
7320 (void *)&cmd_syn_filter_queue_id,
7325 /* *** ADD/REMOVE A 2tuple FILTER *** */
7326 struct cmd_2tuple_filter_result {
7327 cmdline_fixed_string_t filter;
7329 cmdline_fixed_string_t ops;
7330 cmdline_fixed_string_t dst_port;
7331 uint16_t dst_port_value;
7332 cmdline_fixed_string_t protocol;
7333 uint8_t protocol_value;
7334 cmdline_fixed_string_t mask;
7336 cmdline_fixed_string_t tcp_flags;
7337 uint8_t tcp_flags_value;
7338 cmdline_fixed_string_t priority;
7339 uint8_t priority_value;
7340 cmdline_fixed_string_t queue;
7345 cmd_2tuple_filter_parsed(void *parsed_result,
7346 __attribute__((unused)) struct cmdline *cl,
7347 __attribute__((unused)) void *data)
7349 struct rte_eth_ntuple_filter filter;
7350 struct cmd_2tuple_filter_result *res = parsed_result;
7353 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7355 printf("ntuple filter is not supported on port %u.\n",
7360 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7362 filter.flags = RTE_2TUPLE_FLAGS;
7363 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7364 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7365 filter.proto = res->protocol_value;
7366 filter.priority = res->priority_value;
7367 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7368 printf("nonzero tcp_flags is only meaningful"
7369 " when protocol is TCP.\n");
7372 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7373 printf("invalid TCP flags.\n");
7377 if (res->tcp_flags_value != 0) {
7378 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7379 filter.tcp_flags = res->tcp_flags_value;
7382 /* need convert to big endian. */
7383 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7384 filter.queue = res->queue_id;
7386 if (!strcmp(res->ops, "add"))
7387 ret = rte_eth_dev_filter_ctrl(res->port_id,
7388 RTE_ETH_FILTER_NTUPLE,
7392 ret = rte_eth_dev_filter_ctrl(res->port_id,
7393 RTE_ETH_FILTER_NTUPLE,
7394 RTE_ETH_FILTER_DELETE,
7397 printf("2tuple filter programming error: (%s)\n",
7402 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7403 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7404 filter, "2tuple_filter");
7405 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7406 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7408 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7409 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7411 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7412 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7413 dst_port, "dst_port");
7414 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7415 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7416 dst_port_value, UINT16);
7417 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7418 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7419 protocol, "protocol");
7420 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7421 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7422 protocol_value, UINT8);
7423 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7424 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7426 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7427 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7429 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7430 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7431 tcp_flags, "tcp_flags");
7432 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7433 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7434 tcp_flags_value, UINT8);
7435 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7436 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7437 priority, "priority");
7438 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7439 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7440 priority_value, UINT8);
7441 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7442 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7444 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7445 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7448 cmdline_parse_inst_t cmd_2tuple_filter = {
7449 .f = cmd_2tuple_filter_parsed,
7451 .help_str = "add a 2tuple filter",
7453 (void *)&cmd_2tuple_filter_filter,
7454 (void *)&cmd_2tuple_filter_port_id,
7455 (void *)&cmd_2tuple_filter_ops,
7456 (void *)&cmd_2tuple_filter_dst_port,
7457 (void *)&cmd_2tuple_filter_dst_port_value,
7458 (void *)&cmd_2tuple_filter_protocol,
7459 (void *)&cmd_2tuple_filter_protocol_value,
7460 (void *)&cmd_2tuple_filter_mask,
7461 (void *)&cmd_2tuple_filter_mask_value,
7462 (void *)&cmd_2tuple_filter_tcp_flags,
7463 (void *)&cmd_2tuple_filter_tcp_flags_value,
7464 (void *)&cmd_2tuple_filter_priority,
7465 (void *)&cmd_2tuple_filter_priority_value,
7466 (void *)&cmd_2tuple_filter_queue,
7467 (void *)&cmd_2tuple_filter_queue_id,
7472 /* *** ADD/REMOVE A 5tuple FILTER *** */
7473 struct cmd_5tuple_filter_result {
7474 cmdline_fixed_string_t filter;
7476 cmdline_fixed_string_t ops;
7477 cmdline_fixed_string_t dst_ip;
7478 cmdline_ipaddr_t dst_ip_value;
7479 cmdline_fixed_string_t src_ip;
7480 cmdline_ipaddr_t src_ip_value;
7481 cmdline_fixed_string_t dst_port;
7482 uint16_t dst_port_value;
7483 cmdline_fixed_string_t src_port;
7484 uint16_t src_port_value;
7485 cmdline_fixed_string_t protocol;
7486 uint8_t protocol_value;
7487 cmdline_fixed_string_t mask;
7489 cmdline_fixed_string_t tcp_flags;
7490 uint8_t tcp_flags_value;
7491 cmdline_fixed_string_t priority;
7492 uint8_t priority_value;
7493 cmdline_fixed_string_t queue;
7498 cmd_5tuple_filter_parsed(void *parsed_result,
7499 __attribute__((unused)) struct cmdline *cl,
7500 __attribute__((unused)) void *data)
7502 struct rte_eth_ntuple_filter filter;
7503 struct cmd_5tuple_filter_result *res = parsed_result;
7506 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7508 printf("ntuple filter is not supported on port %u.\n",
7513 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7515 filter.flags = RTE_5TUPLE_FLAGS;
7516 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7517 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7518 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7519 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7520 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7521 filter.proto = res->protocol_value;
7522 filter.priority = res->priority_value;
7523 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7524 printf("nonzero tcp_flags is only meaningful"
7525 " when protocol is TCP.\n");
7528 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7529 printf("invalid TCP flags.\n");
7533 if (res->tcp_flags_value != 0) {
7534 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7535 filter.tcp_flags = res->tcp_flags_value;
7538 if (res->dst_ip_value.family == AF_INET)
7539 /* no need to convert, already big endian. */
7540 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7542 if (filter.dst_ip_mask == 0) {
7543 printf("can not support ipv6 involved compare.\n");
7549 if (res->src_ip_value.family == AF_INET)
7550 /* no need to convert, already big endian. */
7551 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7553 if (filter.src_ip_mask == 0) {
7554 printf("can not support ipv6 involved compare.\n");
7559 /* need convert to big endian. */
7560 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7561 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7562 filter.queue = res->queue_id;
7564 if (!strcmp(res->ops, "add"))
7565 ret = rte_eth_dev_filter_ctrl(res->port_id,
7566 RTE_ETH_FILTER_NTUPLE,
7570 ret = rte_eth_dev_filter_ctrl(res->port_id,
7571 RTE_ETH_FILTER_NTUPLE,
7572 RTE_ETH_FILTER_DELETE,
7575 printf("5tuple filter programming error: (%s)\n",
7579 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7580 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7581 filter, "5tuple_filter");
7582 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7583 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7585 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7586 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7588 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7589 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7591 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7592 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7594 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7595 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7597 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7598 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7600 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7601 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7602 dst_port, "dst_port");
7603 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7604 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7605 dst_port_value, UINT16);
7606 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7607 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7608 src_port, "src_port");
7609 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7610 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7611 src_port_value, UINT16);
7612 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7613 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7614 protocol, "protocol");
7615 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7616 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7617 protocol_value, UINT8);
7618 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7619 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7621 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7622 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7624 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7625 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7626 tcp_flags, "tcp_flags");
7627 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7628 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7629 tcp_flags_value, UINT8);
7630 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7631 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7632 priority, "priority");
7633 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7634 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7635 priority_value, UINT8);
7636 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7637 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7639 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7640 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7643 cmdline_parse_inst_t cmd_5tuple_filter = {
7644 .f = cmd_5tuple_filter_parsed,
7646 .help_str = "add/del a 5tuple filter",
7648 (void *)&cmd_5tuple_filter_filter,
7649 (void *)&cmd_5tuple_filter_port_id,
7650 (void *)&cmd_5tuple_filter_ops,
7651 (void *)&cmd_5tuple_filter_dst_ip,
7652 (void *)&cmd_5tuple_filter_dst_ip_value,
7653 (void *)&cmd_5tuple_filter_src_ip,
7654 (void *)&cmd_5tuple_filter_src_ip_value,
7655 (void *)&cmd_5tuple_filter_dst_port,
7656 (void *)&cmd_5tuple_filter_dst_port_value,
7657 (void *)&cmd_5tuple_filter_src_port,
7658 (void *)&cmd_5tuple_filter_src_port_value,
7659 (void *)&cmd_5tuple_filter_protocol,
7660 (void *)&cmd_5tuple_filter_protocol_value,
7661 (void *)&cmd_5tuple_filter_mask,
7662 (void *)&cmd_5tuple_filter_mask_value,
7663 (void *)&cmd_5tuple_filter_tcp_flags,
7664 (void *)&cmd_5tuple_filter_tcp_flags_value,
7665 (void *)&cmd_5tuple_filter_priority,
7666 (void *)&cmd_5tuple_filter_priority_value,
7667 (void *)&cmd_5tuple_filter_queue,
7668 (void *)&cmd_5tuple_filter_queue_id,
7673 /* *** ADD/REMOVE A flex FILTER *** */
7674 struct cmd_flex_filter_result {
7675 cmdline_fixed_string_t filter;
7676 cmdline_fixed_string_t ops;
7678 cmdline_fixed_string_t len;
7680 cmdline_fixed_string_t bytes;
7681 cmdline_fixed_string_t bytes_value;
7682 cmdline_fixed_string_t mask;
7683 cmdline_fixed_string_t mask_value;
7684 cmdline_fixed_string_t priority;
7685 uint8_t priority_value;
7686 cmdline_fixed_string_t queue;
7690 static int xdigit2val(unsigned char c)
7695 else if (isupper(c))
7703 cmd_flex_filter_parsed(void *parsed_result,
7704 __attribute__((unused)) struct cmdline *cl,
7705 __attribute__((unused)) void *data)
7708 struct rte_eth_flex_filter filter;
7709 struct cmd_flex_filter_result *res = parsed_result;
7710 char *bytes_ptr, *mask_ptr;
7711 uint16_t len, i, j = 0;
7716 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7717 printf("the len exceed the max length 128\n");
7720 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7721 filter.len = res->len_value;
7722 filter.priority = res->priority_value;
7723 filter.queue = res->queue_id;
7724 bytes_ptr = res->bytes_value;
7725 mask_ptr = res->mask_value;
7727 /* translate bytes string to array. */
7728 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7729 (bytes_ptr[1] == 'X')))
7731 len = strnlen(bytes_ptr, res->len_value * 2);
7732 if (len == 0 || (len % 8 != 0)) {
7733 printf("please check len and bytes input\n");
7736 for (i = 0; i < len; i++) {
7738 if (isxdigit(c) == 0) {
7739 /* invalid characters. */
7740 printf("invalid input\n");
7743 val = xdigit2val(c);
7746 filter.bytes[j] = byte;
7747 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7754 /* translate mask string to uint8_t array. */
7755 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7756 (mask_ptr[1] == 'X')))
7758 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7760 printf("invalid input\n");
7765 for (i = 0; i < len; i++) {
7767 if (isxdigit(c) == 0) {
7768 /* invalid characters. */
7769 printf("invalid input\n");
7772 val = xdigit2val(c);
7775 filter.mask[j] = byte;
7776 printf("mask[%d]:%02x ", j, filter.mask[j]);
7784 if (!strcmp(res->ops, "add"))
7785 ret = rte_eth_dev_filter_ctrl(res->port_id,
7786 RTE_ETH_FILTER_FLEXIBLE,
7790 ret = rte_eth_dev_filter_ctrl(res->port_id,
7791 RTE_ETH_FILTER_FLEXIBLE,
7792 RTE_ETH_FILTER_DELETE,
7796 printf("flex filter setting error: (%s)\n", strerror(-ret));
7799 cmdline_parse_token_string_t cmd_flex_filter_filter =
7800 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7801 filter, "flex_filter");
7802 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7803 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7805 cmdline_parse_token_string_t cmd_flex_filter_ops =
7806 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7808 cmdline_parse_token_string_t cmd_flex_filter_len =
7809 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7811 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7812 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7814 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7815 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7817 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7818 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7820 cmdline_parse_token_string_t cmd_flex_filter_mask =
7821 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7823 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7824 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7826 cmdline_parse_token_string_t cmd_flex_filter_priority =
7827 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7828 priority, "priority");
7829 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7830 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7831 priority_value, UINT8);
7832 cmdline_parse_token_string_t cmd_flex_filter_queue =
7833 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7835 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7836 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7838 cmdline_parse_inst_t cmd_flex_filter = {
7839 .f = cmd_flex_filter_parsed,
7841 .help_str = "add/del a flex filter",
7843 (void *)&cmd_flex_filter_filter,
7844 (void *)&cmd_flex_filter_port_id,
7845 (void *)&cmd_flex_filter_ops,
7846 (void *)&cmd_flex_filter_len,
7847 (void *)&cmd_flex_filter_len_value,
7848 (void *)&cmd_flex_filter_bytes,
7849 (void *)&cmd_flex_filter_bytes_value,
7850 (void *)&cmd_flex_filter_mask,
7851 (void *)&cmd_flex_filter_mask_value,
7852 (void *)&cmd_flex_filter_priority,
7853 (void *)&cmd_flex_filter_priority_value,
7854 (void *)&cmd_flex_filter_queue,
7855 (void *)&cmd_flex_filter_queue_id,
7860 /* *** Filters Control *** */
7862 /* *** deal with ethertype filter *** */
7863 struct cmd_ethertype_filter_result {
7864 cmdline_fixed_string_t filter;
7866 cmdline_fixed_string_t ops;
7867 cmdline_fixed_string_t mac;
7868 struct ether_addr mac_addr;
7869 cmdline_fixed_string_t ethertype;
7870 uint16_t ethertype_value;
7871 cmdline_fixed_string_t drop;
7872 cmdline_fixed_string_t queue;
7876 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7877 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7878 filter, "ethertype_filter");
7879 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7880 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7882 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7883 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7885 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7886 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7887 mac, "mac_addr#mac_ignr");
7888 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7891 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7892 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7893 ethertype, "ethertype");
7894 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7895 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7896 ethertype_value, UINT16);
7897 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7898 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7900 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7901 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7903 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7904 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7908 cmd_ethertype_filter_parsed(void *parsed_result,
7909 __attribute__((unused)) struct cmdline *cl,
7910 __attribute__((unused)) void *data)
7912 struct cmd_ethertype_filter_result *res = parsed_result;
7913 struct rte_eth_ethertype_filter filter;
7916 ret = rte_eth_dev_filter_supported(res->port_id,
7917 RTE_ETH_FILTER_ETHERTYPE);
7919 printf("ethertype filter is not supported on port %u.\n",
7924 memset(&filter, 0, sizeof(filter));
7925 if (!strcmp(res->mac, "mac_addr")) {
7926 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7927 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7928 sizeof(struct ether_addr));
7930 if (!strcmp(res->drop, "drop"))
7931 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7932 filter.ether_type = res->ethertype_value;
7933 filter.queue = res->queue_id;
7935 if (!strcmp(res->ops, "add"))
7936 ret = rte_eth_dev_filter_ctrl(res->port_id,
7937 RTE_ETH_FILTER_ETHERTYPE,
7941 ret = rte_eth_dev_filter_ctrl(res->port_id,
7942 RTE_ETH_FILTER_ETHERTYPE,
7943 RTE_ETH_FILTER_DELETE,
7946 printf("ethertype filter programming error: (%s)\n",
7950 cmdline_parse_inst_t cmd_ethertype_filter = {
7951 .f = cmd_ethertype_filter_parsed,
7953 .help_str = "add or delete an ethertype filter entry",
7955 (void *)&cmd_ethertype_filter_filter,
7956 (void *)&cmd_ethertype_filter_port_id,
7957 (void *)&cmd_ethertype_filter_ops,
7958 (void *)&cmd_ethertype_filter_mac,
7959 (void *)&cmd_ethertype_filter_mac_addr,
7960 (void *)&cmd_ethertype_filter_ethertype,
7961 (void *)&cmd_ethertype_filter_ethertype_value,
7962 (void *)&cmd_ethertype_filter_drop,
7963 (void *)&cmd_ethertype_filter_queue,
7964 (void *)&cmd_ethertype_filter_queue_id,
7969 /* *** deal with flow director filter *** */
7970 struct cmd_flow_director_result {
7971 cmdline_fixed_string_t flow_director_filter;
7973 cmdline_fixed_string_t mode;
7974 cmdline_fixed_string_t mode_value;
7975 cmdline_fixed_string_t ops;
7976 cmdline_fixed_string_t flow;
7977 cmdline_fixed_string_t flow_type;
7978 cmdline_fixed_string_t ether;
7979 uint16_t ether_type;
7980 cmdline_fixed_string_t src;
7981 cmdline_ipaddr_t ip_src;
7983 cmdline_fixed_string_t dst;
7984 cmdline_ipaddr_t ip_dst;
7986 cmdline_fixed_string_t verify_tag;
7987 uint32_t verify_tag_value;
7988 cmdline_fixed_string_t vlan;
7989 uint16_t vlan_value;
7990 cmdline_fixed_string_t flexbytes;
7991 cmdline_fixed_string_t flexbytes_value;
7992 cmdline_fixed_string_t pf_vf;
7993 cmdline_fixed_string_t drop;
7994 cmdline_fixed_string_t queue;
7996 cmdline_fixed_string_t fd_id;
7997 uint32_t fd_id_value;
7998 cmdline_fixed_string_t mac;
7999 struct ether_addr mac_addr;
8000 cmdline_fixed_string_t tunnel;
8001 cmdline_fixed_string_t tunnel_type;
8002 cmdline_fixed_string_t tunnel_id;
8003 uint32_t tunnel_id_value;
8007 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8010 const char *p, *p0 = q_arg;
8012 unsigned long int_fld;
8013 char *str_fld[max_num];
8018 p = strchr(p0, '(');
8022 p0 = strchr(p, ')');
8027 if (size >= sizeof(s))
8030 snprintf(s, sizeof(s), "%.*s", size, p);
8031 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8032 if (ret < 0 || ret > max_num)
8034 for (i = 0; i < ret; i++) {
8036 int_fld = strtoul(str_fld[i], &end, 0);
8037 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8039 flexbytes[i] = (uint8_t)int_fld;
8045 str2flowtype(char *string)
8048 static const struct {
8051 } flowtype_str[] = {
8052 {"raw", RTE_ETH_FLOW_RAW},
8053 {"ipv4", RTE_ETH_FLOW_IPV4},
8054 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8055 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8056 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8057 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8058 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8059 {"ipv6", RTE_ETH_FLOW_IPV6},
8060 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8061 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8062 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8063 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8064 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8065 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8068 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8069 if (!strcmp(flowtype_str[i].str, string))
8070 return flowtype_str[i].type;
8072 return RTE_ETH_FLOW_UNKNOWN;
8075 static enum rte_eth_fdir_tunnel_type
8076 str2fdir_tunneltype(char *string)
8080 static const struct {
8082 enum rte_eth_fdir_tunnel_type type;
8083 } tunneltype_str[] = {
8084 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8085 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8088 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8089 if (!strcmp(tunneltype_str[i].str, string))
8090 return tunneltype_str[i].type;
8092 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8095 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8097 if ((ip_addr).family == AF_INET) \
8098 (ip) = (ip_addr).addr.ipv4.s_addr; \
8100 printf("invalid parameter.\n"); \
8105 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8107 if ((ip_addr).family == AF_INET6) \
8108 (void)rte_memcpy(&(ip), \
8109 &((ip_addr).addr.ipv6), \
8110 sizeof(struct in6_addr)); \
8112 printf("invalid parameter.\n"); \
8118 cmd_flow_director_filter_parsed(void *parsed_result,
8119 __attribute__((unused)) struct cmdline *cl,
8120 __attribute__((unused)) void *data)
8122 struct cmd_flow_director_result *res = parsed_result;
8123 struct rte_eth_fdir_filter entry;
8124 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8126 unsigned long vf_id;
8129 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8131 printf("flow director is not supported on port %u.\n",
8135 memset(flexbytes, 0, sizeof(flexbytes));
8136 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8138 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8139 if (strcmp(res->mode_value, "MAC-VLAN")) {
8140 printf("Please set mode to MAC-VLAN.\n");
8143 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8144 if (strcmp(res->mode_value, "Tunnel")) {
8145 printf("Please set mode to Tunnel.\n");
8149 if (strcmp(res->mode_value, "IP")) {
8150 printf("Please set mode to IP.\n");
8153 entry.input.flow_type = str2flowtype(res->flow_type);
8156 ret = parse_flexbytes(res->flexbytes_value,
8158 RTE_ETH_FDIR_MAX_FLEXLEN);
8160 printf("error: Cannot parse flexbytes input.\n");
8164 switch (entry.input.flow_type) {
8165 case RTE_ETH_FLOW_FRAG_IPV4:
8166 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8167 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8168 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8169 IPV4_ADDR_TO_UINT(res->ip_dst,
8170 entry.input.flow.ip4_flow.dst_ip);
8171 IPV4_ADDR_TO_UINT(res->ip_src,
8172 entry.input.flow.ip4_flow.src_ip);
8173 /* need convert to big endian. */
8174 entry.input.flow.udp4_flow.dst_port =
8175 rte_cpu_to_be_16(res->port_dst);
8176 entry.input.flow.udp4_flow.src_port =
8177 rte_cpu_to_be_16(res->port_src);
8179 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8180 IPV4_ADDR_TO_UINT(res->ip_dst,
8181 entry.input.flow.sctp4_flow.ip.dst_ip);
8182 IPV4_ADDR_TO_UINT(res->ip_src,
8183 entry.input.flow.sctp4_flow.ip.src_ip);
8184 /* need convert to big endian. */
8185 entry.input.flow.sctp4_flow.dst_port =
8186 rte_cpu_to_be_16(res->port_dst);
8187 entry.input.flow.sctp4_flow.src_port =
8188 rte_cpu_to_be_16(res->port_src);
8189 entry.input.flow.sctp4_flow.verify_tag =
8190 rte_cpu_to_be_32(res->verify_tag_value);
8192 case RTE_ETH_FLOW_FRAG_IPV6:
8193 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8194 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8195 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8196 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8197 entry.input.flow.ipv6_flow.dst_ip);
8198 IPV6_ADDR_TO_ARRAY(res->ip_src,
8199 entry.input.flow.ipv6_flow.src_ip);
8200 /* need convert to big endian. */
8201 entry.input.flow.udp6_flow.dst_port =
8202 rte_cpu_to_be_16(res->port_dst);
8203 entry.input.flow.udp6_flow.src_port =
8204 rte_cpu_to_be_16(res->port_src);
8206 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8207 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8208 entry.input.flow.sctp6_flow.ip.dst_ip);
8209 IPV6_ADDR_TO_ARRAY(res->ip_src,
8210 entry.input.flow.sctp6_flow.ip.src_ip);
8211 /* need convert to big endian. */
8212 entry.input.flow.sctp6_flow.dst_port =
8213 rte_cpu_to_be_16(res->port_dst);
8214 entry.input.flow.sctp6_flow.src_port =
8215 rte_cpu_to_be_16(res->port_src);
8216 entry.input.flow.sctp6_flow.verify_tag =
8217 rte_cpu_to_be_32(res->verify_tag_value);
8219 case RTE_ETH_FLOW_L2_PAYLOAD:
8220 entry.input.flow.l2_flow.ether_type =
8221 rte_cpu_to_be_16(res->ether_type);
8227 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8228 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8230 sizeof(struct ether_addr));
8232 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8233 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8235 sizeof(struct ether_addr));
8236 entry.input.flow.tunnel_flow.tunnel_type =
8237 str2fdir_tunneltype(res->tunnel_type);
8238 entry.input.flow.tunnel_flow.tunnel_id =
8239 rte_cpu_to_be_32(res->tunnel_id_value);
8242 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8244 RTE_ETH_FDIR_MAX_FLEXLEN);
8246 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8248 entry.action.flex_off = 0; /*use 0 by default */
8249 if (!strcmp(res->drop, "drop"))
8250 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8252 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8254 if (!strcmp(res->pf_vf, "pf"))
8255 entry.input.flow_ext.is_vf = 0;
8256 else if (!strncmp(res->pf_vf, "vf", 2)) {
8257 struct rte_eth_dev_info dev_info;
8259 memset(&dev_info, 0, sizeof(dev_info));
8260 rte_eth_dev_info_get(res->port_id, &dev_info);
8262 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8263 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8264 printf("invalid parameter %s.\n", res->pf_vf);
8267 entry.input.flow_ext.is_vf = 1;
8268 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8270 printf("invalid parameter %s.\n", res->pf_vf);
8274 /* set to report FD ID by default */
8275 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8276 entry.action.rx_queue = res->queue_id;
8277 entry.soft_id = res->fd_id_value;
8278 if (!strcmp(res->ops, "add"))
8279 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8280 RTE_ETH_FILTER_ADD, &entry);
8281 else if (!strcmp(res->ops, "del"))
8282 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8283 RTE_ETH_FILTER_DELETE, &entry);
8285 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8286 RTE_ETH_FILTER_UPDATE, &entry);
8288 printf("flow director programming error: (%s)\n",
8292 cmdline_parse_token_string_t cmd_flow_director_filter =
8293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8294 flow_director_filter, "flow_director_filter");
8295 cmdline_parse_token_num_t cmd_flow_director_port_id =
8296 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8298 cmdline_parse_token_string_t cmd_flow_director_ops =
8299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8300 ops, "add#del#update");
8301 cmdline_parse_token_string_t cmd_flow_director_flow =
8302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8304 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8306 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8307 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8308 cmdline_parse_token_string_t cmd_flow_director_ether =
8309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8311 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8313 ether_type, UINT16);
8314 cmdline_parse_token_string_t cmd_flow_director_src =
8315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8317 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8318 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8320 cmdline_parse_token_num_t cmd_flow_director_port_src =
8321 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8323 cmdline_parse_token_string_t cmd_flow_director_dst =
8324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8326 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8327 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8329 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8332 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8334 verify_tag, "verify_tag");
8335 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8337 verify_tag_value, UINT32);
8338 cmdline_parse_token_string_t cmd_flow_director_vlan =
8339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8341 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8343 vlan_value, UINT16);
8344 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8346 flexbytes, "flexbytes");
8347 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8349 flexbytes_value, NULL);
8350 cmdline_parse_token_string_t cmd_flow_director_drop =
8351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8353 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8356 cmdline_parse_token_string_t cmd_flow_director_queue =
8357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8359 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8362 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8365 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8366 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8367 fd_id_value, UINT32);
8369 cmdline_parse_token_string_t cmd_flow_director_mode =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8372 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8375 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8377 mode_value, "MAC-VLAN");
8378 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8380 mode_value, "Tunnel");
8381 cmdline_parse_token_string_t cmd_flow_director_mac =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8384 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8387 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8390 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8392 tunnel_type, "NVGRE#VxLAN");
8393 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8395 tunnel_id, "tunnel-id");
8396 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8398 tunnel_id_value, UINT32);
8400 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8401 .f = cmd_flow_director_filter_parsed,
8403 .help_str = "add or delete an ip flow director entry on NIC",
8405 (void *)&cmd_flow_director_filter,
8406 (void *)&cmd_flow_director_port_id,
8407 (void *)&cmd_flow_director_mode,
8408 (void *)&cmd_flow_director_mode_ip,
8409 (void *)&cmd_flow_director_ops,
8410 (void *)&cmd_flow_director_flow,
8411 (void *)&cmd_flow_director_flow_type,
8412 (void *)&cmd_flow_director_src,
8413 (void *)&cmd_flow_director_ip_src,
8414 (void *)&cmd_flow_director_dst,
8415 (void *)&cmd_flow_director_ip_dst,
8416 (void *)&cmd_flow_director_vlan,
8417 (void *)&cmd_flow_director_vlan_value,
8418 (void *)&cmd_flow_director_flexbytes,
8419 (void *)&cmd_flow_director_flexbytes_value,
8420 (void *)&cmd_flow_director_drop,
8421 (void *)&cmd_flow_director_pf_vf,
8422 (void *)&cmd_flow_director_queue,
8423 (void *)&cmd_flow_director_queue_id,
8424 (void *)&cmd_flow_director_fd_id,
8425 (void *)&cmd_flow_director_fd_id_value,
8430 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8431 .f = cmd_flow_director_filter_parsed,
8433 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8435 (void *)&cmd_flow_director_filter,
8436 (void *)&cmd_flow_director_port_id,
8437 (void *)&cmd_flow_director_mode,
8438 (void *)&cmd_flow_director_mode_ip,
8439 (void *)&cmd_flow_director_ops,
8440 (void *)&cmd_flow_director_flow,
8441 (void *)&cmd_flow_director_flow_type,
8442 (void *)&cmd_flow_director_src,
8443 (void *)&cmd_flow_director_ip_src,
8444 (void *)&cmd_flow_director_port_src,
8445 (void *)&cmd_flow_director_dst,
8446 (void *)&cmd_flow_director_ip_dst,
8447 (void *)&cmd_flow_director_port_dst,
8448 (void *)&cmd_flow_director_vlan,
8449 (void *)&cmd_flow_director_vlan_value,
8450 (void *)&cmd_flow_director_flexbytes,
8451 (void *)&cmd_flow_director_flexbytes_value,
8452 (void *)&cmd_flow_director_drop,
8453 (void *)&cmd_flow_director_pf_vf,
8454 (void *)&cmd_flow_director_queue,
8455 (void *)&cmd_flow_director_queue_id,
8456 (void *)&cmd_flow_director_fd_id,
8457 (void *)&cmd_flow_director_fd_id_value,
8462 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8463 .f = cmd_flow_director_filter_parsed,
8465 .help_str = "add or delete a sctp flow director entry on NIC",
8467 (void *)&cmd_flow_director_filter,
8468 (void *)&cmd_flow_director_port_id,
8469 (void *)&cmd_flow_director_mode,
8470 (void *)&cmd_flow_director_mode_ip,
8471 (void *)&cmd_flow_director_ops,
8472 (void *)&cmd_flow_director_flow,
8473 (void *)&cmd_flow_director_flow_type,
8474 (void *)&cmd_flow_director_src,
8475 (void *)&cmd_flow_director_ip_src,
8476 (void *)&cmd_flow_director_port_dst,
8477 (void *)&cmd_flow_director_dst,
8478 (void *)&cmd_flow_director_ip_dst,
8479 (void *)&cmd_flow_director_port_dst,
8480 (void *)&cmd_flow_director_verify_tag,
8481 (void *)&cmd_flow_director_verify_tag_value,
8482 (void *)&cmd_flow_director_vlan,
8483 (void *)&cmd_flow_director_vlan_value,
8484 (void *)&cmd_flow_director_flexbytes,
8485 (void *)&cmd_flow_director_flexbytes_value,
8486 (void *)&cmd_flow_director_drop,
8487 (void *)&cmd_flow_director_pf_vf,
8488 (void *)&cmd_flow_director_queue,
8489 (void *)&cmd_flow_director_queue_id,
8490 (void *)&cmd_flow_director_fd_id,
8491 (void *)&cmd_flow_director_fd_id_value,
8496 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8497 .f = cmd_flow_director_filter_parsed,
8499 .help_str = "add or delete a L2 flow director entry on NIC",
8501 (void *)&cmd_flow_director_filter,
8502 (void *)&cmd_flow_director_port_id,
8503 (void *)&cmd_flow_director_mode,
8504 (void *)&cmd_flow_director_mode_ip,
8505 (void *)&cmd_flow_director_ops,
8506 (void *)&cmd_flow_director_flow,
8507 (void *)&cmd_flow_director_flow_type,
8508 (void *)&cmd_flow_director_ether,
8509 (void *)&cmd_flow_director_ether_type,
8510 (void *)&cmd_flow_director_flexbytes,
8511 (void *)&cmd_flow_director_flexbytes_value,
8512 (void *)&cmd_flow_director_drop,
8513 (void *)&cmd_flow_director_pf_vf,
8514 (void *)&cmd_flow_director_queue,
8515 (void *)&cmd_flow_director_queue_id,
8516 (void *)&cmd_flow_director_fd_id,
8517 (void *)&cmd_flow_director_fd_id_value,
8522 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8523 .f = cmd_flow_director_filter_parsed,
8525 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8527 (void *)&cmd_flow_director_filter,
8528 (void *)&cmd_flow_director_port_id,
8529 (void *)&cmd_flow_director_mode,
8530 (void *)&cmd_flow_director_mode_mac_vlan,
8531 (void *)&cmd_flow_director_ops,
8532 (void *)&cmd_flow_director_mac,
8533 (void *)&cmd_flow_director_mac_addr,
8534 (void *)&cmd_flow_director_vlan,
8535 (void *)&cmd_flow_director_vlan_value,
8536 (void *)&cmd_flow_director_flexbytes,
8537 (void *)&cmd_flow_director_flexbytes_value,
8538 (void *)&cmd_flow_director_drop,
8539 (void *)&cmd_flow_director_queue,
8540 (void *)&cmd_flow_director_queue_id,
8541 (void *)&cmd_flow_director_fd_id,
8542 (void *)&cmd_flow_director_fd_id_value,
8547 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8548 .f = cmd_flow_director_filter_parsed,
8550 .help_str = "add or delete a tunnel flow director entry on NIC",
8552 (void *)&cmd_flow_director_filter,
8553 (void *)&cmd_flow_director_port_id,
8554 (void *)&cmd_flow_director_mode,
8555 (void *)&cmd_flow_director_mode_tunnel,
8556 (void *)&cmd_flow_director_ops,
8557 (void *)&cmd_flow_director_mac,
8558 (void *)&cmd_flow_director_mac_addr,
8559 (void *)&cmd_flow_director_vlan,
8560 (void *)&cmd_flow_director_vlan_value,
8561 (void *)&cmd_flow_director_tunnel,
8562 (void *)&cmd_flow_director_tunnel_type,
8563 (void *)&cmd_flow_director_tunnel_id,
8564 (void *)&cmd_flow_director_tunnel_id_value,
8565 (void *)&cmd_flow_director_flexbytes,
8566 (void *)&cmd_flow_director_flexbytes_value,
8567 (void *)&cmd_flow_director_drop,
8568 (void *)&cmd_flow_director_queue,
8569 (void *)&cmd_flow_director_queue_id,
8570 (void *)&cmd_flow_director_fd_id,
8571 (void *)&cmd_flow_director_fd_id_value,
8576 struct cmd_flush_flow_director_result {
8577 cmdline_fixed_string_t flush_flow_director;
8581 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8582 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8583 flush_flow_director, "flush_flow_director");
8584 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8585 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8589 cmd_flush_flow_director_parsed(void *parsed_result,
8590 __attribute__((unused)) struct cmdline *cl,
8591 __attribute__((unused)) void *data)
8593 struct cmd_flow_director_result *res = parsed_result;
8596 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8598 printf("flow director is not supported on port %u.\n",
8603 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8604 RTE_ETH_FILTER_FLUSH, NULL);
8606 printf("flow director table flushing error: (%s)\n",
8610 cmdline_parse_inst_t cmd_flush_flow_director = {
8611 .f = cmd_flush_flow_director_parsed,
8613 .help_str = "flush all flow director entries of a device on NIC",
8615 (void *)&cmd_flush_flow_director_flush,
8616 (void *)&cmd_flush_flow_director_port_id,
8621 /* *** deal with flow director mask *** */
8622 struct cmd_flow_director_mask_result {
8623 cmdline_fixed_string_t flow_director_mask;
8625 cmdline_fixed_string_t mode;
8626 cmdline_fixed_string_t mode_value;
8627 cmdline_fixed_string_t vlan;
8629 cmdline_fixed_string_t src_mask;
8630 cmdline_ipaddr_t ipv4_src;
8631 cmdline_ipaddr_t ipv6_src;
8633 cmdline_fixed_string_t dst_mask;
8634 cmdline_ipaddr_t ipv4_dst;
8635 cmdline_ipaddr_t ipv6_dst;
8637 cmdline_fixed_string_t mac;
8638 uint8_t mac_addr_byte_mask;
8639 cmdline_fixed_string_t tunnel_id;
8640 uint32_t tunnel_id_mask;
8641 cmdline_fixed_string_t tunnel_type;
8642 uint8_t tunnel_type_mask;
8646 cmd_flow_director_mask_parsed(void *parsed_result,
8647 __attribute__((unused)) struct cmdline *cl,
8648 __attribute__((unused)) void *data)
8650 struct cmd_flow_director_mask_result *res = parsed_result;
8651 struct rte_eth_fdir_masks *mask;
8652 struct rte_port *port;
8654 if (res->port_id > nb_ports) {
8655 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8659 port = &ports[res->port_id];
8660 /** Check if the port is not started **/
8661 if (port->port_status != RTE_PORT_STOPPED) {
8662 printf("Please stop port %d first\n", res->port_id);
8666 mask = &port->dev_conf.fdir_conf.mask;
8668 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8669 if (strcmp(res->mode_value, "MAC-VLAN")) {
8670 printf("Please set mode to MAC-VLAN.\n");
8674 mask->vlan_tci_mask = res->vlan_mask;
8675 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8676 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8677 if (strcmp(res->mode_value, "Tunnel")) {
8678 printf("Please set mode to Tunnel.\n");
8682 mask->vlan_tci_mask = res->vlan_mask;
8683 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8684 mask->tunnel_id_mask = res->tunnel_id_mask;
8685 mask->tunnel_type_mask = res->tunnel_type_mask;
8687 if (strcmp(res->mode_value, "IP")) {
8688 printf("Please set mode to IP.\n");
8692 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8693 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8694 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8695 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8696 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8697 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8698 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8701 cmd_reconfig_device_queue(res->port_id, 1, 1);
8704 cmdline_parse_token_string_t cmd_flow_director_mask =
8705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8706 flow_director_mask, "flow_director_mask");
8707 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8708 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8710 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8713 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8716 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8718 src_mask, "src_mask");
8719 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8720 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8725 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8728 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8730 dst_mask, "dst_mask");
8731 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8732 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8734 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8735 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8737 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8741 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8744 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8747 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8749 mode_value, "MAC-VLAN");
8750 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8752 mode_value, "Tunnel");
8753 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8756 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8758 mac_addr_byte_mask, UINT8);
8759 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8761 tunnel_type, "tunnel-type");
8762 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8764 tunnel_type_mask, UINT8);
8765 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8767 tunnel_id, "tunnel-id");
8768 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8770 tunnel_id_mask, UINT32);
8772 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8773 .f = cmd_flow_director_mask_parsed,
8775 .help_str = "set IP mode flow director's mask on NIC",
8777 (void *)&cmd_flow_director_mask,
8778 (void *)&cmd_flow_director_mask_port_id,
8779 (void *)&cmd_flow_director_mask_mode,
8780 (void *)&cmd_flow_director_mask_mode_ip,
8781 (void *)&cmd_flow_director_mask_vlan,
8782 (void *)&cmd_flow_director_mask_vlan_value,
8783 (void *)&cmd_flow_director_mask_src,
8784 (void *)&cmd_flow_director_mask_ipv4_src,
8785 (void *)&cmd_flow_director_mask_ipv6_src,
8786 (void *)&cmd_flow_director_mask_port_src,
8787 (void *)&cmd_flow_director_mask_dst,
8788 (void *)&cmd_flow_director_mask_ipv4_dst,
8789 (void *)&cmd_flow_director_mask_ipv6_dst,
8790 (void *)&cmd_flow_director_mask_port_dst,
8795 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8796 .f = cmd_flow_director_mask_parsed,
8798 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8800 (void *)&cmd_flow_director_mask,
8801 (void *)&cmd_flow_director_mask_port_id,
8802 (void *)&cmd_flow_director_mask_mode,
8803 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8804 (void *)&cmd_flow_director_mask_vlan,
8805 (void *)&cmd_flow_director_mask_vlan_value,
8806 (void *)&cmd_flow_director_mask_mac,
8807 (void *)&cmd_flow_director_mask_mac_value,
8812 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8813 .f = cmd_flow_director_mask_parsed,
8815 .help_str = "set tunnel mode flow director's mask on NIC",
8817 (void *)&cmd_flow_director_mask,
8818 (void *)&cmd_flow_director_mask_port_id,
8819 (void *)&cmd_flow_director_mask_mode,
8820 (void *)&cmd_flow_director_mask_mode_tunnel,
8821 (void *)&cmd_flow_director_mask_vlan,
8822 (void *)&cmd_flow_director_mask_vlan_value,
8823 (void *)&cmd_flow_director_mask_mac,
8824 (void *)&cmd_flow_director_mask_mac_value,
8825 (void *)&cmd_flow_director_mask_tunnel_type,
8826 (void *)&cmd_flow_director_mask_tunnel_type_value,
8827 (void *)&cmd_flow_director_mask_tunnel_id,
8828 (void *)&cmd_flow_director_mask_tunnel_id_value,
8833 /* *** deal with flow director mask on flexible payload *** */
8834 struct cmd_flow_director_flex_mask_result {
8835 cmdline_fixed_string_t flow_director_flexmask;
8837 cmdline_fixed_string_t flow;
8838 cmdline_fixed_string_t flow_type;
8839 cmdline_fixed_string_t mask;
8843 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8844 __attribute__((unused)) struct cmdline *cl,
8845 __attribute__((unused)) void *data)
8847 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8848 struct rte_eth_fdir_info fdir_info;
8849 struct rte_eth_fdir_flex_mask flex_mask;
8850 struct rte_port *port;
8851 uint32_t flow_type_mask;
8855 if (res->port_id > nb_ports) {
8856 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8860 port = &ports[res->port_id];
8861 /** Check if the port is not started **/
8862 if (port->port_status != RTE_PORT_STOPPED) {
8863 printf("Please stop port %d first\n", res->port_id);
8867 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8868 ret = parse_flexbytes(res->mask,
8870 RTE_ETH_FDIR_MAX_FLEXLEN);
8872 printf("error: Cannot parse mask input.\n");
8876 memset(&fdir_info, 0, sizeof(fdir_info));
8877 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8878 RTE_ETH_FILTER_INFO, &fdir_info);
8880 printf("Cannot get FDir filter info\n");
8884 if (!strcmp(res->flow_type, "none")) {
8885 /* means don't specify the flow type */
8886 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8887 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8888 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8889 0, sizeof(struct rte_eth_fdir_flex_mask));
8890 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8891 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8893 sizeof(struct rte_eth_fdir_flex_mask));
8894 cmd_reconfig_device_queue(res->port_id, 1, 1);
8897 flow_type_mask = fdir_info.flow_types_mask[0];
8898 if (!strcmp(res->flow_type, "all")) {
8899 if (!flow_type_mask) {
8900 printf("No flow type supported\n");
8903 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8904 if (flow_type_mask & (1 << i)) {
8905 flex_mask.flow_type = i;
8906 fdir_set_flex_mask(res->port_id, &flex_mask);
8909 cmd_reconfig_device_queue(res->port_id, 1, 1);
8912 flex_mask.flow_type = str2flowtype(res->flow_type);
8913 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8914 printf("Flow type %s not supported on port %d\n",
8915 res->flow_type, res->port_id);
8918 fdir_set_flex_mask(res->port_id, &flex_mask);
8919 cmd_reconfig_device_queue(res->port_id, 1, 1);
8922 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8924 flow_director_flexmask,
8925 "flow_director_flex_mask");
8926 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8927 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8929 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8930 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8932 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8933 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8934 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8935 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8936 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8940 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8941 .f = cmd_flow_director_flex_mask_parsed,
8943 .help_str = "set flow director's flex mask on NIC",
8945 (void *)&cmd_flow_director_flexmask,
8946 (void *)&cmd_flow_director_flexmask_port_id,
8947 (void *)&cmd_flow_director_flexmask_flow,
8948 (void *)&cmd_flow_director_flexmask_flow_type,
8949 (void *)&cmd_flow_director_flexmask_mask,
8954 /* *** deal with flow director flexible payload configuration *** */
8955 struct cmd_flow_director_flexpayload_result {
8956 cmdline_fixed_string_t flow_director_flexpayload;
8958 cmdline_fixed_string_t payload_layer;
8959 cmdline_fixed_string_t payload_cfg;
8963 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8966 const char *p, *p0 = q_arg;
8968 unsigned long int_fld;
8969 char *str_fld[max_num];
8974 p = strchr(p0, '(');
8978 p0 = strchr(p, ')');
8983 if (size >= sizeof(s))
8986 snprintf(s, sizeof(s), "%.*s", size, p);
8987 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8988 if (ret < 0 || ret > max_num)
8990 for (i = 0; i < ret; i++) {
8992 int_fld = strtoul(str_fld[i], &end, 0);
8993 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8995 offsets[i] = (uint16_t)int_fld;
9001 cmd_flow_director_flxpld_parsed(void *parsed_result,
9002 __attribute__((unused)) struct cmdline *cl,
9003 __attribute__((unused)) void *data)
9005 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9006 struct rte_eth_flex_payload_cfg flex_cfg;
9007 struct rte_port *port;
9010 if (res->port_id > nb_ports) {
9011 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9015 port = &ports[res->port_id];
9016 /** Check if the port is not started **/
9017 if (port->port_status != RTE_PORT_STOPPED) {
9018 printf("Please stop port %d first\n", res->port_id);
9022 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9024 if (!strcmp(res->payload_layer, "raw"))
9025 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9026 else if (!strcmp(res->payload_layer, "l2"))
9027 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9028 else if (!strcmp(res->payload_layer, "l3"))
9029 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9030 else if (!strcmp(res->payload_layer, "l4"))
9031 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9033 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9034 RTE_ETH_FDIR_MAX_FLEXLEN);
9036 printf("error: Cannot parse flex payload input.\n");
9040 fdir_set_flex_payload(res->port_id, &flex_cfg);
9041 cmd_reconfig_device_queue(res->port_id, 1, 1);
9044 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9045 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9046 flow_director_flexpayload,
9047 "flow_director_flex_payload");
9048 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9049 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9051 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9053 payload_layer, "raw#l2#l3#l4");
9054 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9058 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9059 .f = cmd_flow_director_flxpld_parsed,
9061 .help_str = "set flow director's flex payload on NIC",
9063 (void *)&cmd_flow_director_flexpayload,
9064 (void *)&cmd_flow_director_flexpayload_port_id,
9065 (void *)&cmd_flow_director_flexpayload_payload_layer,
9066 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9071 /* *** Classification Filters Control *** */
9072 /* *** Get symmetric hash enable per port *** */
9073 struct cmd_get_sym_hash_ena_per_port_result {
9074 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9079 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9080 __rte_unused struct cmdline *cl,
9081 __rte_unused void *data)
9083 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9084 struct rte_eth_hash_filter_info info;
9087 if (rte_eth_dev_filter_supported(res->port_id,
9088 RTE_ETH_FILTER_HASH) < 0) {
9089 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9094 memset(&info, 0, sizeof(info));
9095 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9096 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9097 RTE_ETH_FILTER_GET, &info);
9100 printf("Cannot get symmetric hash enable per port "
9101 "on port %u\n", res->port_id);
9105 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9106 "enabled" : "disabled", res->port_id);
9109 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9110 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9111 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9112 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9113 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9116 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9117 .f = cmd_get_sym_hash_per_port_parsed,
9119 .help_str = "get_sym_hash_ena_per_port port_id",
9121 (void *)&cmd_get_sym_hash_ena_per_port_all,
9122 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9127 /* *** Set symmetric hash enable per port *** */
9128 struct cmd_set_sym_hash_ena_per_port_result {
9129 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9130 cmdline_fixed_string_t enable;
9135 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9136 __rte_unused struct cmdline *cl,
9137 __rte_unused void *data)
9139 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9140 struct rte_eth_hash_filter_info info;
9143 if (rte_eth_dev_filter_supported(res->port_id,
9144 RTE_ETH_FILTER_HASH) < 0) {
9145 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9150 memset(&info, 0, sizeof(info));
9151 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9152 if (!strcmp(res->enable, "enable"))
9153 info.info.enable = 1;
9154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9155 RTE_ETH_FILTER_SET, &info);
9157 printf("Cannot set symmetric hash enable per port on "
9158 "port %u\n", res->port_id);
9161 printf("Symmetric hash has been set to %s on port %u\n",
9162 res->enable, res->port_id);
9165 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9166 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9167 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9168 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9169 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9171 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9172 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9173 enable, "enable#disable");
9175 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9176 .f = cmd_set_sym_hash_per_port_parsed,
9178 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9180 (void *)&cmd_set_sym_hash_ena_per_port_all,
9181 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9182 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9187 /* Get global config of hash function */
9188 struct cmd_get_hash_global_config_result {
9189 cmdline_fixed_string_t get_hash_global_config;
9194 flowtype_to_str(uint16_t ftype)
9201 {"ipv4", RTE_ETH_FLOW_IPV4},
9202 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9203 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9204 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9205 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9206 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9207 {"ipv6", RTE_ETH_FLOW_IPV6},
9208 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9209 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9210 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9211 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9212 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9213 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9216 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9217 if (ftype_table[i].ftype == ftype)
9218 return ftype_table[i].str;
9225 cmd_get_hash_global_config_parsed(void *parsed_result,
9226 __rte_unused struct cmdline *cl,
9227 __rte_unused void *data)
9229 struct cmd_get_hash_global_config_result *res = parsed_result;
9230 struct rte_eth_hash_filter_info info;
9231 uint32_t idx, offset;
9236 if (rte_eth_dev_filter_supported(res->port_id,
9237 RTE_ETH_FILTER_HASH) < 0) {
9238 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9243 memset(&info, 0, sizeof(info));
9244 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9245 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9246 RTE_ETH_FILTER_GET, &info);
9248 printf("Cannot get hash global configurations by port %d\n",
9253 switch (info.info.global_conf.hash_func) {
9254 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9255 printf("Hash function is Toeplitz\n");
9257 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9258 printf("Hash function is Simple XOR\n");
9261 printf("Unknown hash function\n");
9265 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9266 idx = i / UINT32_BIT;
9267 offset = i % UINT32_BIT;
9268 if (!(info.info.global_conf.valid_bit_mask[idx] &
9271 str = flowtype_to_str(i);
9274 printf("Symmetric hash is %s globally for flow type %s "
9276 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9277 (1UL << offset)) ? "enabled" : "disabled"), str,
9282 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9283 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9284 get_hash_global_config, "get_hash_global_config");
9285 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9286 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9289 cmdline_parse_inst_t cmd_get_hash_global_config = {
9290 .f = cmd_get_hash_global_config_parsed,
9292 .help_str = "get_hash_global_config port_id",
9294 (void *)&cmd_get_hash_global_config_all,
9295 (void *)&cmd_get_hash_global_config_port_id,
9300 /* Set global config of hash function */
9301 struct cmd_set_hash_global_config_result {
9302 cmdline_fixed_string_t set_hash_global_config;
9304 cmdline_fixed_string_t hash_func;
9305 cmdline_fixed_string_t flow_type;
9306 cmdline_fixed_string_t enable;
9310 cmd_set_hash_global_config_parsed(void *parsed_result,
9311 __rte_unused struct cmdline *cl,
9312 __rte_unused void *data)
9314 struct cmd_set_hash_global_config_result *res = parsed_result;
9315 struct rte_eth_hash_filter_info info;
9316 uint32_t ftype, idx, offset;
9319 if (rte_eth_dev_filter_supported(res->port_id,
9320 RTE_ETH_FILTER_HASH) < 0) {
9321 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9325 memset(&info, 0, sizeof(info));
9326 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9327 if (!strcmp(res->hash_func, "toeplitz"))
9328 info.info.global_conf.hash_func =
9329 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9330 else if (!strcmp(res->hash_func, "simple_xor"))
9331 info.info.global_conf.hash_func =
9332 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9333 else if (!strcmp(res->hash_func, "default"))
9334 info.info.global_conf.hash_func =
9335 RTE_ETH_HASH_FUNCTION_DEFAULT;
9337 ftype = str2flowtype(res->flow_type);
9338 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9339 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9340 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9341 if (!strcmp(res->enable, "enable"))
9342 info.info.global_conf.sym_hash_enable_mask[idx] |=
9344 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9345 RTE_ETH_FILTER_SET, &info);
9347 printf("Cannot set global hash configurations by port %d\n",
9350 printf("Global hash configurations have been set "
9351 "succcessfully by port %d\n", res->port_id);
9354 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9355 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9356 set_hash_global_config, "set_hash_global_config");
9357 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9358 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9360 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9361 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9362 hash_func, "toeplitz#simple_xor#default");
9363 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9364 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9366 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9367 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9368 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9370 enable, "enable#disable");
9372 cmdline_parse_inst_t cmd_set_hash_global_config = {
9373 .f = cmd_set_hash_global_config_parsed,
9375 .help_str = "set_hash_global_config port_id "
9376 "toeplitz|simple_xor|default "
9377 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9378 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9381 (void *)&cmd_set_hash_global_config_all,
9382 (void *)&cmd_set_hash_global_config_port_id,
9383 (void *)&cmd_set_hash_global_config_hash_func,
9384 (void *)&cmd_set_hash_global_config_flow_type,
9385 (void *)&cmd_set_hash_global_config_enable,
9390 /* Set hash input set */
9391 struct cmd_set_hash_input_set_result {
9392 cmdline_fixed_string_t set_hash_input_set;
9394 cmdline_fixed_string_t flow_type;
9395 cmdline_fixed_string_t inset_field;
9396 cmdline_fixed_string_t select;
9399 static enum rte_eth_input_set_field
9400 str2inset(char *string)
9404 static const struct {
9406 enum rte_eth_input_set_field inset;
9408 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9409 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9410 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9411 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9412 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9413 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9414 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9415 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9416 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9417 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9418 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9419 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9420 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9421 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9422 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9423 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9424 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9425 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9426 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9427 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9428 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9429 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9430 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9431 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9432 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9433 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9434 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9435 {"none", RTE_ETH_INPUT_SET_NONE},
9438 for (i = 0; i < RTE_DIM(inset_table); i++) {
9439 if (!strcmp(string, inset_table[i].str))
9440 return inset_table[i].inset;
9443 return RTE_ETH_INPUT_SET_UNKNOWN;
9447 cmd_set_hash_input_set_parsed(void *parsed_result,
9448 __rte_unused struct cmdline *cl,
9449 __rte_unused void *data)
9451 struct cmd_set_hash_input_set_result *res = parsed_result;
9452 struct rte_eth_hash_filter_info info;
9454 memset(&info, 0, sizeof(info));
9455 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9456 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9457 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9458 info.info.input_set_conf.inset_size = 1;
9459 if (!strcmp(res->select, "select"))
9460 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9461 else if (!strcmp(res->select, "add"))
9462 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9463 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9464 RTE_ETH_FILTER_SET, &info);
9467 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9468 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9469 set_hash_input_set, "set_hash_input_set");
9470 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9471 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9473 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9474 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9476 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9477 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9478 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9479 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9481 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9482 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9483 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9484 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9485 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9487 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9488 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9489 select, "select#add");
9491 cmdline_parse_inst_t cmd_set_hash_input_set = {
9492 .f = cmd_set_hash_input_set_parsed,
9494 .help_str = "set_hash_input_set <port_id> "
9495 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9496 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9497 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9498 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9499 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9500 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9501 "fld-7th|fld-8th|none select|add",
9503 (void *)&cmd_set_hash_input_set_cmd,
9504 (void *)&cmd_set_hash_input_set_port_id,
9505 (void *)&cmd_set_hash_input_set_flow_type,
9506 (void *)&cmd_set_hash_input_set_field,
9507 (void *)&cmd_set_hash_input_set_select,
9512 /* Set flow director input set */
9513 struct cmd_set_fdir_input_set_result {
9514 cmdline_fixed_string_t set_fdir_input_set;
9516 cmdline_fixed_string_t flow_type;
9517 cmdline_fixed_string_t inset_field;
9518 cmdline_fixed_string_t select;
9522 cmd_set_fdir_input_set_parsed(void *parsed_result,
9523 __rte_unused struct cmdline *cl,
9524 __rte_unused void *data)
9526 struct cmd_set_fdir_input_set_result *res = parsed_result;
9527 struct rte_eth_fdir_filter_info info;
9529 memset(&info, 0, sizeof(info));
9530 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9531 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9532 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9533 info.info.input_set_conf.inset_size = 1;
9534 if (!strcmp(res->select, "select"))
9535 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9536 else if (!strcmp(res->select, "add"))
9537 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9538 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9539 RTE_ETH_FILTER_SET, &info);
9542 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9543 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9544 set_fdir_input_set, "set_fdir_input_set");
9545 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9546 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9548 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9549 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9551 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9552 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9553 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9554 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9556 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9557 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9558 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9559 "fld-7th#fld-8th#none");
9560 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9561 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9562 select, "select#add");
9564 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9565 .f = cmd_set_fdir_input_set_parsed,
9567 .help_str = "set_fdir_input_set <port_id> "
9568 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9569 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9570 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9571 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9572 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9573 "fld-7th|fld-8th|none select|add",
9575 (void *)&cmd_set_fdir_input_set_cmd,
9576 (void *)&cmd_set_fdir_input_set_port_id,
9577 (void *)&cmd_set_fdir_input_set_flow_type,
9578 (void *)&cmd_set_fdir_input_set_field,
9579 (void *)&cmd_set_fdir_input_set_select,
9584 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9585 struct cmd_mcast_addr_result {
9586 cmdline_fixed_string_t mcast_addr_cmd;
9587 cmdline_fixed_string_t what;
9589 struct ether_addr mc_addr;
9592 static void cmd_mcast_addr_parsed(void *parsed_result,
9593 __attribute__((unused)) struct cmdline *cl,
9594 __attribute__((unused)) void *data)
9596 struct cmd_mcast_addr_result *res = parsed_result;
9598 if (!is_multicast_ether_addr(&res->mc_addr)) {
9599 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9600 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9601 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9602 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9605 if (strcmp(res->what, "add") == 0)
9606 mcast_addr_add(res->port_num, &res->mc_addr);
9608 mcast_addr_remove(res->port_num, &res->mc_addr);
9611 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9612 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9613 mcast_addr_cmd, "mcast_addr");
9614 cmdline_parse_token_string_t cmd_mcast_addr_what =
9615 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9617 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9618 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9619 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9620 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9622 cmdline_parse_inst_t cmd_mcast_addr = {
9623 .f = cmd_mcast_addr_parsed,
9625 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9627 (void *)&cmd_mcast_addr_cmd,
9628 (void *)&cmd_mcast_addr_what,
9629 (void *)&cmd_mcast_addr_portnum,
9630 (void *)&cmd_mcast_addr_addr,
9635 /* ******************************************************************************** */
9637 /* list of instructions */
9638 cmdline_parse_ctx_t main_ctx[] = {
9639 (cmdline_parse_inst_t *)&cmd_help_brief,
9640 (cmdline_parse_inst_t *)&cmd_help_long,
9641 (cmdline_parse_inst_t *)&cmd_quit,
9642 (cmdline_parse_inst_t *)&cmd_showport,
9643 (cmdline_parse_inst_t *)&cmd_showqueue,
9644 (cmdline_parse_inst_t *)&cmd_showportall,
9645 (cmdline_parse_inst_t *)&cmd_showcfg,
9646 (cmdline_parse_inst_t *)&cmd_start,
9647 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9648 (cmdline_parse_inst_t *)&cmd_set_link_up,
9649 (cmdline_parse_inst_t *)&cmd_set_link_down,
9650 (cmdline_parse_inst_t *)&cmd_reset,
9651 (cmdline_parse_inst_t *)&cmd_set_numbers,
9652 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9653 (cmdline_parse_inst_t *)&cmd_set_txsplit,
9654 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9655 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9656 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9657 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9658 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9659 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9660 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9661 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9662 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9663 (cmdline_parse_inst_t *)&cmd_set_link_check,
9664 #ifdef RTE_NIC_BYPASS
9665 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9666 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9667 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9668 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9670 #ifdef RTE_LIBRTE_PMD_BOND
9671 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9672 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9673 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9674 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9675 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9676 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9677 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9678 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9679 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9681 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9682 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9683 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9684 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9685 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9686 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9687 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9688 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9689 (cmdline_parse_inst_t *)&cmd_csum_set,
9690 (cmdline_parse_inst_t *)&cmd_csum_show,
9691 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9692 (cmdline_parse_inst_t *)&cmd_tso_set,
9693 (cmdline_parse_inst_t *)&cmd_tso_show,
9694 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9696 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9697 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9698 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9699 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9700 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9701 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9702 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9703 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9704 (cmdline_parse_inst_t *)&cmd_config_dcb,
9705 (cmdline_parse_inst_t *)&cmd_read_reg,
9706 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9707 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9708 (cmdline_parse_inst_t *)&cmd_write_reg,
9709 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9710 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9711 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9712 (cmdline_parse_inst_t *)&cmd_stop,
9713 (cmdline_parse_inst_t *)&cmd_mac_addr,
9714 (cmdline_parse_inst_t *)&cmd_set_qmap,
9715 (cmdline_parse_inst_t *)&cmd_operate_port,
9716 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9717 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9718 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9719 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9720 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9721 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9722 (cmdline_parse_inst_t *)&cmd_config_mtu,
9723 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9724 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9725 (cmdline_parse_inst_t *)&cmd_config_rss,
9726 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9727 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9728 (cmdline_parse_inst_t *)&cmd_showport_reta,
9729 (cmdline_parse_inst_t *)&cmd_config_burst,
9730 (cmdline_parse_inst_t *)&cmd_config_thresh,
9731 (cmdline_parse_inst_t *)&cmd_config_threshold,
9732 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9733 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9734 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9735 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9736 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9737 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9738 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9739 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9740 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9741 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9742 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9743 (cmdline_parse_inst_t *)&cmd_global_config,
9744 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9745 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9746 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9747 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9748 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9749 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9750 (cmdline_parse_inst_t *)&cmd_dump,
9751 (cmdline_parse_inst_t *)&cmd_dump_one,
9752 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9753 (cmdline_parse_inst_t *)&cmd_syn_filter,
9754 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9755 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9756 (cmdline_parse_inst_t *)&cmd_flex_filter,
9757 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9758 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9759 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9760 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9761 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9762 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9763 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9764 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9765 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9766 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9767 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9768 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9769 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9770 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9771 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9772 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9773 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
9774 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
9775 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9779 /* prompt function, called from main on MASTER lcore */
9783 /* initialize non-constant commands */
9784 cmd_set_fwd_mode_init();
9786 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9787 if (testpmd_cl == NULL)
9789 cmdline_interact(testpmd_cl);
9790 cmdline_stdin_exit(testpmd_cl);
9796 if (testpmd_cl != NULL)
9797 cmdline_quit(testpmd_cl);
9801 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9803 if (id == (portid_t)RTE_PORT_ALL) {
9806 FOREACH_PORT(pid, ports) {
9807 /* check if need_reconfig has been set to 1 */
9808 if (ports[pid].need_reconfig == 0)
9809 ports[pid].need_reconfig = dev;
9810 /* check if need_reconfig_queues has been set to 1 */
9811 if (ports[pid].need_reconfig_queues == 0)
9812 ports[pid].need_reconfig_queues = queue;
9814 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9815 /* check if need_reconfig has been set to 1 */
9816 if (ports[id].need_reconfig == 0)
9817 ports[id].need_reconfig = dev;
9818 /* check if need_reconfig_queues has been set to 1 */
9819 if (ports[id].need_reconfig_queues == 0)
9820 ports[id].need_reconfig_queues = queue;
9824 #ifdef RTE_NIC_BYPASS
9825 #include <rte_pci_dev_ids.h>
9827 bypass_is_supported(portid_t port_id)
9829 struct rte_port *port;
9830 struct rte_pci_id *pci_id;
9832 if (port_id_is_invalid(port_id, ENABLED_WARN))
9835 /* Get the device id. */
9836 port = &ports[port_id];
9837 pci_id = &port->dev_info.pci_dev->id;
9839 /* Check if NIC supports bypass. */
9840 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9844 printf("\tBypass not supported for port_id = %d.\n", port_id);