From: Dongdong Liu <liudongdong3@huawei.com>
To: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<andrew.rybchenko@oktetlabs.ru>, <reshma.pattan@intel.com>
Cc: <stable@dpdk.org>, <yisen.zhuang@huawei.com>,
<liudongdong3@huawei.com>, Huisong Li <lihuisong@huawei.com>
Subject: [PATCH 2/5] net/hns3: support setting and querying RSS hash function
Date: Wed, 15 Mar 2023 19:00:30 +0800 [thread overview]
Message-ID: <20230315110033.30143-3-liudongdong3@huawei.com> (raw)
In-Reply-To: <20230315110033.30143-1-liudongdong3@huawei.com>
From: Huisong Li <lihuisong@huawei.com>
Support setting and querying RSS hash function by ethdev ops.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
| 47 +++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 20 deletions(-)
--git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6126512bd7..c8346d43d1 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto set_tuple_fail;
- if (key) {
- ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo,
- key, hw->rss_key_size);
- if (ret)
- goto set_algo_key_fail;
- /* Update the shadow RSS key with user specified */
+ ret = hns3_update_rss_algo_key(hw, rss_conf->func, key, key_len);
+ if (ret != 0)
+ goto set_algo_key_fail;
+
+ if (rss_conf->func != RTE_ETH_HASH_FUNCTION_DEFAULT)
+ hw->rss_info.hash_algo = hns3_hash_func_map[rss_conf->func];
+ if (key != NULL)
memcpy(hw->rss_info.key, key, hw->rss_key_size);
- }
hw->rss_info.rss_hf = rss_hf;
rte_spinlock_unlock(&hw->lock);
@@ -769,7 +769,13 @@ int
hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf)
{
+ const uint8_t hash_func_map[] = {
+ [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ,
+ [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR,
+ [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+ };
struct hns3_adapter *hns = dev->data->dev_private;
+ uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0};
struct hns3_hw *hw = &hns->hw;
uint8_t hash_algo;
int ret;
@@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
if (ret != 0) {
+ rte_spinlock_unlock(&hw->lock);
hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
- goto out;
+ return ret;
+ }
+
+ ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size);
+ if (ret != 0) {
+ rte_spinlock_unlock(&hw->lock);
+ hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret);
+ return ret;
}
+ rte_spinlock_unlock(&hw->lock);
- /* Get the RSS Key required by the user */
+ /* Get the RSS Key if user required. */
if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
- ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
- hw->rss_key_size);
- if (ret != 0) {
- hns3_err(hw, "obtain hash algo and key failed, ret = %d",
- ret);
- goto out;
- }
+ memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size);
rss_conf->rss_key_len = hw->rss_key_size;
}
+ rss_conf->func = hash_func_map[hash_algo];
-out:
- rte_spinlock_unlock(&hw->lock);
-
- return ret;
+ return 0;
}
/*
--
2.22.0
next prev parent reply other threads:[~2023-03-15 11:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 11:00 [PATCH 0/5] support setting and querying RSS algorithms Dongdong Liu
2023-03-15 11:00 ` [PATCH 1/5] ethdev: support setting and querying rss algorithm Dongdong Liu
2023-03-15 11:28 ` Ivan Malov
2023-03-16 13:10 ` Dongdong Liu
2023-03-16 14:31 ` Ivan Malov
2023-03-15 13:43 ` Thomas Monjalon
2023-03-16 13:16 ` Dongdong Liu
2023-06-02 20:19 ` Ferruh Yigit
2023-06-05 12:34 ` Dongdong Liu
2023-03-15 11:00 ` Dongdong Liu [this message]
2023-03-15 11:00 ` [PATCH 3/5] app/proc-info: fix never show RSS info Dongdong Liu
2023-06-02 20:19 ` Ferruh Yigit
2023-06-05 13:04 ` Dongdong Liu
2023-06-02 21:19 ` Stephen Hemminger
2023-06-05 13:07 ` Dongdong Liu
2023-03-15 11:00 ` [PATCH 4/5] app/proc-info: show RSS types with strings Dongdong Liu
2023-06-02 20:22 ` Ferruh Yigit
2023-06-05 13:12 ` Dongdong Liu
2023-03-15 11:00 ` [PATCH 5/5] app/proc-info: support querying RSS hash algorithm Dongdong Liu
2023-08-26 7:00 ` [PATCH v2 0/5] support setting and querying RSS algorithms Jie Hai
2023-08-26 7:00 ` [PATCH v2 1/5] ethdev: support setting and querying rss algorithm Jie Hai
2023-08-30 11:41 ` Thomas Monjalon
2023-08-26 7:00 ` [PATCH v2 2/5] net/hns3: support setting and querying RSS hash function Jie Hai
2023-08-26 7:00 ` [PATCH v2 3/5] app/proc-info: fix never show RSS info Jie Hai
2023-08-26 7:00 ` [PATCH v2 4/5] app/proc-info: adjust the display format of " Jie Hai
2023-08-26 7:00 ` [PATCH v2 5/5] app/proc-info: support querying RSS hash algorithm Jie Hai
2023-08-26 8:52 ` [PATCH v2 0/5] support setting and querying RSS algorithms Jie Hai
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=20230315110033.30143-3-liudongdong3@huawei.com \
--to=liudongdong3@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=lihuisong@huawei.com \
--cc=reshma.pattan@intel.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
--cc=yisen.zhuang@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).