]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: libwx: restrict change user-set RSS configuration
authorJiawen Wu <jiawenwu@trustnetic.com>
Fri, 26 Sep 2025 02:38:43 +0000 (10:38 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 30 Sep 2025 01:11:16 +0000 (18:11 -0700)
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>
drivers/net/ethernet/wangxun/libwx/wx_hw.c
drivers/net/ethernet/wangxun/libwx/wx_sriov.c

index 73d5a2a7c4f66cbcd0ef043c6a76f773dca2e254..1e2713f0c9212f9f9f17cd3de6ee86181ffea3d6 100644 (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);
index c82ae137756cc7067c39a9cee2b275ae5c07b4e3..c6d158cd70da3fcf6107516ffef949b6a44a8fa7 100644 (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 @@ err_out:
        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;