igb: Streamline RSS queue and queue pairing assignment logic.
authorMatthew Vick <matthew.vick@intel.com>
Fri, 18 May 2012 04:54:58 +0000 (04:54 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 20 Jun 2012 08:35:27 +0000 (01:35 -0700)
Rather than spread out the complexity of the RSS queue and queue pairing
assignment logic, place it all in one location for simplicity and
readability.

Signed-off-by: Matthew Vick <matthew.vick@intel.com>
Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/igb/igb.h
drivers/net/ethernet/intel/igb/igb_main.c

index ae6d3f393a547b892111d382b17b36530e1fb6e2..3ced7b546f7fc09ef31d7256dd1ed08adb5f4e87 100644 (file)
@@ -65,13 +65,10 @@ struct igb_adapter;
 #define MAX_Q_VECTORS                      8
 
 /* Transmit and receive queues */
-#define IGB_MAX_RX_QUEUES              ((adapter->vfs_allocated_count ? 2 : \
-                                       (hw->mac.type > e1000_82575 ? 8 : 4)))
-#define IGB_MAX_RX_QUEUES_I210             4
+#define IGB_MAX_RX_QUEUES                  8
+#define IGB_MAX_RX_QUEUES_82575            4
 #define IGB_MAX_RX_QUEUES_I211             2
-#define IGB_MAX_TX_QUEUES                  16
-#define IGB_MAX_TX_QUEUES_I210             4
-#define IGB_MAX_TX_QUEUES_I211             2
+#define IGB_MAX_TX_QUEUES                  8
 #define IGB_MAX_VF_MC_ENTRIES              30
 #define IGB_MAX_VF_FUNCTIONS               8
 #define IGB_MAX_VFTA_ENTRIES               128
index 64090549722d2eb953023cb36ac6dda44d545920..a7c9c5d77e0b3fb4d0a4fe48cadc5fac76cee96b 100644 (file)
@@ -1048,11 +1048,6 @@ static int igb_set_interrupt_capability(struct igb_adapter *adapter)
        if (!(adapter->flags & IGB_FLAG_QUEUE_PAIRS))
                numvecs += adapter->num_tx_queues;
 
-       /* i210 and i211 can only have 4 MSIX vectors for rx/tx queues. */
-       if ((adapter->hw.mac.type == e1000_i210)
-               || (adapter->hw.mac.type == e1000_i211))
-               numvecs = 4;
-
        /* store the number of vectors reserved for queues */
        adapter->num_q_vectors = numvecs;
 
@@ -2338,6 +2333,7 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
+       u32 max_rss_queues;
 
        pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word);
 
@@ -2370,40 +2366,69 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
                } else
                        adapter->vfs_allocated_count = max_vfs;
                break;
-       case e1000_i210:
-       case e1000_i211:
-               adapter->vfs_allocated_count = 0;
-               break;
        default:
                break;
        }
 #endif /* CONFIG_PCI_IOV */
+
+       /* Determine the maximum number of RSS queues supported. */
        switch (hw->mac.type) {
+       case e1000_i211:
+               max_rss_queues = IGB_MAX_RX_QUEUES_I211;
+               break;
+       case e1000_82575:
        case e1000_i210:
-               adapter->rss_queues = min_t(u32, IGB_MAX_RX_QUEUES_I210,
-                       num_online_cpus());
+               max_rss_queues = IGB_MAX_RX_QUEUES_82575;
+               break;
+       case e1000_i350:
+               /* I350 cannot do RSS and SR-IOV at the same time */
+               if (!!adapter->vfs_allocated_count) {
+                       max_rss_queues = 1;
+                       break;
+               }
+               /* fall through */
+       case e1000_82576:
+               if (!!adapter->vfs_allocated_count) {
+                       max_rss_queues = 2;
+                       break;
+               }
+               /* fall through */
+       case e1000_82580:
+       default:
+               max_rss_queues = IGB_MAX_RX_QUEUES;
                break;
+       }
+
+       adapter->rss_queues = min_t(u32, max_rss_queues, num_online_cpus());
+
+       /* Determine if we need to pair queues. */
+       switch (hw->mac.type) {
+       case e1000_82575:
        case e1000_i211:
-               adapter->rss_queues = min_t(u32, IGB_MAX_RX_QUEUES_I211,
-                       num_online_cpus());
+               /* Device supports enough interrupts without queue pairing. */
                break;
+       case e1000_82576:
+               /*
+                * If VFs are going to be allocated with RSS queues then we
+                * should pair the queues in order to conserve interrupts due
+                * to limited supply.
+                */
+               if ((adapter->rss_queues > 1) &&
+                   (adapter->vfs_allocated_count > 6))
+                       adapter->flags |= IGB_FLAG_QUEUE_PAIRS;
+               /* fall through */
+       case e1000_82580:
+       case e1000_i350:
+       case e1000_i210:
        default:
-               adapter->rss_queues = min_t(u32, IGB_MAX_RX_QUEUES,
-               num_online_cpus());
+               /*
+                * If rss_queues > half of max_rss_queues, pair the queues in
+                * order to conserve interrupts due to limited supply.
+                */
+               if (adapter->rss_queues > (max_rss_queues / 2))
+                       adapter->flags |= IGB_FLAG_QUEUE_PAIRS;
                break;
        }
-       /* i350 cannot do RSS and SR-IOV at the same time */
-       if (hw->mac.type == e1000_i350 && adapter->vfs_allocated_count)
-               adapter->rss_queues = 1;
-
-       /*
-        * if rss_queues > 4 or vfs are going to be allocated with rss_queues
-        * then we should combine the queues into a queue pair in order to
-        * conserve interrupts due to limited supply
-        */
-       if ((adapter->rss_queues > 4) ||
-           ((adapter->rss_queues > 1) && (adapter->vfs_allocated_count > 6)))
-               adapter->flags |= IGB_FLAG_QUEUE_PAIRS;
 
        /* Setup and initialize a copy of the hw vlan table array */
        adapter->shadow_vfta = kzalloc(sizeof(u32) *