aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x_main.c
diff options
context:
space:
mode:
authorDmitry Kravkov <dmitry@broadcom.com>2010-10-05 23:32:10 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-06 17:10:40 -0400
commitd6214d7aaa9a82b206dac9e3b0665c49c522a271 (patch)
tree593dae3485d4d5e13eec568460dcd7d8dde4381d /drivers/net/bnx2x/bnx2x_main.c
parent217de5aaed833982c420fc37d82272d84eaefe64 (diff)
bnx2x: move msix table initialization to probe()
Decide which interrupt mode to use (MSI-X, MSI, INTa) only once in probe() and initialize appropriate structures. Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x/bnx2x_main.c')
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c78
1 files changed, 60 insertions, 18 deletions
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 0ac416a14202..2572eb40c0ed 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -90,7 +90,7 @@ module_param(multi_mode, int, 0);
90MODULE_PARM_DESC(multi_mode, " Multi queue mode " 90MODULE_PARM_DESC(multi_mode, " Multi queue mode "
91 "(0 Disable; 1 Enable (default))"); 91 "(0 Disable; 1 Enable (default))");
92 92
93static int num_queues; 93int num_queues;
94module_param(num_queues, int, 0); 94module_param(num_queues, int, 0);
95MODULE_PARM_DESC(num_queues, " Number of queues for multi_mode=1" 95MODULE_PARM_DESC(num_queues, " Number of queues for multi_mode=1"
96 " (default is as a number of CPUs)"); 96 " (default is as a number of CPUs)");
@@ -6409,28 +6409,57 @@ int bnx2x_setup_fw_client(struct bnx2x *bp,
6409 return rc; 6409 return rc;
6410} 6410}
6411 6411
6412void bnx2x_set_num_queues_msix(struct bnx2x *bp) 6412/**
6413 * Configure interrupt mode according to current configuration.
6414 * In case of MSI-X it will also try to enable MSI-X.
6415 *
6416 * @param bp
6417 *
6418 * @return int
6419 */
6420static int __devinit bnx2x_set_int_mode(struct bnx2x *bp)
6413{ 6421{
6422 int rc = 0;
6414 6423
6415 switch (bp->multi_mode) { 6424 switch (bp->int_mode) {
6416 case ETH_RSS_MODE_DISABLED: 6425 case INT_MODE_MSI:
6426 bnx2x_enable_msi(bp);
6427 /* falling through... */
6428 case INT_MODE_INTx:
6417 bp->num_queues = 1; 6429 bp->num_queues = 1;
6430 DP(NETIF_MSG_IFUP, "set number of queues to 1\n");
6418 break; 6431 break;
6432 default:
6433 /* Set number of queues according to bp->multi_mode value */
6434 bnx2x_set_num_queues(bp);
6419 6435
6420 case ETH_RSS_MODE_REGULAR: 6436 DP(NETIF_MSG_IFUP, "set number of queues to %d\n",
6421 if (num_queues) 6437 bp->num_queues);
6422 bp->num_queues = min_t(u32, num_queues,
6423 BNX2X_MAX_QUEUES(bp));
6424 else
6425 bp->num_queues = min_t(u32, num_online_cpus(),
6426 BNX2X_MAX_QUEUES(bp));
6427 break;
6428 6438
6439 /* if we can't use MSI-X we only need one fp,
6440 * so try to enable MSI-X with the requested number of fp's
6441 * and fallback to MSI or legacy INTx with one fp
6442 */
6443 rc = bnx2x_enable_msix(bp);
6444 if (rc) {
6445 /* failed to enable MSI-X */
6446 if (bp->multi_mode)
6447 DP(NETIF_MSG_IFUP,
6448 "Multi requested but failed to "
6449 "enable MSI-X (%d), "
6450 "set number of queues to %d\n",
6451 bp->num_queues,
6452 1);
6453 bp->num_queues = 1;
6454
6455 if (!(bp->flags & DISABLE_MSI_FLAG))
6456 bnx2x_enable_msi(bp);
6457 }
6429 6458
6430 default:
6431 bp->num_queues = 1;
6432 break; 6459 break;
6433 } 6460 }
6461
6462 return rc;
6434} 6463}
6435 6464
6436void bnx2x_ilt_set_info(struct bnx2x *bp) 6465void bnx2x_ilt_set_info(struct bnx2x *bp)
@@ -6881,7 +6910,7 @@ unload_error:
6881 bnx2x_netif_stop(bp, 1); 6910 bnx2x_netif_stop(bp, 1);
6882 6911
6883 /* Release IRQs */ 6912 /* Release IRQs */
6884 bnx2x_free_irq(bp, false); 6913 bnx2x_free_irq(bp);
6885 6914
6886 /* Reset the chip */ 6915 /* Reset the chip */
6887 bnx2x_reset_chip(bp, reset_code); 6916 bnx2x_reset_chip(bp, reset_code);
@@ -9024,7 +9053,16 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
9024 goto init_one_exit; 9053 goto init_one_exit;
9025 } 9054 }
9026 9055
9056 /* Configure interupt mode: try to enable MSI-X/MSI if
9057 * needed, set bp->num_queues appropriately.
9058 */
9059 bnx2x_set_int_mode(bp);
9060
9061 /* Add all NAPI objects */
9062 bnx2x_add_all_napi(bp);
9063
9027 bnx2x_get_pcie_width_speed(bp, &pcie_width, &pcie_speed); 9064 bnx2x_get_pcie_width_speed(bp, &pcie_width, &pcie_speed);
9065
9028 netdev_info(dev, "%s (%c%d) PCI-E x%d %s found at mem %lx," 9066 netdev_info(dev, "%s (%c%d) PCI-E x%d %s found at mem %lx,"
9029 " IRQ %d, ", board_info[ent->driver_data].name, 9067 " IRQ %d, ", board_info[ent->driver_data].name,
9030 (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4), 9068 (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4),
@@ -9068,6 +9106,11 @@ static void __devexit bnx2x_remove_one(struct pci_dev *pdev)
9068 9106
9069 unregister_netdev(dev); 9107 unregister_netdev(dev);
9070 9108
9109 /* Delete all NAPI objects */
9110 bnx2x_del_all_napi(bp);
9111
9112 /* Disable MSI/MSI-X */
9113 bnx2x_disable_msi(bp);
9071 /* Make sure RESET task is not scheduled before continuing */ 9114 /* Make sure RESET task is not scheduled before continuing */
9072 cancel_delayed_work_sync(&bp->reset_task); 9115 cancel_delayed_work_sync(&bp->reset_task);
9073 9116
@@ -9104,15 +9147,14 @@ static int bnx2x_eeh_nic_unload(struct bnx2x *bp)
9104 DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n"); 9147 DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n");
9105 9148
9106 /* Release IRQs */ 9149 /* Release IRQs */
9107 bnx2x_free_irq(bp, false); 9150 bnx2x_free_irq(bp);
9108 9151
9109 /* Free SKBs, SGEs, TPA pool and driver internals */ 9152 /* Free SKBs, SGEs, TPA pool and driver internals */
9110 bnx2x_free_skbs(bp); 9153 bnx2x_free_skbs(bp);
9111 9154
9112 for_each_queue(bp, i) 9155 for_each_queue(bp, i)
9113 bnx2x_free_rx_sge_range(bp, bp->fp + i, NUM_RX_SGE); 9156 bnx2x_free_rx_sge_range(bp, bp->fp + i, NUM_RX_SGE);
9114 for_each_queue(bp, i) 9157
9115 netif_napi_del(&bnx2x_fp(bp, i, napi));
9116 bnx2x_free_mem(bp); 9158 bnx2x_free_mem(bp);
9117 9159
9118 bp->state = BNX2X_STATE_CLOSED; 9160 bp->state = BNX2X_STATE_CLOSED;