/*-
* BSD LICENSE
*
* Copyright(c) 2010-2015 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
#include "testpmd.h"
static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
#ifdef RTE_NIC_BYPASS
uint8_t bypass_is_supported(portid_t port_id);
#endif
/* *** 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"
" in mac_retry forwarding mode.\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"
"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"
"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 tpid (value) (port_id)\n"
" Set the outer 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"
"rx_vlan set tpid (value) (port_id)\n"
" Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"
"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
"(inner_vlan) (vxlan|nvgre) (filter_type) (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) (filter_type) (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"
" the forward engine (vxlan, gre and ipip are supported)\n"
" Please check the NIC datasheet for HW limits.\n\n"
"csum parse-tunnel (on|off) (tx_port_id)\n"
" If disabled, treat tunnel packets as non-tunneled"
" packets (treat inner headers as payload). The port\n"
" argument is the port used for TX in csum forward"
" engine.\n\n"
"csum show (port_id)\n"
" Display tx checksum offload configuration\n\n"
"tso set (segsize) (portid)\n"
" Enable TCP Segmentation Offload in csum forward"
" engine.\n"
" Please check the NIC datasheet for HW limits.\n\n"
"tso show (portid)"
" Display the status of TCP Segmentation Offload.\n\n"
"set fwd (%s)\n"
" Set packet forwarding mode.\n\n"
"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
" Add a MAC address on port_id.\n\n"
"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
" Remove a MAC address from port_id.\n\n"
"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
" Add a MAC address for a VF on the port.\n\n"
"set port (port_id) uta (mac_address|all) (on|off)\n"
" Add/Remove a or all unicast hash filter(s)"
"from port X.\n\n"
"set promisc (port_id|all) (on|off)\n"
" Set the promiscuous mode on port_id, or all.\n\n"
"set allmulti (port_id|all) (on|off)\n"
" Set the allmulti mode on port_id, or all.\n\n"
"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
" (on|off) autoneg (on|off) (port_id)\n"
"set flow_ctrl rx (on|off) (portid)\n"
"set flow_ctrl tx (on|off) (portid)\n"
"set flow_ctrl high_water (high_water) (portid)\n"
"set flow_ctrl low_water (low_water) (portid)\n"
"set flow_ctrl pause_time (pause_time) (portid)\n"
"set flow_ctrl send_xon (send_xon) (portid)\n"
"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
"set flow_ctrl autoneg (on|off) (port_id)\n"
" Set the link flow control parameter on a port.\n\n"
"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
" (low_water) (pause_time) (priority) (port_id)\n"
" Set the priority flow control parameter on a"
" port.\n\n"
"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
" Set statistics mapping (qmapping 0..15) for RX/TX"
" queue on port.\n"
" e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
" on port 0 to mapping 5.\n\n"
"set port (port_id) vf (vf_id) rx|tx on|off\n"
" Enable/Disable a VF receive/tranmit from a port\n\n"
"set port (port_id) vf (vf_id) (mac_addr)"
" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
" Add/Remove unicast or multicast MAC addr filter"
" for a VF.\n\n"
"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
"|MPE) (on|off)\n"
" AUPE:accepts untagged VLAN;"
"ROPE:accept unicast hash\n\n"
" BAM:accepts broadcast packets;"
"MPE:accepts all multicast packets\n\n"
" Enable/Disable a VF receive mode of a port\n\n"
"set port (port_id) queue (queue_id) rate (rate_num)\n"
" Set rate limit for a queue of a port\n\n"
"set port (port_id) vf (vf_id) rate (rate_num) "
"queue_mask (queue_mask_value)\n"
" Set rate limit for queues in VF of a port\n\n"
"set port (port_id) mirror-rule (rule_id)"
" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
" Set pool or vlan type mirror rule on a port.\n"
" e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
" dst-pool 0 on' enable mirror traffic with vlan 0,1"
" to pool 0.\n\n"
"set port (port_id) mirror-rule (rule_id)"
" (uplink-mirror|downlink-mirror) dst-pool"
" (pool_id) (on|off)\n"
" Set uplink or downlink type mirror rule on a port.\n"
" e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
" 0 on' enable mirror income traffic to pool 0.\n\n"
"reset port (port_id) mirror-rule (rule_id)\n"
" Reset a mirror rule.\n\n"
"set flush_rx (on|off)\n"
" Flush (default) or don't flush RX streams before"
" forwarding. Mainly used with PCAP drivers.\n\n"
#ifdef RTE_NIC_BYPASS
"set bypass mode (normal|bypass|isolate) (port_id)\n"
" Set the bypass mode for the lowest port on bypass enabled"
" NIC.\n\n"
"set bypass event (timeout|os_on|os_off|power_on|power_off) "
"mode (normal|bypass|isolate) (port_id)\n"
" Set the event required to initiate specified bypass mode for"
" the lowest port on a bypass enabled NIC where:\n"
" timeout = enable bypass after watchdog timeout.\n"
" os_on = enable bypass when OS/board is powered on.\n"
" os_off = enable bypass when OS/board is powered off.\n"
" power_on = enable bypass when power supply is turned on.\n"
" power_off = enable bypass when power supply is turned off."
"\n\n"
"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
" Set the bypass watchdog timeout to 'n' seconds"
" where 0 = instant.\n\n"
"show bypass config (port_id)\n"
" Show the bypass configuration for a bypass enabled NIC"
" using the lowest port on the NIC.\n\n"
#endif
#ifdef RTE_LIBRTE_PMD_BOND
"create bonded device (mode) (socket)\n"
" Create a new bonded device with specific bonding mode and socket.\n\n"
"add bonding slave (slave_id) (port_id)\n"
" Add a slave device to a bonded device.\n\n"
"remove bonding slave (slave_id) (port_id)\n"
" Remove a slave device from a bonded device.\n\n"
"set bonding mode (value) (port_id)\n"
" Set the bonding mode on a bonded device.\n\n"
"set bonding primary (slave_id) (port_id)\n"
" Set the primary slave for a bonded device.\n\n"
"show bonding config (port_id)\n"
" Show the bonding config for port_id.\n\n"
"set bonding mac_addr (port_id) (address)\n"
" Set the MAC address of a bonded device.\n\n"
"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
" Set the transmit balance policy for bonded device running in balance mode.\n\n"
"set bonding mon_period (port_id) (value)\n"
" Set the bonding link status monitoring polling period in ms.\n\n"
#endif
"set link-up port (port_id)\n"
" Set link up for a port.\n\n"
"set link-down port (port_id)\n"
" Set link down for a port.\n\n"
, list_pkt_forwarding_modes()
);
}
if (show_all || !strcmp(res->section, "ports")) {
cmdline_printf(
cl,
"\n"
"Port Operations:\n"
"----------------\n\n"
"port start (port_id|all)\n"
" Start all ports or port_id.\n\n"
"port stop (port_id|all)\n"
" Stop all ports or port_id.\n\n"
"port close (port_id|all)\n"
" Close all ports or port_id.\n\n"
"port attach (ident)\n"
" Attach physical or virtual dev by pci address or virtual device name\n\n"
"port detach (port_id)\n"
" Detach physical or virtual dev by port_id\n\n"
"port config (port_id|all)"
" speed (10|100|1000|10000|40000|auto)"
" duplex (half|full|auto)\n"
" Set speed and duplex for all ports or port_id\n\n"
"port config all (rxq|txq|rxd|txd) (value)\n"
" Set number for rxq/txq/rxd/txd.\n\n"
"port config all max-pkt-len (value)\n"
" Set the max packet length.\n\n"
"port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
"hw-vlan-strip|hw-vlan-extend|drop-en)"
" (on|off)\n"
" Set crc-strip/rx-checksum/hardware-vlan/drop_en"
" for ports.\n\n"
"port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
" Set the RSS mode.\n\n"
"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
" Set the RSS redirection table.\n\n"
"port config (port_id) dcb vt (on|off) (traffic_class)"
" pfc (on|off)\n"
" Set the DCB mode.\n\n"
"port config all burst (value)\n"
" Set the number of packets per burst.\n\n"
"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
" (value)\n"
" Set the ring prefetch/host/writeback threshold"
" for tx/rx queue.\n\n"
"port config all (txfreet|txrst|rxfreet) (value)\n"
" Set free threshold for rx/tx, or set"
" tx rs bit threshold.\n\n"
"port config mtu X value\n"
" Set the MTU of port X to a given value\n\n"
"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
" Start/stop a rx/tx queue of port X. Only take effect"
" when port X is started\n"
);
}
if (show_all || !strcmp(res->section, "registers")) {
cmdline_printf(
cl,
"\n"
"Registers:\n"
"----------\n\n"
"read reg (port_id) (address)\n"
" Display value of a port register.\n\n"
"read regfield (port_id) (address) (bit_x) (bit_y)\n"
" Display a port register bit field.\n\n"
"read regbit (port_id) (address) (bit_x)\n"
" Display a single port register bit.\n\n"
"write reg (port_id) (address) (value)\n"
" Set value of a port register.\n\n"
"write regfield (port_id) (address) (bit_x) (bit_y)"
" (value)\n"
" Set bit field of a port register.\n\n"
"write regbit (port_id) (address) (bit_x) (value)\n"
" Set single bit value of a port register.\n\n"
);
}
if (show_all || !strcmp(res->section, "filters")) {
cmdline_printf(
cl,
"\n"
"filters:\n"
"--------\n\n"
"ethertype_filter (port_id) (add|del)"
" (mac_addr|mac_ignr) (mac_address) ethertype"
" (ether_type) (drop|fwd) queue (queue_id)\n"
" Add/Del an ethertype filter.\n\n"
"2tuple_filter (port_id) (add|del)"
" dst_port (dst_port_value) protocol (protocol_value)"
" mask (mask_value) tcp_flags (tcp_flags_value)"
" priority (prio_value) queue (queue_id)\n"
" Add/Del a 2tuple filter.\n\n"
"5tuple_filter (port_id) (add|del)"
" dst_ip (dst_address) src_ip (src_address)"
" dst_port (dst_port_value) src_port (src_port_value)"
" protocol (protocol_value)"
" mask (mask_value) tcp_flags (tcp_flags_value)"
" priority (prio_value) queue (queue_id)\n"
" Add/Del a 5tuple filter.\n\n"
"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
" Add/Del syn filter.\n\n"
"flex_filter (port_id) (add|del) len (len_value)"
" bytes (bytes_value) mask (mask_value)"
" priority (prio_value) queue (queue_id)\n"
" Add/Del a flex filter.\n\n"
"flow_director_filter (port_id) mode IP (add|del|update)"
" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
" src (src_ip_address) dst (dst_ip_address)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
" Add/Del an IP type flow director filter.\n\n"
"flow_director_filter (port_id) mode IP (add|del|update)"
" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
" Add/Del an UDP/TCP type flow director filter.\n\n"
"flow_director_filter (port_id) mode IP (add|del|update)"
" flow (ipv4-sctp|ipv6-sctp)"
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
" tag (verification_tag) vlan (vlan_value)"
" flexbytes (flexbytes_value) (drop|fwd)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
" Add/Del a SCTP type flow director filter.\n\n"
"flow_director_filter (port_id) mode IP (add|del|update)"
" flow l2_payload ether (ethertype)"
" flexbytes (flexbytes_value) (drop|fwd)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
" Add/Del a l2 payload type flow director filter.\n\n"
"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
" mac (mac_address) vlan (vlan_value)"
" flexbytes (flexbytes_value) (drop|fwd)"
" queue (queue_id) fd_id (fd_id_value)\n"
" Add/Del a MAC-VLAN flow director filter.\n\n"
"flow_director_filter (port_id) mode Tunnel (add|del|update)"
" mac (mac_address) vlan (vlan_value)"
" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
" flexbytes (flexbytes_value) (drop|fwd)"
" queue (queue_id) fd_id (fd_id_value)\n"
" Add/Del a Tunnel flow director filter.\n\n"
"flush_flow_director (port_id)\n"
" Flush all flow director entries of a device.\n\n"
"flow_director_mask (port_id) mode IP vlan (vlan_value)"
" src_mask (ipv4_src) (ipv6_src) (src_port)"
" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
" Set flow director IP mask.\n\n"
"flow_director_mask (port_id) mode MAC-VLAN"
" vlan (vlan_value) mac (mac_value)\n"
" Set flow director MAC-VLAN mask.\n\n"
"flow_director_mask (port_id) mode Tunnel"
" vlan (vlan_value) mac (mac_value)"
" tunnel-type (tunnel_type_value)"
" tunnel-id (tunnel_id_value)\n"
" Set flow director Tunnel mask.\n\n"
"flow_director_flex_mask (port_id)"
" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
" (mask)\n"
" Configure mask of flex payload.\n\n"
"flow_director_flex_payload (port_id)"
" (raw|l2|l3|l4) (config)\n"
" Configure flex payload selection.\n\n"
"get_sym_hash_ena_per_port (port_id)\n"
" get symmetric hash enable configuration per port.\n\n"
"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
" set symmetric hash enable configuration per port"
" to enable or disable.\n\n"
"get_hash_global_config (port_id)\n"
" Get the global configurations of hash filters.\n\n"
"set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
" (enable|disable)\n"
" Set the global configurations of hash filters.\n\n"
"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
"l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
"dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
"ipv6-next-header|udp-src-port|udp-dst-port|"
"tcp-src-port|tcp-dst-port|sctp-src-port|"
"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
"fld-8th|none) (select|add)\n"
" Set the input set for hash.\n\n"
"set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
"l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
"udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
"sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
"fld-8th|none) (select|add)\n"
" Set the input set for FDir.\n\n"
);
}
}
cmdline_parse_token_string_t cmd_help_long_help =
TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
cmdline_parse_token_string_t cmd_help_long_section =
TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
"all#control#display#config#"
"ports#registers#filters");
cmdline_parse_inst_t cmd_help_long = {
.f = cmd_help_long_parsed,
.data = NULL,
.help_str = "show help",
.tokens = {
(void *)&cmd_help_long_help,
(void *)&cmd_help_long_section,
NULL,
},
};
/* *** start/stop/close all ports *** */
struct cmd_operate_port_result {
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t name;
cmdline_fixed_string_t value;
};
static void cmd_operate_port_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_operate_port_result *res = parsed_result;
if (!strcmp(res->name, "start"))
start_port(RTE_PORT_ALL);
else if (!strcmp(res->name, "stop"))
stop_port(RTE_PORT_ALL);
else if (!strcmp(res->name, "close"))
close_port(RTE_PORT_ALL);
else
printf("Unknown parameter\n");
}
cmdline_parse_token_string_t cmd_operate_port_all_cmd =
TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
"port");
cmdline_parse_token_string_t cmd_operate_port_all_port =
TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
"start#stop#close");
cmdline_parse_token_string_t cmd_operate_port_all_all =
TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
cmdline_parse_inst_t cmd_operate_port = {
.f = cmd_operate_port_parsed,
.data = NULL,
.help_str = "port start|stop|close all: start/stop/close all ports",
.tokens = {
(void *)&cmd_operate_port_all_cmd,
(void *)&cmd_operate_port_all_port,
(void *)&cmd_operate_port_all_all,
NULL,
},
};
/* *** start/stop/close specific port *** */
struct cmd_operate_specific_port_result {
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t name;
uint8_t value;
};
static void cmd_operate_specific_port_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_operate_specific_port_result *res = parsed_result;
if (!strcmp(res->name, "start"))
start_port(res->value);
else if (!strcmp(res->name, "stop"))
stop_port(res->value);
else if (!strcmp(res->name, "close"))
close_port(res->value);
else
printf("Unknown parameter\n");
}
cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
keyword, "port");
cmdline_parse_token_string_t cmd_operate_specific_port_port =
TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
name, "start#stop#close");
cmdline_parse_token_num_t cmd_operate_specific_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
value, UINT8);
cmdline_parse_inst_t cmd_operate_specific_port = {
.f = cmd_operate_specific_port_parsed,
.data = NULL,
.help_str = "port start|stop|close X: start/stop/close port X",
.tokens = {
(void *)&cmd_operate_specific_port_cmd,
(void *)&cmd_operate_specific_port_port,
(void *)&cmd_operate_specific_port_id,
NULL,
},
};
/* *** attach a specified port *** */
struct cmd_operate_attach_port_result {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t identifier;
};
static void cmd_operate_attach_port_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_operate_attach_port_result *res = parsed_result;
if (!strcmp(res->keyword, "attach"))
attach_port(res->identifier);
else
printf("Unknown parameter\n");
}
cmdline_parse_token_string_t cmd_operate_attach_port_port =
TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
port, "port");
cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
keyword, "attach");
cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
identifier, NULL);
cmdline_parse_inst_t cmd_operate_attach_port = {
.f = cmd_operate_attach_port_parsed,
.data = NULL,
.help_str = "port attach identifier, "
"identifier: pci address or virtual dev name",
.tokens = {
(void *)&cmd_operate_attach_port_port,
(void *)&cmd_operate_attach_port_keyword,
(void *)&cmd_operate_attach_port_identifier,
NULL,
},
};
/* *** detach a specified port *** */
struct cmd_operate_detach_port_result {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
uint8_t port_id;
};
static void cmd_operate_detach_port_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_operate_detach_port_result *res = parsed_result;
if (!strcmp(res->keyword, "detach"))
detach_port(res->port_id);
else
printf("Unknown parameter\n");
}
cmdline_parse_token_string_t cmd_operate_detach_port_port =
TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
port, "port");
cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
keyword, "detach");
cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
port_id, UINT8);
cmdline_parse_inst_t cmd_operate_detach_port = {
.f = cmd_operate_detach_port_parsed,
.data = NULL,
.help_str = "port detach port_id",
.tokens = {
(void *)&cmd_operate_detach_port_port,
(void *)&cmd_operate_detach_port_keyword,
(void *)&cmd_operate_detach_port_port_id,
NULL,
},
};
/* *** configure speed for all ports *** */
struct cmd_config_speed_all {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t all;
cmdline_fixed_string_t item1;
cmdline_fixed_string_t item2;
cmdline_fixed_string_t value1;
cmdline_fixed_string_t value2;
};
static void
cmd_config_speed_all_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_speed_all *res = parsed_result;
uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
uint16_t link_duplex = 0;
portid_t pid;
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
if (!strcmp(res->value1, "10"))
link_speed = ETH_LINK_SPEED_10;
else if (!strcmp(res->value1, "100"))
link_speed = ETH_LINK_SPEED_100;
else if (!strcmp(res->value1, "1000"))
link_speed = ETH_LINK_SPEED_1000;
else if (!strcmp(res->value1, "10000"))
link_speed = ETH_LINK_SPEED_10G;
else if (!strcmp(res->value1, "40000"))
link_speed = ETH_LINK_SPEED_40G;
else if (!strcmp(res->value1, "auto"))
link_speed = ETH_LINK_SPEED_AUTONEG;
else {
printf("Unknown parameter\n");
return;
}
if (!strcmp(res->value2, "half"))
link_duplex = ETH_LINK_HALF_DUPLEX;
else if (!strcmp(res->value2, "full"))
link_duplex = ETH_LINK_FULL_DUPLEX;
else if (!strcmp(res->value2, "auto"))
link_duplex = ETH_LINK_AUTONEG_DUPLEX;
else {
printf("Unknown parameter\n");
return;
}
FOREACH_PORT(pid, ports) {
ports[pid].dev_conf.link_speed = link_speed;
ports[pid].dev_conf.link_duplex = link_duplex;
}
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
}
cmdline_parse_token_string_t cmd_config_speed_all_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
cmdline_parse_token_string_t cmd_config_speed_all_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
"config");
cmdline_parse_token_string_t cmd_config_speed_all_all =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
cmdline_parse_token_string_t cmd_config_speed_all_item1 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
cmdline_parse_token_string_t cmd_config_speed_all_value1 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
"10#100#1000#10000#40000#auto");
cmdline_parse_token_string_t cmd_config_speed_all_item2 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
cmdline_parse_token_string_t cmd_config_speed_all_value2 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
"half#full#auto");
cmdline_parse_inst_t cmd_config_speed_all = {
.f = cmd_config_speed_all_parsed,
.data = NULL,
.help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
"half|full|auto",
.tokens = {
(void *)&cmd_config_speed_all_port,
(void *)&cmd_config_speed_all_keyword,
(void *)&cmd_config_speed_all_all,
(void *)&cmd_config_speed_all_item1,
(void *)&cmd_config_speed_all_value1,
(void *)&cmd_config_speed_all_item2,
(void *)&cmd_config_speed_all_value2,
NULL,
},
};
/* *** configure speed for specific port *** */
struct cmd_config_speed_specific {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
uint8_t id;
cmdline_fixed_string_t item1;
cmdline_fixed_string_t item2;
cmdline_fixed_string_t value1;
cmdline_fixed_string_t value2;
};
static void
cmd_config_speed_specific_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_speed_specific *res = parsed_result;
uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
uint16_t link_duplex = 0;
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
if (port_id_is_invalid(res->id, ENABLED_WARN))
return;
if (!strcmp(res->value1, "10"))
link_speed = ETH_LINK_SPEED_10;
else if (!strcmp(res->value1, "100"))
link_speed = ETH_LINK_SPEED_100;
else if (!strcmp(res->value1, "1000"))
link_speed = ETH_LINK_SPEED_1000;
else if (!strcmp(res->value1, "10000"))
link_speed = ETH_LINK_SPEED_10000;
else if (!strcmp(res->value1, "40000"))
link_speed = ETH_LINK_SPEED_40G;
else if (!strcmp(res->value1, "auto"))
link_speed = ETH_LINK_SPEED_AUTONEG;
else {
printf("Unknown parameter\n");
return;
}
if (!strcmp(res->value2, "half"))
link_duplex = ETH_LINK_HALF_DUPLEX;
else if (!strcmp(res->value2, "full"))
link_duplex = ETH_LINK_FULL_DUPLEX;
else if (!strcmp(res->value2, "auto"))
link_duplex = ETH_LINK_AUTONEG_DUPLEX;
else {
printf("Unknown parameter\n");
return;
}
ports[res->id].dev_conf.link_speed = link_speed;
ports[res->id].dev_conf.link_duplex = link_duplex;
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
}
cmdline_parse_token_string_t cmd_config_speed_specific_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
"port");
cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
"config");
cmdline_parse_token_num_t cmd_config_speed_specific_id =
TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
"speed");
cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
"10#100#1000#10000#40000#auto");
cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
"duplex");
cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
"half#full#auto");
cmdline_parse_inst_t cmd_config_speed_specific = {
.f = cmd_config_speed_specific_parsed,
.data = NULL,
.help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
"half|full|auto",
.tokens = {
(void *)&cmd_config_speed_specific_port,
(void *)&cmd_config_speed_specific_keyword,
(void *)&cmd_config_speed_specific_id,
(void *)&cmd_config_speed_specific_item1,
(void *)&cmd_config_speed_specific_value1,
(void *)&cmd_config_speed_specific_item2,
(void *)&cmd_config_speed_specific_value2,
NULL,
},
};
/* *** configure txq/rxq, txd/rxd *** */
struct cmd_config_rx_tx {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t all;
cmdline_fixed_string_t name;
uint16_t value;
};
static void
cmd_config_rx_tx_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_rx_tx *res = parsed_result;
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
if (!strcmp(res->name, "rxq")) {
if (res->value <= 0) {
printf("rxq %d invalid - must be > 0\n", res->value);
return;
}
nb_rxq = res->value;
}
else if (!strcmp(res->name, "txq")) {
if (res->value <= 0) {
printf("txq %d invalid - must be > 0\n", res->value);
return;
}
nb_txq = res->value;
}
else if (!strcmp(res->name, "rxd")) {
if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
printf("rxd %d invalid - must be > 0 && <= %d\n",
res->value, RTE_TEST_RX_DESC_MAX);
return;
}
nb_rxd = res->value;
} else if (!strcmp(res->name, "txd")) {
if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
printf("txd %d invalid - must be > 0 && <= %d\n",
res->value, RTE_TEST_TX_DESC_MAX);
return;
}
nb_txd = res->value;
} else {
printf("Unknown parameter\n");
return;
}
init_port_config();
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
}
cmdline_parse_token_string_t cmd_config_rx_tx_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
cmdline_parse_token_string_t cmd_config_rx_tx_all =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
cmdline_parse_token_string_t cmd_config_rx_tx_name =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
"rxq#txq#rxd#txd");
cmdline_parse_token_num_t cmd_config_rx_tx_value =
TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
cmdline_parse_inst_t cmd_config_rx_tx = {
.f = cmd_config_rx_tx_parsed,
.data = NULL,
.help_str = "port config all rxq|txq|rxd|txd value",
.tokens = {
(void *)&cmd_config_rx_tx_port,
(void *)&cmd_config_rx_tx_keyword,
(void *)&cmd_config_rx_tx_all,
(void *)&cmd_config_rx_tx_name,
(void *)&cmd_config_rx_tx_value,
NULL,
},
};
/* *** config max packet length *** */
struct cmd_config_max_pkt_len_result {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t all;
cmdline_fixed_string_t name;
uint32_t value;
};
static void
cmd_config_max_pkt_len_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_max_pkt_len_result *res = parsed_result;
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
if (!strcmp(res->name, "max-pkt-len")) {
if (res->value < ETHER_MIN_LEN) {
printf("max-pkt-len can not be less than %d\n",
ETHER_MIN_LEN);
return;
}
if (res->value == rx_mode.max_rx_pkt_len)
return;
rx_mode.max_rx_pkt_len = res->value;
if (res->value > ETHER_MAX_LEN)
rx_mode.jumbo_frame = 1;
else
rx_mode.jumbo_frame = 0;
} else {
printf("Unknown parameter\n");
return;
}
init_port_config();
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
}
cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
"port");
cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
"config");
cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
"all");
cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
"max-pkt-len");
cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
UINT32);
cmdline_parse_inst_t cmd_config_max_pkt_len = {
.f = cmd_config_max_pkt_len_parsed,
.data = NULL,
.help_str = "port config all max-pkt-len value",
.tokens = {
(void *)&cmd_config_max_pkt_len_port,
(void *)&cmd_config_max_pkt_len_keyword,
(void *)&cmd_config_max_pkt_len_all,
(void *)&cmd_config_max_pkt_len_name,
(void *)&cmd_config_max_pkt_len_value,
NULL,
},
};
/* *** configure port MTU *** */
struct cmd_config_mtu_result {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t mtu;
uint8_t port_id;
uint16_t value;
};
static void
cmd_config_mtu_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_mtu_result *res = parsed_result;
if (res->value < ETHER_MIN_LEN) {
printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
return;
}
port_mtu_set(res->port_id, res->value);
}
cmdline_parse_token_string_t cmd_config_mtu_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
"port");
cmdline_parse_token_string_t cmd_config_mtu_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
"config");
cmdline_parse_token_string_t cmd_config_mtu_mtu =
TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
"mtu");
cmdline_parse_token_num_t cmd_config_mtu_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
cmdline_parse_token_num_t cmd_config_mtu_value =
TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
cmdline_parse_inst_t cmd_config_mtu = {
.f = cmd_config_mtu_parsed,
.data = NULL,
.help_str = "port config mtu value",
.tokens = {
(void *)&cmd_config_mtu_port,
(void *)&cmd_config_mtu_keyword,
(void *)&cmd_config_mtu_mtu,
(void *)&cmd_config_mtu_port_id,
(void *)&cmd_config_mtu_value,
NULL,
},
};
/* *** configure rx mode *** */
struct cmd_config_rx_mode_flag {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t all;
cmdline_fixed_string_t name;
cmdline_fixed_string_t value;
};
static void
cmd_config_rx_mode_flag_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_rx_mode_flag *res = parsed_result;
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
if (!strcmp(res->name, "crc-strip")) {
if (!strcmp(res->value, "on"))
rx_mode.hw_strip_crc = 1;
else if (!strcmp(res->value, "off"))
rx_mode.hw_strip_crc = 0;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "rx-cksum")) {
if (!strcmp(res->value, "on"))
rx_mode.hw_ip_checksum = 1;
else if (!strcmp(res->value, "off"))
rx_mode.hw_ip_checksum = 0;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "hw-vlan")) {
if (!strcmp(res->value, "on")) {
rx_mode.hw_vlan_filter = 1;
rx_mode.hw_vlan_strip = 1;
}
else if (!strcmp(res->value, "off")) {
rx_mode.hw_vlan_filter = 0;
rx_mode.hw_vlan_strip = 0;
}
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "hw-vlan-filter")) {
if (!strcmp(res->value, "on"))
rx_mode.hw_vlan_filter = 1;
else if (!strcmp(res->value, "off"))
rx_mode.hw_vlan_filter = 0;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "hw-vlan-strip")) {
if (!strcmp(res->value, "on"))
rx_mode.hw_vlan_strip = 1;
else if (!strcmp(res->value, "off"))
rx_mode.hw_vlan_strip = 0;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "hw-vlan-extend")) {
if (!strcmp(res->value, "on"))
rx_mode.hw_vlan_extend = 1;
else if (!strcmp(res->value, "off"))
rx_mode.hw_vlan_extend = 0;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "drop-en")) {
if (!strcmp(res->value, "on"))
rx_drop_en = 1;
else if (!strcmp(res->value, "off"))
rx_drop_en = 0;
else {
printf("Unknown parameter\n");
return;
}
} else {
printf("Unknown parameter\n");
return;
}
init_port_config();
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
}
cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
"config");
cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
"crc-strip#rx-cksum#hw-vlan#"
"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
"on#off");
cmdline_parse_inst_t cmd_config_rx_mode_flag = {
.f = cmd_config_rx_mode_flag_parsed,
.data = NULL,
.help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
"hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
.tokens = {
(void *)&cmd_config_rx_mode_flag_port,
(void *)&cmd_config_rx_mode_flag_keyword,
(void *)&cmd_config_rx_mode_flag_all,
(void *)&cmd_config_rx_mode_flag_name,
(void *)&cmd_config_rx_mode_flag_value,
NULL,
},
};
/* *** configure rss *** */
struct cmd_config_rss {
cmdline_fixed_string_t port;
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t all;
cmdline_fixed_string_t name;
cmdline_fixed_string_t value;
};
static void
cmd_config_rss_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
struct cmd_config_rss *res = parsed_result;
struct rte_eth_rss_conf rss_conf;
uint8_t i;
if (!strcmp(res->value, "all"))
rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
ETH_RSS_UDP | ETH_RSS_SCTP |
ETH_RSS_L2_PAYLOAD;
else if (!strcmp(res->value, "ip"))
rss_conf.rss_hf = ETH_RSS_IP;
else if (!strcmp(res->value, "udp"))
rss_conf.rss_hf = ETH_RSS_UDP;
else if (!strcmp(res->value, "tcp"))
rss_conf.rss_hf = ETH_RSS_TCP;
else if (!strcmp(res->value, "sctp"))
rss_conf.rss_hf = ETH_RSS_SCTP;
else if (!strcmp(res->value, "ether"))
rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
else if (!strcmp(res->value, "none"))
rss_conf.rss_hf = 0;
else {
printf("Unknown parameter\n");
return;
}
rss_conf.rss_key = NULL;
for (i = 0; i < rte_eth_dev_count(); i++)
rte_eth_dev_rss_hash_update(i, &rss_conf);
}
cmdline_parse_token_string_t cmd_config_rss_port =
TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
cmdline_parse_token_string_t cmd_config_rss_keyword =
TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
cmdline_parse_token_string_t cmd_config_rss_all =
TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
cmdline_parse_token_string_t cmd_config_rss_name =
TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
cmdline_parse_token_string_t cmd_config_rss_value =
TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
"all#ip#tcp#udp#sctp#ether#none");
cmdline_parse_inst_t cmd_config_rss = {
.f = cmd_config_rss_parsed,
.data = NULL,
.help_str = "port config all rss all|ip|tcp|udp|sctp|ether|none",
.tokens = {
(void *)&cmd_config_rss_port,
(void *)&cmd_config_rss_keyword,
(void *)&cmd_config_rss_all,
(void *)&cmd_config_rss_name,
(void *)&cmd_config_rss_value,
NULL,
},
};
/* *** configure rss hash key *** */
struct cmd_config_rss_hash_key {
cmdline_fixed_string_t port;
cmdline_fixed_string_t config;
uint8_t port_id;
cmdline_fixed_string_t rss_hash_key;
cmdline_fixed_string_t rss_type;
cmdline_fixed_string_t key;
};
#define RSS_HASH_KEY_LENGTH 40
static uint8_t