i40evf: Refactor VF RSS code
authorAnjali Singhai Jain <anjali.singhai@intel.com>
Tue, 31 Mar 2015 07:45:06 +0000 (00:45 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 3 Apr 2015 10:54:32 +0000 (03:54 -0700)
Refactor VF RSS code to allow RSS on a single queue and eliminate
the need for the next_queue function.

Change-ID: I9253bad96b7f542ee7036e15636db0e5d58d8ef2
Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
Tested-by: Jim Young <james.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40evf/i40evf_main.c

index 46aef2a..6d5f3b2 100644 (file)
@@ -1435,41 +1435,22 @@ restart_watchdog:
 }
 
 /**
- * next_queue - increment to next available tx queue
- * @adapter: board private structure
- * @j: queue counter
- *
- * Helper function for RSS programming to increment through available
- * queus. Returns the next queue value.
- **/
-static int next_queue(struct i40evf_adapter *adapter, int j)
-{
-       j += 1;
-
-       return j >= adapter->num_active_queues ? 0 : j;
-}
-
-/**
- * i40evf_configure_rss - Prepare for RSS if used
+ * i40evf_configure_rss - Prepare for RSS
  * @adapter: board private structure
  **/
 static void i40evf_configure_rss(struct i40evf_adapter *adapter)
 {
        u32 rss_key[I40E_VFQF_HKEY_MAX_INDEX + 1];
        struct i40e_hw *hw = &adapter->hw;
+       u32 cqueue = 0;
        u32 lut = 0;
        int i, j;
        u64 hena;
 
-       /* No RSS for single queue. */
-       if (adapter->num_active_queues == 1) {
-               wr32(hw, I40E_VFQF_HENA(0), 0);
-               wr32(hw, I40E_VFQF_HENA(1), 0);
-               return;
-       }
-
        /* Hash type is configured by the PF - we just supply the key */
        netdev_rss_key_fill(rss_key, sizeof(rss_key));
+
+       /* Fill out hash function seed */
        for (i = 0; i <= I40E_VFQF_HKEY_MAX_INDEX; i++)
                wr32(hw, I40E_VFQF_HKEY(i), rss_key[i]);
 
@@ -1479,16 +1460,14 @@ static void i40evf_configure_rss(struct i40evf_adapter *adapter)
        wr32(hw, I40E_VFQF_HENA(1), (u32)(hena >> 32));
 
        /* Populate the LUT with max no. of queues in round robin fashion */
-       j = adapter->num_active_queues;
        for (i = 0; i <= I40E_VFQF_HLUT_MAX_INDEX; i++) {
-               j = next_queue(adapter, j);
-               lut = j;
-               j = next_queue(adapter, j);
-               lut |= j << 8;
-               j = next_queue(adapter, j);
-               lut |= j << 16;
-               j = next_queue(adapter, j);
-               lut |= j << 24;
+               lut = 0;
+               for (j = 0; j < 4; j++) {
+                       if (cqueue == adapter->vsi_res->num_queue_pairs)
+                               cqueue = 0;
+                       lut |= ((cqueue) << (8 * j));
+                       cqueue++;
+               }
                wr32(hw, I40E_VFQF_HLUT(i), lut);
        }
        i40e_flush(hw);