diff options
author | Michael Chan <mchan@broadcom.com> | 2010-07-19 10:15:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-19 23:30:06 -0400 |
commit | 379b39a2ad613745bfbfe80256957d19689b7b94 (patch) | |
tree | dba8eff16c8a78aa38c5408250fbf001576d323c /drivers/net/bnx2.c | |
parent | 6fdae995557f0ad16320951593d6f8f48f57c14a (diff) |
bnx2: Call pci_enable_msix() with actual number of vectors.
Based on original patch by Breno Leitão <leitao@linux.vnet.ibm.com>.
Allocate the actual number of vectors and make use of fewer vectors
if pci_enable_msix() returns > 0. We must allocate one additional
vector for the cnic driver.
Cc: Breno Leitão <leitao@linux.vnet.ibm.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r-- | drivers/net/bnx2.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index deb7f83e8245..d44ecc30865f 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -864,7 +864,7 @@ bnx2_alloc_mem(struct bnx2 *bp) | |||
864 | bnapi->hw_rx_cons_ptr = | 864 | bnapi->hw_rx_cons_ptr = |
865 | &bnapi->status_blk.msi->status_rx_quick_consumer_index0; | 865 | &bnapi->status_blk.msi->status_rx_quick_consumer_index0; |
866 | if (bp->flags & BNX2_FLAG_MSIX_CAP) { | 866 | if (bp->flags & BNX2_FLAG_MSIX_CAP) { |
867 | for (i = 1; i < BNX2_MAX_MSIX_VEC; i++) { | 867 | for (i = 1; i < bp->irq_nvecs; i++) { |
868 | struct status_block_msix *sblk; | 868 | struct status_block_msix *sblk; |
869 | 869 | ||
870 | bnapi = &bp->bnx2_napi[i]; | 870 | bnapi = &bp->bnx2_napi[i]; |
@@ -6152,7 +6152,7 @@ bnx2_free_irq(struct bnx2 *bp) | |||
6152 | static void | 6152 | static void |
6153 | bnx2_enable_msix(struct bnx2 *bp, int msix_vecs) | 6153 | bnx2_enable_msix(struct bnx2 *bp, int msix_vecs) |
6154 | { | 6154 | { |
6155 | int i, rc; | 6155 | int i, total_vecs, rc; |
6156 | struct msix_entry msix_ent[BNX2_MAX_MSIX_VEC]; | 6156 | struct msix_entry msix_ent[BNX2_MAX_MSIX_VEC]; |
6157 | struct net_device *dev = bp->dev; | 6157 | struct net_device *dev = bp->dev; |
6158 | const int len = sizeof(bp->irq_tbl[0].name); | 6158 | const int len = sizeof(bp->irq_tbl[0].name); |
@@ -6171,13 +6171,29 @@ bnx2_enable_msix(struct bnx2 *bp, int msix_vecs) | |||
6171 | msix_ent[i].vector = 0; | 6171 | msix_ent[i].vector = 0; |
6172 | } | 6172 | } |
6173 | 6173 | ||
6174 | rc = pci_enable_msix(bp->pdev, msix_ent, BNX2_MAX_MSIX_VEC); | 6174 | total_vecs = msix_vecs; |
6175 | #ifdef BCM_CNIC | ||
6176 | total_vecs++; | ||
6177 | #endif | ||
6178 | rc = -ENOSPC; | ||
6179 | while (total_vecs >= BNX2_MIN_MSIX_VEC) { | ||
6180 | rc = pci_enable_msix(bp->pdev, msix_ent, total_vecs); | ||
6181 | if (rc <= 0) | ||
6182 | break; | ||
6183 | if (rc > 0) | ||
6184 | total_vecs = rc; | ||
6185 | } | ||
6186 | |||
6175 | if (rc != 0) | 6187 | if (rc != 0) |
6176 | return; | 6188 | return; |
6177 | 6189 | ||
6190 | msix_vecs = total_vecs; | ||
6191 | #ifdef BCM_CNIC | ||
6192 | msix_vecs--; | ||
6193 | #endif | ||
6178 | bp->irq_nvecs = msix_vecs; | 6194 | bp->irq_nvecs = msix_vecs; |
6179 | bp->flags |= BNX2_FLAG_USING_MSIX | BNX2_FLAG_ONE_SHOT_MSI; | 6195 | bp->flags |= BNX2_FLAG_USING_MSIX | BNX2_FLAG_ONE_SHOT_MSI; |
6180 | for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) { | 6196 | for (i = 0; i < total_vecs; i++) { |
6181 | bp->irq_tbl[i].vector = msix_ent[i].vector; | 6197 | bp->irq_tbl[i].vector = msix_ent[i].vector; |
6182 | snprintf(bp->irq_tbl[i].name, len, "%s-%d", dev->name, i); | 6198 | snprintf(bp->irq_tbl[i].name, len, "%s-%d", dev->name, i); |
6183 | bp->irq_tbl[i].handler = bnx2_msi_1shot; | 6199 | bp->irq_tbl[i].handler = bnx2_msi_1shot; |