ethdev: more RSS flags

- i40e RSS flags have been added (and enlarged to 64-bit)
- A new configuration of 'uint8_t rss_key_len' has been added in
  'struct rte_eth_rss_conf' to support different length of RSS keys.
- In each PMD, only the supported flags are masked.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
Signed-off-by: Jing Chen <jing.d.chen@intel.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Jijiang Liu <jijiang.liu@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Heqing Zhu <heqing.zhu@intel.com>
Tested-by: Waterman Cao <waterman.cao@intel.com>
This commit is contained in:
Helin Zhang 2014-06-05 13:08:50 +08:00 committed by Thomas Monjalon
parent 78c7149eb0
commit 8a387fa85f
16 changed files with 158 additions and 47 deletions

View File

@ -1201,9 +1201,9 @@ cmd_config_rss_parsed(void *parsed_result,
uint8_t i;
if (!strcmp(res->value, "ip"))
rss_conf.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
rss_conf.rss_hf = ETH_RSS_IP;
else if (!strcmp(res->value, "udp"))
rss_conf.rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6_UDP;
rss_conf.rss_hf = ETH_RSS_UDP;
else if (!strcmp(res->value, "none"))
rss_conf.rss_hf = 0;
else {

View File

@ -832,10 +832,9 @@ launch_args_parse(int argc, char** argv)
if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
set_pkt_forwarding_mode(optarg);
if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
rss_hf = ETH_RSS_IP;
if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
rss_hf = ETH_RSS_IPV4 |
ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
rss_hf = ETH_RSS_UDP;
if (!strcmp(lgopts[opt_idx].name, "rxq")) {
n = atoi(optarg);
if (n >= 1 && n <= (int) MAX_QUEUE_ID)

View File

@ -250,7 +250,7 @@ uint32_t txq_flags = 0; /* No flags set. */
/*
* Receive Side Scaling (RSS) configuration.
*/
uint16_t rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; /* RSS IP by default. */
uint64_t rss_hf = ETH_RSS_IP; /* RSS IP by default. */
/*
* Port topology configuration

View File

@ -326,7 +326,7 @@ extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS];
extern struct rte_port *ports;
extern struct rte_eth_rxmode rx_mode;
extern uint16_t rss_hf;
extern uint64_t rss_hf;
extern queueid_t nb_rxq;
extern queueid_t nb_txq;

View File

@ -170,7 +170,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -228,7 +228,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -247,7 +247,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -207,7 +207,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -251,7 +251,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -87,7 +87,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -251,7 +251,7 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, uint16_t num_queues)
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -94,7 +94,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {

View File

@ -311,31 +311,116 @@ struct rte_eth_rxmode {
* A structure used to configure the Receive Side Scaling (RSS) feature
* of an Ethernet port.
* If not NULL, the *rss_key* pointer of the *rss_conf* structure points
* to an array of 40 bytes holding the RSS key to use for hashing specific
* header fields of received packets.
* Otherwise, a default random hash key is used by the device driver.
* to an array holding the RSS key to use for hashing specific header
* fields of received packets. The length of this array should be indicated
* by *rss_key_len* below. Otherwise, a default random hash key is used by
* the device driver.
*
* The *rss_key_len* field of the *rss_conf* structure indicates the length
* in bytes of the array pointed by *rss_key*. To be compatible, this length
* will be checked in i40e only. Others assume 40 bytes to be used as before.
*
* The *rss_hf* field of the *rss_conf* structure indicates the different
* types of IPv4/IPv6 packets to which the RSS hashing must be applied.
* Supplying an *rss_hf* equal to zero disables the RSS feature.
*/
struct rte_eth_rss_conf {
uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */
uint16_t rss_hf; /**< Hash functions to apply - see below. */
uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */
uint8_t rss_key_len; /**< hash key length in bytes. */
uint64_t rss_hf; /**< Hash functions to apply - see below. */
};
#define ETH_RSS_IPV4 0x0001 /**< IPv4 packet. */
#define ETH_RSS_IPV4_TCP 0x0002 /**< IPv4/TCP packet. */
#define ETH_RSS_IPV6 0x0004 /**< IPv6 packet. */
#define ETH_RSS_IPV6_EX 0x0008 /**< IPv6 packet with extension headers.*/
#define ETH_RSS_IPV6_TCP 0x0010 /**< IPv6/TCP packet. */
#define ETH_RSS_IPV6_TCP_EX 0x0020 /**< IPv6/TCP with extension headers. */
/* Intel RSS extensions to UDP packets */
#define ETH_RSS_IPV4_UDP 0x0040 /**< IPv4/UDP packet. */
#define ETH_RSS_IPV6_UDP 0x0080 /**< IPv6/UDP packet. */
#define ETH_RSS_IPV6_UDP_EX 0x0100 /**< IPv6/UDP with extension headers. */
/* Supported RSS offloads */
/* for 1G & 10G */
#define ETH_RSS_IPV4_SHIFT 0
#define ETH_RSS_IPV4_TCP_SHIFT 1
#define ETH_RSS_IPV6_SHIFT 2
#define ETH_RSS_IPV6_EX_SHIFT 3
#define ETH_RSS_IPV6_TCP_SHIFT 4
#define ETH_RSS_IPV6_TCP_EX_SHIFT 5
#define ETH_RSS_IPV4_UDP_SHIFT 6
#define ETH_RSS_IPV6_UDP_SHIFT 7
#define ETH_RSS_IPV6_UDP_EX_SHIFT 8
/* for 40G only */
#define ETH_RSS_NONF_IPV4_UDP_SHIFT 31
#define ETH_RSS_NONF_IPV4_TCP_SHIFT 33
#define ETH_RSS_NONF_IPV4_SCTP_SHIFT 34
#define ETH_RSS_NONF_IPV4_OTHER_SHIFT 35
#define ETH_RSS_FRAG_IPV4_SHIFT 36
#define ETH_RSS_NONF_IPV6_UDP_SHIFT 41
#define ETH_RSS_NONF_IPV6_TCP_SHIFT 43
#define ETH_RSS_NONF_IPV6_SCTP_SHIFT 44
#define ETH_RSS_NONF_IPV6_OTHER_SHIFT 45
#define ETH_RSS_FRAG_IPV6_SHIFT 46
#define ETH_RSS_FCOE_OX_SHIFT 48
#define ETH_RSS_FCOE_RX_SHIFT 49
#define ETH_RSS_FCOE_OTHER_SHIFT 50
#define ETH_RSS_L2_PAYLOAD_SHIFT 63
/* for 1G & 10G */
#define ETH_RSS_IPV4 ((uint16_t)1 << ETH_RSS_IPV4_SHIFT)
#define ETH_RSS_IPV4_TCP ((uint16_t)1 << ETH_RSS_IPV4_TCP_SHIFT)
#define ETH_RSS_IPV6 ((uint16_t)1 << ETH_RSS_IPV6_SHIFT)
#define ETH_RSS_IPV6_EX ((uint16_t)1 << ETH_RSS_IPV6_EX_SHIFT)
#define ETH_RSS_IPV6_TCP ((uint16_t)1 << ETH_RSS_IPV6_TCP_SHIFT)
#define ETH_RSS_IPV6_TCP_EX ((uint16_t)1 << ETH_RSS_IPV6_TCP_EX_SHIFT)
#define ETH_RSS_IPV4_UDP ((uint16_t)1 << ETH_RSS_IPV4_UDP_SHIFT)
#define ETH_RSS_IPV6_UDP ((uint16_t)1 << ETH_RSS_IPV6_UDP_SHIFT)
#define ETH_RSS_IPV6_UDP_EX ((uint16_t)1 << ETH_RSS_IPV6_UDP_EX_SHIFT)
/* for 40G only */
#define ETH_RSS_NONF_IPV4_UDP ((uint64_t)1 << ETH_RSS_NONF_IPV4_UDP_SHIFT)
#define ETH_RSS_NONF_IPV4_TCP ((uint64_t)1 << ETH_RSS_NONF_IPV4_TCP_SHIFT)
#define ETH_RSS_NONF_IPV4_SCTP ((uint64_t)1 << ETH_RSS_NONF_IPV4_SCTP_SHIFT)
#define ETH_RSS_NONF_IPV4_OTHER ((uint64_t)1 << ETH_RSS_NONF_IPV4_OTHER_SHIFT)
#define ETH_RSS_FRAG_IPV4 ((uint64_t)1 << ETH_RSS_FRAG_IPV4_SHIFT)
#define ETH_RSS_NONF_IPV6_UDP ((uint64_t)1 << ETH_RSS_NONF_IPV6_UDP_SHIFT)
#define ETH_RSS_NONF_IPV6_TCP ((uint64_t)1 << ETH_RSS_NONF_IPV6_TCP_SHIFT)
#define ETH_RSS_NONF_IPV6_SCTP ((uint64_t)1 << ETH_RSS_NONF_IPV6_SCTP_SHIFT)
#define ETH_RSS_NONF_IPV6_OTHER ((uint64_t)1 << ETH_RSS_NONF_IPV6_OTHER_SHIFT)
#define ETH_RSS_FRAG_IPV6 ((uint64_t)1 << ETH_RSS_FRAG_IPV6_SHIFT)
#define ETH_RSS_FCOE_OX ((uint64_t)1 << ETH_RSS_FCOE_OX_SHIFT) /* not used */
#define ETH_RSS_FCOE_RX ((uint64_t)1 << ETH_RSS_FCOE_RX_SHIFT) /* not used */
#define ETH_RSS_FCOE_OTHER ((uint64_t)1 << ETH_RSS_FCOE_OTHER_SHIFT) /* not used */
#define ETH_RSS_L2_PAYLOAD ((uint64_t)1 << ETH_RSS_L2_PAYLOAD_SHIFT)
#define ETH_RSS_IP ( \
ETH_RSS_IPV4 | \
ETH_RSS_IPV6 | \
ETH_RSS_NONF_IPV4_OTHER | \
ETH_RSS_FRAG_IPV4 | \
ETH_RSS_NONF_IPV6_OTHER | \
ETH_RSS_FRAG_IPV6)
#define ETH_RSS_UDP ( \
ETH_RSS_IPV4 | \
ETH_RSS_IPV6 | \
ETH_RSS_IPV4_UDP | \
ETH_RSS_IPV6_UDP | \
ETH_RSS_IPV6_UDP_EX | \
ETH_RSS_NONF_IPV4_UDP | \
ETH_RSS_NONF_IPV6_UDP)
/**< Mask of valid RSS hash protocols */
#define ETH_RSS_PROTO_MASK ( \
ETH_RSS_IPV4 | \
ETH_RSS_IPV4_TCP | \
ETH_RSS_IPV6 | \
ETH_RSS_IPV6_EX | \
ETH_RSS_IPV6_TCP | \
ETH_RSS_IPV6_TCP_EX | \
ETH_RSS_IPV4_UDP | \
ETH_RSS_IPV6_UDP | \
ETH_RSS_IPV6_UDP_EX | \
ETH_RSS_NONF_IPV4_UDP | \
ETH_RSS_NONF_IPV4_TCP | \
ETH_RSS_NONF_IPV4_SCTP | \
ETH_RSS_NONF_IPV4_OTHER | \
ETH_RSS_FRAG_IPV4 | \
ETH_RSS_NONF_IPV6_UDP | \
ETH_RSS_NONF_IPV6_TCP | \
ETH_RSS_NONF_IPV6_SCTP | \
ETH_RSS_NONF_IPV6_OTHER | \
ETH_RSS_FRAG_IPV6 | \
ETH_RSS_L2_PAYLOAD)
#define ETH_RSS_PROTO_MASK 0x01FF /**< Mask of valid RSS hash protocols */
/* Definitions used for redirection table entry size */
#define ETH_RSS_RETA_NUM_ENTRIES 128
#define ETH_RSS_RETA_MAX_QUEUE 16

