/*-
* BSD LICENSE
*
* Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
* Copyright(c) 2014 6WIND S.A.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdarg.h>
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <inttypes.h>
#ifndef __linux__
#ifndef __FreeBSD__
#include <net/socket.h>
#else
#include <sys/socket.h>
#endif
#endif
#include <netinet/in.h>
#include <sys/queue.h>
#include <rte_common.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_cycles.h>
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_malloc.h>
#include <rte_launch.h>
#include <rte_eal.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_interrupts.h>
#include <rte_pci.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_string_fns.h>
#include <rte_devargs.h>
#include <rte_eth_ctrl.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
#include <cmdline_parse_num.h>
#include <cmdline_parse_string.h>
#include <cmdline_parse_ipaddr.h>
#include <cmdline_parse_etheraddr.h>
#include <cmdline_socket.h>
#include <cmdline.h>
#ifdef RTE_LIBRTE_PMD_BOND
#include <rte_eth_bond.h>
#endif
#ifdef RTE_LIBRTE_IXGBE_PMD
#include <rte_pmd_ixgbe.h>
#endif
#include "testpmd.h"
static struct cmdline *testpmd_cl;
static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
/* *** Help command with introduction. *** */
struct cmd_help_brief_result {
cmdline_fixed_string_t help;
};
static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
struct cmdline *cl,
__attribute__((unused)) void *data)
{
cmdline_printf(
cl,
"\n"
"Help is available for the following sections:\n\n"
" help control : Start and stop forwarding.\n"
" help display : Displaying port, stats and config "
"information.\n"
" help config : Configuration information.\n"
" help ports : Configuring ports.\n"
" help registers : Reading and setting port registers.\n"
" help filters : Filters configuration help.\n"
" help all : All of the above sections.\n\n"
);
}
cmdline_parse_token_string_t cmd_help_brief_help =
TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
cmdline_parse_inst_t cmd_help_brief = {
.f = cmd_help_brief_parsed,
.data = NULL,
.help_str = "show help",
.tokens = {
(void *)&cmd_help_brief_help,
NULL,
},
};
/* *** Help command with help sections. *** */
struct cmd_help_long_result {
cmdline_fixed_string_t help;
cmdline_fixed_string_t section;
};
static void cmd_help_long_parsed(void *parsed_result,
struct cmdline *cl,
__attribute__((unused)) void *data)
{
int show_all = 0;
struct cmd_help_long_result *res = parsed_result;
if (!strcmp(res->section, "all"))
show_all = 1;
if (show_all || !strcmp(res->section, "control")) {
cmdline_printf(
cl,
"\n"
"Control forwarding:\n"
"-------------------\n\n"
"start\n"
" Start packet forwarding with current configuration.\n\n"
"start tx_first\n"
" Start packet forwarding with current config"
" after sending one burst of packets.\n\n"
"stop\n"
" Stop packet forwarding, and display accumulated"
" statistics.\n\n"
"quit\n"
" Quit to prompt.\n\n"
);
}
if (show_all || !strcmp(res->section, "display")) {
cmdline_printf(
cl,
"\n"
"Display:\n"
"--------\n\n"
"show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) (port_id|all)\n"
" Display information for port_id, or all.\n\n"
"show port X rss reta (size) (mask0,mask1,...)\n"
" Display the rss redirection table entry indicated"
" by masks on port X. size is used to indicate the"
" hardware supported reta size\n\n"
"show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
"ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
"ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
" Display the RSS hash functions and RSS hash key"
" of port X\n\n"
"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
" Clear information for port_id, or all.\n\n"
"show (rxq|txq) info (port_id) (queue_id)\n"
" Display information for configured RX/TX queue.\n\n"
"show config (rxtx|cores|fwd|txpkts)\n"
" Display the given configuration.\n\n"
"read rxd (port_id) (queue_id) (rxd_id)\n"
" Display an RX descriptor of a port RX queue.\n\n"
"read txd (port_id) (queue_id) (txd_id)\n"
" Display a TX descriptor of a port TX queue.\n\n"
);
}
if (show_all || !strcmp(res->section, "config")) {
cmdline_printf(
cl,
"\n"
"Configuration:\n"
"--------------\n"
"Configuration changes only become active when"
" forwarding is started/restarted.\n\n"
"set default\n"
" Reset forwarding to the default configuration.\n\n"
"set verbose (level)\n"
" Set the debug verbosity level X.\n\n"
"set nbport (num)\n"
" Set number of ports.\n\n"
"set nbcore (num)\n"
" Set number of cores.\n\n"
"set coremask (mask)\n"
" Set the forwarding cores hexadecimal mask.\n\n"
"set portmask (mask)\n"
" Set the forwarding ports hexadecimal mask.\n\n"
"set burst (num)\n"
" Set number of packets per burst.\n\n"
"set burst tx delay (microseconds) retry (num)\n"
" Set the transmit delay time and number of retries,"
" effective when retry is enabled.\n\n"
"set txpkts (x[,y]*)\n"
" Set the length of each segment of TXONLY"
" and optionally CSUM packets.\n\n"
"set txsplit (off|on|rand)\n"
" Set the split policy for the TX packets."
" Right now only applicable for CSUM and TXONLY"
" modes\n\n"
"set corelist (x[,y]*)\n"
" Set the list of forwarding cores.\n\n"
"set portlist (x[,y]*)\n"
" Set the list of forwarding ports.\n\n"
#ifdef RTE_LIBRTE_IXGBE_PMD
"set tx loopback (port_id) (on|off)\n"
" Enable or disable tx loopback.\n\n"
"set all queues drop (port_id) (on|off)\n"
" Set drop enable bit for all queues.\n\n"
"set vf split drop (port_id) (vf_id) (on|off)\n"
" Set split drop enable bit for a VF from the PF.\n\n"
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
" Set MAC antispoof for a VF from the PF.\n\n"
#endif
"vlan set strip (on|off) (port_id)\n"
" Set the VLAN strip on a port.\n\n"
"vlan set stripq (on|off) (port_id,queue_id)\n"
" Set the VLAN strip for a queue on a port.\n\n"
#ifdef RTE_LIBRTE_IXGBE_PMD
"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
" Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
" Set VLAN insert for a VF from the PF.\n\n"
"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
" Set VLAN antispoof for a VF from the PF.\n\n"
#endif
"vlan set filter (on|off) (port_id)\n"
" Set the VLAN filter on a port.\n\n"
"vlan set qinq (on|off) (port_id)\n"
" Set the VLAN QinQ (extended queue in queue)"
" on a port.\n\n"
"vlan set (inner|outer) tpid (value) (port_id)\n"
" Set the VLAN TPID for Packet Filtering on"
" a port\n\n"
"rx_vlan add (vlan_id|all) (port_id)\n"
" Add a vlan_id, or all identifiers, to the set"
" of VLAN identifiers filtered by port_id.\n\n"
"rx_vlan rm (vlan_id|all) (port_id)\n"
" Remove a vlan_id, or all identifiers, from the set"
" of VLAN identifiers filtered by port_id.\n\n"
"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
" Add a vlan_id, to the set of VLAN identifiers"
"filtered for VF(s) from port_id.\n\n"
"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
" Remove a vlan_id, to the set of VLAN identifiers"
"filtered for VF(s) from port_id.\n\n"
"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
" add a tunnel filter of a port.\n\n"
"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
" remove a tunnel filter of a port.\n\n"
"rx_vxlan_port add (udp_port) (port_id)\n"
" Add an UDP port for VXLAN packet filter on a port\n\n"
"rx_vxlan_port rm (udp_port) (port_id)\n"
" Remove an UDP port for VXLAN packet filter on a port\n\n"
"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
" Set hardware insertion of VLAN IDs (single or double VLAN "
"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
"tx_vlan set pvid port_id vlan_id (on|off)\n"
" Set port based TX VLAN insertion.\n\n"
"tx_vlan reset (port_id)\n"
" Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"
"csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
" Select hardware or software calculation of the"
" checksum when transmitting a packet using the"
" csum forward engine.\n"
" ip|udp|tcp|sctp always concern the inner layer.\n"
" outer-ip concerns the outer IP layer in"
" case the packet is recognized as a tunnel packet by"