diff options
| author | songyanchao <[email protected]> | 2023-04-17 11:46:09 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2023-04-17 11:46:09 +0000 |
| commit | 92afd348dd6a4eb0592e14a4e5f7cd3b8e1f663f (patch) | |
| tree | ee4eb0ad175d6abb276bd013de1cba7428ba2eaf /service/src | |
| parent | 86a5cbb2947a073535e5dd0e5f155ef2d05048f1 (diff) | |
🐞 fix: Support modified RSS hash based on hardware supportv4.5.8-20230417rel-4.5dev-4.5
Support modified RSS hash based on hardware support
Diffstat (limited to 'service/src')
| -rw-r--r-- | service/src/phydev.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/service/src/phydev.c b/service/src/phydev.c index d556121..aeb3159 100644 --- a/service/src/phydev.c +++ b/service/src/phydev.c @@ -29,7 +29,7 @@ static struct rte_eth_conf eth_conf_default = { .rxmode = { - .mq_mode = ETH_MQ_RX_RSS, + .mq_mode = ETH_MQ_RX_NONE, .split_hdr_size = 0, }, .txmode = @@ -154,11 +154,11 @@ static int gen_phydev_qconf(struct phydev * dev, struct rte_eth_rxconf * rxconf, } /* 用户参数解析:网卡参数设置 */ -static int gen_phydev_ethconf(struct phydev * dev, struct rte_eth_conf * out_eth_conf) +static int gen_phydev_ethconf(struct phydev * dev, unsigned nr_rxq_use, struct rte_eth_conf * out_eth_conf) { struct rte_eth_conf eth_conf = eth_conf_default; - if (dev->info.type == __PHYDEV_INFO_TYPE_PCI) + if ((dev->info.type == __PHYDEV_INFO_TYPE_PCI) && (nr_rxq_use > 1)) { /* only PCI devices can run at RSS mode. */ eth_conf.rxmode.mq_mode = ETH_MQ_RX_RSS; @@ -183,6 +183,30 @@ static int gen_phydev_ethconf(struct phydev * dev, struct rte_eth_conf * out_eth ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP; eth_conf.rx_adv_conf.rss_conf.rss_key = NULL; } + + /* According to dev info reset rss conf */ + struct rte_eth_conf request_eth_conf = eth_conf; + struct rte_eth_dev_info dev_info = {}; + + /* Get dev info */ + rte_eth_dev_info_get(dev->port_id, &dev_info); + if (dev_info.flow_type_rss_offloads == 0) + { + memcpy(ð_conf, ð_conf_default, sizeof(eth_conf)); + MR_WARNING("The port '%s' no support rss.", dev->symbol); + } + else + { + /* Check request rss_hf the dev supported or not */ + eth_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads; + if (eth_conf.rx_adv_conf.rss_conf.rss_hf != request_eth_conf.rx_adv_conf.rss_conf.rss_hf) + { + MR_WARNING("The port %s modified RSS hash function based on hardware support," + "requested:%#" PRIx64 " configured:%#" PRIx64 "\n", + dev->symbol, request_eth_conf.rx_adv_conf.rss_conf.rss_hf, + eth_conf.rx_adv_conf.rss_conf.rss_hf); + } + } } else if (dev->info.type == __PHYDEV_INFO_TYPE_VDEV) { @@ -470,10 +494,6 @@ static int phydev_setup(struct sc_main * sc, struct phydev_main * ctx, struct ph return RT_ERR; } - // 配置端口信息 - struct rte_eth_conf local_eth_conf; - gen_phydev_ethconf(dev, &local_eth_conf); - unsigned nr_rxq_use = 0; unsigned nr_txq_use = 0; @@ -508,6 +528,10 @@ static int phydev_setup(struct sc_main * sc, struct phydev_main * ctx, struct ph dev->nr_hairpin_q = dev->en_smartoffload ? 1 : 0; calc_phydev_queue(dev, &nr_rxq_use, &nr_txq_use); + // 配置端口信息 + struct rte_eth_conf local_eth_conf; + gen_phydev_ethconf(dev, nr_rxq_use, &local_eth_conf); + retval = rte_eth_dev_configure(dev->port_id, nr_rxq_use, nr_txq_use, &local_eth_conf); if (retval != 0) { |
