Commit 30a5de77 authored by Dmitry Kravkov's avatar Dmitry Kravkov Committed by David S. Miller

bnx2x: added support for working with one msix irq.

Until now, the bnx2x driver needed at least 2 available msix interrupt
vectors in order to use msix. This patch add the possibility of configuring
msix when only one interrupt vector is available.
Notice this patch contains lines with over 80 characters, as it keeps print
strings in a single line.
Signed-off-by: default avatarDmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: default avatarYuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: default avatarEilon Greenstein <eilong@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 79a8557a
...@@ -1300,6 +1300,7 @@ struct bnx2x { ...@@ -1300,6 +1300,7 @@ struct bnx2x {
#define NO_ISCSI_FLAG (1 << 14) #define NO_ISCSI_FLAG (1 << 14)
#define NO_FCOE_FLAG (1 << 15) #define NO_FCOE_FLAG (1 << 15)
#define BC_SUPPORTS_PFC_STATS (1 << 17) #define BC_SUPPORTS_PFC_STATS (1 << 17)
#define USING_SINGLE_MSIX_FLAG (1 << 20)
#define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG) #define NO_ISCSI(bp) ((bp)->flags & NO_ISCSI_FLAG)
#define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG) #define NO_ISCSI_OOO(bp) ((bp)->flags & NO_ISCSI_OOO_FLAG)
......
...@@ -1211,16 +1211,15 @@ static void bnx2x_free_msix_irqs(struct bnx2x *bp, int nvecs) ...@@ -1211,16 +1211,15 @@ static void bnx2x_free_msix_irqs(struct bnx2x *bp, int nvecs)
void bnx2x_free_irq(struct bnx2x *bp) void bnx2x_free_irq(struct bnx2x *bp)
{ {
if (bp->flags & USING_MSIX_FLAG) if (bp->flags & USING_MSIX_FLAG &&
!(bp->flags & USING_SINGLE_MSIX_FLAG))
bnx2x_free_msix_irqs(bp, BNX2X_NUM_ETH_QUEUES(bp) + bnx2x_free_msix_irqs(bp, BNX2X_NUM_ETH_QUEUES(bp) +
CNIC_PRESENT + 1); CNIC_PRESENT + 1);
else if (bp->flags & USING_MSI_FLAG)
free_irq(bp->pdev->irq, bp->dev);
else else
free_irq(bp->pdev->irq, bp->dev); free_irq(bp->dev->irq, bp->dev);
} }
int bnx2x_enable_msix(struct bnx2x *bp) int __devinit bnx2x_enable_msix(struct bnx2x *bp)
{ {
int msix_vec = 0, i, rc, req_cnt; int msix_vec = 0, i, rc, req_cnt;
...@@ -1260,8 +1259,8 @@ int bnx2x_enable_msix(struct bnx2x *bp) ...@@ -1260,8 +1259,8 @@ int bnx2x_enable_msix(struct bnx2x *bp)
rc = pci_enable_msix(bp->pdev, &bp->msix_table[0], rc); rc = pci_enable_msix(bp->pdev, &bp->msix_table[0], rc);
if (rc) { if (rc) {
BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc); BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc);
return rc; goto no_msix;
} }
/* /*
* decrease number of queues by number of unallocated entries * decrease number of queues by number of unallocated entries
...@@ -1269,18 +1268,34 @@ int bnx2x_enable_msix(struct bnx2x *bp) ...@@ -1269,18 +1268,34 @@ int bnx2x_enable_msix(struct bnx2x *bp)
bp->num_queues -= diff; bp->num_queues -= diff;
BNX2X_DEV_INFO("New queue configuration set: %d\n", BNX2X_DEV_INFO("New queue configuration set: %d\n",
bp->num_queues); bp->num_queues);
} else if (rc) { } else if (rc > 0) {
/* fall to INTx if not enough memory */ /* Get by with single vector */
if (rc == -ENOMEM) rc = pci_enable_msix(bp->pdev, &bp->msix_table[0], 1);
bp->flags |= DISABLE_MSI_FLAG; if (rc) {
BNX2X_DEV_INFO("Single MSI-X is not attainable rc %d\n",
rc);
goto no_msix;
}
BNX2X_DEV_INFO("Using single MSI-X vector\n");
bp->flags |= USING_SINGLE_MSIX_FLAG;
} else if (rc < 0) {
BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc); BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc);
return rc; goto no_msix;
} }
bp->flags |= USING_MSIX_FLAG; bp->flags |= USING_MSIX_FLAG;
return 0; return 0;
no_msix:
/* fall to INTx if not enough memory */
if (rc == -ENOMEM)
bp->flags |= DISABLE_MSI_FLAG;
return rc;
} }
static int bnx2x_req_msix_irqs(struct bnx2x *bp) static int bnx2x_req_msix_irqs(struct bnx2x *bp)
...@@ -1342,22 +1357,26 @@ int bnx2x_enable_msi(struct bnx2x *bp) ...@@ -1342,22 +1357,26 @@ int bnx2x_enable_msi(struct bnx2x *bp)
static int bnx2x_req_irq(struct bnx2x *bp) static int bnx2x_req_irq(struct bnx2x *bp)
{ {
unsigned long flags; unsigned long flags;
int rc; unsigned int irq;
if (bp->flags & USING_MSI_FLAG) if (bp->flags & (USING_MSI_FLAG | USING_MSIX_FLAG))
flags = 0; flags = 0;
else else
flags = IRQF_SHARED; flags = IRQF_SHARED;
rc = request_irq(bp->pdev->irq, bnx2x_interrupt, flags, if (bp->flags & USING_MSIX_FLAG)
bp->dev->name, bp->dev); irq = bp->msix_table[0].vector;
return rc; else
irq = bp->pdev->irq;
return request_irq(irq, bnx2x_interrupt, flags, bp->dev->name, bp->dev);
} }
static inline int bnx2x_setup_irqs(struct bnx2x *bp) static inline int bnx2x_setup_irqs(struct bnx2x *bp)
{ {
int rc = 0; int rc = 0;
if (bp->flags & USING_MSIX_FLAG) { if (bp->flags & USING_MSIX_FLAG &&
!(bp->flags & USING_SINGLE_MSIX_FLAG)) {
rc = bnx2x_req_msix_irqs(bp); rc = bnx2x_req_msix_irqs(bp);
if (rc) if (rc)
return rc; return rc;
...@@ -1370,8 +1389,13 @@ static inline int bnx2x_setup_irqs(struct bnx2x *bp) ...@@ -1370,8 +1389,13 @@ static inline int bnx2x_setup_irqs(struct bnx2x *bp)
} }
if (bp->flags & USING_MSI_FLAG) { if (bp->flags & USING_MSI_FLAG) {
bp->dev->irq = bp->pdev->irq; bp->dev->irq = bp->pdev->irq;
netdev_info(bp->dev, "using MSI IRQ %d\n", netdev_info(bp->dev, "using MSI IRQ %d\n",
bp->pdev->irq); bp->dev->irq);
}
if (bp->flags & USING_MSIX_FLAG) {
bp->dev->irq = bp->msix_table[0].vector;
netdev_info(bp->dev, "using MSIX IRQ %d\n",
bp->dev->irq);
} }
} }
......
...@@ -485,7 +485,7 @@ void bnx2x_netif_start(struct bnx2x *bp); ...@@ -485,7 +485,7 @@ void bnx2x_netif_start(struct bnx2x *bp);
* fills msix_table, requests vectors, updates num_queues * fills msix_table, requests vectors, updates num_queues
* according to number of available vectors. * according to number of available vectors.
*/ */
int bnx2x_enable_msix(struct bnx2x *bp); int __devinit bnx2x_enable_msix(struct bnx2x *bp);
/** /**
* bnx2x_enable_msi - request msi mode from OS, updated internals accordingly * bnx2x_enable_msi - request msi mode from OS, updated internals accordingly
...@@ -843,7 +843,7 @@ static inline void bnx2x_disable_msi(struct bnx2x *bp) ...@@ -843,7 +843,7 @@ static inline void bnx2x_disable_msi(struct bnx2x *bp)
{ {
if (bp->flags & USING_MSIX_FLAG) { if (bp->flags & USING_MSIX_FLAG) {
pci_disable_msix(bp->pdev); pci_disable_msix(bp->pdev);
bp->flags &= ~USING_MSIX_FLAG; bp->flags &= ~(USING_MSIX_FLAG | USING_SINGLE_MSIX_FLAG);
} else if (bp->flags & USING_MSI_FLAG) { } else if (bp->flags & USING_MSI_FLAG) {
pci_disable_msi(bp->pdev); pci_disable_msi(bp->pdev);
bp->flags &= ~USING_MSI_FLAG; bp->flags &= ~USING_MSI_FLAG;
......
...@@ -1338,8 +1338,9 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp) ...@@ -1338,8 +1338,9 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp)
static void bnx2x_igu_int_enable(struct bnx2x *bp) static void bnx2x_igu_int_enable(struct bnx2x *bp)
{ {
u32 val; u32 val;
int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0; bool msix = (bp->flags & USING_MSIX_FLAG) ? true : false;
int msi = (bp->flags & USING_MSI_FLAG) ? 1 : 0; bool single_msix = (bp->flags & USING_SINGLE_MSIX_FLAG) ? true : false;
bool msi = (bp->flags & USING_MSI_FLAG) ? true : false;
val = REG_RD(bp, IGU_REG_PF_CONFIGURATION); val = REG_RD(bp, IGU_REG_PF_CONFIGURATION);
...@@ -1349,6 +1350,9 @@ static void bnx2x_igu_int_enable(struct bnx2x *bp) ...@@ -1349,6 +1350,9 @@ static void bnx2x_igu_int_enable(struct bnx2x *bp)
val |= (IGU_PF_CONF_FUNC_EN | val |= (IGU_PF_CONF_FUNC_EN |
IGU_PF_CONF_MSI_MSIX_EN | IGU_PF_CONF_MSI_MSIX_EN |
IGU_PF_CONF_ATTN_BIT_EN); IGU_PF_CONF_ATTN_BIT_EN);
if (single_msix)
val |= IGU_PF_CONF_SINGLE_ISR_EN;
} else if (msi) { } else if (msi) {
val &= ~IGU_PF_CONF_INT_LINE_EN; val &= ~IGU_PF_CONF_INT_LINE_EN;
val |= (IGU_PF_CONF_FUNC_EN | val |= (IGU_PF_CONF_FUNC_EN |
...@@ -7149,7 +7153,7 @@ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp) ...@@ -7149,7 +7153,7 @@ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp)
BNX2X_DEV_INFO("set number of queues to 1\n"); BNX2X_DEV_INFO("set number of queues to 1\n");
break; break;
default: default:
/* Set number of queues according to bp->multi_mode value */ /* Set number of queues for MSI-X mode */
bnx2x_set_num_queues(bp); bnx2x_set_num_queues(bp);
BNX2X_DEV_INFO("set number of queues to %d\n", bp->num_queues); BNX2X_DEV_INFO("set number of queues to %d\n", bp->num_queues);
...@@ -7158,15 +7162,17 @@ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp) ...@@ -7158,15 +7162,17 @@ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp)
* so try to enable MSI-X with the requested number of fp's * so try to enable MSI-X with the requested number of fp's
* and fallback to MSI or legacy INTx with one fp * and fallback to MSI or legacy INTx with one fp
*/ */
if (bnx2x_enable_msix(bp)) { if (bnx2x_enable_msix(bp) ||
/* failed to enable MSI-X */ bp->flags & USING_SINGLE_MSIX_FLAG) {
BNX2X_DEV_INFO("Failed to enable MSI-X (%d), set number of queues to %d\n", /* failed to enable multiple MSI-X */
BNX2X_DEV_INFO("Failed to enable multiple MSI-X (%d), set number of queues to %d\n",
bp->num_queues, 1 + NON_ETH_CONTEXT_USE); bp->num_queues, 1 + NON_ETH_CONTEXT_USE);
bp->num_queues = 1 + NON_ETH_CONTEXT_USE; bp->num_queues = 1 + NON_ETH_CONTEXT_USE;
/* Try to enable MSI */ /* Try to enable MSI */
if (!(bp->flags & DISABLE_MSI_FLAG)) if (!(bp->flags & USING_SINGLE_MSIX_FLAG) &&
!(bp->flags & DISABLE_MSI_FLAG))
bnx2x_enable_msi(bp); bnx2x_enable_msi(bp);
} }
break; break;
......
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