Skip to content

Commit 78f90dc

Browse files
Matt Carlsondavem330
authored andcommitted
tg3: Move napi_add calls below tg3_get_invariants
tg3_get_invariants(), among other things, discovers whether or not the device is MSI-X capable and how many interrupts it supports. This discovery needs to happen before registering NAPI instances with netdev. This patch moves the code block that calls napi_add later in tg3_init_one() so that tg3_get_invariants() has a chance to run first. Signed-off-by: Matt Carlson <[email protected]> Reviewed-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 35f2d7d commit 78f90dc

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

drivers/net/tg3.c

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14089,53 +14089,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
1408914089
tp->rx_pending = TG3_DEF_RX_RING_PENDING;
1409014090
tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING;
1409114091

14092-
intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW;
14093-
rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW;
14094-
sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW;
14095-
for (i = 0; i < TG3_IRQ_MAX_VECS; i++) {
14096-
struct tg3_napi *tnapi = &tp->napi[i];
14097-
14098-
tnapi->tp = tp;
14099-
tnapi->tx_pending = TG3_DEF_TX_RING_PENDING;
14100-
14101-
tnapi->int_mbox = intmbx;
14102-
if (i < 4)
14103-
intmbx += 0x8;
14104-
else
14105-
intmbx += 0x4;
14106-
14107-
tnapi->consmbox = rcvmbx;
14108-
tnapi->prodmbox = sndmbx;
14109-
14110-
if (i) {
14111-
tnapi->coal_now = HOSTCC_MODE_COAL_VEC1_NOW << (i - 1);
14112-
netif_napi_add(dev, &tnapi->napi, tg3_poll_msix, 64);
14113-
} else {
14114-
tnapi->coal_now = HOSTCC_MODE_NOW;
14115-
netif_napi_add(dev, &tnapi->napi, tg3_poll, 64);
14116-
}
14117-
14118-
if (!(tp->tg3_flags & TG3_FLAG_SUPPORT_MSIX))
14119-
break;
14120-
14121-
/*
14122-
* If we support MSIX, we'll be using RSS. If we're using
14123-
* RSS, the first vector only handles link interrupts and the
14124-
* remaining vectors handle rx and tx interrupts. Reuse the
14125-
* mailbox values for the next iteration. The values we setup
14126-
* above are still useful for the single vectored mode.
14127-
*/
14128-
if (!i)
14129-
continue;
14130-
14131-
rcvmbx += 0x8;
14132-
14133-
if (sndmbx & 0x4)
14134-
sndmbx -= 0x4;
14135-
else
14136-
sndmbx += 0xc;
14137-
}
14138-
1413914092
dev->ethtool_ops = &tg3_ethtool_ops;
1414014093
dev->watchdog_timeo = TG3_TX_TIMEOUT;
1414114094
dev->irq = pdev->irq;
@@ -14278,6 +14231,53 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
1427814231
tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG;
1427914232
tp->link_config.flowctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
1428014233

14234+
intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW;
14235+
rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW;
14236+
sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW;
14237+
for (i = 0; i < TG3_IRQ_MAX_VECS; i++) {
14238+
struct tg3_napi *tnapi = &tp->napi[i];
14239+
14240+
tnapi->tp = tp;
14241+
tnapi->tx_pending = TG3_DEF_TX_RING_PENDING;
14242+
14243+
tnapi->int_mbox = intmbx;
14244+
if (i < 4)
14245+
intmbx += 0x8;
14246+
else
14247+
intmbx += 0x4;
14248+
14249+
tnapi->consmbox = rcvmbx;
14250+
tnapi->prodmbox = sndmbx;
14251+
14252+
if (i) {
14253+
tnapi->coal_now = HOSTCC_MODE_COAL_VEC1_NOW << (i - 1);
14254+
netif_napi_add(dev, &tnapi->napi, tg3_poll_msix, 64);
14255+
} else {
14256+
tnapi->coal_now = HOSTCC_MODE_NOW;
14257+
netif_napi_add(dev, &tnapi->napi, tg3_poll, 64);
14258+
}
14259+
14260+
if (!(tp->tg3_flags & TG3_FLAG_SUPPORT_MSIX))
14261+
break;
14262+
14263+
/*
14264+
* If we support MSIX, we'll be using RSS. If we're using
14265+
* RSS, the first vector only handles link interrupts and the
14266+
* remaining vectors handle rx and tx interrupts. Reuse the
14267+
* mailbox values for the next iteration. The values we setup
14268+
* above are still useful for the single vectored mode.
14269+
*/
14270+
if (!i)
14271+
continue;
14272+
14273+
rcvmbx += 0x8;
14274+
14275+
if (sndmbx & 0x4)
14276+
sndmbx -= 0x4;
14277+
else
14278+
sndmbx += 0xc;
14279+
}
14280+
1428114281
tg3_init_coal(tp);
1428214282

1428314283
pci_set_drvdata(pdev, dev);

0 commit comments

Comments
 (0)