Add configuration options `symmetric_rss` to set whether to use symmetric RSS.

This commit is contained in:
fengbojiang 2020-08-30 00:55:08 +08:00
parent 591a17d568
commit f41205e9f3
4 changed files with 29 additions and 13 deletions

View File

@ -35,6 +35,9 @@ idle_sleep=0
# unit: microseconds
pkt_tx_delay=100
# use symmetric Receive-side Scaling(RSS) key, default: disabled.
symmetric_rss=0
# enabled port list
#
# EBNF grammar:

View File

@ -587,6 +587,8 @@ ini_parse_handler(void* user, const char* section, const char* name,
pconfig->dpdk.idle_sleep = atoi(value);
} else if (MATCH("dpdk", "pkt_tx_delay")) {
pconfig->dpdk.pkt_tx_delay = atoi(value);
} else if (MATCH("dpdk", "symmetric_rss")) {
pconfig->dpdk.symmetric_rss = atoi(value);
} else if (MATCH("kni", "enable")) {
pconfig->kni.enable= atoi(value);
} else if (MATCH("kni", "kni_action")) {

View File

@ -128,6 +128,7 @@ struct ff_config {
int tso;
int tx_csum_offoad_skip;
int vlan_strip;
int symmetric_rss;
/* sleep x microseconds when no pkts incomming */
unsigned idle_sleep;

View File

@ -89,7 +89,6 @@ static uint8_t default_rsskey_40bytes[40] = {
0xf3, 0x25, 0x3c, 0x06, 0x2a, 0xdc, 0x1f, 0xfc
};
static int use_rsskey_52bytes = 0;
static uint8_t default_rsskey_52bytes[52] = {
0x44, 0x39, 0x79, 0x6b, 0xb5, 0x4c, 0x50, 0x23,
0xb6, 0x75, 0xea, 0x5b, 0x12, 0x4f, 0x9f, 0x30,
@ -100,6 +99,19 @@ static uint8_t default_rsskey_52bytes[52] = {
0x81, 0x15, 0x03, 0x66
};
static uint8_t symmetric_rsskey[52] = {
0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a, 0x6d, 0x5a,
0x6d, 0x5a, 0x6d, 0x5a
};
static int rsskey_len = sizeof(default_rsskey_40bytes);
static uint8_t *rsskey = default_rsskey_40bytes;
struct lcore_conf lcore_conf;
struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
@ -607,13 +619,15 @@ init_port_start(void)
port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
port_conf.rx_adv_conf.rss_conf.rss_hf = default_rss_hf;
if (dev_info.hash_key_size == 52) {
port_conf.rx_adv_conf.rss_conf.rss_key = default_rsskey_52bytes;
port_conf.rx_adv_conf.rss_conf.rss_key_len = 52;
use_rsskey_52bytes = 1;
} else {
port_conf.rx_adv_conf.rss_conf.rss_key = default_rsskey_40bytes;
port_conf.rx_adv_conf.rss_conf.rss_key_len = 40;
rsskey = default_rsskey_52bytes;
rsskey_len = 52;
}
if (ff_global_cfg.dpdk.symmetric_rss) {
printf("Use symmetric Receive-side Scaling(RSS) key\n");
rsskey = symmetric_rsskey;
}
port_conf.rx_adv_conf.rss_conf.rss_key = rsskey;
port_conf.rx_adv_conf.rss_conf.rss_key_len = rsskey_len;
port_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
ETH_RSS_PROTO_MASK) {
@ -1780,12 +1794,8 @@ ff_rss_check(void *softc, uint32_t saddr, uint32_t daddr,
datalen += sizeof(dport);
uint32_t hash = 0;
if ( !use_rsskey_52bytes )
hash = toeplitz_hash(sizeof(default_rsskey_40bytes),
default_rsskey_40bytes, datalen, data);
else
hash = toeplitz_hash(sizeof(default_rsskey_52bytes),
default_rsskey_52bytes, datalen, data);
hash = toeplitz_hash(rsskey_len, rsskey, datalen, data);
return ((hash & (reta_size - 1)) % nb_queues) == queueid;
}