aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
diff options
context:
space:
mode:
authorYufeng Mo <moyufeng@huawei.com>2019-06-07 10:03:11 +0800
committerDavid S. Miller <davem@davemloft.net>2019-06-09 13:20:59 -0700
commit3caf772bcea18a3c5045113aaa119dd2dd81f98f (patch)
tree417d6945725b9b4110ef4554a95672408a6518cc /drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
parentnet: hns3: use macros instead of magic numbers (diff)
downloadlinux-dev-3caf772bcea18a3c5045113aaa119dd2dd81f98f.tar.xz
linux-dev-3caf772bcea18a3c5045113aaa119dd2dd81f98f.zip
net: hns3: refactor PF/VF RSS hash key configuration
In order to make it more readable, this patch modifies PF/VF's RSS hash key configuring function. Signed-off-by: Yufeng Mo <moyufeng@huawei.com> Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Weihang Li <liweihang@hisilicon.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 7fd25abbd57c..c44877443022 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -539,13 +539,15 @@ static int hclgevf_set_rss_algo_key(struct hclgevf_dev *hdev,
{
struct hclgevf_rss_config_cmd *req;
struct hclgevf_desc desc;
- int key_offset;
+ int key_offset = 0;
+ int key_counts;
int key_size;
int ret;
+ key_counts = HCLGEVF_RSS_KEY_SIZE;
req = (struct hclgevf_rss_config_cmd *)desc.data;
- for (key_offset = 0; key_offset < 3; key_offset++) {
+ while (key_counts) {
hclgevf_cmd_setup_basic_desc(&desc,
HCLGEVF_OPC_RSS_GENERIC_CONFIG,
false);
@@ -554,15 +556,12 @@ static int hclgevf_set_rss_algo_key(struct hclgevf_dev *hdev,
req->hash_config |=
(key_offset << HCLGEVF_RSS_HASH_KEY_OFFSET_B);
- if (key_offset == 2)
- key_size =
- HCLGEVF_RSS_KEY_SIZE - HCLGEVF_RSS_HASH_KEY_NUM * 2;
- else
- key_size = HCLGEVF_RSS_HASH_KEY_NUM;
-
+ key_size = min(HCLGEVF_RSS_HASH_KEY_NUM, key_counts);
memcpy(req->hash_key,
key + key_offset * HCLGEVF_RSS_HASH_KEY_NUM, key_size);
+ key_counts -= key_size;
+ key_offset++;
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
if (ret) {
dev_err(&hdev->pdev->dev,