Change igc_ethtool_set_rxfh() to accept and save a userspace-provided
RSS key. When a key is provided, store it in the adapter and write the
RSSRK registers accordingly.

This can be tested using `ethtool -X <dev> hkey <key>`.

Signed-off-by: Kohei Enju <[email protected]>
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 30 +++++++++++---------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 661b044073ca..eb5b146f6f10 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1539,24 +1539,28 @@ static int igc_ethtool_set_rxfh(struct net_device 
*netdev,
        int i;
 
        /* We do not allow change in unsupported parameters */
-       if (rxfh->key ||
-           (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
-            rxfh->hfunc != ETH_RSS_HASH_TOP))
+       if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
+           rxfh->hfunc != ETH_RSS_HASH_TOP)
                return -EOPNOTSUPP;
-       if (!rxfh->indir)
-               return 0;
 
-       num_queues = adapter->rss_queues;
+       if (rxfh->indir) {
+               num_queues = adapter->rss_queues;
 
-       /* Verify user input. */
-       for (i = 0; i < IGC_RETA_SIZE; i++)
-               if (rxfh->indir[i] >= num_queues)
-                       return -EINVAL;
+               /* Verify user input. */
+               for (i = 0; i < IGC_RETA_SIZE; i++)
+                       if (rxfh->indir[i] >= num_queues)
+                               return -EINVAL;
 
-       for (i = 0; i < IGC_RETA_SIZE; i++)
-               adapter->rss_indir_tbl[i] = rxfh->indir[i];
+               for (i = 0; i < IGC_RETA_SIZE; i++)
+                       adapter->rss_indir_tbl[i] = rxfh->indir[i];
 
-       igc_write_rss_indir_tbl(adapter);
+               igc_write_rss_indir_tbl(adapter);
+       }
+
+       if (rxfh->key) {
+               memcpy(adapter->rss_key, rxfh->key, sizeof(adapter->rss_key));
+               igc_write_rss_key(adapter);
+       }
 
        return 0;
 }
-- 
2.51.0

Reply via email to