From: Lijun Ou <oulijun@huawei.com>
To: <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <linuxarm@huawei.com>
Subject: [dpdk-dev] [PATCH v2 3/8] net/hns3: fix RSS max queue id allowed in multi-TC case
Date: Thu, 29 Oct 2020 20:49:06 +0800 [thread overview]
Message-ID: <1603975751-27955-4-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1603975751-27955-1-git-send-email-oulijun@huawei.com>
From: Huisong Li <lihuisong@huawei.com>
Currently, driver uses the maximum number of queues configured by user
as the maximum queue id that can be specified by the RSS rule or the
reta_update api. It is unreasonable and may trigger an incorrect behavior
in the multi-TC scenario. The driver must ensure that the queue id
configured in the redirection table must be within the range of the number
of queues allocated to a TC.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 45 ++++++++++++++++++--------------------------
| 13 ++++++-------
2 files changed, 24 insertions(+), 34 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 73f5e8e..0d5dd1a 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1367,13 +1367,18 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev,
act, "no valid queues");
}
+ if (rss->queue_num > RTE_DIM(rss_conf->queue))
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
+ "queue number configured exceeds "
+ "queue buffer size driver supported");
+
for (n = 0; n < rss->queue_num; n++) {
- if (rss->queue[n] < dev->data->nb_rx_queues)
+ if (rss->queue[n] < hw->alloc_rss_size)
continue;
return rte_flow_error_set(error, EINVAL,
- RTE_FLOW_ERROR_TYPE_ACTION_CONF,
- act,
- "queue id > max number of queues");
+ RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
+ "queue id must be less than queue number allocated to a TC");
}
if (!(rss->types & HNS3_ETH_RSS_SUPPORT) && rss->types)
@@ -1394,10 +1399,6 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev,
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
"RSS hash key must be exactly 40 bytes");
- if (rss->queue_num > RTE_DIM(rss_conf->queue))
- return rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ACTION_CONF, act,
- "too many queues for RSS context");
/*
* For Kunpeng920 and Kunpeng930 NIC hardware, it is not supported to
@@ -1450,9 +1451,8 @@ hns3_disable_rss(struct hns3_hw *hw)
static void
hns3_parse_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf)
{
- if (rss_conf->key == NULL ||
- rss_conf->key_len < HNS3_RSS_KEY_SIZE) {
- hns3_info(hw, "Default RSS hash key to be set");
+ if (rss_conf->key == NULL || rss_conf->key_len < HNS3_RSS_KEY_SIZE) {
+ hns3_warn(hw, "Default RSS hash key to be set");
rss_conf->key = hns3_hash_key;
rss_conf->key_len = HNS3_RSS_KEY_SIZE;
}
@@ -1493,10 +1493,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
struct hns3_rss_tuple_cfg *tuple;
int ret;
- /* Parse hash key */
hns3_parse_rss_key(hw, rss_config);
- /* Parse hash algorithm */
ret = hns3_parse_rss_algorithm(hw, &rss_config->func,
&hw->rss_info.hash_algo);
if (ret)
@@ -1525,20 +1523,18 @@ hns3_update_indir_table(struct rte_eth_dev *dev,
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE];
- uint16_t j, allow_rss_queues;
+ uint16_t j;
uint32_t i;
- allow_rss_queues = RTE_MIN(dev->data->nb_rx_queues, hw->rss_size_max);
/* Fill in redirection table */
memcpy(indir_tbl, hw->rss_info.rss_indirection_tbl,
sizeof(hw->rss_info.rss_indirection_tbl));
for (i = 0, j = 0; i < HNS3_RSS_IND_TBL_SIZE; i++, j++) {
j %= num;
- if (conf->queue[j] >= allow_rss_queues) {
- hns3_err(hw, "Invalid queue id(%u) to be set in "
- "redirection table, max number of rss "
- "queues: %u", conf->queue[j],
- allow_rss_queues);
+ if (conf->queue[j] >= hw->alloc_rss_size) {
+ hns3_err(hw, "queue id(%u) set to redirection table "
+ "exceeds queue number(%u) allocated to a TC.",
+ conf->queue[j], hw->alloc_rss_size);
return -EINVAL;
}
indir_tbl[i] = conf->queue[j];
@@ -1607,11 +1603,8 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
return 0;
}
- /* Get rx queues num */
- num = dev->data->nb_rx_queues;
-
/* Set rx queues to use */
- num = RTE_MIN(num, rss_flow_conf.queue_num);
+ num = RTE_MIN(dev->data->nb_rx_queues, rss_flow_conf.queue_num);
if (rss_flow_conf.queue_num > num)
hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated",
rss_flow_conf.queue_num);
@@ -1648,7 +1641,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
return ret;
}
-/* Remove the rss filter */
static int
hns3_clear_rss_filter(struct rte_eth_dev *dev)
{
@@ -1684,7 +1676,6 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
return ret;
}
-/* Restore the rss filter */
int
hns3_restore_rss_filter(struct rte_eth_dev *dev)
{
@@ -1706,7 +1697,6 @@ hns3_flow_parse_rss(struct rte_eth_dev *dev,
struct hns3_hw *hw = &hns->hw;
bool ret;
- /* Action rss same */
ret = hns3_action_rss_same(&hw->rss_info.conf, &conf->conf);
if (ret) {
hns3_err(hw, "Enter duplicate RSS configuration : %d", ret);
@@ -1864,6 +1854,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
ret = -ENOMEM;
goto err_fdir;
}
+
memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule,
sizeof(struct hns3_fdir_rule));
TAILQ_INSERT_TAIL(&process_list->fdir_list,
--git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 2efd410..a4e552b 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -510,7 +510,7 @@ hns3_dev_rss_reta_update(struct rte_eth_dev *dev,
struct hns3_rss_conf *rss_cfg = &hw->rss_info;
uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */
uint16_t indirection_tbl[HNS3_RSS_IND_TBL_SIZE];
- uint16_t idx, shift, allow_rss_queues;
+ uint16_t idx, shift;
int ret;
if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) {
@@ -522,16 +522,15 @@ hns3_dev_rss_reta_update(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
memcpy(indirection_tbl, rss_cfg->rss_indirection_tbl,
sizeof(rss_cfg->rss_indirection_tbl));
- allow_rss_queues = RTE_MIN(dev->data->nb_rx_queues, hw->rss_size_max);
for (i = 0; i < reta_size; i++) {
idx = i / RTE_RETA_GROUP_SIZE;
shift = i % RTE_RETA_GROUP_SIZE;
- if (reta_conf[idx].reta[shift] >= allow_rss_queues) {
+ if (reta_conf[idx].reta[shift] >= hw->alloc_rss_size) {
rte_spinlock_unlock(&hw->lock);
- hns3_err(hw, "Invalid queue id(%u) to be set in "
- "redirection table, max number of rss "
- "queues: %u", reta_conf[idx].reta[shift],
- allow_rss_queues);
+ hns3_err(hw, "queue id(%u) set to redirection table "
+ "exceeds queue number(%u) allocated to a TC",
+ reta_conf[idx].reta[shift],
+ hw->alloc_rss_size);
return -EINVAL;
}
--
2.7.4
next prev parent reply other threads:[~2020-10-29 12:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 11:14 [dpdk-dev] [PATCH 0/8] hns3 misc updates Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 1/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 2/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 3/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 4/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 5/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 6/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 7/8] net/hns3: fix return value check of setting VF bus master Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 8/8] net/hns3: fix meson build for enabling SVE Rx/Tx Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 0/8] hns3 misc updates Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 1/8] net/hns3: enable RSS for ipv6-sctp dst/src port fields Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 2/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 3/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 4/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 5/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 6/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 7/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 8/8] net/hns3: fix return value check of setting VF bus Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 0/8] hns3 misc updates Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 1/8] net/hns3: enable RSS for ipv6-sctp dst/src port fields Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 2/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 12:49 ` Lijun Ou [this message]
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 4/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 5/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 6/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 7/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 12:49 ` [dpdk-dev] [PATCH v2 8/8] net/hns3: fix return value check of setting VF bus Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 0/8] hns3 misc updates Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 1/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 2/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 3/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 4/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 5/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 6/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 7/8] net/hns3: fix value check of setting VF PCI bus function Lijun Ou
2020-10-29 12:51 ` [dpdk-dev] [PATCH v3 8/8] net/hns3: fix meson build for enabling SVE Rx/Tx Lijun Ou
2020-10-30 17:00 ` [dpdk-dev] [PATCH v3 0/8] hns3 misc updates Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1603975751-27955-4-git-send-email-oulijun@huawei.com \
--to=oulijun@huawei.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=linuxarm@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).