Skip to contentSkip to conversation

net: hns3: fix wrong use of rss size during VF rss config

PATCH Applied Hao Lan 3 participants 5 messages Jan 10, 2023 – Jan 12, 2023

Subsystems (4)
lore
Share & tools
lore

Hao Lan

author
#0 lore raw

PATCH 1/1 net: hns3: fix wrong use of rss size during VF rss config

From: Jie Wang <[email protected]>

Currently, it used old rss size to get current tc mode. As a result, the rss size is updated, but the tc mode is still configured based on the old rss size.

So this patch fixes it by using the new rss size in both process.

Fixes 93969dc14fcd ("net: hns3: refactor VF rss init APIs with new common rss init APIs")
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +1 -1
index 081bd2c3f289..e84e5be8e59e 100644
@@ -3130,7 +3130,7 @@ static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num,
 
 	hclgevf_update_rss_size(handle, new_tqps_num);
 
-	hclge_comm_get_rss_tc_info(cur_rss_size, hdev->hw_tc_map,
+	hclge_comm_get_rss_tc_info(kinfo->rss_size, hdev->hw_tc_map,
 				   tc_offset, tc_valid, tc_size);
 	ret = hclge_comm_set_rss_tc_mode(&hdev->hw.hw, tc_offset,
 					 tc_valid, tc_size);
Signature · 1 line
2.30.0
Reviewed-by Alexander Duyck on v1 1/1
#1 lore raw
Quoted 20 lines · Hao Lan

From: Jie Wang <[email protected]>

Currently, it used old rss size to get current tc mode. As a result, the rss size is updated, but the tc mode is still configured based on the old rss size.

So this patch fixes it by using the new rss size in both process.

Fixes 93969dc14fcd ("net: hns3: refactor VF rss init APIs with new common rss init APIs")
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +0 -0
index 081bd2c3f289..e84e5be8e59e 100644

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num, · line 3136

Quoted 8 lines
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +1 -1
@@ -3130,7 +3130,7 @@ static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num,
 
 	hclgevf_update_rss_size(handle, new_tqps_num);
 
-	hclge_comm_get_rss_tc_info(cur_rss_size, hdev->hw_tc_map,
+	hclge_comm_get_rss_tc_info(kinfo->rss_size, hdev->hw_tc_map,
 				   tc_offset, tc_valid, tc_size);
 	ret = hclge_comm_set_rss_tc_mode(&hdev->hw.hw, tc_offset,
 					 tc_valid, tc_size);

I can see how this was confused. It isn't really clear that handle is being used to update the kinfo->rss_size value. Maybe think about adding a comment to prevent someone from reverting this without realizing that? It might also be useful to do a follow-on patch for net-next that renames cur_rss_size to orig_rss_size to make it more obvious that the value is changing.

author
#2 lore raw
Quoted 37 lines · Alexander H Duyck
Quoted 20 lines · Hao Lan

From: Jie Wang <[email protected]>

Currently, it used old rss size to get current tc mode. As a result, the rss size is updated, but the tc mode is still configured based on the old rss size.

So this patch fixes it by using the new rss size in both process.

Fixes 93969dc14fcd ("net: hns3: refactor VF rss init APIs with new common rss init APIs")
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +0 -0
index 081bd2c3f289..e84e5be8e59e 100644

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num, · line 3136

Quoted 8 lines
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +1 -1
@@ -3130,7 +3130,7 @@ static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num,
 
 	hclgevf_update_rss_size(handle, new_tqps_num);
 
-	hclge_comm_get_rss_tc_info(cur_rss_size, hdev->hw_tc_map,
+	hclge_comm_get_rss_tc_info(kinfo->rss_size, hdev->hw_tc_map,
 				   tc_offset, tc_valid, tc_size);
 	ret = hclge_comm_set_rss_tc_mode(&hdev->hw.hw, tc_offset,
 					 tc_valid, tc_size);

I can see how this was confused. It isn't really clear that handle is being used to update the kinfo->rss_size value. Maybe think about adding a comment to prevent someone from reverting this without realizing that? It might also be useful to do a follow-on patch for net-next that renames cur_rss_size to orig_rss_size to make it more obvious that the value is changing.

Quoted 3 lines

.

Hi Alexander Duyck,
Thank you for your reviewed.And thank you for your valuable advice. Would it be better if we changed it to the following.

- u16 cur_rss_size = kinfo->rss_size;
- u16 cur_tqps = kinfo->num_tqps;
+ u16 orig_rss_size = kinfo->rss_size;
+ u16 orig_tqps = kinfo->num_tqps;
u32 *rss_indir;
unsigned int i;
int ret;

hclgevf_update_rss_size(handle, new_tqps_num);

- hclge_comm_get_rss_tc_info(cur_rss_size, hdev->hw_tc_map,
+ /* RSS size will be updated after hclgevf_update_rss_size,
+ * so we use kinfo->rss_size instead of orig_rss_size.
+ */
+ hclge_comm_get_rss_tc_info(kinfo->rss_size, hdev->hw_tc_map,

#3 lore raw
Quoted 53 lines · Hao Lan
Quoted 37 lines · Alexander H Duyck
Quoted 20 lines · Hao Lan

From: Jie Wang <[email protected]>

Currently, it used old rss size to get current tc mode. As a result, the rss size is updated, but the tc mode is still configured based on the old rss size.

So this patch fixes it by using the new rss size in both process.

Fixes 93969dc14fcd ("net: hns3: refactor VF rss init APIs with new common rss init APIs")
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +0 -0
index 081bd2c3f289..e84e5be8e59e 100644

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num, · line 3136

Quoted 8 lines
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +1 -1
@@ -3130,7 +3130,7 @@ static int hclgevf_set_channels(struct hnae3_handle *handle, u32 new_tqps_num,
 
     hclgevf_update_rss_size(handle, new_tqps_num);
 
-    hclge_comm_get_rss_tc_info(cur_rss_size, hdev->hw_tc_map,
+    hclge_comm_get_rss_tc_info(kinfo->rss_size, hdev->hw_tc_map,
                                tc_offset, tc_valid, tc_size);
     ret = hclge_comm_set_rss_tc_mode(&hdev->hw.hw, tc_offset,
                                      tc_valid, tc_size);

I can see how this was confused. It isn't really clear that handle is being used to update the kinfo->rss_size value. Maybe think about adding a comment to prevent someone from reverting this without realizing that? It might also be useful to do a follow-on patch for net-next that renames cur_rss_size to orig_rss_size to make it more obvious that the value is changing.

Quoted 3 lines

.

Hi Alexander Duyck,
Thank you for your reviewed.And thank you for your valuable advice. Would it be better if we changed it to the following.

(quoted diff) +2 -2
-       u16 cur_rss_size = kinfo->rss_size;
-       u16 cur_tqps = kinfo->num_tqps;
+       u16 orig_rss_size = kinfo->rss_size;
+       u16 orig_tqps = kinfo->num_tqps;
        u32 *rss_indir;

Review

Quoted 10 lines
(quoted diff) +4 -1
        unsigned int i;
        int ret;
 
        hclgevf_update_rss_size(handle, new_tqps_num);
 
-       hclge_comm_get_rss_tc_info(cur_rss_size, hdev->hw_tc_map,
+       /* RSS size will be updated after hclgevf_update_rss_size,
+        * so we use kinfo->rss_size instead of orig_rss_size.
+        */
+       hclge_comm_get_rss_tc_info(kinfo->rss_size, hdev->hw_tc_map,

Yes, something like this would make it more obvious that these fields are changing.

#4 lore raw
In reply to Hao Lan
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 10 Jan 2023 19:53:59 +0800 you wrote:

From: Jie Wang <[email protected]>

Currently, it used old rss size to get current tc mode. As a result, the rss size is updated, but the tc mode is still configured based on the old rss size.

So this patch fixes it by using the new rss size in both process.

[...]

Here is the summary with links:
- [net] net: hns3: fix wrong use of rss size during VF rss config

    https://git.kernel.org/netdev/net/c/ae9f29fdfd82

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html