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;
2958 tx_vlan_set(res->port_id, res->vlan_id);
2961 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2962 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2963 tx_vlan, "tx_vlan");
2964 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2965 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2967 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2968 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2970 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2971 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2974 cmdline_parse_inst_t cmd_tx_vlan_set = {
2975 .f = cmd_tx_vlan_set_parsed,
2977 .help_str = "enable hardware insertion of a single VLAN header "
2978 "with a given TAG Identifier in packets sent on a port",
2980 (void *)&cmd_tx_vlan_set_tx_vlan,
2981 (void *)&cmd_tx_vlan_set_set,
2982 (void *)&cmd_tx_vlan_set_portid,
2983 (void *)&cmd_tx_vlan_set_vlanid,
2988 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
2989 struct cmd_tx_vlan_set_qinq_result {
2990 cmdline_fixed_string_t tx_vlan;
2991 cmdline_fixed_string_t set;
2994 uint16_t vlan_id_outer;
2998 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
2999 __attribute__((unused)) struct cmdline *cl,
3000 __attribute__((unused)) void *data)
3002 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3004 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3007 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3008 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3009 tx_vlan, "tx_vlan");
3010 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3011 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3013 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3014 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3016 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3017 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3019 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3020 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3021 vlan_id_outer, UINT16);
3023 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3024 .f = cmd_tx_vlan_set_qinq_parsed,
3026 .help_str = "enable hardware insertion of double VLAN header "
3027 "with given TAG Identifiers in packets sent on a port",
3029 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3030 (void *)&cmd_tx_vlan_set_qinq_set,
3031 (void *)&cmd_tx_vlan_set_qinq_portid,
3032 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3033 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3038 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3039 struct cmd_tx_vlan_set_pvid_result {
3040 cmdline_fixed_string_t tx_vlan;
3041 cmdline_fixed_string_t set;
3042 cmdline_fixed_string_t pvid;
3045 cmdline_fixed_string_t mode;
3049 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3050 __attribute__((unused)) struct cmdline *cl,
3051 __attribute__((unused)) void *data)
3053 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3055 if (strcmp(res->mode, "on") == 0)
3056 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3058 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3061 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3062 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3063 tx_vlan, "tx_vlan");
3064 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3065 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3067 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3068 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3070 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3071 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3073 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3074 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3076 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3077 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3080 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3081 .f = cmd_tx_vlan_set_pvid_parsed,
3083 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
3085 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3086 (void *)&cmd_tx_vlan_set_pvid_set,
3087 (void *)&cmd_tx_vlan_set_pvid_pvid,
3088 (void *)&cmd_tx_vlan_set_pvid_port_id,
3089 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3090 (void *)&cmd_tx_vlan_set_pvid_mode,
3095 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3096 struct cmd_tx_vlan_reset_result {
3097 cmdline_fixed_string_t tx_vlan;
3098 cmdline_fixed_string_t reset;
3103 cmd_tx_vlan_reset_parsed(void *parsed_result,
3104 __attribute__((unused)) struct cmdline *cl,
3105 __attribute__((unused)) void *data)
3107 struct cmd_tx_vlan_reset_result *res = parsed_result;
3109 tx_vlan_reset(res->port_id);
3112 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3113 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3114 tx_vlan, "tx_vlan");
3115 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3116 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3118 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3119 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3122 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3123 .f = cmd_tx_vlan_reset_parsed,
3125 .help_str = "disable hardware insertion of a VLAN header in packets "
3128 (void *)&cmd_tx_vlan_reset_tx_vlan,
3129 (void *)&cmd_tx_vlan_reset_reset,
3130 (void *)&cmd_tx_vlan_reset_portid,
3136 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3137 struct cmd_csum_result {
3138 cmdline_fixed_string_t csum;
3139 cmdline_fixed_string_t mode;
3140 cmdline_fixed_string_t proto;
3141 cmdline_fixed_string_t hwsw;
3146 csum_show(int port_id)
3148 struct rte_eth_dev_info dev_info;
3151 ol_flags = ports[port_id].tx_ol_flags;
3152 printf("Parse tunnel is %s\n",
3153 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3154 printf("IP checksum offload is %s\n",
3155 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3156 printf("UDP checksum offload is %s\n",
3157 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3158 printf("TCP checksum offload is %s\n",
3159 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3160 printf("SCTP checksum offload is %s\n",
3161 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3162 printf("Outer-Ip checksum offload is %s\n",
3163 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3165 /* display warnings if configuration is not supported by the NIC */
3166 rte_eth_dev_info_get(port_id, &dev_info);
3167 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3168 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3169 printf("Warning: hardware IP checksum enabled but not "
3170 "supported by port %d\n", port_id);
3172 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3173 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3174 printf("Warning: hardware UDP checksum enabled but not "
3175 "supported by port %d\n", port_id);
3177 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3178 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3179 printf("Warning: hardware TCP checksum enabled but not "
3180 "supported by port %d\n", port_id);
3182 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3183 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3184 printf("Warning: hardware SCTP checksum enabled but not "
3185 "supported by port %d\n", port_id);
3187 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3188 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3189 printf("Warning: hardware outer IP checksum enabled but not "
3190 "supported by port %d\n", port_id);
3195 cmd_csum_parsed(void *parsed_result,
3196 __attribute__((unused)) struct cmdline *cl,
3197 __attribute__((unused)) void *data)
3199 struct cmd_csum_result *res = parsed_result;
3203 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3204 printf("invalid port %d\n", res->port_id);
3208 if (!strcmp(res->mode, "set")) {
3210 if (!strcmp(res->hwsw, "hw"))
3213 if (!strcmp(res->proto, "ip")) {
3214 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3215 } else if (!strcmp(res->proto, "udp")) {
3216 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3217 } else if (!strcmp(res->proto, "tcp")) {
3218 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3219 } else if (!strcmp(res->proto, "sctp")) {
3220 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3221 } else if (!strcmp(res->proto, "outer-ip")) {
3222 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3226 ports[res->port_id].tx_ol_flags |= mask;
3228 ports[res->port_id].tx_ol_flags &= (~mask);
3230 csum_show(res->port_id);
3233 cmdline_parse_token_string_t cmd_csum_csum =
3234 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3236 cmdline_parse_token_string_t cmd_csum_mode =
3237 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3239 cmdline_parse_token_string_t cmd_csum_proto =
3240 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3241 proto, "ip#tcp#udp#sctp#outer-ip");
3242 cmdline_parse_token_string_t cmd_csum_hwsw =
3243 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3245 cmdline_parse_token_num_t cmd_csum_portid =
3246 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3249 cmdline_parse_inst_t cmd_csum_set = {
3250 .f = cmd_csum_parsed,
3252 .help_str = "enable/disable hardware calculation of L3/L4 checksum when "
3253 "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>",
3255 (void *)&cmd_csum_csum,
3256 (void *)&cmd_csum_mode,
3257 (void *)&cmd_csum_proto,
3258 (void *)&cmd_csum_hwsw,
3259 (void *)&cmd_csum_portid,
3264 cmdline_parse_token_string_t cmd_csum_mode_show =
3265 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3268 cmdline_parse_inst_t cmd_csum_show = {
3269 .f = cmd_csum_parsed,
3271 .help_str = "show checksum offload configuration: csum show <port>",
3273 (void *)&cmd_csum_csum,
3274 (void *)&cmd_csum_mode_show,
3275 (void *)&cmd_csum_portid,
3280 /* Enable/disable tunnel parsing */
3281 struct cmd_csum_tunnel_result {
3282 cmdline_fixed_string_t csum;
3283 cmdline_fixed_string_t parse;
3284 cmdline_fixed_string_t onoff;
3289 cmd_csum_tunnel_parsed(void *parsed_result,
3290 __attribute__((unused)) struct cmdline *cl,
3291 __attribute__((unused)) void *data)
3293 struct cmd_csum_tunnel_result *res = parsed_result;
3295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3298 if (!strcmp(res->onoff, "on"))
3299 ports[res->port_id].tx_ol_flags |=
3300 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3302 ports[res->port_id].tx_ol_flags &=
3303 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3305 csum_show(res->port_id);
3308 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3309 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3311 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3312 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3313 parse, "parse_tunnel");
3314 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3315 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3317 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3318 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3321 cmdline_parse_inst_t cmd_csum_tunnel = {
3322 .f = cmd_csum_tunnel_parsed,
3324 .help_str = "enable/disable parsing of tunnels for csum engine: "
3325 "csum parse_tunnel on|off <tx-port>",
3327 (void *)&cmd_csum_tunnel_csum,
3328 (void *)&cmd_csum_tunnel_parse,
3329 (void *)&cmd_csum_tunnel_onoff,
3330 (void *)&cmd_csum_tunnel_portid,
3335 /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */
3336 struct cmd_tso_set_result {
3337 cmdline_fixed_string_t tso;
3338 cmdline_fixed_string_t mode;
3344 cmd_tso_set_parsed(void *parsed_result,
3345 __attribute__((unused)) struct cmdline *cl,
3346 __attribute__((unused)) void *data)
3348 struct cmd_tso_set_result *res = parsed_result;
3349 struct rte_eth_dev_info dev_info;
3351 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3354 if (!strcmp(res->mode, "set"))
3355 ports[res->port_id].tso_segsz = res->tso_segsz;
3357 if (ports[res->port_id].tso_segsz == 0)
3358 printf("TSO is disabled\n");
3360 printf("TSO segment size is %d\n",
3361 ports[res->port_id].tso_segsz);
3363 /* display warnings if configuration is not supported by the NIC */
3364 rte_eth_dev_info_get(res->port_id, &dev_info);
3365 if ((ports[res->port_id].tso_segsz != 0) &&
3366 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3367 printf("Warning: TSO enabled but not "
3368 "supported by port %d\n", res->port_id);
3372 cmdline_parse_token_string_t cmd_tso_set_tso =
3373 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3375 cmdline_parse_token_string_t cmd_tso_set_mode =
3376 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3378 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3379 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3381 cmdline_parse_token_num_t cmd_tso_set_portid =
3382 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3385 cmdline_parse_inst_t cmd_tso_set = {
3386 .f = cmd_tso_set_parsed,
3388 .help_str = "Set TSO segment size for csum engine (0 to disable): "
3389 "tso set <tso_segsz> <port>",
3391 (void *)&cmd_tso_set_tso,
3392 (void *)&cmd_tso_set_mode,
3393 (void *)&cmd_tso_set_tso_segsz,
3394 (void *)&cmd_tso_set_portid,
3399 cmdline_parse_token_string_t cmd_tso_show_mode =
3400 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3404 cmdline_parse_inst_t cmd_tso_show = {
3405 .f = cmd_tso_set_parsed,
3407 .help_str = "Show TSO segment size for csum engine: "
3410 (void *)&cmd_tso_set_tso,
3411 (void *)&cmd_tso_show_mode,
3412 (void *)&cmd_tso_set_portid,
3417 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3418 struct cmd_set_flush_rx {
3419 cmdline_fixed_string_t set;
3420 cmdline_fixed_string_t flush_rx;
3421 cmdline_fixed_string_t mode;
3425 cmd_set_flush_rx_parsed(void *parsed_result,
3426 __attribute__((unused)) struct cmdline *cl,
3427 __attribute__((unused)) void *data)
3429 struct cmd_set_flush_rx *res = parsed_result;
3430 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3433 cmdline_parse_token_string_t cmd_setflushrx_set =
3434 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3436 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3437 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3438 flush_rx, "flush_rx");
3439 cmdline_parse_token_string_t cmd_setflushrx_mode =
3440 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3444 cmdline_parse_inst_t cmd_set_flush_rx = {
3445 .f = cmd_set_flush_rx_parsed,
3446 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
3449 (void *)&cmd_setflushrx_set,
3450 (void *)&cmd_setflushrx_flush_rx,
3451 (void *)&cmd_setflushrx_mode,
3456 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3457 struct cmd_set_link_check {
3458 cmdline_fixed_string_t set;
3459 cmdline_fixed_string_t link_check;
3460 cmdline_fixed_string_t mode;
3464 cmd_set_link_check_parsed(void *parsed_result,
3465 __attribute__((unused)) struct cmdline *cl,
3466 __attribute__((unused)) void *data)
3468 struct cmd_set_link_check *res = parsed_result;
3469 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3472 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3473 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3475 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3476 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3477 link_check, "link_check");
3478 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3479 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3483 cmdline_parse_inst_t cmd_set_link_check = {
3484 .f = cmd_set_link_check_parsed,
3485 .help_str = "set link_check on|off: enable/disable link status check "
3486 "when starting/stopping a port",
3489 (void *)&cmd_setlinkcheck_set,
3490 (void *)&cmd_setlinkcheck_link_check,
3491 (void *)&cmd_setlinkcheck_mode,
3496 #ifdef RTE_NIC_BYPASS
3497 /* *** SET NIC BYPASS MODE *** */
3498 struct cmd_set_bypass_mode_result {
3499 cmdline_fixed_string_t set;
3500 cmdline_fixed_string_t bypass;
3501 cmdline_fixed_string_t mode;
3502 cmdline_fixed_string_t value;
3507 cmd_set_bypass_mode_parsed(void *parsed_result,
3508 __attribute__((unused)) struct cmdline *cl,
3509 __attribute__((unused)) void *data)
3511 struct cmd_set_bypass_mode_result *res = parsed_result;
3512 portid_t port_id = res->port_id;
3513 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3515 if (!bypass_is_supported(port_id))
3518 if (!strcmp(res->value, "bypass"))
3519 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3520 else if (!strcmp(res->value, "isolate"))
3521 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3523 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3525 /* Set the bypass mode for the relevant port. */
3526 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3527 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3531 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3532 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3534 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3537 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3540 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3542 value, "normal#bypass#isolate");
3543 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3544 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3547 cmdline_parse_inst_t cmd_set_bypass_mode = {
3548 .f = cmd_set_bypass_mode_parsed,
3549 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3550 "Set the NIC bypass mode for port_id",
3553 (void *)&cmd_setbypass_mode_set,
3554 (void *)&cmd_setbypass_mode_bypass,
3555 (void *)&cmd_setbypass_mode_mode,
3556 (void *)&cmd_setbypass_mode_value,
3557 (void *)&cmd_setbypass_mode_port,
3562 /* *** SET NIC BYPASS EVENT *** */
3563 struct cmd_set_bypass_event_result {
3564 cmdline_fixed_string_t set;
3565 cmdline_fixed_string_t bypass;
3566 cmdline_fixed_string_t event;
3567 cmdline_fixed_string_t event_value;
3568 cmdline_fixed_string_t mode;
3569 cmdline_fixed_string_t mode_value;
3574 cmd_set_bypass_event_parsed(void *parsed_result,
3575 __attribute__((unused)) struct cmdline *cl,
3576 __attribute__((unused)) void *data)
3579 struct cmd_set_bypass_event_result *res = parsed_result;
3580 portid_t port_id = res->port_id;
3581 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3582 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3584 if (!bypass_is_supported(port_id))
3587 if (!strcmp(res->event_value, "timeout"))
3588 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3589 else if (!strcmp(res->event_value, "os_on"))
3590 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3591 else if (!strcmp(res->event_value, "os_off"))
3592 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3593 else if (!strcmp(res->event_value, "power_on"))
3594 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3595 else if (!strcmp(res->event_value, "power_off"))
3596 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3598 bypass_event = RTE_BYPASS_EVENT_NONE;
3600 if (!strcmp(res->mode_value, "bypass"))
3601 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3602 else if (!strcmp(res->mode_value, "isolate"))
3603 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3605 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3607 /* Set the watchdog timeout. */
3608 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3611 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3612 (rc = rte_eth_dev_wd_timeout_store(port_id,
3613 bypass_timeout)) != 0) {
3614 printf("Failed to set timeout value %u "
3615 "for port %d, errto code: %d.\n",
3616 bypass_timeout, port_id, rc);
3620 /* Set the bypass event to transition to bypass mode. */
3621 if (0 != rte_eth_dev_bypass_event_store(port_id,
3622 bypass_event, bypass_mode)) {
3623 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3628 cmdline_parse_token_string_t cmd_setbypass_event_set =
3629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3631 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3634 cmdline_parse_token_string_t cmd_setbypass_event_event =
3635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3637 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3639 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3640 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3643 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3645 mode_value, "normal#bypass#isolate");
3646 cmdline_parse_token_num_t cmd_setbypass_event_port =
3647 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3650 cmdline_parse_inst_t cmd_set_bypass_event = {
3651 .f = cmd_set_bypass_event_parsed,
3652 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3653 "mode (normal|bypass|isolate) (port_id): "
3654 "Set the NIC bypass event mode for port_id",
3657 (void *)&cmd_setbypass_event_set,
3658 (void *)&cmd_setbypass_event_bypass,
3659 (void *)&cmd_setbypass_event_event,
3660 (void *)&cmd_setbypass_event_event_value,
3661 (void *)&cmd_setbypass_event_mode,
3662 (void *)&cmd_setbypass_event_mode_value,
3663 (void *)&cmd_setbypass_event_port,
3669 /* *** SET NIC BYPASS TIMEOUT *** */
3670 struct cmd_set_bypass_timeout_result {
3671 cmdline_fixed_string_t set;
3672 cmdline_fixed_string_t bypass;
3673 cmdline_fixed_string_t timeout;
3674 cmdline_fixed_string_t value;
3678 cmd_set_bypass_timeout_parsed(void *parsed_result,
3679 __attribute__((unused)) struct cmdline *cl,
3680 __attribute__((unused)) void *data)
3682 struct cmd_set_bypass_timeout_result *res = parsed_result;
3684 if (!strcmp(res->value, "1.5"))
3685 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3686 else if (!strcmp(res->value, "2"))
3687 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3688 else if (!strcmp(res->value, "3"))
3689 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3690 else if (!strcmp(res->value, "4"))
3691 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3692 else if (!strcmp(res->value, "8"))
3693 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3694 else if (!strcmp(res->value, "16"))
3695 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3696 else if (!strcmp(res->value, "32"))
3697 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3699 bypass_timeout = RTE_BYPASS_TMT_OFF;
3702 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3705 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3708 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3710 timeout, "timeout");
3711 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3713 value, "0#1.5#2#3#4#8#16#32");
3715 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3716 .f = cmd_set_bypass_timeout_parsed,
3717 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3718 "Set the NIC bypass watchdog timeout",
3721 (void *)&cmd_setbypass_timeout_set,
3722 (void *)&cmd_setbypass_timeout_bypass,
3723 (void *)&cmd_setbypass_timeout_timeout,
3724 (void *)&cmd_setbypass_timeout_value,
3729 /* *** SHOW NIC BYPASS MODE *** */
3730 struct cmd_show_bypass_config_result {
3731 cmdline_fixed_string_t show;
3732 cmdline_fixed_string_t bypass;
3733 cmdline_fixed_string_t config;
3738 cmd_show_bypass_config_parsed(void *parsed_result,
3739 __attribute__((unused)) struct cmdline *cl,
3740 __attribute__((unused)) void *data)
3742 struct cmd_show_bypass_config_result *res = parsed_result;
3743 uint32_t event_mode;
3744 uint32_t bypass_mode;
3745 portid_t port_id = res->port_id;
3746 uint32_t timeout = bypass_timeout;
3749 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3750 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3751 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3752 {"UNKNOWN", "normal", "bypass", "isolate"};
3753 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3760 int num_events = (sizeof events) / (sizeof events[0]);
3762 if (!bypass_is_supported(port_id))
3765 /* Display the bypass mode.*/
3766 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3767 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3771 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3772 bypass_mode = RTE_BYPASS_MODE_NONE;
3774 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3777 /* Display the bypass timeout.*/
3778 if (!RTE_BYPASS_TMT_VALID(timeout))
3779 timeout = RTE_BYPASS_TMT_OFF;
3781 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3783 /* Display the bypass events and associated modes. */
3784 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3786 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3787 printf("\tFailed to get bypass mode for event = %s\n",
3790 if (!RTE_BYPASS_MODE_VALID(event_mode))
3791 event_mode = RTE_BYPASS_MODE_NONE;
3793 printf("\tbypass event: %-16s = %s\n", events[i],
3799 cmdline_parse_token_string_t cmd_showbypass_config_show =
3800 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3802 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3803 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3805 cmdline_parse_token_string_t cmd_showbypass_config_config =
3806 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3808 cmdline_parse_token_num_t cmd_showbypass_config_port =
3809 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3812 cmdline_parse_inst_t cmd_show_bypass_config = {
3813 .f = cmd_show_bypass_config_parsed,
3814 .help_str = "show bypass config (port_id): "
3815 "Show the NIC bypass config for port_id",
3818 (void *)&cmd_showbypass_config_show,
3819 (void *)&cmd_showbypass_config_bypass,
3820 (void *)&cmd_showbypass_config_config,
3821 (void *)&cmd_showbypass_config_port,
3827 #ifdef RTE_LIBRTE_PMD_BOND
3828 /* *** SET BONDING MODE *** */
3829 struct cmd_set_bonding_mode_result {
3830 cmdline_fixed_string_t set;
3831 cmdline_fixed_string_t bonding;
3832 cmdline_fixed_string_t mode;
3837 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3838 __attribute__((unused)) struct cmdline *cl,
3839 __attribute__((unused)) void *data)
3841 struct cmd_set_bonding_mode_result *res = parsed_result;
3842 portid_t port_id = res->port_id;
3844 /* Set the bonding mode for the relevant port. */
3845 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3846 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3849 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3852 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3854 bonding, "bonding");
3855 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3858 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3859 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3861 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3865 cmdline_parse_inst_t cmd_set_bonding_mode = {
3866 .f = cmd_set_bonding_mode_parsed,
3867 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3870 (void *) &cmd_setbonding_mode_set,
3871 (void *) &cmd_setbonding_mode_bonding,
3872 (void *) &cmd_setbonding_mode_mode,
3873 (void *) &cmd_setbonding_mode_value,
3874 (void *) &cmd_setbonding_mode_port,
3879 /* *** SET BALANCE XMIT POLICY *** */
3880 struct cmd_set_bonding_balance_xmit_policy_result {
3881 cmdline_fixed_string_t set;
3882 cmdline_fixed_string_t bonding;
3883 cmdline_fixed_string_t balance_xmit_policy;
3885 cmdline_fixed_string_t policy;
3888 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3889 __attribute__((unused)) struct cmdline *cl,
3890 __attribute__((unused)) void *data)
3892 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3893 portid_t port_id = res->port_id;
3896 if (!strcmp(res->policy, "l2")) {
3897 policy = BALANCE_XMIT_POLICY_LAYER2;
3898 } else if (!strcmp(res->policy, "l23")) {
3899 policy = BALANCE_XMIT_POLICY_LAYER23;
3900 } else if (!strcmp(res->policy, "l34")) {
3901 policy = BALANCE_XMIT_POLICY_LAYER34;
3903 printf("\t Invalid xmit policy selection");
3907 /* Set the bonding mode for the relevant port. */
3908 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3909 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3914 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3919 bonding, "bonding");
3920 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3922 balance_xmit_policy, "balance_xmit_policy");
3923 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3924 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3926 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3928 policy, "l2#l23#l34");
3930 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3931 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3932 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3935 (void *)&cmd_setbonding_balance_xmit_policy_set,
3936 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3937 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3938 (void *)&cmd_setbonding_balance_xmit_policy_port,
3939 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3944 /* *** SHOW NIC BONDING CONFIGURATION *** */
3945 struct cmd_show_bonding_config_result {
3946 cmdline_fixed_string_t show;
3947 cmdline_fixed_string_t bonding;
3948 cmdline_fixed_string_t config;
3952 static void cmd_show_bonding_config_parsed(void *parsed_result,
3953 __attribute__((unused)) struct cmdline *cl,
3954 __attribute__((unused)) void *data)
3956 struct cmd_show_bonding_config_result *res = parsed_result;
3958 uint8_t slaves[RTE_MAX_ETHPORTS];
3959 int num_slaves, num_active_slaves;
3962 portid_t port_id = res->port_id;
3964 /* Display the bonding mode.*/
3965 bonding_mode = rte_eth_bond_mode_get(port_id);
3966 if (bonding_mode < 0) {
3967 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3970 printf("\tBonding mode: %d\n", bonding_mode);
3972 if (bonding_mode == BONDING_MODE_BALANCE) {
3973 int balance_xmit_policy;
3975 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3976 if (balance_xmit_policy < 0) {
3977 printf("\tFailed to get balance xmit policy for port = %d\n",
3981 printf("\tBalance Xmit Policy: ");
3983 switch (balance_xmit_policy) {
3984 case BALANCE_XMIT_POLICY_LAYER2:
3985 printf("BALANCE_XMIT_POLICY_LAYER2");
3987 case BALANCE_XMIT_POLICY_LAYER23:
3988 printf("BALANCE_XMIT_POLICY_LAYER23");
3990 case BALANCE_XMIT_POLICY_LAYER34:
3991 printf("BALANCE_XMIT_POLICY_LAYER34");
3998 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4000 if (num_slaves < 0) {
4001 printf("\tFailed to get slave list for port = %d\n", port_id);
4004 if (num_slaves > 0) {
4005 printf("\tSlaves (%d): [", num_slaves);
4006 for (i = 0; i < num_slaves - 1; i++)
4007 printf("%d ", slaves[i]);
4009 printf("%d]\n", slaves[num_slaves - 1]);
4011 printf("\tSlaves: []\n");
4015 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4018 if (num_active_slaves < 0) {
4019 printf("\tFailed to get active slave list for port = %d\n", port_id);
4022 if (num_active_slaves > 0) {
4023 printf("\tActive Slaves (%d): [", num_active_slaves);
4024 for (i = 0; i < num_active_slaves - 1; i++)
4025 printf("%d ", slaves[i]);
4027 printf("%d]\n", slaves[num_active_slaves - 1]);
4030 printf("\tActive Slaves: []\n");
4034 primary_id = rte_eth_bond_primary_get(port_id);
4035 if (primary_id < 0) {
4036 printf("\tFailed to get primary slave for port = %d\n", port_id);
4039 printf("\tPrimary: [%d]\n", primary_id);
4043 cmdline_parse_token_string_t cmd_showbonding_config_show =
4044 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4046 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4047 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4048 bonding, "bonding");
4049 cmdline_parse_token_string_t cmd_showbonding_config_config =
4050 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4052 cmdline_parse_token_num_t cmd_showbonding_config_port =
4053 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4056 cmdline_parse_inst_t cmd_show_bonding_config = {
4057 .f = cmd_show_bonding_config_parsed,
4058 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
4061 (void *)&cmd_showbonding_config_show,
4062 (void *)&cmd_showbonding_config_bonding,
4063 (void *)&cmd_showbonding_config_config,
4064 (void *)&cmd_showbonding_config_port,
4069 /* *** SET BONDING PRIMARY *** */
4070 struct cmd_set_bonding_primary_result {
4071 cmdline_fixed_string_t set;
4072 cmdline_fixed_string_t bonding;
4073 cmdline_fixed_string_t primary;
4078 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4079 __attribute__((unused)) struct cmdline *cl,
4080 __attribute__((unused)) void *data)
4082 struct cmd_set_bonding_primary_result *res = parsed_result;
4083 portid_t master_port_id = res->port_id;
4084 portid_t slave_port_id = res->slave_id;
4086 /* Set the primary slave for a bonded device. */
4087 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4088 printf("\t Failed to set primary slave for port = %d.\n",
4095 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4098 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4100 bonding, "bonding");
4101 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4102 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4103 primary, "primary");
4104 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4105 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4107 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4108 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4111 cmdline_parse_inst_t cmd_set_bonding_primary = {
4112 .f = cmd_set_bonding_primary_parsed,
4113 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
4116 (void *)&cmd_setbonding_primary_set,
4117 (void *)&cmd_setbonding_primary_bonding,
4118 (void *)&cmd_setbonding_primary_primary,
4119 (void *)&cmd_setbonding_primary_slave,
4120 (void *)&cmd_setbonding_primary_port,
4125 /* *** ADD SLAVE *** */
4126 struct cmd_add_bonding_slave_result {
4127 cmdline_fixed_string_t add;
4128 cmdline_fixed_string_t bonding;
4129 cmdline_fixed_string_t slave;
4134 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4135 __attribute__((unused)) struct cmdline *cl,
4136 __attribute__((unused)) void *data)
4138 struct cmd_add_bonding_slave_result *res = parsed_result;
4139 portid_t master_port_id = res->port_id;
4140 portid_t slave_port_id = res->slave_id;
4142 /* Set the primary slave for a bonded device. */
4143 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4144 printf("\t Failed to add slave %d to master port = %d.\n",
4145 slave_port_id, master_port_id);
4149 set_port_slave_flag(slave_port_id);
4152 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4153 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4155 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4156 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4157 bonding, "bonding");
4158 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4159 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4161 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4162 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4164 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4165 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4168 cmdline_parse_inst_t cmd_add_bonding_slave = {
4169 .f = cmd_add_bonding_slave_parsed,
4170 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
4173 (void *)&cmd_addbonding_slave_add,
4174 (void *)&cmd_addbonding_slave_bonding,
4175 (void *)&cmd_addbonding_slave_slave,
4176 (void *)&cmd_addbonding_slave_slaveid,
4177 (void *)&cmd_addbonding_slave_port,
4182 /* *** REMOVE SLAVE *** */
4183 struct cmd_remove_bonding_slave_result {
4184 cmdline_fixed_string_t remove;
4185 cmdline_fixed_string_t bonding;
4186 cmdline_fixed_string_t slave;
4191 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4192 __attribute__((unused)) struct cmdline *cl,
4193 __attribute__((unused)) void *data)
4195 struct cmd_remove_bonding_slave_result *res = parsed_result;
4196 portid_t master_port_id = res->port_id;
4197 portid_t slave_port_id = res->slave_id;
4199 /* Set the primary slave for a bonded device. */
4200 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4201 printf("\t Failed to remove slave %d from master port = %d.\n",
4202 slave_port_id, master_port_id);
4206 clear_port_slave_flag(slave_port_id);
4209 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4210 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4212 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4213 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4214 bonding, "bonding");
4215 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4216 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4218 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4219 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4221 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4222 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4225 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4226 .f = cmd_remove_bonding_slave_parsed,
4227 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
4230 (void *)&cmd_removebonding_slave_remove,
4231 (void *)&cmd_removebonding_slave_bonding,
4232 (void *)&cmd_removebonding_slave_slave,
4233 (void *)&cmd_removebonding_slave_slaveid,
4234 (void *)&cmd_removebonding_slave_port,
4239 /* *** CREATE BONDED DEVICE *** */
4240 struct cmd_create_bonded_device_result {
4241 cmdline_fixed_string_t create;
4242 cmdline_fixed_string_t bonded;
4243 cmdline_fixed_string_t device;
4248 static int bond_dev_num = 0;
4250 static void cmd_create_bonded_device_parsed(void *parsed_result,
4251 __attribute__((unused)) struct cmdline *cl,
4252 __attribute__((unused)) void *data)
4254 struct cmd_create_bonded_device_result *res = parsed_result;
4255 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4258 if (test_done == 0) {
4259 printf("Please stop forwarding first\n");
4263 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
4266 /* Create a new bonded device. */
4267 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4269 printf("\t Failed to create bonded device.\n");
4272 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4275 /* Update number of ports */
4276 nb_ports = rte_eth_dev_count();
4277 reconfig(port_id, res->socket);
4278 rte_eth_promiscuous_enable(port_id);
4279 ports[port_id].enabled = 1;
4284 cmdline_parse_token_string_t cmd_createbonded_device_create =
4285 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4287 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4288 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4290 cmdline_parse_token_string_t cmd_createbonded_device_device =
4291 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4293 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4294 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4296 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4297 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4300 cmdline_parse_inst_t cmd_create_bonded_device = {
4301 .f = cmd_create_bonded_device_parsed,
4302 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
4305 (void *)&cmd_createbonded_device_create,
4306 (void *)&cmd_createbonded_device_bonded,
4307 (void *)&cmd_createbonded_device_device,
4308 (void *)&cmd_createbonded_device_mode,
4309 (void *)&cmd_createbonded_device_socket,
4314 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4315 struct cmd_set_bond_mac_addr_result {
4316 cmdline_fixed_string_t set;
4317 cmdline_fixed_string_t bonding;
4318 cmdline_fixed_string_t mac_addr;
4320 struct ether_addr address;
4323 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4324 __attribute__((unused)) struct cmdline *cl,
4325 __attribute__((unused)) void *data)
4327 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4330 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4333 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4335 /* check the return value and print it if is < 0 */
4337 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4340 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4341 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4342 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4343 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4345 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4346 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4348 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4349 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4350 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4351 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4353 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4354 .f = cmd_set_bond_mac_addr_parsed,
4356 .help_str = "set bonding mac_addr (port_id) (address): ",
4358 (void *)&cmd_set_bond_mac_addr_set,
4359 (void *)&cmd_set_bond_mac_addr_bonding,
4360 (void *)&cmd_set_bond_mac_addr_mac,
4361 (void *)&cmd_set_bond_mac_addr_portnum,
4362 (void *)&cmd_set_bond_mac_addr_addr,
4368 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4369 struct cmd_set_bond_mon_period_result {
4370 cmdline_fixed_string_t set;
4371 cmdline_fixed_string_t bonding;
4372 cmdline_fixed_string_t mon_period;
4377 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4378 __attribute__((unused)) struct cmdline *cl,
4379 __attribute__((unused)) void *data)
4381 struct cmd_set_bond_mon_period_result *res = parsed_result;
4384 if (res->port_num >= nb_ports) {
4385 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4389 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4391 /* check the return value and print it if is < 0 */
4393 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4396 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4397 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4399 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4400 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4401 bonding, "bonding");
4402 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4403 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4404 mon_period, "mon_period");
4405 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4406 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4408 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4409 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4412 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4413 .f = cmd_set_bond_mon_period_parsed,
4415 .help_str = "set bonding mon_period (port_id) (period_ms): ",
4417 (void *)&cmd_set_bond_mon_period_set,
4418 (void *)&cmd_set_bond_mon_period_bonding,
4419 (void *)&cmd_set_bond_mon_period_mon_period,
4420 (void *)&cmd_set_bond_mon_period_portnum,
4421 (void *)&cmd_set_bond_mon_period_period_ms,
4426 #endif /* RTE_LIBRTE_PMD_BOND */
4428 /* *** SET FORWARDING MODE *** */
4429 struct cmd_set_fwd_mode_result {
4430 cmdline_fixed_string_t set;
4431 cmdline_fixed_string_t fwd;
4432 cmdline_fixed_string_t mode;
4435 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4436 __attribute__((unused)) struct cmdline *cl,
4437 __attribute__((unused)) void *data)
4439 struct cmd_set_fwd_mode_result *res = parsed_result;
4441 set_pkt_forwarding_mode(res->mode);
4444 cmdline_parse_token_string_t cmd_setfwd_set =
4445 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4446 cmdline_parse_token_string_t cmd_setfwd_fwd =
4447 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4448 cmdline_parse_token_string_t cmd_setfwd_mode =
4449 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4450 "" /* defined at init */);
4452 cmdline_parse_inst_t cmd_set_fwd_mode = {
4453 .f = cmd_set_fwd_mode_parsed,
4455 .help_str = NULL, /* defined at init */
4457 (void *)&cmd_setfwd_set,
4458 (void *)&cmd_setfwd_fwd,
4459 (void *)&cmd_setfwd_mode,
4464 static void cmd_set_fwd_mode_init(void)
4467 static char token[128];
4468 static char help[256];
4469 cmdline_parse_token_string_t *token_struct;
4471 modes = list_pkt_forwarding_modes();
4472 snprintf(help, sizeof help, "set fwd %s - "
4473 "set packet forwarding mode", modes);
4474 cmd_set_fwd_mode.help_str = help;
4476 /* string token separator is # */
4477 for (c = token; *modes != '\0'; modes++)
4482 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4483 token_struct->string_data.str = token;
4486 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4487 struct cmd_set_burst_tx_retry_result {
4488 cmdline_fixed_string_t set;
4489 cmdline_fixed_string_t burst;
4490 cmdline_fixed_string_t tx;
4491 cmdline_fixed_string_t delay;
4493 cmdline_fixed_string_t retry;
4497 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4498 __attribute__((unused)) struct cmdline *cl,
4499 __attribute__((unused)) void *data)
4501 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4503 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4504 && !strcmp(res->tx, "tx")) {
4505 if (!strcmp(res->delay, "delay"))
4506 burst_tx_delay_time = res->time;
4507 if (!strcmp(res->retry, "retry"))
4508 burst_tx_retry_num = res->retry_num;
4513 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4514 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4515 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4516 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4518 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4519 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4520 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4522 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4523 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4524 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4525 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4526 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4527 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4529 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4530 .f = cmd_set_burst_tx_retry_parsed,
4531 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4533 (void *)&cmd_set_burst_tx_retry_set,
4534 (void *)&cmd_set_burst_tx_retry_burst,
4535 (void *)&cmd_set_burst_tx_retry_tx,
4536 (void *)&cmd_set_burst_tx_retry_delay,
4537 (void *)&cmd_set_burst_tx_retry_time,
4538 (void *)&cmd_set_burst_tx_retry_retry,
4539 (void *)&cmd_set_burst_tx_retry_retry_num,
4544 /* *** SET PROMISC MODE *** */
4545 struct cmd_set_promisc_mode_result {
4546 cmdline_fixed_string_t set;
4547 cmdline_fixed_string_t promisc;
4548 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4549 uint8_t port_num; /* valid if "allports" argument == 0 */
4550 cmdline_fixed_string_t mode;
4553 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4554 __attribute__((unused)) struct cmdline *cl,
4557 struct cmd_set_promisc_mode_result *res = parsed_result;
4561 if (!strcmp(res->mode, "on"))
4568 FOREACH_PORT(i, ports) {
4570 rte_eth_promiscuous_enable(i);
4572 rte_eth_promiscuous_disable(i);
4577 rte_eth_promiscuous_enable(res->port_num);
4579 rte_eth_promiscuous_disable(res->port_num);
4583 cmdline_parse_token_string_t cmd_setpromisc_set =
4584 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4585 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4586 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4588 cmdline_parse_token_string_t cmd_setpromisc_portall =
4589 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4591 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4592 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4594 cmdline_parse_token_string_t cmd_setpromisc_mode =
4595 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4598 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4599 .f = cmd_set_promisc_mode_parsed,
4601 .help_str = "set promisc all on|off: set promisc mode for all ports",
4603 (void *)&cmd_setpromisc_set,
4604 (void *)&cmd_setpromisc_promisc,
4605 (void *)&cmd_setpromisc_portall,
4606 (void *)&cmd_setpromisc_mode,
4611 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4612 .f = cmd_set_promisc_mode_parsed,
4614 .help_str = "set promisc X on|off: set promisc mode on port X",
4616 (void *)&cmd_setpromisc_set,
4617 (void *)&cmd_setpromisc_promisc,
4618 (void *)&cmd_setpromisc_portnum,
4619 (void *)&cmd_setpromisc_mode,
4624 /* *** SET ALLMULTI MODE *** */
4625 struct cmd_set_allmulti_mode_result {
4626 cmdline_fixed_string_t set;
4627 cmdline_fixed_string_t allmulti;
4628 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4629 uint8_t port_num; /* valid if "allports" argument == 0 */
4630 cmdline_fixed_string_t mode;
4633 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4634 __attribute__((unused)) struct cmdline *cl,
4637 struct cmd_set_allmulti_mode_result *res = parsed_result;
4641 if (!strcmp(res->mode, "on"))
4648 FOREACH_PORT(i, ports) {
4650 rte_eth_allmulticast_enable(i);
4652 rte_eth_allmulticast_disable(i);
4657 rte_eth_allmulticast_enable(res->port_num);
4659 rte_eth_allmulticast_disable(res->port_num);
4663 cmdline_parse_token_string_t cmd_setallmulti_set =
4664 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4665 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4666 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4668 cmdline_parse_token_string_t cmd_setallmulti_portall =
4669 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4671 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4672 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4674 cmdline_parse_token_string_t cmd_setallmulti_mode =
4675 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4678 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4679 .f = cmd_set_allmulti_mode_parsed,
4681 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4683 (void *)&cmd_setallmulti_set,
4684 (void *)&cmd_setallmulti_allmulti,
4685 (void *)&cmd_setallmulti_portall,
4686 (void *)&cmd_setallmulti_mode,
4691 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4692 .f = cmd_set_allmulti_mode_parsed,
4694 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4696 (void *)&cmd_setallmulti_set,
4697 (void *)&cmd_setallmulti_allmulti,
4698 (void *)&cmd_setallmulti_portnum,
4699 (void *)&cmd_setallmulti_mode,
4704 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4705 struct cmd_link_flow_ctrl_set_result {
4706 cmdline_fixed_string_t set;
4707 cmdline_fixed_string_t flow_ctrl;
4708 cmdline_fixed_string_t rx;
4709 cmdline_fixed_string_t rx_lfc_mode;
4710 cmdline_fixed_string_t tx;
4711 cmdline_fixed_string_t tx_lfc_mode;
4712 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4713 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4714 cmdline_fixed_string_t autoneg_str;
4715 cmdline_fixed_string_t autoneg;
4716 cmdline_fixed_string_t hw_str;
4717 uint32_t high_water;
4718 cmdline_fixed_string_t lw_str;
4720 cmdline_fixed_string_t pt_str;
4721 uint16_t pause_time;
4722 cmdline_fixed_string_t xon_str;
4727 cmdline_parse_token_string_t cmd_lfc_set_set =
4728 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4730 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4731 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4732 flow_ctrl, "flow_ctrl");
4733 cmdline_parse_token_string_t cmd_lfc_set_rx =
4734 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4736 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4737 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4738 rx_lfc_mode, "on#off");
4739 cmdline_parse_token_string_t cmd_lfc_set_tx =
4740 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4742 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4743 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4744 tx_lfc_mode, "on#off");
4745 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4746 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4747 hw_str, "high_water");
4748 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4749 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4750 high_water, UINT32);
4751 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4752 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4753 lw_str, "low_water");
4754 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4755 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4757 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4758 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4759 pt_str, "pause_time");
4760 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4761 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4762 pause_time, UINT16);
4763 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4764 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4765 xon_str, "send_xon");
4766 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4767 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4769 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4770 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4771 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4772 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4773 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4774 mac_ctrl_frame_fwd_mode, "on#off");
4775 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4776 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4777 autoneg_str, "autoneg");
4778 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4779 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4781 cmdline_parse_token_num_t cmd_lfc_set_portid =
4782 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4785 /* forward declaration */
4787 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4790 cmdline_parse_inst_t cmd_link_flow_control_set = {
4791 .f = cmd_link_flow_ctrl_set_parsed,
4793 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4794 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4795 autoneg on|off port_id",
4797 (void *)&cmd_lfc_set_set,
4798 (void *)&cmd_lfc_set_flow_ctrl,
4799 (void *)&cmd_lfc_set_rx,
4800 (void *)&cmd_lfc_set_rx_mode,
4801 (void *)&cmd_lfc_set_tx,
4802 (void *)&cmd_lfc_set_tx_mode,
4803 (void *)&cmd_lfc_set_high_water,
4804 (void *)&cmd_lfc_set_low_water,
4805 (void *)&cmd_lfc_set_pause_time,
4806 (void *)&cmd_lfc_set_send_xon,
4807 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4808 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4809 (void *)&cmd_lfc_set_autoneg_str,
4810 (void *)&cmd_lfc_set_autoneg,
4811 (void *)&cmd_lfc_set_portid,
4816 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4817 .f = cmd_link_flow_ctrl_set_parsed,
4818 .data = (void *)&cmd_link_flow_control_set_rx,
4819 .help_str = "Change rx flow control parameter: set flow_ctrl "
4820 "rx on|off port_id",
4822 (void *)&cmd_lfc_set_set,
4823 (void *)&cmd_lfc_set_flow_ctrl,
4824 (void *)&cmd_lfc_set_rx,
4825 (void *)&cmd_lfc_set_rx_mode,
4826 (void *)&cmd_lfc_set_portid,
4831 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4832 .f = cmd_link_flow_ctrl_set_parsed,
4833 .data = (void *)&cmd_link_flow_control_set_tx,
4834 .help_str = "Change tx flow control parameter: set flow_ctrl "
4835 "tx on|off port_id",
4837 (void *)&cmd_lfc_set_set,
4838 (void *)&cmd_lfc_set_flow_ctrl,
4839 (void *)&cmd_lfc_set_tx,
4840 (void *)&cmd_lfc_set_tx_mode,
4841 (void *)&cmd_lfc_set_portid,
4846 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4847 .f = cmd_link_flow_ctrl_set_parsed,
4848 .data = (void *)&cmd_link_flow_control_set_hw,
4849 .help_str = "Change high water flow control parameter: set flow_ctrl "
4850 "high_water value port_id",
4852 (void *)&cmd_lfc_set_set,
4853 (void *)&cmd_lfc_set_flow_ctrl,
4854 (void *)&cmd_lfc_set_high_water_str,
4855 (void *)&cmd_lfc_set_high_water,
4856 (void *)&cmd_lfc_set_portid,
4861 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4862 .f = cmd_link_flow_ctrl_set_parsed,
4863 .data = (void *)&cmd_link_flow_control_set_lw,
4864 .help_str = "Change low water flow control parameter: set flow_ctrl "
4865 "low_water value port_id",
4867 (void *)&cmd_lfc_set_set,
4868 (void *)&cmd_lfc_set_flow_ctrl,
4869 (void *)&cmd_lfc_set_low_water_str,
4870 (void *)&cmd_lfc_set_low_water,
4871 (void *)&cmd_lfc_set_portid,
4876 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4877 .f = cmd_link_flow_ctrl_set_parsed,
4878 .data = (void *)&cmd_link_flow_control_set_pt,
4879 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4880 "pause_time value port_id",
4882 (void *)&cmd_lfc_set_set,
4883 (void *)&cmd_lfc_set_flow_ctrl,
4884 (void *)&cmd_lfc_set_pause_time_str,
4885 (void *)&cmd_lfc_set_pause_time,
4886 (void *)&cmd_lfc_set_portid,
4891 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4892 .f = cmd_link_flow_ctrl_set_parsed,
4893 .data = (void *)&cmd_link_flow_control_set_xon,
4894 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4895 "send_xon value port_id",
4897 (void *)&cmd_lfc_set_set,
4898 (void *)&cmd_lfc_set_flow_ctrl,
4899 (void *)&cmd_lfc_set_send_xon_str,
4900 (void *)&cmd_lfc_set_send_xon,
4901 (void *)&cmd_lfc_set_portid,
4906 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4907 .f = cmd_link_flow_ctrl_set_parsed,
4908 .data = (void *)&cmd_link_flow_control_set_macfwd,
4909 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4910 "mac_ctrl_frame_fwd on|off port_id",
4912 (void *)&cmd_lfc_set_set,
4913 (void *)&cmd_lfc_set_flow_ctrl,
4914 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4915 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4916 (void *)&cmd_lfc_set_portid,
4921 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4922 .f = cmd_link_flow_ctrl_set_parsed,
4923 .data = (void *)&cmd_link_flow_control_set_autoneg,
4924 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4925 "autoneg on|off port_id",
4927 (void *)&cmd_lfc_set_set,
4928 (void *)&cmd_lfc_set_flow_ctrl,
4929 (void *)&cmd_lfc_set_autoneg_str,
4930 (void *)&cmd_lfc_set_autoneg,
4931 (void *)&cmd_lfc_set_portid,
4937 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4938 __attribute__((unused)) struct cmdline *cl,
4941 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4942 cmdline_parse_inst_t *cmd = data;
4943 struct rte_eth_fc_conf fc_conf;
4949 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4950 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4951 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4952 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4954 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4955 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4958 /* Partial command line, retrieve current configuration */
4960 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4962 printf("cannot get current flow ctrl parameters, return"
4963 "code = %d\n", ret);
4967 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4968 (fc_conf.mode == RTE_FC_FULL))
4970 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4971 (fc_conf.mode == RTE_FC_FULL))
4975 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4976 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4978 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4979 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4981 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4983 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4984 fc_conf.high_water = res->high_water;
4986 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4987 fc_conf.low_water = res->low_water;
4989 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4990 fc_conf.pause_time = res->pause_time;
4992 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4993 fc_conf.send_xon = res->send_xon;
4995 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4996 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4997 fc_conf.mac_ctrl_frame_fwd = 1;
4999 fc_conf.mac_ctrl_frame_fwd = 0;
5002 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5003 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5005 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5007 printf("bad flow contrl parameter, return code = %d \n", ret);
5010 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
5011 struct cmd_priority_flow_ctrl_set_result {
5012 cmdline_fixed_string_t set;
5013 cmdline_fixed_string_t pfc_ctrl;
5014 cmdline_fixed_string_t rx;
5015 cmdline_fixed_string_t rx_pfc_mode;
5016 cmdline_fixed_string_t tx;
5017 cmdline_fixed_string_t tx_pfc_mode;
5018 uint32_t high_water;
5020 uint16_t pause_time;
5026 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5031 struct rte_eth_pfc_conf pfc_conf;
5032 int rx_fc_enable, tx_fc_enable;
5036 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5037 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5038 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5039 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5041 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5042 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5045 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5046 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5047 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5048 pfc_conf.fc.high_water = res->high_water;
5049 pfc_conf.fc.low_water = res->low_water;
5050 pfc_conf.fc.pause_time = res->pause_time;
5051 pfc_conf.priority = res->priority;
5053 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5055 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5058 cmdline_parse_token_string_t cmd_pfc_set_set =
5059 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5061 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5062 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5063 pfc_ctrl, "pfc_ctrl");
5064 cmdline_parse_token_string_t cmd_pfc_set_rx =
5065 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5067 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5068 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5069 rx_pfc_mode, "on#off");
5070 cmdline_parse_token_string_t cmd_pfc_set_tx =
5071 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5073 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5074 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5075 tx_pfc_mode, "on#off");
5076 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5077 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5078 high_water, UINT32);
5079 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5080 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5082 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5083 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5084 pause_time, UINT16);
5085 cmdline_parse_token_num_t cmd_pfc_set_priority =
5086 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5088 cmdline_parse_token_num_t cmd_pfc_set_portid =
5089 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5092 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5093 .f = cmd_priority_flow_ctrl_set_parsed,
5095 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5096 tx on|off high_water low_water pause_time priority port_id",
5098 (void *)&cmd_pfc_set_set,
5099 (void *)&cmd_pfc_set_flow_ctrl,
5100 (void *)&cmd_pfc_set_rx,
5101 (void *)&cmd_pfc_set_rx_mode,
5102 (void *)&cmd_pfc_set_tx,
5103 (void *)&cmd_pfc_set_tx_mode,
5104 (void *)&cmd_pfc_set_high_water,
5105 (void *)&cmd_pfc_set_low_water,
5106 (void *)&cmd_pfc_set_pause_time,
5107 (void *)&cmd_pfc_set_priority,
5108 (void *)&cmd_pfc_set_portid,
5113 /* *** RESET CONFIGURATION *** */
5114 struct cmd_reset_result {
5115 cmdline_fixed_string_t reset;
5116 cmdline_fixed_string_t def;
5119 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5121 __attribute__((unused)) void *data)
5123 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5124 set_def_fwd_config();
5127 cmdline_parse_token_string_t cmd_reset_set =
5128 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5129 cmdline_parse_token_string_t cmd_reset_def =
5130 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5133 cmdline_parse_inst_t cmd_reset = {
5134 .f = cmd_reset_parsed,
5136 .help_str = "set default: reset default forwarding configuration",
5138 (void *)&cmd_reset_set,
5139 (void *)&cmd_reset_def,
5144 /* *** START FORWARDING *** */
5145 struct cmd_start_result {
5146 cmdline_fixed_string_t start;
5149 cmdline_parse_token_string_t cmd_start_start =
5150 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5152 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5153 __attribute__((unused)) struct cmdline *cl,
5154 __attribute__((unused)) void *data)
5156 start_packet_forwarding(0);
5159 cmdline_parse_inst_t cmd_start = {
5160 .f = cmd_start_parsed,
5162 .help_str = "start packet forwarding",
5164 (void *)&cmd_start_start,
5169 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5170 struct cmd_start_tx_first_result {
5171 cmdline_fixed_string_t start;
5172 cmdline_fixed_string_t tx_first;
5176 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5177 __attribute__((unused)) struct cmdline *cl,
5178 __attribute__((unused)) void *data)
5180 start_packet_forwarding(1);
5183 cmdline_parse_token_string_t cmd_start_tx_first_start =
5184 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5186 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5187 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5188 tx_first, "tx_first");
5190 cmdline_parse_inst_t cmd_start_tx_first = {
5191 .f = cmd_start_tx_first_parsed,
5193 .help_str = "start packet forwarding, after sending 1 burst of packets",
5195 (void *)&cmd_start_tx_first_start,
5196 (void *)&cmd_start_tx_first_tx_first,
5201 /* *** SET LINK UP *** */
5202 struct cmd_set_link_up_result {
5203 cmdline_fixed_string_t set;
5204 cmdline_fixed_string_t link_up;
5205 cmdline_fixed_string_t port;
5209 cmdline_parse_token_string_t cmd_set_link_up_set =
5210 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5211 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5212 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5214 cmdline_parse_token_string_t cmd_set_link_up_port =
5215 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5216 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5217 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5219 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5220 __attribute__((unused)) struct cmdline *cl,
5221 __attribute__((unused)) void *data)
5223 struct cmd_set_link_up_result *res = parsed_result;
5224 dev_set_link_up(res->port_id);
5227 cmdline_parse_inst_t cmd_set_link_up = {
5228 .f = cmd_set_link_up_parsed,
5230 .help_str = "set link-up port (port id)",
5232 (void *)&cmd_set_link_up_set,
5233 (void *)&cmd_set_link_up_link_up,
5234 (void *)&cmd_set_link_up_port,
5235 (void *)&cmd_set_link_up_port_id,
5240 /* *** SET LINK DOWN *** */
5241 struct cmd_set_link_down_result {
5242 cmdline_fixed_string_t set;
5243 cmdline_fixed_string_t link_down;
5244 cmdline_fixed_string_t port;
5248 cmdline_parse_token_string_t cmd_set_link_down_set =
5249 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5250 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5251 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5253 cmdline_parse_token_string_t cmd_set_link_down_port =
5254 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5255 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5256 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5258 static void cmd_set_link_down_parsed(
5259 __attribute__((unused)) void *parsed_result,
5260 __attribute__((unused)) struct cmdline *cl,
5261 __attribute__((unused)) void *data)
5263 struct cmd_set_link_down_result *res = parsed_result;
5264 dev_set_link_down(res->port_id);
5267 cmdline_parse_inst_t cmd_set_link_down = {
5268 .f = cmd_set_link_down_parsed,
5270 .help_str = "set link-down port (port id)",
5272 (void *)&cmd_set_link_down_set,
5273 (void *)&cmd_set_link_down_link_down,
5274 (void *)&cmd_set_link_down_port,
5275 (void *)&cmd_set_link_down_port_id,
5280 /* *** SHOW CFG *** */
5281 struct cmd_showcfg_result {
5282 cmdline_fixed_string_t show;
5283 cmdline_fixed_string_t cfg;
5284 cmdline_fixed_string_t what;
5287 static void cmd_showcfg_parsed(void *parsed_result,
5288 __attribute__((unused)) struct cmdline *cl,
5289 __attribute__((unused)) void *data)
5291 struct cmd_showcfg_result *res = parsed_result;
5292 if (!strcmp(res->what, "rxtx"))
5293 rxtx_config_display();
5294 else if (!strcmp(res->what, "cores"))
5295 fwd_lcores_config_display();
5296 else if (!strcmp(res->what, "fwd"))
5297 fwd_config_display();
5298 else if (!strcmp(res->what, "txpkts"))
5299 show_tx_pkt_segments();
5302 cmdline_parse_token_string_t cmd_showcfg_show =
5303 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5304 cmdline_parse_token_string_t cmd_showcfg_port =
5305 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5306 cmdline_parse_token_string_t cmd_showcfg_what =
5307 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5308 "rxtx#cores#fwd#txpkts");
5310 cmdline_parse_inst_t cmd_showcfg = {
5311 .f = cmd_showcfg_parsed,
5313 .help_str = "show config rxtx|cores|fwd|txpkts",
5315 (void *)&cmd_showcfg_show,
5316 (void *)&cmd_showcfg_port,
5317 (void *)&cmd_showcfg_what,
5322 /* *** SHOW ALL PORT INFO *** */
5323 struct cmd_showportall_result {
5324 cmdline_fixed_string_t show;
5325 cmdline_fixed_string_t port;
5326 cmdline_fixed_string_t what;
5327 cmdline_fixed_string_t all;
5330 static void cmd_showportall_parsed(void *parsed_result,
5331 __attribute__((unused)) struct cmdline *cl,
5332 __attribute__((unused)) void *data)
5336 struct cmd_showportall_result *res = parsed_result;
5337 if (!strcmp(res->show, "clear")) {
5338 if (!strcmp(res->what, "stats"))
5339 FOREACH_PORT(i, ports)
5341 else if (!strcmp(res->what, "xstats"))
5342 FOREACH_PORT(i, ports)
5343 nic_xstats_clear(i);
5344 } else if (!strcmp(res->what, "info"))
5345 FOREACH_PORT(i, ports)
5346 port_infos_display(i);
5347 else if (!strcmp(res->what, "stats"))
5348 FOREACH_PORT(i, ports)
5349 nic_stats_display(i);
5350 else if (!strcmp(res->what, "xstats"))
5351 FOREACH_PORT(i, ports)
5352 nic_xstats_display(i);
5353 else if (!strcmp(res->what, "fdir"))
5354 FOREACH_PORT(i, ports)
5356 else if (!strcmp(res->what, "stat_qmap"))
5357 FOREACH_PORT(i, ports)
5358 nic_stats_mapping_display(i);
5359 else if (!strcmp(res->what, "dcb_tc"))
5360 FOREACH_PORT(i, ports)
5361 port_dcb_info_display(i);
5364 cmdline_parse_token_string_t cmd_showportall_show =
5365 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5367 cmdline_parse_token_string_t cmd_showportall_port =
5368 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5369 cmdline_parse_token_string_t cmd_showportall_what =
5370 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5371 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5372 cmdline_parse_token_string_t cmd_showportall_all =
5373 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5374 cmdline_parse_inst_t cmd_showportall = {
5375 .f = cmd_showportall_parsed,
5377 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc all",
5379 (void *)&cmd_showportall_show,
5380 (void *)&cmd_showportall_port,
5381 (void *)&cmd_showportall_what,
5382 (void *)&cmd_showportall_all,
5387 /* *** SHOW PORT INFO *** */
5388 struct cmd_showport_result {
5389 cmdline_fixed_string_t show;
5390 cmdline_fixed_string_t port;
5391 cmdline_fixed_string_t what;
5395 static void cmd_showport_parsed(void *parsed_result,
5396 __attribute__((unused)) struct cmdline *cl,
5397 __attribute__((unused)) void *data)
5399 struct cmd_showport_result *res = parsed_result;
5400 if (!strcmp(res->show, "clear")) {
5401 if (!strcmp(res->what, "stats"))
5402 nic_stats_clear(res->portnum);
5403 else if (!strcmp(res->what, "xstats"))
5404 nic_xstats_clear(res->portnum);
5405 } else if (!strcmp(res->what, "info"))
5406 port_infos_display(res->portnum);
5407 else if (!strcmp(res->what, "stats"))
5408 nic_stats_display(res->portnum);
5409 else if (!strcmp(res->what, "xstats"))
5410 nic_xstats_display(res->portnum);
5411 else if (!strcmp(res->what, "fdir"))
5412 fdir_get_infos(res->portnum);
5413 else if (!strcmp(res->what, "stat_qmap"))
5414 nic_stats_mapping_display(res->portnum);
5415 else if (!strcmp(res->what, "dcb_tc"))
5416 port_dcb_info_display(res->portnum);
5419 cmdline_parse_token_string_t cmd_showport_show =
5420 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5422 cmdline_parse_token_string_t cmd_showport_port =
5423 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5424 cmdline_parse_token_string_t cmd_showport_what =
5425 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5426 "info#stats#xstats#fdir#stat_qmap#dcb_tc");
5427 cmdline_parse_token_num_t cmd_showport_portnum =
5428 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5430 cmdline_parse_inst_t cmd_showport = {
5431 .f = cmd_showport_parsed,
5433 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X (X = port number)",
5435 (void *)&cmd_showport_show,
5436 (void *)&cmd_showport_port,
5437 (void *)&cmd_showport_what,
5438 (void *)&cmd_showport_portnum,
5443 /* *** SHOW QUEUE INFO *** */
5444 struct cmd_showqueue_result {
5445 cmdline_fixed_string_t show;
5446 cmdline_fixed_string_t type;
5447 cmdline_fixed_string_t what;
5453 cmd_showqueue_parsed(void *parsed_result,
5454 __attribute__((unused)) struct cmdline *cl,
5455 __attribute__((unused)) void *data)
5457 struct cmd_showqueue_result *res = parsed_result;
5459 if (!strcmp(res->type, "rxq"))
5460 rx_queue_infos_display(res->portnum, res->queuenum);
5461 else if (!strcmp(res->type, "txq"))
5462 tx_queue_infos_display(res->portnum, res->queuenum);
5465 cmdline_parse_token_string_t cmd_showqueue_show =
5466 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5467 cmdline_parse_token_string_t cmd_showqueue_type =
5468 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5469 cmdline_parse_token_string_t cmd_showqueue_what =
5470 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5471 cmdline_parse_token_num_t cmd_showqueue_portnum =
5472 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5473 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5474 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5476 cmdline_parse_inst_t cmd_showqueue = {
5477 .f = cmd_showqueue_parsed,
5479 .help_str = "show rxq|txq info <port number> <queue_number>",
5481 (void *)&cmd_showqueue_show,
5482 (void *)&cmd_showqueue_type,
5483 (void *)&cmd_showqueue_what,
5484 (void *)&cmd_showqueue_portnum,
5485 (void *)&cmd_showqueue_queuenum,
5490 /* *** READ PORT REGISTER *** */
5491 struct cmd_read_reg_result {
5492 cmdline_fixed_string_t read;
5493 cmdline_fixed_string_t reg;
5499 cmd_read_reg_parsed(void *parsed_result,
5500 __attribute__((unused)) struct cmdline *cl,
5501 __attribute__((unused)) void *data)
5503 struct cmd_read_reg_result *res = parsed_result;
5504 port_reg_display(res->port_id, res->reg_off);
5507 cmdline_parse_token_string_t cmd_read_reg_read =
5508 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5509 cmdline_parse_token_string_t cmd_read_reg_reg =
5510 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5511 cmdline_parse_token_num_t cmd_read_reg_port_id =
5512 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5513 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5514 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5516 cmdline_parse_inst_t cmd_read_reg = {
5517 .f = cmd_read_reg_parsed,
5519 .help_str = "read reg port_id reg_off",
5521 (void *)&cmd_read_reg_read,
5522 (void *)&cmd_read_reg_reg,
5523 (void *)&cmd_read_reg_port_id,
5524 (void *)&cmd_read_reg_reg_off,
5529 /* *** READ PORT REGISTER BIT FIELD *** */
5530 struct cmd_read_reg_bit_field_result {
5531 cmdline_fixed_string_t read;
5532 cmdline_fixed_string_t regfield;
5540 cmd_read_reg_bit_field_parsed(void *parsed_result,
5541 __attribute__((unused)) struct cmdline *cl,
5542 __attribute__((unused)) void *data)
5544 struct cmd_read_reg_bit_field_result *res = parsed_result;
5545 port_reg_bit_field_display(res->port_id, res->reg_off,
5546 res->bit1_pos, res->bit2_pos);
5549 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5550 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5552 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5553 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5554 regfield, "regfield");
5555 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5556 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5558 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5559 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5561 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5562 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5564 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5565 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5568 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5569 .f = cmd_read_reg_bit_field_parsed,
5571 .help_str = "read regfield port_id reg_off bit_x bit_y "
5572 "(read register bit field between bit_x and bit_y included)",
5574 (void *)&cmd_read_reg_bit_field_read,
5575 (void *)&cmd_read_reg_bit_field_regfield,
5576 (void *)&cmd_read_reg_bit_field_port_id,
5577 (void *)&cmd_read_reg_bit_field_reg_off,
5578 (void *)&cmd_read_reg_bit_field_bit1_pos,
5579 (void *)&cmd_read_reg_bit_field_bit2_pos,
5584 /* *** READ PORT REGISTER BIT *** */
5585 struct cmd_read_reg_bit_result {
5586 cmdline_fixed_string_t read;
5587 cmdline_fixed_string_t regbit;
5594 cmd_read_reg_bit_parsed(void *parsed_result,
5595 __attribute__((unused)) struct cmdline *cl,
5596 __attribute__((unused)) void *data)
5598 struct cmd_read_reg_bit_result *res = parsed_result;
5599 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5602 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5603 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5604 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5605 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5607 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5608 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5609 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5610 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5611 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5612 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5614 cmdline_parse_inst_t cmd_read_reg_bit = {
5615 .f = cmd_read_reg_bit_parsed,
5617 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5619 (void *)&cmd_read_reg_bit_read,
5620 (void *)&cmd_read_reg_bit_regbit,
5621 (void *)&cmd_read_reg_bit_port_id,
5622 (void *)&cmd_read_reg_bit_reg_off,
5623 (void *)&cmd_read_reg_bit_bit_pos,
5628 /* *** WRITE PORT REGISTER *** */
5629 struct cmd_write_reg_result {
5630 cmdline_fixed_string_t write;
5631 cmdline_fixed_string_t reg;
5638 cmd_write_reg_parsed(void *parsed_result,
5639 __attribute__((unused)) struct cmdline *cl,
5640 __attribute__((unused)) void *data)
5642 struct cmd_write_reg_result *res = parsed_result;
5643 port_reg_set(res->port_id, res->reg_off, res->value);
5646 cmdline_parse_token_string_t cmd_write_reg_write =
5647 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5648 cmdline_parse_token_string_t cmd_write_reg_reg =
5649 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5650 cmdline_parse_token_num_t cmd_write_reg_port_id =
5651 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5652 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5653 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5654 cmdline_parse_token_num_t cmd_write_reg_value =
5655 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5657 cmdline_parse_inst_t cmd_write_reg = {
5658 .f = cmd_write_reg_parsed,
5660 .help_str = "write reg port_id reg_off reg_value",
5662 (void *)&cmd_write_reg_write,
5663 (void *)&cmd_write_reg_reg,
5664 (void *)&cmd_write_reg_port_id,
5665 (void *)&cmd_write_reg_reg_off,
5666 (void *)&cmd_write_reg_value,
5671 /* *** WRITE PORT REGISTER BIT FIELD *** */
5672 struct cmd_write_reg_bit_field_result {
5673 cmdline_fixed_string_t write;
5674 cmdline_fixed_string_t regfield;
5683 cmd_write_reg_bit_field_parsed(void *parsed_result,
5684 __attribute__((unused)) struct cmdline *cl,
5685 __attribute__((unused)) void *data)
5687 struct cmd_write_reg_bit_field_result *res = parsed_result;
5688 port_reg_bit_field_set(res->port_id, res->reg_off,
5689 res->bit1_pos, res->bit2_pos, res->value);
5692 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5693 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5695 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5696 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5697 regfield, "regfield");
5698 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5699 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5701 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5702 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5704 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5705 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5707 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5708 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5710 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5711 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5714 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5715 .f = cmd_write_reg_bit_field_parsed,
5717 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5718 "(set register bit field between bit_x and bit_y included)",
5720 (void *)&cmd_write_reg_bit_field_write,
5721 (void *)&cmd_write_reg_bit_field_regfield,
5722 (void *)&cmd_write_reg_bit_field_port_id,
5723 (void *)&cmd_write_reg_bit_field_reg_off,
5724 (void *)&cmd_write_reg_bit_field_bit1_pos,
5725 (void *)&cmd_write_reg_bit_field_bit2_pos,
5726 (void *)&cmd_write_reg_bit_field_value,
5731 /* *** WRITE PORT REGISTER BIT *** */
5732 struct cmd_write_reg_bit_result {
5733 cmdline_fixed_string_t write;
5734 cmdline_fixed_string_t regbit;
5742 cmd_write_reg_bit_parsed(void *parsed_result,
5743 __attribute__((unused)) struct cmdline *cl,
5744 __attribute__((unused)) void *data)
5746 struct cmd_write_reg_bit_result *res = parsed_result;
5747 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5750 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5751 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5753 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5754 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5756 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5757 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5758 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5759 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5760 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5761 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5762 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5763 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5765 cmdline_parse_inst_t cmd_write_reg_bit = {
5766 .f = cmd_write_reg_bit_parsed,
5768 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5770 (void *)&cmd_write_reg_bit_write,
5771 (void *)&cmd_write_reg_bit_regbit,
5772 (void *)&cmd_write_reg_bit_port_id,
5773 (void *)&cmd_write_reg_bit_reg_off,
5774 (void *)&cmd_write_reg_bit_bit_pos,
5775 (void *)&cmd_write_reg_bit_value,
5780 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5781 struct cmd_read_rxd_txd_result {
5782 cmdline_fixed_string_t read;
5783 cmdline_fixed_string_t rxd_txd;
5790 cmd_read_rxd_txd_parsed(void *parsed_result,
5791 __attribute__((unused)) struct cmdline *cl,
5792 __attribute__((unused)) void *data)
5794 struct cmd_read_rxd_txd_result *res = parsed_result;
5796 if (!strcmp(res->rxd_txd, "rxd"))
5797 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5798 else if (!strcmp(res->rxd_txd, "txd"))
5799 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5802 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5803 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5804 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5805 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5807 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5808 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5809 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5810 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5811 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5812 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5814 cmdline_parse_inst_t cmd_read_rxd_txd = {
5815 .f = cmd_read_rxd_txd_parsed,
5817 .help_str = "read rxd|txd port_id queue_id rxd_id",
5819 (void *)&cmd_read_rxd_txd_read,
5820 (void *)&cmd_read_rxd_txd_rxd_txd,
5821 (void *)&cmd_read_rxd_txd_port_id,
5822 (void *)&cmd_read_rxd_txd_queue_id,
5823 (void *)&cmd_read_rxd_txd_desc_id,
5829 struct cmd_quit_result {
5830 cmdline_fixed_string_t quit;
5833 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5835 __attribute__((unused)) void *data)
5841 cmdline_parse_token_string_t cmd_quit_quit =
5842 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5844 cmdline_parse_inst_t cmd_quit = {
5845 .f = cmd_quit_parsed,
5847 .help_str = "exit application",
5849 (void *)&cmd_quit_quit,
5854 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5855 struct cmd_mac_addr_result {
5856 cmdline_fixed_string_t mac_addr_cmd;
5857 cmdline_fixed_string_t what;
5859 struct ether_addr address;
5862 static void cmd_mac_addr_parsed(void *parsed_result,
5863 __attribute__((unused)) struct cmdline *cl,
5864 __attribute__((unused)) void *data)
5866 struct cmd_mac_addr_result *res = parsed_result;
5869 if (strcmp(res->what, "add") == 0)
5870 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5872 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5874 /* check the return value and print it if is < 0 */
5876 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5880 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5881 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5883 cmdline_parse_token_string_t cmd_mac_addr_what =
5884 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5886 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5887 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5888 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5891 cmdline_parse_inst_t cmd_mac_addr = {
5892 .f = cmd_mac_addr_parsed,
5894 .help_str = "mac_addr add|remove X <address>: "
5895 "add/remove MAC address on port X",
5897 (void *)&cmd_mac_addr_cmd,
5898 (void *)&cmd_mac_addr_what,
5899 (void *)&cmd_mac_addr_portnum,
5900 (void *)&cmd_mac_addr_addr,
5906 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5907 struct cmd_set_qmap_result {
5908 cmdline_fixed_string_t set;
5909 cmdline_fixed_string_t qmap;
5910 cmdline_fixed_string_t what;
5917 cmd_set_qmap_parsed(void *parsed_result,
5918 __attribute__((unused)) struct cmdline *cl,
5919 __attribute__((unused)) void *data)
5921 struct cmd_set_qmap_result *res = parsed_result;
5922 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5924 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5927 cmdline_parse_token_string_t cmd_setqmap_set =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5930 cmdline_parse_token_string_t cmd_setqmap_qmap =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5933 cmdline_parse_token_string_t cmd_setqmap_what =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5936 cmdline_parse_token_num_t cmd_setqmap_portid =
5937 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5939 cmdline_parse_token_num_t cmd_setqmap_queueid =
5940 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5942 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5943 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5946 cmdline_parse_inst_t cmd_set_qmap = {
5947 .f = cmd_set_qmap_parsed,
5949 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5951 (void *)&cmd_setqmap_set,
5952 (void *)&cmd_setqmap_qmap,
5953 (void *)&cmd_setqmap_what,
5954 (void *)&cmd_setqmap_portid,
5955 (void *)&cmd_setqmap_queueid,
5956 (void *)&cmd_setqmap_mapvalue,
5961 /* *** CONFIGURE UNICAST HASH TABLE *** */
5962 struct cmd_set_uc_hash_table {
5963 cmdline_fixed_string_t set;
5964 cmdline_fixed_string_t port;
5966 cmdline_fixed_string_t what;
5967 struct ether_addr address;
5968 cmdline_fixed_string_t mode;
5972 cmd_set_uc_hash_parsed(void *parsed_result,
5973 __attribute__((unused)) struct cmdline *cl,
5974 __attribute__((unused)) void *data)
5977 struct cmd_set_uc_hash_table *res = parsed_result;
5979 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5981 if (strcmp(res->what, "uta") == 0)
5982 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5983 &res->address,(uint8_t)is_on);
5985 printf("bad unicast hash table parameter, return code = %d \n", ret);
5989 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5990 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5992 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5993 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5995 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5996 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5998 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5999 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6001 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6002 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6004 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6005 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6008 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6009 .f = cmd_set_uc_hash_parsed,
6011 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
6013 (void *)&cmd_set_uc_hash_set,
6014 (void *)&cmd_set_uc_hash_port,
6015 (void *)&cmd_set_uc_hash_portid,
6016 (void *)&cmd_set_uc_hash_what,
6017 (void *)&cmd_set_uc_hash_mac,
6018 (void *)&cmd_set_uc_hash_mode,
6023 struct cmd_set_uc_all_hash_table {
6024 cmdline_fixed_string_t set;
6025 cmdline_fixed_string_t port;
6027 cmdline_fixed_string_t what;
6028 cmdline_fixed_string_t value;
6029 cmdline_fixed_string_t mode;
6033 cmd_set_uc_all_hash_parsed(void *parsed_result,
6034 __attribute__((unused)) struct cmdline *cl,
6035 __attribute__((unused)) void *data)
6038 struct cmd_set_uc_all_hash_table *res = parsed_result;
6040 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6042 if ((strcmp(res->what, "uta") == 0) &&
6043 (strcmp(res->value, "all") == 0))
6044 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6046 printf("bad unicast hash table parameter,"
6047 "return code = %d \n", ret);
6050 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6051 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6053 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6056 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6057 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6059 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6060 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6062 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6065 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6066 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6069 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6070 .f = cmd_set_uc_all_hash_parsed,
6072 .help_str = "set port X uta all on|off (X = port number)",
6074 (void *)&cmd_set_uc_all_hash_set,
6075 (void *)&cmd_set_uc_all_hash_port,
6076 (void *)&cmd_set_uc_all_hash_portid,
6077 (void *)&cmd_set_uc_all_hash_what,
6078 (void *)&cmd_set_uc_all_hash_value,
6079 (void *)&cmd_set_uc_all_hash_mode,
6084 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6085 struct cmd_set_vf_macvlan_filter {
6086 cmdline_fixed_string_t set;
6087 cmdline_fixed_string_t port;
6089 cmdline_fixed_string_t vf;
6091 struct ether_addr address;
6092 cmdline_fixed_string_t filter_type;
6093 cmdline_fixed_string_t mode;
6097 cmd_set_vf_macvlan_parsed(void *parsed_result,
6098 __attribute__((unused)) struct cmdline *cl,
6099 __attribute__((unused)) void *data)
6102 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6103 struct rte_eth_mac_filter filter;
6105 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6107 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6109 /* set VF MAC filter */
6113 filter.dst_id = res->vf_id;
6115 if (!strcmp(res->filter_type, "exact-mac"))
6116 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6117 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6118 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6119 else if (!strcmp(res->filter_type, "hashmac"))
6120 filter.filter_type = RTE_MAC_HASH_MATCH;
6121 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6122 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6124 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6127 ret = rte_eth_dev_filter_ctrl(res->port_id,
6128 RTE_ETH_FILTER_MACVLAN,
6132 ret = rte_eth_dev_filter_ctrl(res->port_id,
6133 RTE_ETH_FILTER_MACVLAN,
6134 RTE_ETH_FILTER_DELETE,
6138 printf("bad set MAC hash parameter, return code = %d\n", ret);
6142 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6143 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6145 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6146 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6148 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6149 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6151 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6152 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6154 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6155 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6157 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6158 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6160 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6161 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6162 filter_type, "exact-mac#exact-mac-vlan"
6163 "#hashmac#hashmac-vlan");
6164 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6165 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6168 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6169 .f = cmd_set_vf_macvlan_parsed,
6171 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6172 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6174 "exact match rule:exact match of MAC or MAC and VLAN; "
6175 "hash match rule: hash match of MAC and exact match "
6178 (void *)&cmd_set_vf_macvlan_set,
6179 (void *)&cmd_set_vf_macvlan_port,
6180 (void *)&cmd_set_vf_macvlan_portid,
6181 (void *)&cmd_set_vf_macvlan_vf,
6182 (void *)&cmd_set_vf_macvlan_vf_id,
6183 (void *)&cmd_set_vf_macvlan_mac,
6184 (void *)&cmd_set_vf_macvlan_filter_type,
6185 (void *)&cmd_set_vf_macvlan_mode,
6190 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6191 struct cmd_set_vf_traffic {
6192 cmdline_fixed_string_t set;
6193 cmdline_fixed_string_t port;
6195 cmdline_fixed_string_t vf;
6197 cmdline_fixed_string_t what;
6198 cmdline_fixed_string_t mode;
6202 cmd_set_vf_traffic_parsed(void *parsed_result,
6203 __attribute__((unused)) struct cmdline *cl,
6204 __attribute__((unused)) void *data)
6206 struct cmd_set_vf_traffic *res = parsed_result;
6207 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6208 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6210 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6213 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6214 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6216 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6217 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6219 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6220 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6222 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6223 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6225 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6226 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6228 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6231 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6235 cmdline_parse_inst_t cmd_set_vf_traffic = {
6236 .f = cmd_set_vf_traffic_parsed,
6238 .help_str = "set port X vf Y rx|tx on|off"
6239 "(X = port number,Y = vf id)",
6241 (void *)&cmd_setvf_traffic_set,
6242 (void *)&cmd_setvf_traffic_port,
6243 (void *)&cmd_setvf_traffic_portid,
6244 (void *)&cmd_setvf_traffic_vf,
6245 (void *)&cmd_setvf_traffic_vfid,
6246 (void *)&cmd_setvf_traffic_what,
6247 (void *)&cmd_setvf_traffic_mode,
6252 /* *** CONFIGURE VF RECEIVE MODE *** */
6253 struct cmd_set_vf_rxmode {
6254 cmdline_fixed_string_t set;
6255 cmdline_fixed_string_t port;
6257 cmdline_fixed_string_t vf;
6259 cmdline_fixed_string_t what;
6260 cmdline_fixed_string_t mode;
6261 cmdline_fixed_string_t on;
6265 cmd_set_vf_rxmode_parsed(void *parsed_result,
6266 __attribute__((unused)) struct cmdline *cl,
6267 __attribute__((unused)) void *data)
6270 uint16_t rx_mode = 0;
6271 struct cmd_set_vf_rxmode *res = parsed_result;
6273 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6274 if (!strcmp(res->what,"rxmode")) {
6275 if (!strcmp(res->mode, "AUPE"))
6276 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6277 else if (!strcmp(res->mode, "ROPE"))
6278 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6279 else if (!strcmp(res->mode, "BAM"))
6280 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6281 else if (!strncmp(res->mode, "MPE",3))
6282 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6285 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6287 printf("bad VF receive mode parameter, return code = %d \n",
6291 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6292 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6294 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6295 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6297 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6298 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6300 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6301 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6303 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6304 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6306 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6307 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6309 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6311 mode, "AUPE#ROPE#BAM#MPE");
6312 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6316 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6317 .f = cmd_set_vf_rxmode_parsed,
6319 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6321 (void *)&cmd_set_vf_rxmode_set,
6322 (void *)&cmd_set_vf_rxmode_port,
6323 (void *)&cmd_set_vf_rxmode_portid,
6324 (void *)&cmd_set_vf_rxmode_vf,
6325 (void *)&cmd_set_vf_rxmode_vfid,
6326 (void *)&cmd_set_vf_rxmode_what,
6327 (void *)&cmd_set_vf_rxmode_mode,
6328 (void *)&cmd_set_vf_rxmode_on,
6333 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6334 struct cmd_vf_mac_addr_result {
6335 cmdline_fixed_string_t mac_addr_cmd;
6336 cmdline_fixed_string_t what;
6337 cmdline_fixed_string_t port;
6339 cmdline_fixed_string_t vf;
6341 struct ether_addr address;
6344 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6345 __attribute__((unused)) struct cmdline *cl,
6346 __attribute__((unused)) void *data)
6348 struct cmd_vf_mac_addr_result *res = parsed_result;
6351 if (strcmp(res->what, "add") == 0)
6352 ret = rte_eth_dev_mac_addr_add(res->port_num,
6353 &res->address, res->vf_num);
6355 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6359 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6360 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6361 mac_addr_cmd,"mac_addr");
6362 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6363 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6365 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6366 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6368 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6369 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6371 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6372 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6374 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6375 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6377 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6378 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6381 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6382 .f = cmd_vf_mac_addr_parsed,
6384 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6385 "Y = VF number)add MAC address filtering for a VF on port X",
6387 (void *)&cmd_vf_mac_addr_cmd,
6388 (void *)&cmd_vf_mac_addr_what,
6389 (void *)&cmd_vf_mac_addr_port,
6390 (void *)&cmd_vf_mac_addr_portnum,
6391 (void *)&cmd_vf_mac_addr_vf,
6392 (void *)&cmd_vf_mac_addr_vfnum,
6393 (void *)&cmd_vf_mac_addr_addr,
6398 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6399 struct cmd_vf_rx_vlan_filter {
6400 cmdline_fixed_string_t rx_vlan;
6401 cmdline_fixed_string_t what;
6403 cmdline_fixed_string_t port;
6405 cmdline_fixed_string_t vf;
6410 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6411 __attribute__((unused)) struct cmdline *cl,
6412 __attribute__((unused)) void *data)
6414 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6416 if (!strcmp(res->what, "add"))
6417 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6419 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6422 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6423 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6424 rx_vlan, "rx_vlan");
6425 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6426 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6428 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6429 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6431 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6432 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6434 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6435 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6437 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6438 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6440 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6441 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6444 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6445 .f = cmd_vf_rx_vlan_filter_parsed,
6447 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6448 "Y = port number,Z = hexadecimal VF mask)",
6450 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6451 (void *)&cmd_vf_rx_vlan_filter_what,
6452 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6453 (void *)&cmd_vf_rx_vlan_filter_port,
6454 (void *)&cmd_vf_rx_vlan_filter_portid,
6455 (void *)&cmd_vf_rx_vlan_filter_vf,
6456 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6461 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6462 struct cmd_queue_rate_limit_result {
6463 cmdline_fixed_string_t set;
6464 cmdline_fixed_string_t port;
6466 cmdline_fixed_string_t queue;
6468 cmdline_fixed_string_t rate;
6472 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6473 __attribute__((unused)) struct cmdline *cl,
6474 __attribute__((unused)) void *data)
6476 struct cmd_queue_rate_limit_result *res = parsed_result;
6479 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6480 && (strcmp(res->queue, "queue") == 0)
6481 && (strcmp(res->rate, "rate") == 0))
6482 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6485 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6489 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6490 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6492 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6493 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6495 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6496 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6498 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6499 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6501 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6502 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6504 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6505 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6507 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6508 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6511 cmdline_parse_inst_t cmd_queue_rate_limit = {
6512 .f = cmd_queue_rate_limit_parsed,
6514 .help_str = "set port X queue Y rate Z:(X = port number,"
6515 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6517 (void *)&cmd_queue_rate_limit_set,
6518 (void *)&cmd_queue_rate_limit_port,
6519 (void *)&cmd_queue_rate_limit_portnum,
6520 (void *)&cmd_queue_rate_limit_queue,
6521 (void *)&cmd_queue_rate_limit_queuenum,
6522 (void *)&cmd_queue_rate_limit_rate,
6523 (void *)&cmd_queue_rate_limit_ratenum,
6528 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6529 struct cmd_vf_rate_limit_result {
6530 cmdline_fixed_string_t set;
6531 cmdline_fixed_string_t port;
6533 cmdline_fixed_string_t vf;
6535 cmdline_fixed_string_t rate;
6537 cmdline_fixed_string_t q_msk;
6541 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6542 __attribute__((unused)) struct cmdline *cl,
6543 __attribute__((unused)) void *data)
6545 struct cmd_vf_rate_limit_result *res = parsed_result;
6548 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6549 && (strcmp(res->vf, "vf") == 0)
6550 && (strcmp(res->rate, "rate") == 0)
6551 && (strcmp(res->q_msk, "queue_mask") == 0))
6552 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6553 res->rate_num, res->q_msk_val);
6555 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6559 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6560 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6562 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6563 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6565 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6566 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6568 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6569 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6571 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6572 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6574 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6575 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6577 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6578 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6580 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6581 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6582 q_msk, "queue_mask");
6583 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6584 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6587 cmdline_parse_inst_t cmd_vf_rate_limit = {
6588 .f = cmd_vf_rate_limit_parsed,
6590 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6591 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6592 "for queues of VF on port X",
6594 (void *)&cmd_vf_rate_limit_set,
6595 (void *)&cmd_vf_rate_limit_port,
6596 (void *)&cmd_vf_rate_limit_portnum,
6597 (void *)&cmd_vf_rate_limit_vf,
6598 (void *)&cmd_vf_rate_limit_vfnum,
6599 (void *)&cmd_vf_rate_limit_rate,
6600 (void *)&cmd_vf_rate_limit_ratenum,
6601 (void *)&cmd_vf_rate_limit_q_msk,
6602 (void *)&cmd_vf_rate_limit_q_msk_val,
6607 /* *** ADD TUNNEL FILTER OF A PORT *** */
6608 struct cmd_tunnel_filter_result {
6609 cmdline_fixed_string_t cmd;
6610 cmdline_fixed_string_t what;
6612 struct ether_addr outer_mac;
6613 struct ether_addr inner_mac;
6614 cmdline_ipaddr_t ip_value;
6615 uint16_t inner_vlan;
6616 cmdline_fixed_string_t tunnel_type;
6617 cmdline_fixed_string_t filter_type;
6623 cmd_tunnel_filter_parsed(void *parsed_result,
6624 __attribute__((unused)) struct cmdline *cl,
6625 __attribute__((unused)) void *data)
6627 struct cmd_tunnel_filter_result *res = parsed_result;
6628 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6631 tunnel_filter_conf.outer_mac = &res->outer_mac;
6632 tunnel_filter_conf.inner_mac = &res->inner_mac;
6633 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6635 if (res->ip_value.family == AF_INET) {
6636 tunnel_filter_conf.ip_addr.ipv4_addr =
6637 res->ip_value.addr.ipv4.s_addr;
6638 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6640 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6641 &(res->ip_value.addr.ipv6),
6642 sizeof(struct in6_addr));
6643 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6646 if (!strcmp(res->filter_type, "imac-ivlan"))
6647 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6648 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6649 tunnel_filter_conf.filter_type =
6650 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6651 else if (!strcmp(res->filter_type, "imac-tenid"))
6652 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6653 else if (!strcmp(res->filter_type, "imac"))
6654 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6655 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6656 tunnel_filter_conf.filter_type =
6657 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6659 printf("The filter type is not supported");
6663 if (!strcmp(res->tunnel_type, "vxlan"))
6664 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6665 else if (!strcmp(res->tunnel_type, "nvgre"))
6666 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
6668 printf("The tunnel type %s not supported.\n", res->tunnel_type);
6672 tunnel_filter_conf.tenant_id = res->tenant_id;
6673 tunnel_filter_conf.queue_id = res->queue_num;
6674 if (!strcmp(res->what, "add"))
6675 ret = rte_eth_dev_filter_ctrl(res->port_id,
6676 RTE_ETH_FILTER_TUNNEL,
6678 &tunnel_filter_conf);
6680 ret = rte_eth_dev_filter_ctrl(res->port_id,
6681 RTE_ETH_FILTER_TUNNEL,
6682 RTE_ETH_FILTER_DELETE,
6683 &tunnel_filter_conf);
6685 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6689 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6690 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6691 cmd, "tunnel_filter");
6692 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6693 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6695 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6696 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6698 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6699 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6701 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6702 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6704 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6705 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6706 inner_vlan, UINT16);
6707 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6708 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6710 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6711 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6712 tunnel_type, "vxlan#nvgre");
6714 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6715 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6716 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6717 "imac#omac-imac-tenid");
6718 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6719 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6721 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6722 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6725 cmdline_parse_inst_t cmd_tunnel_filter = {
6726 .f = cmd_tunnel_filter_parsed,
6728 .help_str = "add/rm tunnel filter of a port: "
6729 "tunnel_filter add port_id outer_mac inner_mac ip "
6730 "inner_vlan tunnel_type(vxlan|nvgre) filter_type "
6731 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6732 "imac|omac-imac-tenid) "
6733 "tenant_id queue_num",
6735 (void *)&cmd_tunnel_filter_cmd,
6736 (void *)&cmd_tunnel_filter_what,
6737 (void *)&cmd_tunnel_filter_port_id,
6738 (void *)&cmd_tunnel_filter_outer_mac,
6739 (void *)&cmd_tunnel_filter_inner_mac,
6740 (void *)&cmd_tunnel_filter_ip_value,
6741 (void *)&cmd_tunnel_filter_innner_vlan,
6742 (void *)&cmd_tunnel_filter_tunnel_type,
6743 (void *)&cmd_tunnel_filter_filter_type,
6744 (void *)&cmd_tunnel_filter_tenant_id,
6745 (void *)&cmd_tunnel_filter_queue_num,
6750 /* *** CONFIGURE TUNNEL UDP PORT *** */
6751 struct cmd_tunnel_udp_config {
6752 cmdline_fixed_string_t cmd;
6753 cmdline_fixed_string_t what;
6759 cmd_tunnel_udp_config_parsed(void *parsed_result,
6760 __attribute__((unused)) struct cmdline *cl,
6761 __attribute__((unused)) void *data)
6763 struct cmd_tunnel_udp_config *res = parsed_result;
6764 struct rte_eth_udp_tunnel tunnel_udp;
6767 tunnel_udp.udp_port = res->udp_port;
6769 if (!strcmp(res->cmd, "rx_vxlan_port"))
6770 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6772 if (!strcmp(res->what, "add"))
6773 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6775 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6778 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6781 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6782 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6783 cmd, "rx_vxlan_port");
6784 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6785 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6787 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6788 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6790 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6791 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6794 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6795 .f = cmd_tunnel_udp_config_parsed,
6797 .help_str = "add/rm an tunneling UDP port filter: "
6798 "rx_vxlan_port add udp_port port_id",
6800 (void *)&cmd_tunnel_udp_config_cmd,
6801 (void *)&cmd_tunnel_udp_config_what,
6802 (void *)&cmd_tunnel_udp_config_udp_port,
6803 (void *)&cmd_tunnel_udp_config_port_id,
6808 /* *** GLOBAL CONFIG *** */
6809 struct cmd_global_config_result {
6810 cmdline_fixed_string_t cmd;
6812 cmdline_fixed_string_t cfg_type;
6817 cmd_global_config_parsed(void *parsed_result,
6818 __attribute__((unused)) struct cmdline *cl,
6819 __attribute__((unused)) void *data)
6821 struct cmd_global_config_result *res = parsed_result;
6822 struct rte_eth_global_cfg conf;
6825 memset(&conf, 0, sizeof(conf));
6826 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
6827 conf.cfg.gre_key_len = res->len;
6828 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
6829 RTE_ETH_FILTER_SET, &conf);
6831 printf("Global config error\n");
6834 cmdline_parse_token_string_t cmd_global_config_cmd =
6835 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
6837 cmdline_parse_token_num_t cmd_global_config_port_id =
6838 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
6839 cmdline_parse_token_string_t cmd_global_config_type =
6840 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
6841 cfg_type, "gre-key-len");
6842 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
6843 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
6846 cmdline_parse_inst_t cmd_global_config = {
6847 .f = cmd_global_config_parsed,
6848 .data = (void *)NULL,
6849 .help_str = "global_config <port_id> gre-key-len <number>",
6851 (void *)&cmd_global_config_cmd,
6852 (void *)&cmd_global_config_port_id,
6853 (void *)&cmd_global_config_type,
6854 (void *)&cmd_global_config_gre_key_len,
6859 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6860 struct cmd_set_mirror_mask_result {
6861 cmdline_fixed_string_t set;
6862 cmdline_fixed_string_t port;
6864 cmdline_fixed_string_t mirror;
6866 cmdline_fixed_string_t what;
6867 cmdline_fixed_string_t value;
6868 cmdline_fixed_string_t dstpool;
6870 cmdline_fixed_string_t on;
6873 cmdline_parse_token_string_t cmd_mirror_mask_set =
6874 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6876 cmdline_parse_token_string_t cmd_mirror_mask_port =
6877 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6879 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6880 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6882 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6883 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6884 mirror, "mirror-rule");
6885 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6886 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6888 cmdline_parse_token_string_t cmd_mirror_mask_what =
6889 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6890 what, "pool-mirror-up#pool-mirror-down"
6892 cmdline_parse_token_string_t cmd_mirror_mask_value =
6893 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6895 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6896 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6897 dstpool, "dst-pool");
6898 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6899 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6901 cmdline_parse_token_string_t cmd_mirror_mask_on =
6902 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6906 cmd_set_mirror_mask_parsed(void *parsed_result,
6907 __attribute__((unused)) struct cmdline *cl,
6908 __attribute__((unused)) void *data)
6911 struct cmd_set_mirror_mask_result *res = parsed_result;
6912 struct rte_eth_mirror_conf mr_conf;
6914 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
6916 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
6918 mr_conf.dst_pool = res->dstpool_id;
6920 if (!strcmp(res->what, "pool-mirror-up")) {
6921 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6922 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
6923 } else if (!strcmp(res->what, "pool-mirror-down")) {
6924 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
6925 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
6926 } else if (!strcmp(res->what, "vlan-mirror")) {
6927 mr_conf.rule_type = ETH_MIRROR_VLAN;
6928 nb_item = parse_item_list(res->value, "vlan",
6929 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
6933 for (i = 0; i < nb_item; i++) {
6934 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6935 printf("Invalid vlan_id: must be < 4096\n");
6939 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6940 mr_conf.vlan.vlan_mask |= 1ULL << i;
6944 if (!strcmp(res->on, "on"))
6945 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6948 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
6951 printf("mirror rule add error: (%s)\n", strerror(-ret));
6954 cmdline_parse_inst_t cmd_set_mirror_mask = {
6955 .f = cmd_set_mirror_mask_parsed,
6957 .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
6958 " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6960 (void *)&cmd_mirror_mask_set,
6961 (void *)&cmd_mirror_mask_port,
6962 (void *)&cmd_mirror_mask_portid,
6963 (void *)&cmd_mirror_mask_mirror,
6964 (void *)&cmd_mirror_mask_ruleid,
6965 (void *)&cmd_mirror_mask_what,
6966 (void *)&cmd_mirror_mask_value,
6967 (void *)&cmd_mirror_mask_dstpool,
6968 (void *)&cmd_mirror_mask_poolid,
6969 (void *)&cmd_mirror_mask_on,
6974 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6975 struct cmd_set_mirror_link_result {
6976 cmdline_fixed_string_t set;
6977 cmdline_fixed_string_t port;
6979 cmdline_fixed_string_t mirror;
6981 cmdline_fixed_string_t what;
6982 cmdline_fixed_string_t dstpool;
6984 cmdline_fixed_string_t on;
6987 cmdline_parse_token_string_t cmd_mirror_link_set =
6988 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6990 cmdline_parse_token_string_t cmd_mirror_link_port =
6991 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6993 cmdline_parse_token_num_t cmd_mirror_link_portid =
6994 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6996 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6997 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6998 mirror, "mirror-rule");
6999 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7000 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7002 cmdline_parse_token_string_t cmd_mirror_link_what =
7003 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7004 what, "uplink-mirror#downlink-mirror");
7005 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7006 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7007 dstpool, "dst-pool");
7008 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7009 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7011 cmdline_parse_token_string_t cmd_mirror_link_on =
7012 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7016 cmd_set_mirror_link_parsed(void *parsed_result,
7017 __attribute__((unused)) struct cmdline *cl,
7018 __attribute__((unused)) void *data)
7021 struct cmd_set_mirror_link_result *res = parsed_result;
7022 struct rte_eth_mirror_conf mr_conf;
7024 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7025 if (!strcmp(res->what, "uplink-mirror"))
7026 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7028 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7030 mr_conf.dst_pool = res->dstpool_id;
7032 if (!strcmp(res->on, "on"))
7033 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7036 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7039 /* check the return value and print it if is < 0 */
7041 printf("mirror rule add error: (%s)\n", strerror(-ret));
7045 cmdline_parse_inst_t cmd_set_mirror_link = {
7046 .f = cmd_set_mirror_link_parsed,
7048 .help_str = "set port X mirror-rule Y uplink-mirror|"
7049 "downlink-mirror dst-pool Z on|off",
7051 (void *)&cmd_mirror_link_set,
7052 (void *)&cmd_mirror_link_port,
7053 (void *)&cmd_mirror_link_portid,
7054 (void *)&cmd_mirror_link_mirror,
7055 (void *)&cmd_mirror_link_ruleid,
7056 (void *)&cmd_mirror_link_what,
7057 (void *)&cmd_mirror_link_dstpool,
7058 (void *)&cmd_mirror_link_poolid,
7059 (void *)&cmd_mirror_link_on,
7064 /* *** RESET VM MIRROR RULE *** */
7065 struct cmd_rm_mirror_rule_result {
7066 cmdline_fixed_string_t reset;
7067 cmdline_fixed_string_t port;
7069 cmdline_fixed_string_t mirror;
7073 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7074 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7076 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7077 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7079 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7080 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7082 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7083 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7084 mirror, "mirror-rule");
7085 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7086 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7090 cmd_reset_mirror_rule_parsed(void *parsed_result,
7091 __attribute__((unused)) struct cmdline *cl,
7092 __attribute__((unused)) void *data)
7095 struct cmd_set_mirror_link_result *res = parsed_result;
7097 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7099 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7102 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7103 .f = cmd_reset_mirror_rule_parsed,
7105 .help_str = "reset port X mirror-rule Y",
7107 (void *)&cmd_rm_mirror_rule_reset,
7108 (void *)&cmd_rm_mirror_rule_port,
7109 (void *)&cmd_rm_mirror_rule_portid,
7110 (void *)&cmd_rm_mirror_rule_mirror,
7111 (void *)&cmd_rm_mirror_rule_ruleid,
7116 /* ******************************************************************************** */
7118 struct cmd_dump_result {
7119 cmdline_fixed_string_t dump;
7123 dump_struct_sizes(void)
7125 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7126 DUMP_SIZE(struct rte_mbuf);
7127 DUMP_SIZE(struct rte_mempool);
7128 DUMP_SIZE(struct rte_ring);
7132 static void cmd_dump_parsed(void *parsed_result,
7133 __attribute__((unused)) struct cmdline *cl,
7134 __attribute__((unused)) void *data)
7136 struct cmd_dump_result *res = parsed_result;
7138 if (!strcmp(res->dump, "dump_physmem"))
7139 rte_dump_physmem_layout(stdout);
7140 else if (!strcmp(res->dump, "dump_memzone"))
7141 rte_memzone_dump(stdout);
7142 else if (!strcmp(res->dump, "dump_log_history"))
7143 rte_log_dump_history(stdout);
7144 else if (!strcmp(res->dump, "dump_struct_sizes"))
7145 dump_struct_sizes();
7146 else if (!strcmp(res->dump, "dump_ring"))
7147 rte_ring_list_dump(stdout);
7148 else if (!strcmp(res->dump, "dump_mempool"))
7149 rte_mempool_list_dump(stdout);
7150 else if (!strcmp(res->dump, "dump_devargs"))
7151 rte_eal_devargs_dump(stdout);
7154 cmdline_parse_token_string_t cmd_dump_dump =
7155 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7159 "dump_struct_sizes#"
7164 cmdline_parse_inst_t cmd_dump = {
7165 .f = cmd_dump_parsed, /* function to call */
7166 .data = NULL, /* 2nd arg of func */
7167 .help_str = "dump status",
7168 .tokens = { /* token list, NULL terminated */
7169 (void *)&cmd_dump_dump,
7174 /* ******************************************************************************** */
7176 struct cmd_dump_one_result {
7177 cmdline_fixed_string_t dump;
7178 cmdline_fixed_string_t name;
7181 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7182 __attribute__((unused)) void *data)
7184 struct cmd_dump_one_result *res = parsed_result;
7186 if (!strcmp(res->dump, "dump_ring")) {
7188 r = rte_ring_lookup(res->name);
7190 cmdline_printf(cl, "Cannot find ring\n");
7193 rte_ring_dump(stdout, r);
7194 } else if (!strcmp(res->dump, "dump_mempool")) {
7195 struct rte_mempool *mp;
7196 mp = rte_mempool_lookup(res->name);
7198 cmdline_printf(cl, "Cannot find mempool\n");
7201 rte_mempool_dump(stdout, mp);
7205 cmdline_parse_token_string_t cmd_dump_one_dump =
7206 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7207 "dump_ring#dump_mempool");
7209 cmdline_parse_token_string_t cmd_dump_one_name =
7210 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7212 cmdline_parse_inst_t cmd_dump_one = {
7213 .f = cmd_dump_one_parsed, /* function to call */
7214 .data = NULL, /* 2nd arg of func */
7215 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7216 .tokens = { /* token list, NULL terminated */
7217 (void *)&cmd_dump_one_dump,
7218 (void *)&cmd_dump_one_name,
7223 /* *** Add/Del syn filter *** */
7224 struct cmd_syn_filter_result {
7225 cmdline_fixed_string_t filter;
7227 cmdline_fixed_string_t ops;
7228 cmdline_fixed_string_t priority;
7229 cmdline_fixed_string_t high;
7230 cmdline_fixed_string_t queue;
7235 cmd_syn_filter_parsed(void *parsed_result,
7236 __attribute__((unused)) struct cmdline *cl,
7237 __attribute__((unused)) void *data)
7239 struct cmd_syn_filter_result *res = parsed_result;
7240 struct rte_eth_syn_filter syn_filter;
7243 ret = rte_eth_dev_filter_supported(res->port_id,
7244 RTE_ETH_FILTER_SYN);
7246 printf("syn filter is not supported on port %u.\n",
7251 memset(&syn_filter, 0, sizeof(syn_filter));
7253 if (!strcmp(res->ops, "add")) {
7254 if (!strcmp(res->high, "high"))
7255 syn_filter.hig_pri = 1;
7257 syn_filter.hig_pri = 0;
7259 syn_filter.queue = res->queue_id;
7260 ret = rte_eth_dev_filter_ctrl(res->port_id,
7265 ret = rte_eth_dev_filter_ctrl(res->port_id,
7267 RTE_ETH_FILTER_DELETE,
7271 printf("syn filter programming error: (%s)\n",
7275 cmdline_parse_token_string_t cmd_syn_filter_filter =
7276 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7277 filter, "syn_filter");
7278 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7279 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7281 cmdline_parse_token_string_t cmd_syn_filter_ops =
7282 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7284 cmdline_parse_token_string_t cmd_syn_filter_priority =
7285 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7286 priority, "priority");
7287 cmdline_parse_token_string_t cmd_syn_filter_high =
7288 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7290 cmdline_parse_token_string_t cmd_syn_filter_queue =
7291 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7293 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7294 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7297 cmdline_parse_inst_t cmd_syn_filter = {
7298 .f = cmd_syn_filter_parsed,
7300 .help_str = "add/delete syn filter",
7302 (void *)&cmd_syn_filter_filter,
7303 (void *)&cmd_syn_filter_port_id,
7304 (void *)&cmd_syn_filter_ops,
7305 (void *)&cmd_syn_filter_priority,
7306 (void *)&cmd_syn_filter_high,
7307 (void *)&cmd_syn_filter_queue,
7308 (void *)&cmd_syn_filter_queue_id,
7313 /* *** ADD/REMOVE A 2tuple FILTER *** */
7314 struct cmd_2tuple_filter_result {
7315 cmdline_fixed_string_t filter;
7317 cmdline_fixed_string_t ops;
7318 cmdline_fixed_string_t dst_port;
7319 uint16_t dst_port_value;
7320 cmdline_fixed_string_t protocol;
7321 uint8_t protocol_value;
7322 cmdline_fixed_string_t mask;
7324 cmdline_fixed_string_t tcp_flags;
7325 uint8_t tcp_flags_value;
7326 cmdline_fixed_string_t priority;
7327 uint8_t priority_value;
7328 cmdline_fixed_string_t queue;
7333 cmd_2tuple_filter_parsed(void *parsed_result,
7334 __attribute__((unused)) struct cmdline *cl,
7335 __attribute__((unused)) void *data)
7337 struct rte_eth_ntuple_filter filter;
7338 struct cmd_2tuple_filter_result *res = parsed_result;
7341 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7343 printf("ntuple filter is not supported on port %u.\n",
7348 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7350 filter.flags = RTE_2TUPLE_FLAGS;
7351 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7352 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7353 filter.proto = res->protocol_value;
7354 filter.priority = res->priority_value;
7355 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7356 printf("nonzero tcp_flags is only meaningful"
7357 " when protocol is TCP.\n");
7360 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7361 printf("invalid TCP flags.\n");
7365 if (res->tcp_flags_value != 0) {
7366 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7367 filter.tcp_flags = res->tcp_flags_value;
7370 /* need convert to big endian. */
7371 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7372 filter.queue = res->queue_id;
7374 if (!strcmp(res->ops, "add"))
7375 ret = rte_eth_dev_filter_ctrl(res->port_id,
7376 RTE_ETH_FILTER_NTUPLE,
7380 ret = rte_eth_dev_filter_ctrl(res->port_id,
7381 RTE_ETH_FILTER_NTUPLE,
7382 RTE_ETH_FILTER_DELETE,
7385 printf("2tuple filter programming error: (%s)\n",
7390 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7391 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7392 filter, "2tuple_filter");
7393 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7394 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7396 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7397 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7399 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7400 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7401 dst_port, "dst_port");
7402 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7403 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7404 dst_port_value, UINT16);
7405 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7406 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7407 protocol, "protocol");
7408 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7409 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7410 protocol_value, UINT8);
7411 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7412 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7414 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7415 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7417 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7418 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7419 tcp_flags, "tcp_flags");
7420 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7421 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7422 tcp_flags_value, UINT8);
7423 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7424 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7425 priority, "priority");
7426 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7427 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7428 priority_value, UINT8);
7429 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7430 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7432 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7433 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7436 cmdline_parse_inst_t cmd_2tuple_filter = {
7437 .f = cmd_2tuple_filter_parsed,
7439 .help_str = "add a 2tuple filter",
7441 (void *)&cmd_2tuple_filter_filter,
7442 (void *)&cmd_2tuple_filter_port_id,
7443 (void *)&cmd_2tuple_filter_ops,
7444 (void *)&cmd_2tuple_filter_dst_port,
7445 (void *)&cmd_2tuple_filter_dst_port_value,
7446 (void *)&cmd_2tuple_filter_protocol,
7447 (void *)&cmd_2tuple_filter_protocol_value,
7448 (void *)&cmd_2tuple_filter_mask,
7449 (void *)&cmd_2tuple_filter_mask_value,
7450 (void *)&cmd_2tuple_filter_tcp_flags,
7451 (void *)&cmd_2tuple_filter_tcp_flags_value,
7452 (void *)&cmd_2tuple_filter_priority,
7453 (void *)&cmd_2tuple_filter_priority_value,
7454 (void *)&cmd_2tuple_filter_queue,
7455 (void *)&cmd_2tuple_filter_queue_id,
7460 /* *** ADD/REMOVE A 5tuple FILTER *** */
7461 struct cmd_5tuple_filter_result {
7462 cmdline_fixed_string_t filter;
7464 cmdline_fixed_string_t ops;
7465 cmdline_fixed_string_t dst_ip;
7466 cmdline_ipaddr_t dst_ip_value;
7467 cmdline_fixed_string_t src_ip;
7468 cmdline_ipaddr_t src_ip_value;
7469 cmdline_fixed_string_t dst_port;
7470 uint16_t dst_port_value;
7471 cmdline_fixed_string_t src_port;
7472 uint16_t src_port_value;
7473 cmdline_fixed_string_t protocol;
7474 uint8_t protocol_value;
7475 cmdline_fixed_string_t mask;
7477 cmdline_fixed_string_t tcp_flags;
7478 uint8_t tcp_flags_value;
7479 cmdline_fixed_string_t priority;
7480 uint8_t priority_value;
7481 cmdline_fixed_string_t queue;
7486 cmd_5tuple_filter_parsed(void *parsed_result,
7487 __attribute__((unused)) struct cmdline *cl,
7488 __attribute__((unused)) void *data)
7490 struct rte_eth_ntuple_filter filter;
7491 struct cmd_5tuple_filter_result *res = parsed_result;
7494 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7496 printf("ntuple filter is not supported on port %u.\n",
7501 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7503 filter.flags = RTE_5TUPLE_FLAGS;
7504 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
7505 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
7506 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
7507 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7508 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7509 filter.proto = res->protocol_value;
7510 filter.priority = res->priority_value;
7511 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7512 printf("nonzero tcp_flags is only meaningful"
7513 " when protocol is TCP.\n");
7516 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7517 printf("invalid TCP flags.\n");
7521 if (res->tcp_flags_value != 0) {
7522 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7523 filter.tcp_flags = res->tcp_flags_value;
7526 if (res->dst_ip_value.family == AF_INET)
7527 /* no need to convert, already big endian. */
7528 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7530 if (filter.dst_ip_mask == 0) {
7531 printf("can not support ipv6 involved compare.\n");
7537 if (res->src_ip_value.family == AF_INET)
7538 /* no need to convert, already big endian. */
7539 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7541 if (filter.src_ip_mask == 0) {
7542 printf("can not support ipv6 involved compare.\n");
7547 /* need convert to big endian. */
7548 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7549 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7550 filter.queue = res->queue_id;
7552 if (!strcmp(res->ops, "add"))
7553 ret = rte_eth_dev_filter_ctrl(res->port_id,
7554 RTE_ETH_FILTER_NTUPLE,
7558 ret = rte_eth_dev_filter_ctrl(res->port_id,
7559 RTE_ETH_FILTER_NTUPLE,
7560 RTE_ETH_FILTER_DELETE,
7563 printf("5tuple filter programming error: (%s)\n",
7567 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
7568 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7569 filter, "5tuple_filter");
7570 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7571 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7573 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
7574 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7576 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7577 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7579 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7580 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7582 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7583 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7585 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7586 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7588 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7589 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7590 dst_port, "dst_port");
7591 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7592 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7593 dst_port_value, UINT16);
7594 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7595 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7596 src_port, "src_port");
7597 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7598 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7599 src_port_value, UINT16);
7600 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7601 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7602 protocol, "protocol");
7603 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7604 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7605 protocol_value, UINT8);
7606 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7607 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7609 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7610 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7612 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
7613 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7614 tcp_flags, "tcp_flags");
7615 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
7616 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7617 tcp_flags_value, UINT8);
7618 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7619 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7620 priority, "priority");
7621 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7622 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7623 priority_value, UINT8);
7624 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7625 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7627 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7628 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7631 cmdline_parse_inst_t cmd_5tuple_filter = {
7632 .f = cmd_5tuple_filter_parsed,
7634 .help_str = "add/del a 5tuple filter",
7636 (void *)&cmd_5tuple_filter_filter,
7637 (void *)&cmd_5tuple_filter_port_id,
7638 (void *)&cmd_5tuple_filter_ops,
7639 (void *)&cmd_5tuple_filter_dst_ip,
7640 (void *)&cmd_5tuple_filter_dst_ip_value,
7641 (void *)&cmd_5tuple_filter_src_ip,
7642 (void *)&cmd_5tuple_filter_src_ip_value,
7643 (void *)&cmd_5tuple_filter_dst_port,
7644 (void *)&cmd_5tuple_filter_dst_port_value,
7645 (void *)&cmd_5tuple_filter_src_port,
7646 (void *)&cmd_5tuple_filter_src_port_value,
7647 (void *)&cmd_5tuple_filter_protocol,
7648 (void *)&cmd_5tuple_filter_protocol_value,
7649 (void *)&cmd_5tuple_filter_mask,
7650 (void *)&cmd_5tuple_filter_mask_value,
7651 (void *)&cmd_5tuple_filter_tcp_flags,
7652 (void *)&cmd_5tuple_filter_tcp_flags_value,
7653 (void *)&cmd_5tuple_filter_priority,
7654 (void *)&cmd_5tuple_filter_priority_value,
7655 (void *)&cmd_5tuple_filter_queue,
7656 (void *)&cmd_5tuple_filter_queue_id,
7661 /* *** ADD/REMOVE A flex FILTER *** */
7662 struct cmd_flex_filter_result {
7663 cmdline_fixed_string_t filter;
7664 cmdline_fixed_string_t ops;
7666 cmdline_fixed_string_t len;
7668 cmdline_fixed_string_t bytes;
7669 cmdline_fixed_string_t bytes_value;
7670 cmdline_fixed_string_t mask;
7671 cmdline_fixed_string_t mask_value;
7672 cmdline_fixed_string_t priority;
7673 uint8_t priority_value;
7674 cmdline_fixed_string_t queue;
7678 static int xdigit2val(unsigned char c)
7683 else if (isupper(c))
7691 cmd_flex_filter_parsed(void *parsed_result,
7692 __attribute__((unused)) struct cmdline *cl,
7693 __attribute__((unused)) void *data)
7696 struct rte_eth_flex_filter filter;
7697 struct cmd_flex_filter_result *res = parsed_result;
7698 char *bytes_ptr, *mask_ptr;
7699 uint16_t len, i, j = 0;
7704 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
7705 printf("the len exceed the max length 128\n");
7708 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
7709 filter.len = res->len_value;
7710 filter.priority = res->priority_value;
7711 filter.queue = res->queue_id;
7712 bytes_ptr = res->bytes_value;
7713 mask_ptr = res->mask_value;
7715 /* translate bytes string to array. */
7716 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7717 (bytes_ptr[1] == 'X')))
7719 len = strnlen(bytes_ptr, res->len_value * 2);
7720 if (len == 0 || (len % 8 != 0)) {
7721 printf("please check len and bytes input\n");
7724 for (i = 0; i < len; i++) {
7726 if (isxdigit(c) == 0) {
7727 /* invalid characters. */
7728 printf("invalid input\n");
7731 val = xdigit2val(c);
7734 filter.bytes[j] = byte;
7735 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
7742 /* translate mask string to uint8_t array. */
7743 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7744 (mask_ptr[1] == 'X')))
7746 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
7748 printf("invalid input\n");
7753 for (i = 0; i < len; i++) {
7755 if (isxdigit(c) == 0) {
7756 /* invalid characters. */
7757 printf("invalid input\n");
7760 val = xdigit2val(c);
7763 filter.mask[j] = byte;
7764 printf("mask[%d]:%02x ", j, filter.mask[j]);
7772 if (!strcmp(res->ops, "add"))
7773 ret = rte_eth_dev_filter_ctrl(res->port_id,
7774 RTE_ETH_FILTER_FLEXIBLE,
7778 ret = rte_eth_dev_filter_ctrl(res->port_id,
7779 RTE_ETH_FILTER_FLEXIBLE,
7780 RTE_ETH_FILTER_DELETE,
7784 printf("flex filter setting error: (%s)\n", strerror(-ret));
7787 cmdline_parse_token_string_t cmd_flex_filter_filter =
7788 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7789 filter, "flex_filter");
7790 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7791 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7793 cmdline_parse_token_string_t cmd_flex_filter_ops =
7794 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7796 cmdline_parse_token_string_t cmd_flex_filter_len =
7797 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7799 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7800 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7802 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7803 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7805 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7806 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7808 cmdline_parse_token_string_t cmd_flex_filter_mask =
7809 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7811 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7812 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7814 cmdline_parse_token_string_t cmd_flex_filter_priority =
7815 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7816 priority, "priority");
7817 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7818 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7819 priority_value, UINT8);
7820 cmdline_parse_token_string_t cmd_flex_filter_queue =
7821 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7823 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7824 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7826 cmdline_parse_inst_t cmd_flex_filter = {
7827 .f = cmd_flex_filter_parsed,
7829 .help_str = "add/del a flex filter",
7831 (void *)&cmd_flex_filter_filter,
7832 (void *)&cmd_flex_filter_port_id,
7833 (void *)&cmd_flex_filter_ops,
7834 (void *)&cmd_flex_filter_len,
7835 (void *)&cmd_flex_filter_len_value,
7836 (void *)&cmd_flex_filter_bytes,
7837 (void *)&cmd_flex_filter_bytes_value,
7838 (void *)&cmd_flex_filter_mask,
7839 (void *)&cmd_flex_filter_mask_value,
7840 (void *)&cmd_flex_filter_priority,
7841 (void *)&cmd_flex_filter_priority_value,
7842 (void *)&cmd_flex_filter_queue,
7843 (void *)&cmd_flex_filter_queue_id,
7848 /* *** Filters Control *** */
7850 /* *** deal with ethertype filter *** */
7851 struct cmd_ethertype_filter_result {
7852 cmdline_fixed_string_t filter;
7854 cmdline_fixed_string_t ops;
7855 cmdline_fixed_string_t mac;
7856 struct ether_addr mac_addr;
7857 cmdline_fixed_string_t ethertype;
7858 uint16_t ethertype_value;
7859 cmdline_fixed_string_t drop;
7860 cmdline_fixed_string_t queue;
7864 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
7865 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7866 filter, "ethertype_filter");
7867 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7868 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7870 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
7871 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7873 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
7874 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7875 mac, "mac_addr#mac_ignr");
7876 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
7877 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
7879 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7880 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7881 ethertype, "ethertype");
7882 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
7883 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7884 ethertype_value, UINT16);
7885 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
7886 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7888 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7889 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7891 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7892 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7896 cmd_ethertype_filter_parsed(void *parsed_result,
7897 __attribute__((unused)) struct cmdline *cl,
7898 __attribute__((unused)) void *data)
7900 struct cmd_ethertype_filter_result *res = parsed_result;
7901 struct rte_eth_ethertype_filter filter;
7904 ret = rte_eth_dev_filter_supported(res->port_id,
7905 RTE_ETH_FILTER_ETHERTYPE);
7907 printf("ethertype filter is not supported on port %u.\n",
7912 memset(&filter, 0, sizeof(filter));
7913 if (!strcmp(res->mac, "mac_addr")) {
7914 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
7915 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
7916 sizeof(struct ether_addr));
7918 if (!strcmp(res->drop, "drop"))
7919 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
7920 filter.ether_type = res->ethertype_value;
7921 filter.queue = res->queue_id;
7923 if (!strcmp(res->ops, "add"))
7924 ret = rte_eth_dev_filter_ctrl(res->port_id,
7925 RTE_ETH_FILTER_ETHERTYPE,
7929 ret = rte_eth_dev_filter_ctrl(res->port_id,
7930 RTE_ETH_FILTER_ETHERTYPE,
7931 RTE_ETH_FILTER_DELETE,
7934 printf("ethertype filter programming error: (%s)\n",
7938 cmdline_parse_inst_t cmd_ethertype_filter = {
7939 .f = cmd_ethertype_filter_parsed,
7941 .help_str = "add or delete an ethertype filter entry",
7943 (void *)&cmd_ethertype_filter_filter,
7944 (void *)&cmd_ethertype_filter_port_id,
7945 (void *)&cmd_ethertype_filter_ops,
7946 (void *)&cmd_ethertype_filter_mac,
7947 (void *)&cmd_ethertype_filter_mac_addr,
7948 (void *)&cmd_ethertype_filter_ethertype,
7949 (void *)&cmd_ethertype_filter_ethertype_value,
7950 (void *)&cmd_ethertype_filter_drop,
7951 (void *)&cmd_ethertype_filter_queue,
7952 (void *)&cmd_ethertype_filter_queue_id,
7957 /* *** deal with flow director filter *** */
7958 struct cmd_flow_director_result {
7959 cmdline_fixed_string_t flow_director_filter;
7961 cmdline_fixed_string_t mode;
7962 cmdline_fixed_string_t mode_value;
7963 cmdline_fixed_string_t ops;
7964 cmdline_fixed_string_t flow;
7965 cmdline_fixed_string_t flow_type;
7966 cmdline_fixed_string_t ether;
7967 uint16_t ether_type;
7968 cmdline_fixed_string_t src;
7969 cmdline_ipaddr_t ip_src;
7971 cmdline_fixed_string_t dst;
7972 cmdline_ipaddr_t ip_dst;
7974 cmdline_fixed_string_t verify_tag;
7975 uint32_t verify_tag_value;
7976 cmdline_fixed_string_t vlan;
7977 uint16_t vlan_value;
7978 cmdline_fixed_string_t flexbytes;
7979 cmdline_fixed_string_t flexbytes_value;
7980 cmdline_fixed_string_t pf_vf;
7981 cmdline_fixed_string_t drop;
7982 cmdline_fixed_string_t queue;
7984 cmdline_fixed_string_t fd_id;
7985 uint32_t fd_id_value;
7986 cmdline_fixed_string_t mac;
7987 struct ether_addr mac_addr;
7988 cmdline_fixed_string_t tunnel;
7989 cmdline_fixed_string_t tunnel_type;
7990 cmdline_fixed_string_t tunnel_id;
7991 uint32_t tunnel_id_value;
7995 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7998 const char *p, *p0 = q_arg;
8000 unsigned long int_fld;
8001 char *str_fld[max_num];
8006 p = strchr(p0, '(');
8010 p0 = strchr(p, ')');
8015 if (size >= sizeof(s))
8018 snprintf(s, sizeof(s), "%.*s", size, p);
8019 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8020 if (ret < 0 || ret > max_num)
8022 for (i = 0; i < ret; i++) {
8024 int_fld = strtoul(str_fld[i], &end, 0);
8025 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8027 flexbytes[i] = (uint8_t)int_fld;
8033 str2flowtype(char *string)
8036 static const struct {
8039 } flowtype_str[] = {
8040 {"raw", RTE_ETH_FLOW_RAW},
8041 {"ipv4", RTE_ETH_FLOW_IPV4},
8042 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8043 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8044 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8045 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8046 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8047 {"ipv6", RTE_ETH_FLOW_IPV6},
8048 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8049 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8050 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8051 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8052 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8053 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8056 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8057 if (!strcmp(flowtype_str[i].str, string))
8058 return flowtype_str[i].type;
8060 return RTE_ETH_FLOW_UNKNOWN;
8063 static enum rte_eth_fdir_tunnel_type
8064 str2fdir_tunneltype(char *string)
8068 static const struct {
8070 enum rte_eth_fdir_tunnel_type type;
8071 } tunneltype_str[] = {
8072 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8073 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8076 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8077 if (!strcmp(tunneltype_str[i].str, string))
8078 return tunneltype_str[i].type;
8080 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8083 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8085 if ((ip_addr).family == AF_INET) \
8086 (ip) = (ip_addr).addr.ipv4.s_addr; \
8088 printf("invalid parameter.\n"); \
8093 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8095 if ((ip_addr).family == AF_INET6) \
8096 (void)rte_memcpy(&(ip), \
8097 &((ip_addr).addr.ipv6), \
8098 sizeof(struct in6_addr)); \
8100 printf("invalid parameter.\n"); \
8106 cmd_flow_director_filter_parsed(void *parsed_result,
8107 __attribute__((unused)) struct cmdline *cl,
8108 __attribute__((unused)) void *data)
8110 struct cmd_flow_director_result *res = parsed_result;
8111 struct rte_eth_fdir_filter entry;
8112 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8114 unsigned long vf_id;
8117 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8119 printf("flow director is not supported on port %u.\n",
8123 memset(flexbytes, 0, sizeof(flexbytes));
8124 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8126 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8127 if (strcmp(res->mode_value, "MAC-VLAN")) {
8128 printf("Please set mode to MAC-VLAN.\n");
8131 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8132 if (strcmp(res->mode_value, "Tunnel")) {
8133 printf("Please set mode to Tunnel.\n");
8137 if (strcmp(res->mode_value, "IP")) {
8138 printf("Please set mode to IP.\n");
8141 entry.input.flow_type = str2flowtype(res->flow_type);
8144 ret = parse_flexbytes(res->flexbytes_value,
8146 RTE_ETH_FDIR_MAX_FLEXLEN);
8148 printf("error: Cannot parse flexbytes input.\n");
8152 switch (entry.input.flow_type) {
8153 case RTE_ETH_FLOW_FRAG_IPV4:
8154 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8155 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8156 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8157 IPV4_ADDR_TO_UINT(res->ip_dst,
8158 entry.input.flow.ip4_flow.dst_ip);
8159 IPV4_ADDR_TO_UINT(res->ip_src,
8160 entry.input.flow.ip4_flow.src_ip);
8161 /* need convert to big endian. */
8162 entry.input.flow.udp4_flow.dst_port =
8163 rte_cpu_to_be_16(res->port_dst);
8164 entry.input.flow.udp4_flow.src_port =
8165 rte_cpu_to_be_16(res->port_src);
8167 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8168 IPV4_ADDR_TO_UINT(res->ip_dst,
8169 entry.input.flow.sctp4_flow.ip.dst_ip);
8170 IPV4_ADDR_TO_UINT(res->ip_src,
8171 entry.input.flow.sctp4_flow.ip.src_ip);
8172 /* need convert to big endian. */
8173 entry.input.flow.sctp4_flow.dst_port =
8174 rte_cpu_to_be_16(res->port_dst);
8175 entry.input.flow.sctp4_flow.src_port =
8176 rte_cpu_to_be_16(res->port_src);
8177 entry.input.flow.sctp4_flow.verify_tag =
8178 rte_cpu_to_be_32(res->verify_tag_value);
8180 case RTE_ETH_FLOW_FRAG_IPV6:
8181 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8182 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8183 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8184 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8185 entry.input.flow.ipv6_flow.dst_ip);
8186 IPV6_ADDR_TO_ARRAY(res->ip_src,
8187 entry.input.flow.ipv6_flow.src_ip);
8188 /* need convert to big endian. */
8189 entry.input.flow.udp6_flow.dst_port =
8190 rte_cpu_to_be_16(res->port_dst);
8191 entry.input.flow.udp6_flow.src_port =
8192 rte_cpu_to_be_16(res->port_src);
8194 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8195 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8196 entry.input.flow.sctp6_flow.ip.dst_ip);
8197 IPV6_ADDR_TO_ARRAY(res->ip_src,
8198 entry.input.flow.sctp6_flow.ip.src_ip);
8199 /* need convert to big endian. */
8200 entry.input.flow.sctp6_flow.dst_port =
8201 rte_cpu_to_be_16(res->port_dst);
8202 entry.input.flow.sctp6_flow.src_port =
8203 rte_cpu_to_be_16(res->port_src);
8204 entry.input.flow.sctp6_flow.verify_tag =
8205 rte_cpu_to_be_32(res->verify_tag_value);
8207 case RTE_ETH_FLOW_L2_PAYLOAD:
8208 entry.input.flow.l2_flow.ether_type =
8209 rte_cpu_to_be_16(res->ether_type);
8215 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8216 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8218 sizeof(struct ether_addr));
8220 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8221 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8223 sizeof(struct ether_addr));
8224 entry.input.flow.tunnel_flow.tunnel_type =
8225 str2fdir_tunneltype(res->tunnel_type);
8226 entry.input.flow.tunnel_flow.tunnel_id =
8227 rte_cpu_to_be_32(res->tunnel_id_value);
8230 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8232 RTE_ETH_FDIR_MAX_FLEXLEN);
8234 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8236 entry.action.flex_off = 0; /*use 0 by default */
8237 if (!strcmp(res->drop, "drop"))
8238 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8240 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8242 if (!strcmp(res->pf_vf, "pf"))
8243 entry.input.flow_ext.is_vf = 0;
8244 else if (!strncmp(res->pf_vf, "vf", 2)) {
8245 struct rte_eth_dev_info dev_info;
8247 memset(&dev_info, 0, sizeof(dev_info));
8248 rte_eth_dev_info_get(res->port_id, &dev_info);
8250 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8251 if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
8252 printf("invalid parameter %s.\n", res->pf_vf);
8255 entry.input.flow_ext.is_vf = 1;
8256 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8258 printf("invalid parameter %s.\n", res->pf_vf);
8262 /* set to report FD ID by default */
8263 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8264 entry.action.rx_queue = res->queue_id;
8265 entry.soft_id = res->fd_id_value;
8266 if (!strcmp(res->ops, "add"))
8267 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8268 RTE_ETH_FILTER_ADD, &entry);
8269 else if (!strcmp(res->ops, "del"))
8270 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8271 RTE_ETH_FILTER_DELETE, &entry);
8273 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8274 RTE_ETH_FILTER_UPDATE, &entry);
8276 printf("flow director programming error: (%s)\n",
8280 cmdline_parse_token_string_t cmd_flow_director_filter =
8281 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8282 flow_director_filter, "flow_director_filter");
8283 cmdline_parse_token_num_t cmd_flow_director_port_id =
8284 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8286 cmdline_parse_token_string_t cmd_flow_director_ops =
8287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8288 ops, "add#del#update");
8289 cmdline_parse_token_string_t cmd_flow_director_flow =
8290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8292 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8294 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8295 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8296 cmdline_parse_token_string_t cmd_flow_director_ether =
8297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8299 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8301 ether_type, UINT16);
8302 cmdline_parse_token_string_t cmd_flow_director_src =
8303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8305 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8306 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8308 cmdline_parse_token_num_t cmd_flow_director_port_src =
8309 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8311 cmdline_parse_token_string_t cmd_flow_director_dst =
8312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8314 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8315 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8317 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8318 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8320 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8322 verify_tag, "verify_tag");
8323 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8324 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8325 verify_tag_value, UINT32);
8326 cmdline_parse_token_string_t cmd_flow_director_vlan =
8327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8329 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8331 vlan_value, UINT16);
8332 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8334 flexbytes, "flexbytes");
8335 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8337 flexbytes_value, NULL);
8338 cmdline_parse_token_string_t cmd_flow_director_drop =
8339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8341 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8344 cmdline_parse_token_string_t cmd_flow_director_queue =
8345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8347 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8348 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8350 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8353 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8354 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8355 fd_id_value, UINT32);
8357 cmdline_parse_token_string_t cmd_flow_director_mode =
8358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8360 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8363 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8365 mode_value, "MAC-VLAN");
8366 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8368 mode_value, "Tunnel");
8369 cmdline_parse_token_string_t cmd_flow_director_mac =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8372 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8373 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8375 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8378 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8380 tunnel_type, "NVGRE#VxLAN");
8381 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8383 tunnel_id, "tunnel-id");
8384 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8386 tunnel_id_value, UINT32);
8388 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8389 .f = cmd_flow_director_filter_parsed,
8391 .help_str = "add or delete an ip flow director entry on NIC",
8393 (void *)&cmd_flow_director_filter,
8394 (void *)&cmd_flow_director_port_id,
8395 (void *)&cmd_flow_director_mode,
8396 (void *)&cmd_flow_director_mode_ip,
8397 (void *)&cmd_flow_director_ops,
8398 (void *)&cmd_flow_director_flow,
8399 (void *)&cmd_flow_director_flow_type,
8400 (void *)&cmd_flow_director_src,
8401 (void *)&cmd_flow_director_ip_src,
8402 (void *)&cmd_flow_director_dst,
8403 (void *)&cmd_flow_director_ip_dst,
8404 (void *)&cmd_flow_director_vlan,
8405 (void *)&cmd_flow_director_vlan_value,
8406 (void *)&cmd_flow_director_flexbytes,
8407 (void *)&cmd_flow_director_flexbytes_value,
8408 (void *)&cmd_flow_director_drop,
8409 (void *)&cmd_flow_director_pf_vf,
8410 (void *)&cmd_flow_director_queue,
8411 (void *)&cmd_flow_director_queue_id,
8412 (void *)&cmd_flow_director_fd_id,
8413 (void *)&cmd_flow_director_fd_id_value,
8418 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8419 .f = cmd_flow_director_filter_parsed,
8421 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8423 (void *)&cmd_flow_director_filter,
8424 (void *)&cmd_flow_director_port_id,
8425 (void *)&cmd_flow_director_mode,
8426 (void *)&cmd_flow_director_mode_ip,
8427 (void *)&cmd_flow_director_ops,
8428 (void *)&cmd_flow_director_flow,
8429 (void *)&cmd_flow_director_flow_type,
8430 (void *)&cmd_flow_director_src,
8431 (void *)&cmd_flow_director_ip_src,
8432 (void *)&cmd_flow_director_port_src,
8433 (void *)&cmd_flow_director_dst,
8434 (void *)&cmd_flow_director_ip_dst,
8435 (void *)&cmd_flow_director_port_dst,
8436 (void *)&cmd_flow_director_vlan,
8437 (void *)&cmd_flow_director_vlan_value,
8438 (void *)&cmd_flow_director_flexbytes,
8439 (void *)&cmd_flow_director_flexbytes_value,
8440 (void *)&cmd_flow_director_drop,
8441 (void *)&cmd_flow_director_pf_vf,
8442 (void *)&cmd_flow_director_queue,
8443 (void *)&cmd_flow_director_queue_id,
8444 (void *)&cmd_flow_director_fd_id,
8445 (void *)&cmd_flow_director_fd_id_value,
8450 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8451 .f = cmd_flow_director_filter_parsed,
8453 .help_str = "add or delete a sctp flow director entry on NIC",
8455 (void *)&cmd_flow_director_filter,
8456 (void *)&cmd_flow_director_port_id,
8457 (void *)&cmd_flow_director_mode,
8458 (void *)&cmd_flow_director_mode_ip,
8459 (void *)&cmd_flow_director_ops,
8460 (void *)&cmd_flow_director_flow,
8461 (void *)&cmd_flow_director_flow_type,
8462 (void *)&cmd_flow_director_src,
8463 (void *)&cmd_flow_director_ip_src,
8464 (void *)&cmd_flow_director_port_dst,
8465 (void *)&cmd_flow_director_dst,
8466 (void *)&cmd_flow_director_ip_dst,
8467 (void *)&cmd_flow_director_port_dst,
8468 (void *)&cmd_flow_director_verify_tag,
8469 (void *)&cmd_flow_director_verify_tag_value,
8470 (void *)&cmd_flow_director_vlan,
8471 (void *)&cmd_flow_director_vlan_value,
8472 (void *)&cmd_flow_director_flexbytes,
8473 (void *)&cmd_flow_director_flexbytes_value,
8474 (void *)&cmd_flow_director_drop,
8475 (void *)&cmd_flow_director_pf_vf,
8476 (void *)&cmd_flow_director_queue,
8477 (void *)&cmd_flow_director_queue_id,
8478 (void *)&cmd_flow_director_fd_id,
8479 (void *)&cmd_flow_director_fd_id_value,
8484 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
8485 .f = cmd_flow_director_filter_parsed,
8487 .help_str = "add or delete a L2 flow director entry on NIC",
8489 (void *)&cmd_flow_director_filter,
8490 (void *)&cmd_flow_director_port_id,
8491 (void *)&cmd_flow_director_mode,
8492 (void *)&cmd_flow_director_mode_ip,
8493 (void *)&cmd_flow_director_ops,
8494 (void *)&cmd_flow_director_flow,
8495 (void *)&cmd_flow_director_flow_type,
8496 (void *)&cmd_flow_director_ether,
8497 (void *)&cmd_flow_director_ether_type,
8498 (void *)&cmd_flow_director_flexbytes,
8499 (void *)&cmd_flow_director_flexbytes_value,
8500 (void *)&cmd_flow_director_drop,
8501 (void *)&cmd_flow_director_pf_vf,
8502 (void *)&cmd_flow_director_queue,
8503 (void *)&cmd_flow_director_queue_id,
8504 (void *)&cmd_flow_director_fd_id,
8505 (void *)&cmd_flow_director_fd_id_value,
8510 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
8511 .f = cmd_flow_director_filter_parsed,
8513 .help_str = "add or delete a MAC VLAN flow director entry on NIC",
8515 (void *)&cmd_flow_director_filter,
8516 (void *)&cmd_flow_director_port_id,
8517 (void *)&cmd_flow_director_mode,
8518 (void *)&cmd_flow_director_mode_mac_vlan,
8519 (void *)&cmd_flow_director_ops,
8520 (void *)&cmd_flow_director_mac,
8521 (void *)&cmd_flow_director_mac_addr,
8522 (void *)&cmd_flow_director_vlan,
8523 (void *)&cmd_flow_director_vlan_value,
8524 (void *)&cmd_flow_director_flexbytes,
8525 (void *)&cmd_flow_director_flexbytes_value,
8526 (void *)&cmd_flow_director_drop,
8527 (void *)&cmd_flow_director_queue,
8528 (void *)&cmd_flow_director_queue_id,
8529 (void *)&cmd_flow_director_fd_id,
8530 (void *)&cmd_flow_director_fd_id_value,
8535 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
8536 .f = cmd_flow_director_filter_parsed,
8538 .help_str = "add or delete a tunnel flow director entry on NIC",
8540 (void *)&cmd_flow_director_filter,
8541 (void *)&cmd_flow_director_port_id,
8542 (void *)&cmd_flow_director_mode,
8543 (void *)&cmd_flow_director_mode_tunnel,
8544 (void *)&cmd_flow_director_ops,
8545 (void *)&cmd_flow_director_mac,
8546 (void *)&cmd_flow_director_mac_addr,
8547 (void *)&cmd_flow_director_vlan,
8548 (void *)&cmd_flow_director_vlan_value,
8549 (void *)&cmd_flow_director_tunnel,
8550 (void *)&cmd_flow_director_tunnel_type,
8551 (void *)&cmd_flow_director_tunnel_id,
8552 (void *)&cmd_flow_director_tunnel_id_value,
8553 (void *)&cmd_flow_director_flexbytes,
8554 (void *)&cmd_flow_director_flexbytes_value,
8555 (void *)&cmd_flow_director_drop,
8556 (void *)&cmd_flow_director_queue,
8557 (void *)&cmd_flow_director_queue_id,
8558 (void *)&cmd_flow_director_fd_id,
8559 (void *)&cmd_flow_director_fd_id_value,
8564 struct cmd_flush_flow_director_result {
8565 cmdline_fixed_string_t flush_flow_director;
8569 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8570 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8571 flush_flow_director, "flush_flow_director");
8572 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8573 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8577 cmd_flush_flow_director_parsed(void *parsed_result,
8578 __attribute__((unused)) struct cmdline *cl,
8579 __attribute__((unused)) void *data)
8581 struct cmd_flow_director_result *res = parsed_result;
8584 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8586 printf("flow director is not supported on port %u.\n",
8591 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8592 RTE_ETH_FILTER_FLUSH, NULL);
8594 printf("flow director table flushing error: (%s)\n",
8598 cmdline_parse_inst_t cmd_flush_flow_director = {
8599 .f = cmd_flush_flow_director_parsed,
8601 .help_str = "flush all flow director entries of a device on NIC",
8603 (void *)&cmd_flush_flow_director_flush,
8604 (void *)&cmd_flush_flow_director_port_id,
8609 /* *** deal with flow director mask *** */
8610 struct cmd_flow_director_mask_result {
8611 cmdline_fixed_string_t flow_director_mask;
8613 cmdline_fixed_string_t mode;
8614 cmdline_fixed_string_t mode_value;
8615 cmdline_fixed_string_t vlan;
8617 cmdline_fixed_string_t src_mask;
8618 cmdline_ipaddr_t ipv4_src;
8619 cmdline_ipaddr_t ipv6_src;
8621 cmdline_fixed_string_t dst_mask;
8622 cmdline_ipaddr_t ipv4_dst;
8623 cmdline_ipaddr_t ipv6_dst;
8625 cmdline_fixed_string_t mac;
8626 uint8_t mac_addr_byte_mask;
8627 cmdline_fixed_string_t tunnel_id;
8628 uint32_t tunnel_id_mask;
8629 cmdline_fixed_string_t tunnel_type;
8630 uint8_t tunnel_type_mask;
8634 cmd_flow_director_mask_parsed(void *parsed_result,
8635 __attribute__((unused)) struct cmdline *cl,
8636 __attribute__((unused)) void *data)
8638 struct cmd_flow_director_mask_result *res = parsed_result;
8639 struct rte_eth_fdir_masks *mask;
8640 struct rte_port *port;
8642 if (res->port_id > nb_ports) {
8643 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8647 port = &ports[res->port_id];
8648 /** Check if the port is not started **/
8649 if (port->port_status != RTE_PORT_STOPPED) {
8650 printf("Please stop port %d first\n", res->port_id);
8654 mask = &port->dev_conf.fdir_conf.mask;
8656 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8657 if (strcmp(res->mode_value, "MAC-VLAN")) {
8658 printf("Please set mode to MAC-VLAN.\n");
8662 mask->vlan_tci_mask = res->vlan_mask;
8663 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8664 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8665 if (strcmp(res->mode_value, "Tunnel")) {
8666 printf("Please set mode to Tunnel.\n");
8670 mask->vlan_tci_mask = res->vlan_mask;
8671 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
8672 mask->tunnel_id_mask = res->tunnel_id_mask;
8673 mask->tunnel_type_mask = res->tunnel_type_mask;
8675 if (strcmp(res->mode_value, "IP")) {
8676 printf("Please set mode to IP.\n");
8680 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
8681 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
8682 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
8683 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
8684 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
8685 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
8686 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
8689 cmd_reconfig_device_queue(res->port_id, 1, 1);
8692 cmdline_parse_token_string_t cmd_flow_director_mask =
8693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8694 flow_director_mask, "flow_director_mask");
8695 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
8696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8698 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
8699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8701 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
8702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8704 cmdline_parse_token_string_t cmd_flow_director_mask_src =
8705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8706 src_mask, "src_mask");
8707 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
8708 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8710 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
8711 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8713 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
8714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8716 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
8717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8718 dst_mask, "dst_mask");
8719 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
8720 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
8723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
8725 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
8726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8729 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
8730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8732 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
8733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8735 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
8736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8737 mode_value, "MAC-VLAN");
8738 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
8739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8740 mode_value, "Tunnel");
8741 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
8742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8744 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
8745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8746 mac_addr_byte_mask, UINT8);
8747 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
8748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8749 tunnel_type, "tunnel-type");
8750 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
8751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8752 tunnel_type_mask, UINT8);
8753 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
8754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
8755 tunnel_id, "tunnel-id");
8756 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
8757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
8758 tunnel_id_mask, UINT32);
8760 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
8761 .f = cmd_flow_director_mask_parsed,
8763 .help_str = "set IP mode flow director's mask on NIC",
8765 (void *)&cmd_flow_director_mask,
8766 (void *)&cmd_flow_director_mask_port_id,
8767 (void *)&cmd_flow_director_mask_mode,
8768 (void *)&cmd_flow_director_mask_mode_ip,
8769 (void *)&cmd_flow_director_mask_vlan,
8770 (void *)&cmd_flow_director_mask_vlan_value,
8771 (void *)&cmd_flow_director_mask_src,
8772 (void *)&cmd_flow_director_mask_ipv4_src,
8773 (void *)&cmd_flow_director_mask_ipv6_src,
8774 (void *)&cmd_flow_director_mask_port_src,
8775 (void *)&cmd_flow_director_mask_dst,
8776 (void *)&cmd_flow_director_mask_ipv4_dst,
8777 (void *)&cmd_flow_director_mask_ipv6_dst,
8778 (void *)&cmd_flow_director_mask_port_dst,
8783 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
8784 .f = cmd_flow_director_mask_parsed,
8786 .help_str = "set MAC VLAN mode flow director's mask on NIC",
8788 (void *)&cmd_flow_director_mask,
8789 (void *)&cmd_flow_director_mask_port_id,
8790 (void *)&cmd_flow_director_mask_mode,
8791 (void *)&cmd_flow_director_mask_mode_mac_vlan,
8792 (void *)&cmd_flow_director_mask_vlan,
8793 (void *)&cmd_flow_director_mask_vlan_value,
8794 (void *)&cmd_flow_director_mask_mac,
8795 (void *)&cmd_flow_director_mask_mac_value,
8800 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
8801 .f = cmd_flow_director_mask_parsed,
8803 .help_str = "set tunnel mode flow director's mask on NIC",
8805 (void *)&cmd_flow_director_mask,
8806 (void *)&cmd_flow_director_mask_port_id,
8807 (void *)&cmd_flow_director_mask_mode,
8808 (void *)&cmd_flow_director_mask_mode_tunnel,
8809 (void *)&cmd_flow_director_mask_vlan,
8810 (void *)&cmd_flow_director_mask_vlan_value,
8811 (void *)&cmd_flow_director_mask_mac,
8812 (void *)&cmd_flow_director_mask_mac_value,
8813 (void *)&cmd_flow_director_mask_tunnel_type,
8814 (void *)&cmd_flow_director_mask_tunnel_type_value,
8815 (void *)&cmd_flow_director_mask_tunnel_id,
8816 (void *)&cmd_flow_director_mask_tunnel_id_value,
8821 /* *** deal with flow director mask on flexible payload *** */
8822 struct cmd_flow_director_flex_mask_result {
8823 cmdline_fixed_string_t flow_director_flexmask;
8825 cmdline_fixed_string_t flow;
8826 cmdline_fixed_string_t flow_type;
8827 cmdline_fixed_string_t mask;
8831 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8832 __attribute__((unused)) struct cmdline *cl,
8833 __attribute__((unused)) void *data)
8835 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8836 struct rte_eth_fdir_info fdir_info;
8837 struct rte_eth_fdir_flex_mask flex_mask;
8838 struct rte_port *port;
8839 uint32_t flow_type_mask;
8843 if (res->port_id > nb_ports) {
8844 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8848 port = &ports[res->port_id];
8849 /** Check if the port is not started **/
8850 if (port->port_status != RTE_PORT_STOPPED) {
8851 printf("Please stop port %d first\n", res->port_id);
8855 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8856 ret = parse_flexbytes(res->mask,
8858 RTE_ETH_FDIR_MAX_FLEXLEN);
8860 printf("error: Cannot parse mask input.\n");
8864 memset(&fdir_info, 0, sizeof(fdir_info));
8865 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8866 RTE_ETH_FILTER_INFO, &fdir_info);
8868 printf("Cannot get FDir filter info\n");
8872 if (!strcmp(res->flow_type, "none")) {
8873 /* means don't specify the flow type */
8874 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
8875 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
8876 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
8877 0, sizeof(struct rte_eth_fdir_flex_mask));
8878 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
8879 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
8881 sizeof(struct rte_eth_fdir_flex_mask));
8882 cmd_reconfig_device_queue(res->port_id, 1, 1);
8885 flow_type_mask = fdir_info.flow_types_mask[0];
8886 if (!strcmp(res->flow_type, "all")) {
8887 if (!flow_type_mask) {
8888 printf("No flow type supported\n");
8891 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
8892 if (flow_type_mask & (1 << i)) {
8893 flex_mask.flow_type = i;
8894 fdir_set_flex_mask(res->port_id, &flex_mask);
8897 cmd_reconfig_device_queue(res->port_id, 1, 1);
8900 flex_mask.flow_type = str2flowtype(res->flow_type);
8901 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
8902 printf("Flow type %s not supported on port %d\n",
8903 res->flow_type, res->port_id);
8906 fdir_set_flex_mask(res->port_id, &flex_mask);
8907 cmd_reconfig_device_queue(res->port_id, 1, 1);
8910 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8912 flow_director_flexmask,
8913 "flow_director_flex_mask");
8914 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8915 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8917 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8920 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8921 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8922 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8923 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
8924 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8928 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8929 .f = cmd_flow_director_flex_mask_parsed,
8931 .help_str = "set flow director's flex mask on NIC",
8933 (void *)&cmd_flow_director_flexmask,
8934 (void *)&cmd_flow_director_flexmask_port_id,
8935 (void *)&cmd_flow_director_flexmask_flow,
8936 (void *)&cmd_flow_director_flexmask_flow_type,
8937 (void *)&cmd_flow_director_flexmask_mask,
8942 /* *** deal with flow director flexible payload configuration *** */
8943 struct cmd_flow_director_flexpayload_result {
8944 cmdline_fixed_string_t flow_director_flexpayload;
8946 cmdline_fixed_string_t payload_layer;
8947 cmdline_fixed_string_t payload_cfg;
8951 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8954 const char *p, *p0 = q_arg;
8956 unsigned long int_fld;
8957 char *str_fld[max_num];
8962 p = strchr(p0, '(');
8966 p0 = strchr(p, ')');
8971 if (size >= sizeof(s))
8974 snprintf(s, sizeof(s), "%.*s", size, p);
8975 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8976 if (ret < 0 || ret > max_num)
8978 for (i = 0; i < ret; i++) {
8980 int_fld = strtoul(str_fld[i], &end, 0);
8981 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8983 offsets[i] = (uint16_t)int_fld;
8989 cmd_flow_director_flxpld_parsed(void *parsed_result,
8990 __attribute__((unused)) struct cmdline *cl,
8991 __attribute__((unused)) void *data)
8993 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8994 struct rte_eth_flex_payload_cfg flex_cfg;
8995 struct rte_port *port;
8998 if (res->port_id > nb_ports) {
8999 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9003 port = &ports[res->port_id];
9004 /** Check if the port is not started **/
9005 if (port->port_status != RTE_PORT_STOPPED) {
9006 printf("Please stop port %d first\n", res->port_id);
9010 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9012 if (!strcmp(res->payload_layer, "raw"))
9013 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9014 else if (!strcmp(res->payload_layer, "l2"))
9015 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9016 else if (!strcmp(res->payload_layer, "l3"))
9017 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9018 else if (!strcmp(res->payload_layer, "l4"))
9019 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9021 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9022 RTE_ETH_FDIR_MAX_FLEXLEN);
9024 printf("error: Cannot parse flex payload input.\n");
9028 fdir_set_flex_payload(res->port_id, &flex_cfg);
9029 cmd_reconfig_device_queue(res->port_id, 1, 1);
9032 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9034 flow_director_flexpayload,
9035 "flow_director_flex_payload");
9036 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9037 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9039 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9041 payload_layer, "raw#l2#l3#l4");
9042 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9046 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9047 .f = cmd_flow_director_flxpld_parsed,
9049 .help_str = "set flow director's flex payload on NIC",
9051 (void *)&cmd_flow_director_flexpayload,
9052 (void *)&cmd_flow_director_flexpayload_port_id,
9053 (void *)&cmd_flow_director_flexpayload_payload_layer,
9054 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9059 /* *** Classification Filters Control *** */
9060 /* *** Get symmetric hash enable per port *** */
9061 struct cmd_get_sym_hash_ena_per_port_result {
9062 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9067 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9068 __rte_unused struct cmdline *cl,
9069 __rte_unused void *data)
9071 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9072 struct rte_eth_hash_filter_info info;
9075 if (rte_eth_dev_filter_supported(res->port_id,
9076 RTE_ETH_FILTER_HASH) < 0) {
9077 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9082 memset(&info, 0, sizeof(info));
9083 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9084 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9085 RTE_ETH_FILTER_GET, &info);
9088 printf("Cannot get symmetric hash enable per port "
9089 "on port %u\n", res->port_id);
9093 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9094 "enabled" : "disabled", res->port_id);
9097 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9098 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9099 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9100 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9101 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9104 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9105 .f = cmd_get_sym_hash_per_port_parsed,
9107 .help_str = "get_sym_hash_ena_per_port port_id",
9109 (void *)&cmd_get_sym_hash_ena_per_port_all,
9110 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9115 /* *** Set symmetric hash enable per port *** */
9116 struct cmd_set_sym_hash_ena_per_port_result {
9117 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9118 cmdline_fixed_string_t enable;
9123 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9124 __rte_unused struct cmdline *cl,
9125 __rte_unused void *data)
9127 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9128 struct rte_eth_hash_filter_info info;
9131 if (rte_eth_dev_filter_supported(res->port_id,
9132 RTE_ETH_FILTER_HASH) < 0) {
9133 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9138 memset(&info, 0, sizeof(info));
9139 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9140 if (!strcmp(res->enable, "enable"))
9141 info.info.enable = 1;
9142 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9143 RTE_ETH_FILTER_SET, &info);
9145 printf("Cannot set symmetric hash enable per port on "
9146 "port %u\n", res->port_id);
9149 printf("Symmetric hash has been set to %s on port %u\n",
9150 res->enable, res->port_id);
9153 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9154 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9155 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9156 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9157 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9159 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9160 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9161 enable, "enable#disable");
9163 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9164 .f = cmd_set_sym_hash_per_port_parsed,
9166 .help_str = "set_sym_hash_ena_per_port port_id enable|disable",
9168 (void *)&cmd_set_sym_hash_ena_per_port_all,
9169 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9170 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9175 /* Get global config of hash function */
9176 struct cmd_get_hash_global_config_result {
9177 cmdline_fixed_string_t get_hash_global_config;
9182 flowtype_to_str(uint16_t ftype)
9189 {"ipv4", RTE_ETH_FLOW_IPV4},
9190 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9191 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9192 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9193 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9194 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9195 {"ipv6", RTE_ETH_FLOW_IPV6},
9196 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9197 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9198 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9199 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9200 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9201 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9204 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9205 if (ftype_table[i].ftype == ftype)
9206 return ftype_table[i].str;
9213 cmd_get_hash_global_config_parsed(void *parsed_result,
9214 __rte_unused struct cmdline *cl,
9215 __rte_unused void *data)
9217 struct cmd_get_hash_global_config_result *res = parsed_result;
9218 struct rte_eth_hash_filter_info info;
9219 uint32_t idx, offset;
9224 if (rte_eth_dev_filter_supported(res->port_id,
9225 RTE_ETH_FILTER_HASH) < 0) {
9226 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9231 memset(&info, 0, sizeof(info));
9232 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9233 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9234 RTE_ETH_FILTER_GET, &info);
9236 printf("Cannot get hash global configurations by port %d\n",
9241 switch (info.info.global_conf.hash_func) {
9242 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9243 printf("Hash function is Toeplitz\n");
9245 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9246 printf("Hash function is Simple XOR\n");
9249 printf("Unknown hash function\n");
9253 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9254 idx = i / UINT32_BIT;
9255 offset = i % UINT32_BIT;
9256 if (!(info.info.global_conf.valid_bit_mask[idx] &
9259 str = flowtype_to_str(i);
9262 printf("Symmetric hash is %s globally for flow type %s "
9264 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9265 (1UL << offset)) ? "enabled" : "disabled"), str,
9270 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9271 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9272 get_hash_global_config, "get_hash_global_config");
9273 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9274 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9277 cmdline_parse_inst_t cmd_get_hash_global_config = {
9278 .f = cmd_get_hash_global_config_parsed,
9280 .help_str = "get_hash_global_config port_id",
9282 (void *)&cmd_get_hash_global_config_all,
9283 (void *)&cmd_get_hash_global_config_port_id,
9288 /* Set global config of hash function */
9289 struct cmd_set_hash_global_config_result {
9290 cmdline_fixed_string_t set_hash_global_config;
9292 cmdline_fixed_string_t hash_func;
9293 cmdline_fixed_string_t flow_type;
9294 cmdline_fixed_string_t enable;
9298 cmd_set_hash_global_config_parsed(void *parsed_result,
9299 __rte_unused struct cmdline *cl,
9300 __rte_unused void *data)
9302 struct cmd_set_hash_global_config_result *res = parsed_result;
9303 struct rte_eth_hash_filter_info info;
9304 uint32_t ftype, idx, offset;
9307 if (rte_eth_dev_filter_supported(res->port_id,
9308 RTE_ETH_FILTER_HASH) < 0) {
9309 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9313 memset(&info, 0, sizeof(info));
9314 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9315 if (!strcmp(res->hash_func, "toeplitz"))
9316 info.info.global_conf.hash_func =
9317 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9318 else if (!strcmp(res->hash_func, "simple_xor"))
9319 info.info.global_conf.hash_func =
9320 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9321 else if (!strcmp(res->hash_func, "default"))
9322 info.info.global_conf.hash_func =
9323 RTE_ETH_HASH_FUNCTION_DEFAULT;
9325 ftype = str2flowtype(res->flow_type);
9326 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9327 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9328 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9329 if (!strcmp(res->enable, "enable"))
9330 info.info.global_conf.sym_hash_enable_mask[idx] |=
9332 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9333 RTE_ETH_FILTER_SET, &info);
9335 printf("Cannot set global hash configurations by port %d\n",
9338 printf("Global hash configurations have been set "
9339 "succcessfully by port %d\n", res->port_id);
9342 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9343 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9344 set_hash_global_config, "set_hash_global_config");
9345 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9346 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9348 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9349 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9350 hash_func, "toeplitz#simple_xor#default");
9351 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9352 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9354 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9355 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9356 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9357 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9358 enable, "enable#disable");
9360 cmdline_parse_inst_t cmd_set_hash_global_config = {
9361 .f = cmd_set_hash_global_config_parsed,
9363 .help_str = "set_hash_global_config port_id "
9364 "toeplitz|simple_xor|default "
9365 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
9366 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9369 (void *)&cmd_set_hash_global_config_all,
9370 (void *)&cmd_set_hash_global_config_port_id,
9371 (void *)&cmd_set_hash_global_config_hash_func,
9372 (void *)&cmd_set_hash_global_config_flow_type,
9373 (void *)&cmd_set_hash_global_config_enable,
9378 /* Set hash input set */
9379 struct cmd_set_hash_input_set_result {
9380 cmdline_fixed_string_t set_hash_input_set;
9382 cmdline_fixed_string_t flow_type;
9383 cmdline_fixed_string_t inset_field;
9384 cmdline_fixed_string_t select;
9387 static enum rte_eth_input_set_field
9388 str2inset(char *string)
9392 static const struct {
9394 enum rte_eth_input_set_field inset;
9396 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
9397 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
9398 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
9399 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
9400 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
9401 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
9402 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
9403 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
9404 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
9405 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
9406 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
9407 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
9408 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
9409 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
9410 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
9411 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
9412 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
9413 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
9414 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
9415 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
9416 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
9417 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
9418 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
9419 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
9420 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
9421 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
9422 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
9423 {"none", RTE_ETH_INPUT_SET_NONE},
9426 for (i = 0; i < RTE_DIM(inset_table); i++) {
9427 if (!strcmp(string, inset_table[i].str))
9428 return inset_table[i].inset;
9431 return RTE_ETH_INPUT_SET_UNKNOWN;
9435 cmd_set_hash_input_set_parsed(void *parsed_result,
9436 __rte_unused struct cmdline *cl,
9437 __rte_unused void *data)
9439 struct cmd_set_hash_input_set_result *res = parsed_result;
9440 struct rte_eth_hash_filter_info info;
9442 memset(&info, 0, sizeof(info));
9443 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
9444 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9445 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9446 info.info.input_set_conf.inset_size = 1;
9447 if (!strcmp(res->select, "select"))
9448 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9449 else if (!strcmp(res->select, "add"))
9450 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9451 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9452 RTE_ETH_FILTER_SET, &info);
9455 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
9456 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9457 set_hash_input_set, "set_hash_input_set");
9458 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
9459 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
9461 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
9462 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9464 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9465 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9466 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
9467 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9469 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
9470 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
9471 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
9472 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
9473 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
9475 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
9476 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
9477 select, "select#add");
9479 cmdline_parse_inst_t cmd_set_hash_input_set = {
9480 .f = cmd_set_hash_input_set_parsed,
9482 .help_str = "set_hash_input_set <port_id> "
9483 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9484 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9485 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
9486 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
9487 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
9488 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9489 "fld-7th|fld-8th|none select|add",
9491 (void *)&cmd_set_hash_input_set_cmd,
9492 (void *)&cmd_set_hash_input_set_port_id,
9493 (void *)&cmd_set_hash_input_set_flow_type,
9494 (void *)&cmd_set_hash_input_set_field,
9495 (void *)&cmd_set_hash_input_set_select,
9500 /* Set flow director input set */
9501 struct cmd_set_fdir_input_set_result {
9502 cmdline_fixed_string_t set_fdir_input_set;
9504 cmdline_fixed_string_t flow_type;
9505 cmdline_fixed_string_t inset_field;
9506 cmdline_fixed_string_t select;
9510 cmd_set_fdir_input_set_parsed(void *parsed_result,
9511 __rte_unused struct cmdline *cl,
9512 __rte_unused void *data)
9514 struct cmd_set_fdir_input_set_result *res = parsed_result;
9515 struct rte_eth_fdir_filter_info info;
9517 memset(&info, 0, sizeof(info));
9518 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
9519 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
9520 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
9521 info.info.input_set_conf.inset_size = 1;
9522 if (!strcmp(res->select, "select"))
9523 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
9524 else if (!strcmp(res->select, "add"))
9525 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
9526 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9527 RTE_ETH_FILTER_SET, &info);
9530 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
9531 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9532 set_fdir_input_set, "set_fdir_input_set");
9533 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
9534 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
9536 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
9537 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9539 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9540 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9541 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
9542 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9544 "src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#udp-src-port#udp-dst-port#"
9545 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
9546 "sctp-veri-tag#fld-1st#fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#"
9547 "fld-7th#fld-8th#none");
9548 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
9549 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
9550 select, "select#add");
9552 cmdline_parse_inst_t cmd_set_fdir_input_set = {
9553 .f = cmd_set_fdir_input_set_parsed,
9555 .help_str = "set_fdir_input_set <port_id> "
9556 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|ipv6-frag|"
9557 "ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
9558 "src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port|"
9559 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|"
9560 "fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
9561 "fld-7th|fld-8th|none select|add",
9563 (void *)&cmd_set_fdir_input_set_cmd,
9564 (void *)&cmd_set_fdir_input_set_port_id,
9565 (void *)&cmd_set_fdir_input_set_flow_type,
9566 (void *)&cmd_set_fdir_input_set_field,
9567 (void *)&cmd_set_fdir_input_set_select,
9572 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9573 struct cmd_mcast_addr_result {
9574 cmdline_fixed_string_t mcast_addr_cmd;
9575 cmdline_fixed_string_t what;
9577 struct ether_addr mc_addr;
9580 static void cmd_mcast_addr_parsed(void *parsed_result,
9581 __attribute__((unused)) struct cmdline *cl,
9582 __attribute__((unused)) void *data)
9584 struct cmd_mcast_addr_result *res = parsed_result;
9586 if (!is_multicast_ether_addr(&res->mc_addr)) {
9587 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
9588 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
9589 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
9590 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
9593 if (strcmp(res->what, "add") == 0)
9594 mcast_addr_add(res->port_num, &res->mc_addr);
9596 mcast_addr_remove(res->port_num, &res->mc_addr);
9599 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9600 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9601 mcast_addr_cmd, "mcast_addr");
9602 cmdline_parse_token_string_t cmd_mcast_addr_what =
9603 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9605 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9606 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
9607 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9610 cmdline_parse_inst_t cmd_mcast_addr = {
9611 .f = cmd_mcast_addr_parsed,
9613 .help_str = "mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X",
9615 (void *)&cmd_mcast_addr_cmd,
9616 (void *)&cmd_mcast_addr_what,
9617 (void *)&cmd_mcast_addr_portnum,
9618 (void *)&cmd_mcast_addr_addr,
9623 /* ******************************************************************************** */
9625 /* list of instructions */
9626 cmdline_parse_ctx_t main_ctx[] = {
9627 (cmdline_parse_inst_t *)&cmd_help_brief,
9628 (cmdline_parse_inst_t *)&cmd_help_long,
9629 (cmdline_parse_inst_t *)&cmd_quit,
9630 (cmdline_parse_inst_t *)&cmd_showport,
9631 (cmdline_parse_inst_t *)&cmd_showqueue,
9632 (cmdline_parse_inst_t *)&cmd_showportall,
9633 (cmdline_parse_inst_t *)&cmd_showcfg,
9634 (cmdline_parse_inst_t *)&cmd_start,
9635 (cmdline_parse_inst_t *)&cmd_start_tx_first,
9636 (cmdline_parse_inst_t *)&cmd_set_link_up,
9637 (cmdline_parse_inst_t *)&cmd_set_link_down,
9638 (cmdline_parse_inst_t *)&cmd_reset,
9639 (cmdline_parse_inst_t *)&cmd_set_numbers,
9640 (cmdline_parse_inst_t *)&cmd_set_txpkts,
9641 (cmdline_parse_inst_t *)&cmd_set_txsplit,
9642 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
9643 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
9644 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
9645 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
9646 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
9647 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
9648 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
9649 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
9650 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
9651 (cmdline_parse_inst_t *)&cmd_set_link_check,
9652 #ifdef RTE_NIC_BYPASS
9653 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
9654 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
9655 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
9656 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
9658 #ifdef RTE_LIBRTE_PMD_BOND
9659 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
9660 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
9661 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
9662 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
9663 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
9664 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
9665 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
9666 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
9667 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
9669 (cmdline_parse_inst_t *)&cmd_vlan_offload,
9670 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
9671 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
9672 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
9673 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
9674 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
9675 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
9676 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
9677 (cmdline_parse_inst_t *)&cmd_csum_set,
9678 (cmdline_parse_inst_t *)&cmd_csum_show,
9679 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
9680 (cmdline_parse_inst_t *)&cmd_tso_set,
9681 (cmdline_parse_inst_t *)&cmd_tso_show,
9682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
9683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
9684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
9685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
9686 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
9687 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
9688 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
9689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
9690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
9691 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
9692 (cmdline_parse_inst_t *)&cmd_config_dcb,
9693 (cmdline_parse_inst_t *)&cmd_read_reg,
9694 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
9695 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
9696 (cmdline_parse_inst_t *)&cmd_write_reg,
9697 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
9698 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
9699 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
9700 (cmdline_parse_inst_t *)&cmd_stop,
9701 (cmdline_parse_inst_t *)&cmd_mac_addr,
9702 (cmdline_parse_inst_t *)&cmd_set_qmap,
9703 (cmdline_parse_inst_t *)&cmd_operate_port,
9704 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
9705 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
9706 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
9707 (cmdline_parse_inst_t *)&cmd_config_speed_all,
9708 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
9709 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
9710 (cmdline_parse_inst_t *)&cmd_config_mtu,
9711 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
9712 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
9713 (cmdline_parse_inst_t *)&cmd_config_rss,
9714 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
9715 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
9716 (cmdline_parse_inst_t *)&cmd_showport_reta,
9717 (cmdline_parse_inst_t *)&cmd_config_burst,
9718 (cmdline_parse_inst_t *)&cmd_config_thresh,
9719 (cmdline_parse_inst_t *)&cmd_config_threshold,
9720 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
9721 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
9722 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
9723 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
9724 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
9725 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
9726 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
9727 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
9728 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
9729 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
9730 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
9731 (cmdline_parse_inst_t *)&cmd_global_config,
9732 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
9733 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
9734 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
9735 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
9736 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
9737 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
9738 (cmdline_parse_inst_t *)&cmd_dump,
9739 (cmdline_parse_inst_t *)&cmd_dump_one,
9740 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
9741 (cmdline_parse_inst_t *)&cmd_syn_filter,
9742 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
9743 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
9744 (cmdline_parse_inst_t *)&cmd_flex_filter,
9745 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
9746 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
9747 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
9748 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
9749 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
9750 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
9751 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
9752 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
9753 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
9754 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
9755 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
9756 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
9757 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
9758 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
9759 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
9760 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
9761 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
9762 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
9763 (cmdline_parse_inst_t *)&cmd_mcast_addr,
9767 /* prompt function, called from main on MASTER lcore */
9771 /* initialize non-constant commands */
9772 cmd_set_fwd_mode_init();
9774 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
9775 if (testpmd_cl == NULL)
9777 cmdline_interact(testpmd_cl);
9778 cmdline_stdin_exit(testpmd_cl);
9784 if (testpmd_cl != NULL)
9785 cmdline_quit(testpmd_cl);
9789 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
9791 if (id == (portid_t)RTE_PORT_ALL) {
9794 FOREACH_PORT(pid, ports) {
9795 /* check if need_reconfig has been set to 1 */
9796 if (ports[pid].need_reconfig == 0)
9797 ports[pid].need_reconfig = dev;
9798 /* check if need_reconfig_queues has been set to 1 */
9799 if (ports[pid].need_reconfig_queues == 0)
9800 ports[pid].need_reconfig_queues = queue;
9802 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
9803 /* check if need_reconfig has been set to 1 */
9804 if (ports[id].need_reconfig == 0)
9805 ports[id].need_reconfig = dev;
9806 /* check if need_reconfig_queues has been set to 1 */
9807 if (ports[id].need_reconfig_queues == 0)
9808 ports[id].need_reconfig_queues = queue;
9812 #ifdef RTE_NIC_BYPASS
9813 #include <rte_pci_dev_ids.h>
9815 bypass_is_supported(portid_t port_id)
9817 struct rte_port *port;
9818 struct rte_pci_id *pci_id;
9820 if (port_id_is_invalid(port_id, ENABLED_WARN))
9823 /* Get the device id. */
9824 port = &ports[port_id];
9825 pci_id = &port->dev_info.pci_dev->id;
9827 /* Check if NIC supports bypass. */
9828 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
9832 printf("\tBypass not supported for port_id = %d.\n", port_id);