ixgbe: Check for RSS key before setting value
authorTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 13 Apr 2017 14:26:05 +0000 (07:26 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Sun, 30 Apr 2017 03:01:04 +0000 (20:01 -0700)
The RSS key is being repopulated every time the interface is brought up
regardless of whether there is an existing value. If the user sets the RSS
key and the interface is brought up (e.g. reset), the user specified RSS
key will be overwritten.

This patch changes the rss_key to a pointer so we can check to see if the
key has been populated and preserve it accordingly.

Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

index 85b1afb345e3f10d237f72efec5275193be800cf..76263762bea17eb27bd4f42c0064f4e8a9747b2d 100644 (file)
@@ -769,7 +769,7 @@ struct ixgbe_adapter {
        u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES];
 
 #define IXGBE_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
-       u32 rss_key[IXGBE_RSS_KEY_SIZE / sizeof(u32)];
+       u32 *rss_key;
 };
 
 static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
index b0fd2f58a69c94173c49603bd04b015d4a17639f..7e5e336d7dcc0ec297a300e984fbb4ecda40be34 100644 (file)
@@ -2967,9 +2967,7 @@ static int ixgbe_rss_indir_tbl_max(struct ixgbe_adapter *adapter)
 
 static u32 ixgbe_get_rxfh_key_size(struct net_device *netdev)
 {
-       struct ixgbe_adapter *adapter = netdev_priv(netdev);
-
-       return sizeof(adapter->rss_key);
+       return IXGBE_RSS_KEY_SIZE;
 }
 
 static u32 ixgbe_rss_indir_size(struct net_device *netdev)
index f765a2a0ed4bf8069248c1851dcdc91907a738c0..22a29df1d29eab871818353111e6abc9197e73bf 100644 (file)
@@ -3638,6 +3638,28 @@ void ixgbe_store_key(struct ixgbe_adapter *adapter)
                IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), adapter->rss_key[i]);
 }
 
+/**
+ * ixgbe_init_rss_key - Initialize adapter RSS key
+ * @adapter: device handle
+ *
+ * Allocates and initializes the RSS key if it is not allocated.
+ **/
+static inline int ixgbe_init_rss_key(struct ixgbe_adapter *adapter)
+{
+       u32 *rss_key;
+
+       if (!adapter->rss_key) {
+               rss_key = kzalloc(IXGBE_RSS_KEY_SIZE, GFP_KERNEL);
+               if (unlikely(!rss_key))
+                       return -ENOMEM;
+
+               netdev_rss_key_fill(rss_key, IXGBE_RSS_KEY_SIZE);
+               adapter->rss_key = rss_key;
+       }
+
+       return 0;
+}
+
 /**
  * ixgbe_store_reta - Write the RETA table to HW
  * @adapter: device handle
@@ -3740,7 +3762,7 @@ static void ixgbe_setup_vfreta(struct ixgbe_adapter *adapter)
        /* Fill out hash function seeds */
        for (i = 0; i < 10; i++)
                IXGBE_WRITE_REG(hw, IXGBE_PFVFRSSRK(i, pf_pool),
-                               adapter->rss_key[i]);
+                               *(adapter->rss_key + i));
 
        /* Fill out the redirection table */
        for (i = 0, j = 0; i < 64; i++, j++) {
@@ -3801,7 +3823,6 @@ static void ixgbe_setup_mrqc(struct ixgbe_adapter *adapter)
        if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP)
                rss_field |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
 
-       netdev_rss_key_fill(adapter->rss_key, sizeof(adapter->rss_key));
        if ((hw->mac.type >= ixgbe_mac_X550) &&
            (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) {
                unsigned int pf_pool = adapter->num_vfs;
@@ -6015,6 +6036,9 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,
        if (!adapter->mac_table)
                return -ENOMEM;
 
+       if (ixgbe_init_rss_key(adapter))
+               return -ENOMEM;
+
        /* Set MAC specific capability flags and exceptions */
        switch (hw->mac.type) {
        case ixgbe_mac_82598EB:
@@ -10391,6 +10415,7 @@ err_sw_init:
        iounmap(adapter->io_addr);
        kfree(adapter->jump_tables[0]);
        kfree(adapter->mac_table);
+       kfree(adapter->rss_key);
 err_ioremap:
        disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
        free_netdev(netdev);
@@ -10475,6 +10500,7 @@ static void ixgbe_remove(struct pci_dev *pdev)
        }
 
        kfree(adapter->mac_table);
+       kfree(adapter->rss_key);
        disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
        free_netdev(netdev);
 
index 58897d97412e7dc636ef6978f80dff1fc986a4fd..8baf298a85160c9d270e930083b5100c97f826c5 100644 (file)
@@ -1113,7 +1113,7 @@ static int ixgbe_get_vf_rss_key(struct ixgbe_adapter *adapter,
                return -EOPNOTSUPP;
        }
 
-       memcpy(rss_key, adapter->rss_key, sizeof(adapter->rss_key));
+       memcpy(rss_key, adapter->rss_key, IXGBE_RSS_KEY_SIZE);
 
        return 0;
 }