Skip to content

Commit 2a251b8

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: libwx: restrict change user-set RSS configuration
Enable/disable SR-IOV will change the number of rings, thereby changing the RSS configuration that the user has set. So reject these attempts if netif_is_rxfh_configured() returns true. And remind the user to reset the RSS configuration. Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Link: https://patch.msgid.link/20250926023843.34340-5-jiawenwu@trustnetic.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2556f80 commit 2a251b8

2 files changed

Lines changed: 35 additions & 23 deletions

File tree

drivers/net/ethernet/wangxun/libwx/wx_hw.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,28 +2047,30 @@ void wx_store_rsskey(struct wx *wx)
20472047

20482048
static void wx_setup_reta(struct wx *wx)
20492049
{
2050-
u16 rss_i = wx->ring_feature[RING_F_RSS].indices;
2051-
u32 reta_entries = wx_rss_indir_tbl_entries(wx);
2052-
u32 i, j;
2053-
2054-
if (test_bit(WX_FLAG_SRIOV_ENABLED, wx->flags)) {
2055-
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
2056-
rss_i = rss_i < 2 ? 2 : rss_i;
2057-
else
2058-
rss_i = 1;
2059-
}
2060-
20612050
/* Fill out hash function seeds */
20622051
wx_store_rsskey(wx);
20632052

20642053
/* Fill out redirection table */
2065-
memset(wx->rss_indir_tbl, 0, sizeof(wx->rss_indir_tbl));
2054+
if (!netif_is_rxfh_configured(wx->netdev)) {
2055+
u16 rss_i = wx->ring_feature[RING_F_RSS].indices;
2056+
u32 reta_entries = wx_rss_indir_tbl_entries(wx);
2057+
u32 i, j;
20662058

2067-
for (i = 0, j = 0; i < reta_entries; i++, j++) {
2068-
if (j == rss_i)
2069-
j = 0;
2059+
memset(wx->rss_indir_tbl, 0, sizeof(wx->rss_indir_tbl));
20702060

2071-
wx->rss_indir_tbl[i] = j;
2061+
if (test_bit(WX_FLAG_SRIOV_ENABLED, wx->flags)) {
2062+
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
2063+
rss_i = rss_i < 2 ? 2 : rss_i;
2064+
else
2065+
rss_i = 1;
2066+
}
2067+
2068+
for (i = 0, j = 0; i < reta_entries; i++, j++) {
2069+
if (j == rss_i)
2070+
j = 0;
2071+
2072+
wx->rss_indir_tbl[i] = j;
2073+
}
20722074
}
20732075

20742076
wx_store_reta(wx);
@@ -2151,8 +2153,6 @@ static void wx_setup_mrqc(struct wx *wx)
21512153
/* Disable indicating checksum in descriptor, enables RSS hash */
21522154
wr32m(wx, WX_PSR_CTL, WX_PSR_CTL_PCSD, WX_PSR_CTL_PCSD);
21532155

2154-
netdev_rss_key_fill(wx->rss_key, sizeof(wx->rss_key));
2155-
21562156
wx_config_rss_field(wx);
21572157
wx_enable_rss(wx, wx->rss_enabled);
21582158
wx_setup_reta(wx);

drivers/net/ethernet/wangxun/libwx/wx_sriov.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ static int wx_pci_sriov_enable(struct pci_dev *dev,
150150
struct wx *wx = pci_get_drvdata(dev);
151151
int err = 0, i;
152152

153+
if (netif_is_rxfh_configured(wx->netdev)) {
154+
wx_err(wx, "Cannot enable SR-IOV while RXFH is configured\n");
155+
wx_err(wx, "Run 'ethtool -X <if> default' to reset RSS table\n");
156+
return -EBUSY;
157+
}
158+
153159
err = __wx_enable_sriov(wx, num_vfs);
154160
if (err)
155161
return err;
@@ -173,12 +179,20 @@ static int wx_pci_sriov_enable(struct pci_dev *dev,
173179
return err;
174180
}
175181

176-
static void wx_pci_sriov_disable(struct pci_dev *dev)
182+
static int wx_pci_sriov_disable(struct pci_dev *dev)
177183
{
178184
struct wx *wx = pci_get_drvdata(dev);
179185

186+
if (netif_is_rxfh_configured(wx->netdev)) {
187+
wx_err(wx, "Cannot disable SR-IOV while RXFH is configured\n");
188+
wx_err(wx, "Run 'ethtool -X <if> default' to reset RSS table\n");
189+
return -EBUSY;
190+
}
191+
180192
wx_disable_sriov(wx);
181193
wx_sriov_reinit(wx);
194+
195+
return 0;
182196
}
183197

184198
int wx_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
@@ -187,10 +201,8 @@ int wx_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
187201
int err;
188202

189203
if (!num_vfs) {
190-
if (!pci_vfs_assigned(pdev)) {
191-
wx_pci_sriov_disable(pdev);
192-
return 0;
193-
}
204+
if (!pci_vfs_assigned(pdev))
205+
return wx_pci_sriov_disable(pdev);
194206

195207
wx_err(wx, "can't free VFs because some are assigned to VMs.\n");
196208
return -EBUSY;

0 commit comments

Comments
 (0)