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>
This commit is contained in:
Jiawen Wu
2025-09-26 10:38:43 +08:00
committed by Jakub Kicinski
parent 2556f80a6a
commit 2a251b85ce
2 changed files with 35 additions and 23 deletions

View File

@@ -2047,28 +2047,30 @@ void wx_store_rsskey(struct wx *wx)
static void wx_setup_reta(struct wx *wx)
{
u16 rss_i = wx->ring_feature[RING_F_RSS].indices;
u32 reta_entries = wx_rss_indir_tbl_entries(wx);
u32 i, j;
if (test_bit(WX_FLAG_SRIOV_ENABLED, wx->flags)) {
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
rss_i = rss_i < 2 ? 2 : rss_i;
else
rss_i = 1;
}
/* Fill out hash function seeds */
wx_store_rsskey(wx);
/* Fill out redirection table */
memset(wx->rss_indir_tbl, 0, sizeof(wx->rss_indir_tbl));
if (!netif_is_rxfh_configured(wx->netdev)) {
u16 rss_i = wx->ring_feature[RING_F_RSS].indices;
u32 reta_entries = wx_rss_indir_tbl_entries(wx);
u32 i, j;
for (i = 0, j = 0; i < reta_entries; i++, j++) {
if (j == rss_i)
j = 0;
memset(wx->rss_indir_tbl, 0, sizeof(wx->rss_indir_tbl));
wx->rss_indir_tbl[i] = j;
if (test_bit(WX_FLAG_SRIOV_ENABLED, wx->flags)) {
if (test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags))
rss_i = rss_i < 2 ? 2 : rss_i;
else
rss_i = 1;
}
for (i = 0, j = 0; i < reta_entries; i++, j++) {
if (j == rss_i)
j = 0;
wx->rss_indir_tbl[i] = j;
}
}
wx_store_reta(wx);
@@ -2151,8 +2153,6 @@ static void wx_setup_mrqc(struct wx *wx)
/* Disable indicating checksum in descriptor, enables RSS hash */
wr32m(wx, WX_PSR_CTL, WX_PSR_CTL_PCSD, WX_PSR_CTL_PCSD);
netdev_rss_key_fill(wx->rss_key, sizeof(wx->rss_key));
wx_config_rss_field(wx);
wx_enable_rss(wx, wx->rss_enabled);
wx_setup_reta(wx);

View File

@@ -150,6 +150,12 @@ static int wx_pci_sriov_enable(struct pci_dev *dev,
struct wx *wx = pci_get_drvdata(dev);
int err = 0, i;
if (netif_is_rxfh_configured(wx->netdev)) {
wx_err(wx, "Cannot enable SR-IOV while RXFH is configured\n");
wx_err(wx, "Run 'ethtool -X <if> default' to reset RSS table\n");
return -EBUSY;
}
err = __wx_enable_sriov(wx, num_vfs);
if (err)
return err;
@@ -173,12 +179,20 @@ static int wx_pci_sriov_enable(struct pci_dev *dev,
return err;
}
static void wx_pci_sriov_disable(struct pci_dev *dev)
static int wx_pci_sriov_disable(struct pci_dev *dev)
{
struct wx *wx = pci_get_drvdata(dev);
if (netif_is_rxfh_configured(wx->netdev)) {
wx_err(wx, "Cannot disable SR-IOV while RXFH is configured\n");
wx_err(wx, "Run 'ethtool -X <if> default' to reset RSS table\n");
return -EBUSY;
}
wx_disable_sriov(wx);
wx_sriov_reinit(wx);
return 0;
}
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)
int err;
if (!num_vfs) {
if (!pci_vfs_assigned(pdev)) {
wx_pci_sriov_disable(pdev);
return 0;
}
if (!pci_vfs_assigned(pdev))
return wx_pci_sriov_disable(pdev);
wx_err(wx, "can't free VFs because some are assigned to VMs.\n");
return -EBUSY;