From: Jie Hai <haijie1@huawei.com>
To: <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<andrew.rybchenko@oktetlabs.ru>, <reshma.pattan@intel.com>,
Dongdong Liu <liudongdong3@huawei.com>,
Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: <haijie1@huawei.com>, <stable@dpdk.org>
Subject: [PATCH v2 2/5] net/hns3: support setting and querying RSS hash function
Date: Sat, 26 Aug 2023 15:00:41 +0800 [thread overview]
Message-ID: <20230826070044.64120-3-haijie1@huawei.com> (raw)
In-Reply-To: <20230826070044.64120-1-haijie1@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 6126512bd780..c8346d43d15c 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.33.0
next prev parent reply other threads:[~2023-08-26 7:04 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 ` [PATCH 2/5] net/hns3: support setting and querying RSS hash function Dongdong Liu
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 ` Jie Hai [this message]
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=20230826070044.64120-3-haijie1@huawei.com \
--to=haijie1@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=ferruh.yigit@amd.com \
--cc=liudongdong3@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).