Commit cd14ef54 authored by Carolyn Wyborny's avatar Carolyn Wyborny Committed by Jeff Kirsher

igb: Change to use statically allocated array for MSIx entries

This patch changes how the driver initializes MSIx and checks
for MSIx configuration.  This change makes it easier to reconfigure the
device when queue changes happen at runtime using ethtool's set_channels
feature.
Signed-off-by: default avatarCarolyn Wyborny <carolyn.wyborny@intel.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 02ef6e1d
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#include <linux/pci.h>
struct igb_adapter; struct igb_adapter;
...@@ -67,6 +68,7 @@ struct igb_adapter; ...@@ -67,6 +68,7 @@ struct igb_adapter;
#define IGB_MIN_ITR_USECS 10 #define IGB_MIN_ITR_USECS 10
#define NON_Q_VECTORS 1 #define NON_Q_VECTORS 1
#define MAX_Q_VECTORS 8 #define MAX_Q_VECTORS 8
#define MAX_MSIX_ENTRIES 10
/* Transmit and receive queues */ /* Transmit and receive queues */
#define IGB_MAX_RX_QUEUES 8 #define IGB_MAX_RX_QUEUES 8
...@@ -127,9 +129,9 @@ struct vf_data_storage { ...@@ -127,9 +129,9 @@ struct vf_data_storage {
#define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8) #define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8)
#define IGB_TX_HTHRESH 1 #define IGB_TX_HTHRESH 1
#define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \ #define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \
adapter->msix_entries) ? 1 : 4) (adapter->flags & IGB_FLAG_HAS_MSIX)) ? 1 : 4)
#define IGB_TX_WTHRESH ((hw->mac.type == e1000_82576 && \ #define IGB_TX_WTHRESH ((hw->mac.type == e1000_82576 && \
adapter->msix_entries) ? 1 : 16) (adapter->flags & IGB_FLAG_HAS_MSIX)) ? 1 : 16)
/* this is the size past which hardware will drop packets when setting LPE=0 */ /* this is the size past which hardware will drop packets when setting LPE=0 */
#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
...@@ -357,7 +359,7 @@ struct igb_adapter { ...@@ -357,7 +359,7 @@ struct igb_adapter {
unsigned int flags; unsigned int flags;
unsigned int num_q_vectors; unsigned int num_q_vectors;
struct msix_entry *msix_entries; struct msix_entry msix_entries[MAX_MSIX_ENTRIES];
/* Interrupt Throttle Rate */ /* Interrupt Throttle Rate */
u32 rx_itr_setting; u32 rx_itr_setting;
...@@ -469,6 +471,7 @@ struct igb_adapter { ...@@ -469,6 +471,7 @@ struct igb_adapter {
#define IGB_FLAG_MEDIA_RESET (1 << 10) #define IGB_FLAG_MEDIA_RESET (1 << 10)
#define IGB_FLAG_MAS_CAPABLE (1 << 11) #define IGB_FLAG_MAS_CAPABLE (1 << 11)
#define IGB_FLAG_MAS_ENABLE (1 << 12) #define IGB_FLAG_MAS_ENABLE (1 << 12)
#define IGB_FLAG_HAS_MSIX (1 << 13)
/* Media Auto Sense */ /* Media Auto Sense */
#define IGB_MAS_ENABLE_0 0X0001 #define IGB_MAS_ENABLE_0 0X0001
......
...@@ -1386,7 +1386,7 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data) ...@@ -1386,7 +1386,7 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
*data = 0; *data = 0;
/* Hook up test interrupt handler just for this test */ /* Hook up test interrupt handler just for this test */
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
if (request_irq(adapter->msix_entries[0].vector, if (request_irq(adapter->msix_entries[0].vector,
igb_test_intr, 0, netdev->name, adapter)) { igb_test_intr, 0, netdev->name, adapter)) {
*data = 1; *data = 1;
...@@ -1519,7 +1519,7 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data) ...@@ -1519,7 +1519,7 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
msleep(10); msleep(10);
/* Unhook test interrupt handler */ /* Unhook test interrupt handler */
if (adapter->msix_entries) if (adapter->flags & IGB_FLAG_HAS_MSIX)
free_irq(adapter->msix_entries[0].vector, adapter); free_irq(adapter->msix_entries[0].vector, adapter);
else else
free_irq(irq, adapter); free_irq(irq, adapter);
...@@ -2933,7 +2933,7 @@ static void igb_get_channels(struct net_device *netdev, ...@@ -2933,7 +2933,7 @@ static void igb_get_channels(struct net_device *netdev,
ch->max_combined = igb_max_channels(adapter); ch->max_combined = igb_max_channels(adapter);
/* Report info for other vector */ /* Report info for other vector */
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
ch->max_other = NON_Q_VECTORS; ch->max_other = NON_Q_VECTORS;
ch->other_count = NON_Q_VECTORS; ch->other_count = NON_Q_VECTORS;
} }
......
...@@ -803,7 +803,7 @@ static void igb_assign_vector(struct igb_q_vector *q_vector, int msix_vector) ...@@ -803,7 +803,7 @@ static void igb_assign_vector(struct igb_q_vector *q_vector, int msix_vector)
msixbm = E1000_EICR_RX_QUEUE0 << rx_queue; msixbm = E1000_EICR_RX_QUEUE0 << rx_queue;
if (tx_queue > IGB_N0_QUEUE) if (tx_queue > IGB_N0_QUEUE)
msixbm |= E1000_EICR_TX_QUEUE0 << tx_queue; msixbm |= E1000_EICR_TX_QUEUE0 << tx_queue;
if (!adapter->msix_entries && msix_vector == 0) if (!(adapter->flags & IGB_FLAG_HAS_MSIX) && msix_vector == 0)
msixbm |= E1000_EIMS_OTHER; msixbm |= E1000_EIMS_OTHER;
array_wr32(E1000_MSIXBM(0), msix_vector, msixbm); array_wr32(E1000_MSIXBM(0), msix_vector, msixbm);
q_vector->eims_value = msixbm; q_vector->eims_value = msixbm;
...@@ -1028,13 +1028,10 @@ static void igb_reset_interrupt_capability(struct igb_adapter *adapter) ...@@ -1028,13 +1028,10 @@ static void igb_reset_interrupt_capability(struct igb_adapter *adapter)
{ {
int v_idx = adapter->num_q_vectors; int v_idx = adapter->num_q_vectors;
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX)
pci_disable_msix(adapter->pdev); pci_disable_msix(adapter->pdev);
kfree(adapter->msix_entries); else if (adapter->flags & IGB_FLAG_HAS_MSI)
adapter->msix_entries = NULL;
} else if (adapter->flags & IGB_FLAG_HAS_MSI) {
pci_disable_msi(adapter->pdev); pci_disable_msi(adapter->pdev);
}
while (v_idx--) while (v_idx--)
igb_reset_q_vector(adapter, v_idx); igb_reset_q_vector(adapter, v_idx);
...@@ -1090,6 +1087,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix) ...@@ -1090,6 +1087,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
if (!msix) if (!msix)
goto msi_only; goto msi_only;
adapter->flags |= IGB_FLAG_HAS_MSIX;
/* Number of supported queues. */ /* Number of supported queues. */
adapter->num_rx_queues = adapter->rss_queues; adapter->num_rx_queues = adapter->rss_queues;
...@@ -1110,12 +1108,6 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix) ...@@ -1110,12 +1108,6 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
/* add 1 vector for link status interrupts */ /* add 1 vector for link status interrupts */
numvecs++; numvecs++;
adapter->msix_entries = kcalloc(numvecs, sizeof(struct msix_entry),
GFP_KERNEL);
if (!adapter->msix_entries)
goto msi_only;
for (i = 0; i < numvecs; i++) for (i = 0; i < numvecs; i++)
adapter->msix_entries[i].entry = i; adapter->msix_entries[i].entry = i;
...@@ -1392,7 +1384,7 @@ static int igb_request_irq(struct igb_adapter *adapter) ...@@ -1392,7 +1384,7 @@ static int igb_request_irq(struct igb_adapter *adapter)
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
int err = 0; int err = 0;
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
err = igb_request_msix(adapter); err = igb_request_msix(adapter);
if (!err) if (!err)
goto request_done; goto request_done;
...@@ -1436,7 +1428,7 @@ static int igb_request_irq(struct igb_adapter *adapter) ...@@ -1436,7 +1428,7 @@ static int igb_request_irq(struct igb_adapter *adapter)
static void igb_free_irq(struct igb_adapter *adapter) static void igb_free_irq(struct igb_adapter *adapter)
{ {
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
int vector = 0, i; int vector = 0, i;
free_irq(adapter->msix_entries[vector++].vector, adapter); free_irq(adapter->msix_entries[vector++].vector, adapter);
...@@ -1461,7 +1453,7 @@ static void igb_irq_disable(struct igb_adapter *adapter) ...@@ -1461,7 +1453,7 @@ static void igb_irq_disable(struct igb_adapter *adapter)
* mapped into these registers and so clearing the bits can cause * mapped into these registers and so clearing the bits can cause
* issues on the VF drivers so we only need to clear what we set * issues on the VF drivers so we only need to clear what we set
*/ */
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
u32 regval = rd32(E1000_EIAM); u32 regval = rd32(E1000_EIAM);
wr32(E1000_EIAM, regval & ~adapter->eims_enable_mask); wr32(E1000_EIAM, regval & ~adapter->eims_enable_mask);
wr32(E1000_EIMC, adapter->eims_enable_mask); wr32(E1000_EIMC, adapter->eims_enable_mask);
...@@ -1472,7 +1464,7 @@ static void igb_irq_disable(struct igb_adapter *adapter) ...@@ -1472,7 +1464,7 @@ static void igb_irq_disable(struct igb_adapter *adapter)
wr32(E1000_IAM, 0); wr32(E1000_IAM, 0);
wr32(E1000_IMC, ~0); wr32(E1000_IMC, ~0);
wrfl(); wrfl();
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
int i; int i;
for (i = 0; i < adapter->num_q_vectors; i++) for (i = 0; i < adapter->num_q_vectors; i++)
synchronize_irq(adapter->msix_entries[i].vector); synchronize_irq(adapter->msix_entries[i].vector);
...@@ -1489,7 +1481,7 @@ static void igb_irq_enable(struct igb_adapter *adapter) ...@@ -1489,7 +1481,7 @@ static void igb_irq_enable(struct igb_adapter *adapter)
{ {
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
u32 ims = E1000_IMS_LSC | E1000_IMS_DOUTSYNC | E1000_IMS_DRSTA; u32 ims = E1000_IMS_LSC | E1000_IMS_DOUTSYNC | E1000_IMS_DRSTA;
u32 regval = rd32(E1000_EIAC); u32 regval = rd32(E1000_EIAC);
wr32(E1000_EIAC, regval | adapter->eims_enable_mask); wr32(E1000_EIAC, regval | adapter->eims_enable_mask);
...@@ -1712,7 +1704,7 @@ int igb_up(struct igb_adapter *adapter) ...@@ -1712,7 +1704,7 @@ int igb_up(struct igb_adapter *adapter)
for (i = 0; i < adapter->num_q_vectors; i++) for (i = 0; i < adapter->num_q_vectors; i++)
napi_enable(&(adapter->q_vector[i]->napi)); napi_enable(&(adapter->q_vector[i]->napi));
if (adapter->msix_entries) if (adapter->flags & IGB_FLAG_HAS_MSIX)
igb_configure_msix(adapter); igb_configure_msix(adapter);
else else
igb_assign_vector(adapter->q_vector[0], 0); igb_assign_vector(adapter->q_vector[0], 0);
...@@ -2565,7 +2557,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2565,7 +2557,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev_info(&pdev->dev, "%s: PBA No: %s\n", netdev->name, part_str); dev_info(&pdev->dev, "%s: PBA No: %s\n", netdev->name, part_str);
dev_info(&pdev->dev, dev_info(&pdev->dev,
"Using %s interrupts. %d rx queue(s), %d tx queue(s)\n", "Using %s interrupts. %d rx queue(s), %d tx queue(s)\n",
adapter->msix_entries ? "MSI-X" : (adapter->flags & IGB_FLAG_HAS_MSIX) ? "MSI-X" :
(adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy", (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy",
adapter->num_rx_queues, adapter->num_tx_queues); adapter->num_rx_queues, adapter->num_tx_queues);
switch (hw->mac.type) { switch (hw->mac.type) {
...@@ -2653,7 +2645,7 @@ static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs) ...@@ -2653,7 +2645,7 @@ static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs)
int err = 0; int err = 0;
int i; int i;
if (!adapter->msix_entries || num_vfs > 7) { if (!(adapter->flags & IGB_FLAG_HAS_MSIX) || num_vfs > 7) {
err = -EPERM; err = -EPERM;
goto out; goto out;
} }
...@@ -4273,7 +4265,7 @@ static void igb_watchdog_task(struct work_struct *work) ...@@ -4273,7 +4265,7 @@ static void igb_watchdog_task(struct work_struct *work)
} }
/* Cause software interrupt to ensure Rx ring is cleaned */ /* Cause software interrupt to ensure Rx ring is cleaned */
if (adapter->msix_entries) { if (adapter->flags & IGB_FLAG_HAS_MSIX) {
u32 eics = 0; u32 eics = 0;
for (i = 0; i < adapter->num_q_vectors; i++) for (i = 0; i < adapter->num_q_vectors; i++)
eics |= adapter->q_vector[i]->eims_value; eics |= adapter->q_vector[i]->eims_value;
...@@ -6194,7 +6186,7 @@ static void igb_ring_irq_enable(struct igb_q_vector *q_vector) ...@@ -6194,7 +6186,7 @@ static void igb_ring_irq_enable(struct igb_q_vector *q_vector)
} }
if (!test_bit(__IGB_DOWN, &adapter->state)) { if (!test_bit(__IGB_DOWN, &adapter->state)) {
if (adapter->msix_entries) if (adapter->flags & IGB_FLAG_HAS_MSIX)
wr32(E1000_EIMS, q_vector->eims_value); wr32(E1000_EIMS, q_vector->eims_value);
else else
igb_irq_enable(adapter); igb_irq_enable(adapter);
...@@ -7561,7 +7553,7 @@ static void igb_netpoll(struct net_device *netdev) ...@@ -7561,7 +7553,7 @@ static void igb_netpoll(struct net_device *netdev)
for (i = 0; i < adapter->num_q_vectors; i++) { for (i = 0; i < adapter->num_q_vectors; i++) {
q_vector = adapter->q_vector[i]; q_vector = adapter->q_vector[i];
if (adapter->msix_entries) if (adapter->flags & IGB_FLAG_HAS_MSIX)
wr32(E1000_EIMC, q_vector->eims_value); wr32(E1000_EIMC, q_vector->eims_value);
else else
igb_irq_disable(adapter); igb_irq_disable(adapter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment