From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>
To: <dev@dpdk.org>
Cc: <xavier.huwei@huawei.com>
Subject: [dpdk-dev] [PATCH v2 15/17] net/hns3: fix flushing RSS rule
Date: Tue, 22 Sep 2020 20:03:27 +0800 [thread overview]
Message-ID: <20200922120329.21185-16-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20200922120329.21185-1-huwei013@chinasoftinc.com>
From: Lijun Ou <oulijun@huawei.com>
When user create a flow without RSS by calling rte_flow_create API and then
destroy it by calling rte_flow_flush API, driver should not clear RSS rule.
A reasonable handling method is that when user creates an RSS rule, the
driver should clear the created RSS rule when flushing destroy all flow
rules. Also, hw->rss_info should save the RSS config of the last success
RSS rule. When create n RSS rules, the RSS should not be disabled before
the last RSS rule destroyed.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 79 ++++++++++++++++++++++++++++++++------------
| 1 +
2 files changed, 58 insertions(+), 22 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 5b5124c..05cc95e 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1560,7 +1560,9 @@ static int
hns3_config_rss_filter(struct rte_eth_dev *dev,
const struct hns3_rss_conf *conf, bool add)
{
+ struct hns3_process_private *process_list = dev->process_private;
struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_rss_conf_ele *rss_filter_ptr;
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_conf *rss_info;
uint64_t flow_types;
@@ -1591,28 +1593,27 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
rss_info = &hw->rss_info;
if (!add) {
- if (hns3_action_rss_same(&rss_info->conf, &rss_flow_conf)) {
- ret = hns3_disable_rss(hw);
- if (ret) {
- hns3_err(hw, "RSS disable failed(%d)", ret);
- return ret;
- }
+ if (!conf->valid)
+ return 0;
- if (rss_flow_conf.queue_num) {
- /*
- * Due the content of queue pointer have been
- * reset to 0, the rss_info->conf.queue should
- * be set NULL.
- */
- rss_info->conf.queue = NULL;
- rss_info->conf.queue_num = 0;
- }
+ ret = hns3_disable_rss(hw);
+ if (ret) {
+ hns3_err(hw, "RSS disable failed(%d)", ret);
+ return ret;
+ }
- /* set RSS func invalid after flushed */
- rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX;
- return 0;
+ if (rss_flow_conf.queue_num) {
+ /*
+ * Due the content of queue pointer have been reset to
+ * 0, the rss_info->conf.queue should be set NULL
+ */
+ rss_info->conf.queue = NULL;
+ rss_info->conf.queue_num = 0;
}
- return -EINVAL;
+
+ /* set RSS func invalid after flushed */
+ rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX;
+ return 0;
}
/* Get rx queues num */
@@ -1643,6 +1644,13 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
goto rss_config_err;
}
+ /*
+ * When create a new RSS rule, the old rule will be overlaid and set
+ * invalid.
+ */
+ TAILQ_FOREACH(rss_filter_ptr, &process_list->filter_rss_list, entries)
+ rss_filter_ptr->filter_info.valid = false;
+
rss_config_err:
rte_spinlock_unlock(&hw->lock);
@@ -1653,10 +1661,36 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
static int
hns3_clear_rss_filter(struct rte_eth_dev *dev)
{
+ struct hns3_process_private *process_list = dev->process_private;
struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_rss_conf_ele *rss_filter_ptr;
struct hns3_hw *hw = &hns->hw;
+ int rss_rule_succ_cnt = 0; /* count for success of clearing RSS rules */
+ int rss_rule_fail_cnt = 0; /* count for failure of clearing RSS rules */
+ int ret = 0;
+
+ rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list);
+ while (rss_filter_ptr) {
+ TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr,
+ entries);
+ ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+ false);
+ if (ret)
+ rss_rule_fail_cnt++;
+ else
+ rss_rule_succ_cnt++;
+ rte_free(rss_filter_ptr);
+ rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list);
+ }
- return hns3_config_rss_filter(dev, &hw->rss_info, false);
+ if (rss_rule_fail_cnt) {
+ hns3_err(hw, "fail to delete all RSS filters, success num = %d "
+ "fail num = %d", rss_rule_succ_cnt,
+ rss_rule_fail_cnt);
+ ret = -EIO;
+ }
+
+ return ret;
}
/* Restore the rss filter */
@@ -1807,6 +1841,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
}
memcpy(&rss_filter_ptr->filter_info, rss_conf,
sizeof(struct hns3_rss_conf));
+ rss_filter_ptr->filter_info.valid = true;
TAILQ_INSERT_TAIL(&process_list->filter_rss_list,
rss_filter_ptr, entries);
@@ -1872,7 +1907,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
struct hns3_fdir_rule_ele *fdir_rule_ptr;
struct hns3_rss_conf_ele *rss_filter_ptr;
struct hns3_flow_mem *flow_node;
- struct hns3_hw *hw = &hns->hw;
enum rte_filter_type filter_type;
struct hns3_fdir_rule fdir_rule;
int ret;
@@ -1902,7 +1936,8 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
break;
case RTE_ETH_FILTER_HASH:
rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule;
- ret = hns3_config_rss_filter(dev, &hw->rss_info, false);
+ ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+ false);
if (ret)
return rte_flow_error_set(error, EIO,
RTE_FLOW_ERROR_TYPE_HANDLE,
--git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 47d3586..8fa1b30 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -47,6 +47,7 @@ struct hns3_rss_conf {
struct hns3_rss_tuple_cfg rss_tuple_sets;
uint8_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; /* Shadow table */
uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
+ bool valid; /* check if RSS rule is valid */
};
#ifndef ilog2
--
2.9.5
next prev parent reply other threads:[~2020-09-22 12:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 8:53 [dpdk-dev] [PATCH 00/17] updates for hns3 PMD driver Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 01/17] net/hns3: add VLAN configuration compatibility Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 02/17] net/hns3: fix default VLAN won't be deleted when set PF PVID Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 03/17] net/hns3: add default branch to switch in Rx VLAN processing Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 04/17] net/hns3: add max number of segs compatibility Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 05/17] net/hns3: add TSO pseudo header calculation compatibility Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 06/17] net/hns3: avoid accessing nonexistent VF reg when PF in FLR Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 07/17] net/hns3: add default branch to switch when parsing fd tuple Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 08/17] net/hns3: add break to exit loop when err stat item found Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 09/17] net/hns3: support flow action of queue region Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 10/17] net/hns3: support querying RSS flow rule Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 11/17] net/hns3: check input RSS type when creating flow with RSS Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 12/17] net/hns3: set RSS hash type input configuration Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 13/17] net/hns3: fix config when creating RSS rule after flush Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 14/17] net/hns3: fix flow RSS queue num with 0 Wei Hu (Xavier)
2020-09-22 8:53 ` [dpdk-dev] [PATCH 15/17] net/hns3: fix flushing RSS rule Wei Hu (Xavier)
2020-09-22 8:54 ` [dpdk-dev] [PATCH 16/17] net/hns3: fix configuring device with RSS is enabled Wei Hu (Xavier)
2020-09-22 8:54 ` [dpdk-dev] [PATCH 17/17] net/hns3: fix storing RSS info when creating flow action Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 00/17] updates for hns3 PMD driver Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 01/17] net/hns3: add VLAN configuration compatibility Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 02/17] net/hns3: fix default VLAN won't be deleted when set PF PVID Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 03/17] net/hns3: add default branch to switch in Rx VLAN processing Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 04/17] net/hns3: add max number of segs compatibility Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 05/17] net/hns3: add TSO pseudo header calculation compatibility Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 06/17] net/hns3: avoid accessing nonexistent VF reg when PF in FLR Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 07/17] net/hns3: add default branch to switch when parsing fd tuple Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 08/17] net/hns3: add break to exit loop when err stat item found Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 09/17] net/hns3: support flow action of queue region Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 10/17] net/hns3: support querying RSS flow rule Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 11/17] net/hns3: check input RSS type when creating flow with RSS Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 12/17] net/hns3: set RSS hash type input configuration Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 13/17] net/hns3: fix config when creating RSS rule after flush Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 14/17] net/hns3: fix flow RSS queue num with 0 Wei Hu (Xavier)
2020-09-22 12:03 ` Wei Hu (Xavier) [this message]
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 16/17] net/hns3: fix configuring device with RSS is enabled Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 17/17] net/hns3: fix storing RSS info when creating flow action Wei Hu (Xavier)
2020-09-28 13:29 ` [dpdk-dev] [PATCH v2 00/17] updates for hns3 PMD driver 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=20200922120329.21185-16-huwei013@chinasoftinc.com \
--to=huwei013@chinasoftinc.com \
--cc=dev@dpdk.org \
--cc=xavier.huwei@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).