View File

@ -73,6 +73,17 @@
#include "e1000/e1000_api.h"
#include "e1000_ethdev.h"
#define IGB_RSS_OFFLOAD_ALL ( \
ETH_RSS_IPV4 | \
ETH_RSS_IPV4_TCP | \
ETH_RSS_IPV6 | \
ETH_RSS_IPV6_EX | \
ETH_RSS_IPV6_TCP | \
ETH_RSS_IPV6_TCP_EX | \
ETH_RSS_IPV4_UDP | \
ETH_RSS_IPV6_UDP | \
ETH_RSS_IPV6_UDP_EX)
static inline struct rte_mbuf *
rte_rxmbuf_alloc(struct rte_mempool *mp)
{
@ -1526,7 +1537,7 @@ igb_hw_rss_hash_set(struct e1000_hw *hw, struct rte_eth_rss_conf *rss_conf)
uint8_t *hash_key;
uint32_t rss_key;
uint32_t mrqc;
uint16_t rss_hf;
uint64_t rss_hf;
uint16_t i;
hash_key = rss_conf->rss_key;
@ -1571,7 +1582,7 @@ eth_igb_rss_hash_update(struct rte_eth_dev *dev,
{
struct e1000_hw *hw;
uint32_t mrqc;
uint16_t rss_hf;
uint64_t rss_hf;
hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@ -1581,7 +1592,7 @@ eth_igb_rss_hash_update(struct rte_eth_dev *dev,
* initialization time, or does not attempt to enable RSS, if RSS was
* disabled at initialization time.
*/
rss_hf = rss_conf->rss_hf;
rss_hf = rss_conf->rss_hf & IGB_RSS_OFFLOAD_ALL;
mrqc = E1000_READ_REG(hw, E1000_MRQC);
if (!(mrqc & E1000_MRQC_ENABLE_MASK)) { /* RSS disabled */
if (rss_hf != 0) /* Enable RSS */
@ -1602,7 +1613,7 @@ int eth_igb_rss_hash_conf_get(struct rte_eth_dev *dev,
uint8_t *hash_key;
uint32_t rss_key;
uint32_t mrqc;
uint16_t rss_hf;
uint64_t rss_hf;
uint16_t i;
hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@ -1678,7 +1689,7 @@ igb_rss_configure(struct rte_eth_dev *dev)
* the RSS hash of input packets.
*/
rss_conf = dev->data->dev_conf.rx_adv_conf.rss_conf;
if (rss_conf.rss_hf == 0) {
if ((rss_conf.rss_hf & IGB_RSS_OFFLOAD_ALL) == 0) {
igb_rss_disable(dev);
return;
}

View File

@ -77,10 +77,18 @@
#include "ixgbe_ethdev.h"
#include "ixgbe/ixgbe_dcb.h"
#include "ixgbe/ixgbe_common.h"
#include "ixgbe_rxtx.h"
#define IXGBE_RSS_OFFLOAD_ALL ( \
ETH_RSS_IPV4 | \
ETH_RSS_IPV4_TCP | \
ETH_RSS_IPV6 | \
ETH_RSS_IPV6_EX | \
ETH_RSS_IPV6_TCP | \
ETH_RSS_IPV6_TCP_EX | \
ETH_RSS_IPV4_UDP | \
ETH_RSS_IPV6_UDP | \
ETH_RSS_IPV6_UDP_EX)
static inline struct rte_mbuf *
rte_rxmbuf_alloc(struct rte_mempool *mp)
@ -2303,7 +2311,7 @@ ixgbe_hw_rss_hash_set(struct ixgbe_hw *hw, struct rte_eth_rss_conf *rss_conf)
uint8_t *hash_key;
uint32_t mrqc;
uint32_t rss_key;
uint16_t rss_hf;
uint64_t rss_hf;
uint16_t i;
hash_key = rss_conf->rss_key;
@ -2348,7 +2356,7 @@ ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
{
struct ixgbe_hw *hw;
uint32_t mrqc;
uint16_t rss_hf;
uint64_t rss_hf;
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@ -2361,7 +2369,7 @@ ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
* initialization time, or does not attempt to enable RSS, if RSS was
* disabled at initialization time.
*/
rss_hf = rss_conf->rss_hf;
rss_hf = rss_conf->rss_hf & IXGBE_RSS_OFFLOAD_ALL;
mrqc = IXGBE_READ_REG(hw, IXGBE_MRQC);
if (!(mrqc & IXGBE_MRQC_RSSEN)) { /* RSS disabled */
if (rss_hf != 0) /* Enable RSS */
@ -2383,7 +2391,7 @@ ixgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
uint8_t *hash_key;
uint32_t mrqc;
uint32_t rss_key;
uint16_t rss_hf;
uint64_t rss_hf;
uint16_t i;
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@ -2460,7 +2468,7 @@ ixgbe_rss_configure(struct rte_eth_dev *dev)
* the RSS hash of input packets.
*/
rss_conf = dev->data->dev_conf.rx_adv_conf.rss_conf;
if (rss_conf.rss_hf == 0) {
if ((rss_conf.rss_hf & IXGBE_RSS_OFFLOAD_ALL) == 0) {
ixgbe_rss_disable(dev);
return;
}

View File

@ -882,9 +882,16 @@ static uint8_t rss_intel_key[40] = {
int
vmxnet3_rss_configure(struct rte_eth_dev *dev)
{
#define VMXNET3_RSS_OFFLOAD_ALL ( \
ETH_RSS_IPV4 | \
ETH_RSS_IPV4_TCP | \
ETH_RSS_IPV6 | \
ETH_RSS_IPV6_TCP)
struct vmxnet3_hw *hw;
struct VMXNET3_RSSConf *dev_rss_conf;
struct rte_eth_rss_conf *port_rss_conf;
uint64_t rss_hf;
uint8_t i, j;
PMD_INIT_FUNC_TRACE();
@ -916,13 +923,14 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
/* loading hashType */
dev_rss_conf->hashType = 0;
if (port_rss_conf->rss_hf & ETH_RSS_IPV4)
rss_hf = port_rss_conf->rss_hf & VMXNET3_RSS_OFFLOAD_ALL;
if (rss_hf & ETH_RSS_IPV4)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_IPV4;
if (port_rss_conf->rss_hf & ETH_RSS_IPV4_TCP)
if (rss_hf & ETH_RSS_IPV4_TCP)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_TCP_IPV4;
if (port_rss_conf->rss_hf & ETH_RSS_IPV6)
if (rss_hf & ETH_RSS_IPV6)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_IPV6;
if (port_rss_conf->rss_hf & ETH_RSS_IPV6_TCP)
if (rss_hf & ETH_RSS_IPV6_TCP)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_TCP_IPV6;
return VMXNET3_SUCCESS;