net: hns3: fix change RSS 'hfunc' ineffective issue
[ Upstream commit e184cec5e29d8eb3c3435b12a9074b75e2d69e4a ] When user change rss 'hfunc' without set rss 'hkey' by ethtool -X command, the driver will ignore the 'hfunc' for the hkey is NULL. It's unreasonable. So fix it. Fixes:46a3df9f97
("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Fixes:374ad29176
("net: hns3: Add RSS general configuration support for VF") Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
1365a0dc55
commit
ca435999bc
@@ -4377,6 +4377,24 @@ static int hclge_get_rss(struct hnae3_handle *handle, u32 *indir,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int hclge_parse_rss_hfunc(struct hclge_vport *vport, const u8 hfunc,
|
||||||
|
u8 *hash_algo)
|
||||||
|
{
|
||||||
|
switch (hfunc) {
|
||||||
|
case ETH_RSS_HASH_TOP:
|
||||||
|
*hash_algo = HCLGE_RSS_HASH_ALGO_TOEPLITZ;
|
||||||
|
return 0;
|
||||||
|
case ETH_RSS_HASH_XOR:
|
||||||
|
*hash_algo = HCLGE_RSS_HASH_ALGO_SIMPLE;
|
||||||
|
return 0;
|
||||||
|
case ETH_RSS_HASH_NO_CHANGE:
|
||||||
|
*hash_algo = vport->rss_algo;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir,
|
static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir,
|
||||||
const u8 *key, const u8 hfunc)
|
const u8 *key, const u8 hfunc)
|
||||||
{
|
{
|
||||||
@@ -4385,30 +4403,27 @@ static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir,
|
|||||||
u8 hash_algo;
|
u8 hash_algo;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
/* Set the RSS Hash Key if specififed by the user */
|
ret = hclge_parse_rss_hfunc(vport, hfunc, &hash_algo);
|
||||||
if (key) {
|
if (ret) {
|
||||||
switch (hfunc) {
|
dev_err(&hdev->pdev->dev, "invalid hfunc type %u\n", hfunc);
|
||||||
case ETH_RSS_HASH_TOP:
|
return ret;
|
||||||
hash_algo = HCLGE_RSS_HASH_ALGO_TOEPLITZ;
|
|
||||||
break;
|
|
||||||
case ETH_RSS_HASH_XOR:
|
|
||||||
hash_algo = HCLGE_RSS_HASH_ALGO_SIMPLE;
|
|
||||||
break;
|
|
||||||
case ETH_RSS_HASH_NO_CHANGE:
|
|
||||||
hash_algo = vport->rss_algo;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the RSS Hash Key if specififed by the user */
|
||||||
|
if (key) {
|
||||||
ret = hclge_set_rss_algo_key(hdev, hash_algo, key);
|
ret = hclge_set_rss_algo_key(hdev, hash_algo, key);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Update the shadow RSS key with user specified qids */
|
/* Update the shadow RSS key with user specified qids */
|
||||||
memcpy(vport->rss_hash_key, key, HCLGE_RSS_KEY_SIZE);
|
memcpy(vport->rss_hash_key, key, HCLGE_RSS_KEY_SIZE);
|
||||||
vport->rss_algo = hash_algo;
|
} else {
|
||||||
|
ret = hclge_set_rss_algo_key(hdev, hash_algo,
|
||||||
|
vport->rss_hash_key);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
vport->rss_algo = hash_algo;
|
||||||
|
|
||||||
/* Update the shadow RSS table with user specified qids */
|
/* Update the shadow RSS table with user specified qids */
|
||||||
for (i = 0; i < HCLGE_RSS_IND_TBL_SIZE; i++)
|
for (i = 0; i < HCLGE_RSS_IND_TBL_SIZE; i++)
|
||||||
|
@@ -785,40 +785,56 @@ static int hclgevf_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int hclgevf_parse_rss_hfunc(struct hclgevf_dev *hdev, const u8 hfunc,
|
||||||
|
u8 *hash_algo)
|
||||||
|
{
|
||||||
|
switch (hfunc) {
|
||||||
|
case ETH_RSS_HASH_TOP:
|
||||||
|
*hash_algo = HCLGEVF_RSS_HASH_ALGO_TOEPLITZ;
|
||||||
|
return 0;
|
||||||
|
case ETH_RSS_HASH_XOR:
|
||||||
|
*hash_algo = HCLGEVF_RSS_HASH_ALGO_SIMPLE;
|
||||||
|
return 0;
|
||||||
|
case ETH_RSS_HASH_NO_CHANGE:
|
||||||
|
*hash_algo = hdev->rss_cfg.hash_algo;
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int hclgevf_set_rss(struct hnae3_handle *handle, const u32 *indir,
|
static int hclgevf_set_rss(struct hnae3_handle *handle, const u32 *indir,
|
||||||
const u8 *key, const u8 hfunc)
|
const u8 *key, const u8 hfunc)
|
||||||
{
|
{
|
||||||
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
||||||
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
|
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
|
||||||
|
u8 hash_algo;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) {
|
if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) {
|
||||||
/* Set the RSS Hash Key if specififed by the user */
|
ret = hclgevf_parse_rss_hfunc(hdev, hfunc, &hash_algo);
|
||||||
if (key) {
|
|
||||||
switch (hfunc) {
|
|
||||||
case ETH_RSS_HASH_TOP:
|
|
||||||
rss_cfg->hash_algo =
|
|
||||||
HCLGEVF_RSS_HASH_ALGO_TOEPLITZ;
|
|
||||||
break;
|
|
||||||
case ETH_RSS_HASH_XOR:
|
|
||||||
rss_cfg->hash_algo =
|
|
||||||
HCLGEVF_RSS_HASH_ALGO_SIMPLE;
|
|
||||||
break;
|
|
||||||
case ETH_RSS_HASH_NO_CHANGE:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = hclgevf_set_rss_algo_key(hdev, rss_cfg->hash_algo,
|
|
||||||
key);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* Set the RSS Hash Key if specififed by the user */
|
||||||
|
if (key) {
|
||||||
|
ret = hclgevf_set_rss_algo_key(hdev, hash_algo, key);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&hdev->pdev->dev,
|
||||||
|
"invalid hfunc type %u\n", hfunc);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the shadow RSS key with user specified qids */
|
/* Update the shadow RSS key with user specified qids */
|
||||||
memcpy(rss_cfg->rss_hash_key, key,
|
memcpy(rss_cfg->rss_hash_key, key,
|
||||||
HCLGEVF_RSS_KEY_SIZE);
|
HCLGEVF_RSS_KEY_SIZE);
|
||||||
|
} else {
|
||||||
|
ret = hclgevf_set_rss_algo_key(hdev, hash_algo,
|
||||||
|
rss_cfg->rss_hash_key);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
rss_cfg->hash_algo = hash_algo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the shadow RSS table with user specified qids */
|
/* update the shadow RSS table with user specified qids */
|
||||||
|
Reference in New Issue
Block a user