aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-07-05 22:06:45 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-05 22:06:45 -0400
commit6b1344724e10c166d9e3c17011ed879ddf302e94 (patch)
treebbfa98b183c1249a58ad2debdb696392d8c4a029 /drivers
parent8e4a718ff38d8539938ec3421935904c27e00c39 (diff)
parent1ded3f59f35a2642852b3e2a1c0fa8a97777e9af (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'drivers')
-rw-r--r--drivers/isdn/gigaset/ev-layer.c44
-rw-r--r--drivers/isdn/gigaset/isocdata.c6
-rw-r--r--drivers/net/benet/be_hw.h4
-rw-r--r--drivers/net/benet/be_main.c16
-rw-r--r--drivers/net/bnx2x.h2
-rw-r--r--drivers/net/bnx2x_main.c12
-rw-r--r--drivers/net/e1000e/defines.h3
-rw-r--r--drivers/net/e1000e/hw.h4
-rw-r--r--drivers/net/e1000e/ich8lan.c270
-rw-r--r--drivers/net/e1000e/lib.c6
-rw-r--r--drivers/net/e1000e/phy.c12
-rw-r--r--drivers/net/forcedeth.c25
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c32
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c3
-rw-r--r--drivers/net/netxen/netxen_nic.h17
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h1
-rw-r--r--drivers/net/netxen/netxen_nic_init.c111
-rw-r--r--drivers/net/netxen/netxen_nic_main.c4
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c1
-rw-r--r--drivers/net/phy/phy.c25
-rw-r--r--drivers/net/qlge/qlge.h2
-rw-r--r--drivers/net/qlge/qlge_ethtool.c4
-rw-r--r--drivers/net/qlge/qlge_main.c153
-rw-r--r--drivers/net/qlge/qlge_mpi.c6
-rw-r--r--drivers/net/smsc911x.c6
-rw-r--r--drivers/net/tun.c16
27 files changed, 583 insertions, 203 deletions
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index ec5169604a6a..2d91049571a4 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -294,32 +294,33 @@ struct reply_t gigaset_tab_cid[] =
294 {RSP_OK, 604,604, -1, 605, 5, {ACT_CMD+AT_MSN}}, 294 {RSP_OK, 604,604, -1, 605, 5, {ACT_CMD+AT_MSN}},
295 {RSP_OK, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}}, 295 {RSP_OK, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}},
296 {RSP_NULL, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}}, 296 {RSP_NULL, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}},
297 {RSP_OK, 606,606, -1, 607, 5, {0}, "+VLS=17\r"}, /* set "Endgeraetemodus" */ 297 {RSP_OK, 606,606, -1, 607, 5, {0}, "+VLS=17\r"},
298 {RSP_OK, 607,607, -1, 608,-1}, 298 {RSP_OK, 607,607, -1, 608,-1},
299 //{RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 608, 0, {ACT_ERROR}},//DELETE
300 {RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 609, 5, {ACT_CMD+AT_DIAL}}, 299 {RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 609, 5, {ACT_CMD+AT_DIAL}},
301 {RSP_OK, 609,609, -1, 650, 0, {ACT_DIALING}}, 300 {RSP_OK, 609,609, -1, 650, 0, {ACT_DIALING}},
302 301
303 {RSP_ZVLS, 608,608, 17, -1,-1, {ACT_DEBUG}},
304 {RSP_ZCTP, 609,609, -1, -1,-1, {ACT_DEBUG}},
305 {RSP_ZCPN, 609,609, -1, -1,-1, {ACT_DEBUG}},
306 {RSP_ERROR, 601,609, -1, 0, 0, {ACT_ABORTDIAL}}, 302 {RSP_ERROR, 601,609, -1, 0, 0, {ACT_ABORTDIAL}},
307 {EV_TIMEOUT, 601,609, -1, 0, 0, {ACT_ABORTDIAL}}, 303 {EV_TIMEOUT, 601,609, -1, 0, 0, {ACT_ABORTDIAL}},
308 304
309 /* dialing */ 305 /* optional dialing responses */
310 {RSP_ZCTP, 650,650, -1, -1,-1, {ACT_DEBUG}}, 306 {EV_BC_OPEN, 650,650, -1, 651,-1},
311 {RSP_ZCPN, 650,650, -1, -1,-1, {ACT_DEBUG}}, 307 {RSP_ZVLS, 608,651, 17, -1,-1, {ACT_DEBUG}},
312 {RSP_ZSAU, 650,650,ZSAU_CALL_DELIVERED, -1,-1, {ACT_DEBUG}}, /* some devices don't send this */ 308 {RSP_ZCTP, 609,651, -1, -1,-1, {ACT_DEBUG}},
313 309 {RSP_ZCPN, 609,651, -1, -1,-1, {ACT_DEBUG}},
314 /* connection established */ 310 {RSP_ZSAU, 650,651,ZSAU_CALL_DELIVERED, -1,-1, {ACT_DEBUG}},
315 {RSP_ZSAU, 650,650,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}}, //FIXME -> DLE1 311
316 {RSP_ZSAU, 750,750,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}}, //FIXME -> DLE1 312 /* connect */
317 313 {RSP_ZSAU, 650,650,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}},
318 {EV_BC_OPEN, 800,800, -1, 800,-1, {ACT_NOTIFY_BC_UP}}, //FIXME new constate + timeout 314 {RSP_ZSAU, 651,651,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT,
315 ACT_NOTIFY_BC_UP}},
316 {RSP_ZSAU, 750,750,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}},
317 {RSP_ZSAU, 751,751,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT,
318 ACT_NOTIFY_BC_UP}},
319 {EV_BC_OPEN, 800,800, -1, 800,-1, {ACT_NOTIFY_BC_UP}},
319 320
320 /* remote hangup */ 321 /* remote hangup */
321 {RSP_ZSAU, 650,650,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT}}, 322 {RSP_ZSAU, 650,651,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT}},
322 {RSP_ZSAU, 750,750,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}}, 323 {RSP_ZSAU, 750,751,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}},
323 {RSP_ZSAU, 800,800,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}}, 324 {RSP_ZSAU, 800,800,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}},
324 325
325 /* hangup */ 326 /* hangup */
@@ -358,7 +359,8 @@ struct reply_t gigaset_tab_cid[] =
358 {RSP_ZSAU, 700,729,ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT}}, 359 {RSP_ZSAU, 700,729,ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT}},
359 {RSP_ZSAU, 700,729,ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT}}, 360 {RSP_ZSAU, 700,729,ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT}},
360 361
361 {EV_TIMEOUT, 750,750, -1, 0, 0, {ACT_CONNTIMEOUT}}, 362 {EV_BC_OPEN, 750,750, -1, 751,-1},
363 {EV_TIMEOUT, 750,751, -1, 0, 0, {ACT_CONNTIMEOUT}},
362 364
363 /* B channel closed (general case) */ 365 /* B channel closed (general case) */
364 {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME 366 {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME
@@ -876,12 +878,6 @@ static void bchannel_down(struct bc_state *bcs)
876 878
877static void bchannel_up(struct bc_state *bcs) 879static void bchannel_up(struct bc_state *bcs)
878{ 880{
879 if (!(bcs->chstate & CHS_D_UP)) {
880 dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
881 bcs->chstate |= CHS_D_UP;
882 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
883 }
884
885 if (bcs->chstate & CHS_B_UP) { 881 if (bcs->chstate & CHS_B_UP) {
886 dev_notice(bcs->cs->dev, "%s: B channel already up\n", 882 dev_notice(bcs->cs->dev, "%s: B channel already up\n",
887 __func__); 883 __func__);
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index db3a1e4cd489..bed38fcc432b 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -174,12 +174,6 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
174 pr_err("invalid size %d\n", size); 174 pr_err("invalid size %d\n", size);
175 return -EINVAL; 175 return -EINVAL;
176 } 176 }
177 src = iwb->read;
178 if (unlikely(limit >= BAS_OUTBUFSIZE + BAS_OUTBUFPAD ||
179 (read < src && limit >= src))) {
180 pr_err("isoc write buffer frame reservation violated\n");
181 return -EFAULT;
182 }
183#endif 177#endif
184 178
185 if (read < write) { 179 if (read < write) {
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h
index b02e805c1db3..29c33c709c6d 100644
--- a/drivers/net/benet/be_hw.h
+++ b/drivers/net/benet/be_hw.h
@@ -55,6 +55,10 @@
55#define MEMBAR_CTRL_INT_CTRL_PFUNC_MASK 0x7 /* bits 26 - 28 */ 55#define MEMBAR_CTRL_INT_CTRL_PFUNC_MASK 0x7 /* bits 26 - 28 */
56#define MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT 26 56#define MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT 26
57 57
58/********* ISR0 Register offset **********/
59#define CEV_ISR0_OFFSET 0xC18
60#define CEV_ISR_SIZE 4
61
58/********* Event Q door bell *************/ 62/********* Event Q door bell *************/
59#define DB_EQ_OFFSET DB_CQ_OFFSET 63#define DB_EQ_OFFSET DB_CQ_OFFSET
60#define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */ 64#define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 308eb09ca56b..c43f6a119295 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1274,15 +1274,17 @@ static irqreturn_t be_intx(int irq, void *dev)
1274{ 1274{
1275 struct be_adapter *adapter = dev; 1275 struct be_adapter *adapter = dev;
1276 struct be_ctrl_info *ctrl = &adapter->ctrl; 1276 struct be_ctrl_info *ctrl = &adapter->ctrl;
1277 int rx, tx; 1277 int isr;
1278 1278
1279 tx = event_handle(ctrl, &adapter->tx_eq); 1279 isr = ioread32(ctrl->csr + CEV_ISR0_OFFSET +
1280 rx = event_handle(ctrl, &adapter->rx_eq); 1280 ctrl->pci_func * CEV_ISR_SIZE);
1281 if (!isr)
1282 return IRQ_NONE;
1281 1283
1282 if (rx || tx) 1284 event_handle(ctrl, &adapter->tx_eq);
1283 return IRQ_HANDLED; 1285 event_handle(ctrl, &adapter->rx_eq);
1284 else 1286
1285 return IRQ_NONE; 1287 return IRQ_HANDLED;
1286} 1288}
1287 1289
1288static irqreturn_t be_msix_rx(int irq, void *dev) 1290static irqreturn_t be_msix_rx(int irq, void *dev)
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index 8678457849f9..85a737c5c23f 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -902,6 +902,8 @@ struct bnx2x {
902 u16 rx_quick_cons_trip; 902 u16 rx_quick_cons_trip;
903 u16 rx_ticks_int; 903 u16 rx_ticks_int;
904 u16 rx_ticks; 904 u16 rx_ticks;
905/* Maximal coalescing timeout in us */
906#define BNX2X_MAX_COALESCE_TOUT (0xf0*12)
905 907
906 u32 lin_cnt; 908 u32 lin_cnt;
907 909
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 951714a7f90a..6c67be679764 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -4434,7 +4434,7 @@ static void bnx2x_update_coalesce(struct bnx2x *bp)
4434 REG_WR16(bp, BAR_USTRORM_INTMEM + 4434 REG_WR16(bp, BAR_USTRORM_INTMEM +
4435 USTORM_SB_HC_DISABLE_OFFSET(port, sb_id, 4435 USTORM_SB_HC_DISABLE_OFFSET(port, sb_id,
4436 U_SB_ETH_RX_CQ_INDEX), 4436 U_SB_ETH_RX_CQ_INDEX),
4437 bp->rx_ticks ? 0 : 1); 4437 (bp->rx_ticks/12) ? 0 : 1);
4438 4438
4439 /* HC_INDEX_C_ETH_TX_CQ_CONS */ 4439 /* HC_INDEX_C_ETH_TX_CQ_CONS */
4440 REG_WR8(bp, BAR_CSTRORM_INTMEM + 4440 REG_WR8(bp, BAR_CSTRORM_INTMEM +
@@ -4444,7 +4444,7 @@ static void bnx2x_update_coalesce(struct bnx2x *bp)
4444 REG_WR16(bp, BAR_CSTRORM_INTMEM + 4444 REG_WR16(bp, BAR_CSTRORM_INTMEM +
4445 CSTORM_SB_HC_DISABLE_OFFSET(port, sb_id, 4445 CSTORM_SB_HC_DISABLE_OFFSET(port, sb_id,
4446 C_SB_ETH_TX_CQ_INDEX), 4446 C_SB_ETH_TX_CQ_INDEX),
4447 bp->tx_ticks ? 0 : 1); 4447 (bp->tx_ticks/12) ? 0 : 1);
4448 } 4448 }
4449} 4449}
4450 4450
@@ -9069,12 +9069,12 @@ static int bnx2x_set_coalesce(struct net_device *dev,
9069 struct bnx2x *bp = netdev_priv(dev); 9069 struct bnx2x *bp = netdev_priv(dev);
9070 9070
9071 bp->rx_ticks = (u16) coal->rx_coalesce_usecs; 9071 bp->rx_ticks = (u16) coal->rx_coalesce_usecs;
9072 if (bp->rx_ticks > 3000) 9072 if (bp->rx_ticks > BNX2X_MAX_COALESCE_TOUT)
9073 bp->rx_ticks = 3000; 9073 bp->rx_ticks = BNX2X_MAX_COALESCE_TOUT;
9074 9074
9075 bp->tx_ticks = (u16) coal->tx_coalesce_usecs; 9075 bp->tx_ticks = (u16) coal->tx_coalesce_usecs;
9076 if (bp->tx_ticks > 0x3000) 9076 if (bp->tx_ticks > BNX2X_MAX_COALESCE_TOUT)
9077 bp->tx_ticks = 0x3000; 9077 bp->tx_ticks = BNX2X_MAX_COALESCE_TOUT;
9078 9078
9079 if (netif_running(dev)) 9079 if (netif_running(dev))
9080 bnx2x_update_coalesce(bp); 9080 bnx2x_update_coalesce(bp);
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 8890c97e1120..c0f185beb8bc 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -238,6 +238,7 @@
238#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */ 238#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */
239#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */ 239#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */
240#define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion by NVM */ 240#define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion by NVM */
241#define E1000_STATUS_PHYRA 0x00000400 /* PHY Reset Asserted */
241#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */ 242#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */
242 243
243/* Constants used to interpret the masked PCI-X bus speed. */ 244/* Constants used to interpret the masked PCI-X bus speed. */
@@ -575,6 +576,8 @@
575#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */ 576#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
576#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */ 577#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */
577 578
579#define PHY_CONTROL_LB 0x4000 /* PHY Loopback bit */
580
578/* NVM Control */ 581/* NVM Control */
579#define E1000_EECD_SK 0x00000001 /* NVM Clock */ 582#define E1000_EECD_SK 0x00000001 /* NVM Clock */
580#define E1000_EECD_CS 0x00000002 /* NVM Chip Select */ 583#define E1000_EECD_CS 0x00000002 /* NVM Chip Select */
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 163c1c0cfee7..fd44d9f90769 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -215,6 +215,7 @@ enum e1e_registers {
215 E1000_SWSM = 0x05B50, /* SW Semaphore */ 215 E1000_SWSM = 0x05B50, /* SW Semaphore */
216 E1000_FWSM = 0x05B54, /* FW Semaphore */ 216 E1000_FWSM = 0x05B54, /* FW Semaphore */
217 E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */ 217 E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */
218 E1000_CRC_OFFSET = 0x05F50, /* CRC Offset register */
218 E1000_HICR = 0x08F00, /* Host Interface Control */ 219 E1000_HICR = 0x08F00, /* Host Interface Control */
219}; 220};
220 221
@@ -302,6 +303,9 @@ enum e1e_registers {
302#define E1000_KMRNCTRLSTA_REN 0x00200000 303#define E1000_KMRNCTRLSTA_REN 0x00200000
303#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */ 304#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */
304#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */ 305#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */
306#define E1000_KMRNCTRLSTA_K1_CONFIG 0x7
307#define E1000_KMRNCTRLSTA_K1_ENABLE 0x140E
308#define E1000_KMRNCTRLSTA_K1_DISABLE 0x1400
305 309
306#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10 310#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10
307#define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Control */ 311#define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Control */
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 9e23f50fb9cd..d56c7473144a 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -338,6 +338,7 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
338{ 338{
339 struct e1000_nvm_info *nvm = &hw->nvm; 339 struct e1000_nvm_info *nvm = &hw->nvm;
340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
341 union ich8_hws_flash_status hsfsts;
341 u32 gfpreg; 342 u32 gfpreg;
342 u32 sector_base_addr; 343 u32 sector_base_addr;
343 u32 sector_end_addr; 344 u32 sector_end_addr;
@@ -374,6 +375,20 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
374 /* Adjust to word count */ 375 /* Adjust to word count */
375 nvm->flash_bank_size /= sizeof(u16); 376 nvm->flash_bank_size /= sizeof(u16);
376 377
378 /*
379 * Make sure the flash bank size does not overwrite the 4k
380 * sector ranges. We may have 64k allotted to us but we only care
381 * about the first 2 4k sectors. Therefore, if we have anything less
382 * than 64k set in the HSFSTS register, we will reduce the bank size
383 * down to 4k and let the rest remain unused. If berasesz == 3, then
384 * we are working in 64k mode. Otherwise we are not.
385 */
386 if (nvm->flash_bank_size > E1000_ICH8_SHADOW_RAM_WORDS) {
387 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
388 if (hsfsts.hsf_status.berasesz != 3)
389 nvm->flash_bank_size = E1000_ICH8_SHADOW_RAM_WORDS;
390 }
391
377 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; 392 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
378 393
379 /* Clear shadow ram */ 394 /* Clear shadow ram */
@@ -446,6 +461,95 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
446 return 0; 461 return 0;
447} 462}
448 463
464/**
465 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
466 * @hw: pointer to the HW structure
467 *
468 * Checks to see of the link status of the hardware has changed. If a
469 * change in link status has been detected, then we read the PHY registers
470 * to get the current speed/duplex if link exists.
471 **/
472static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
473{
474 struct e1000_mac_info *mac = &hw->mac;
475 s32 ret_val;
476 bool link;
477
478 /*
479 * We only want to go out to the PHY registers to see if Auto-Neg
480 * has completed and/or if our link status has changed. The
481 * get_link_status flag is set upon receiving a Link Status
482 * Change or Rx Sequence Error interrupt.
483 */
484 if (!mac->get_link_status) {
485 ret_val = 0;
486 goto out;
487 }
488
489 if (hw->mac.type == e1000_pchlan) {
490 ret_val = e1000e_write_kmrn_reg(hw,
491 E1000_KMRNCTRLSTA_K1_CONFIG,
492 E1000_KMRNCTRLSTA_K1_ENABLE);
493 if (ret_val)
494 goto out;
495 }
496
497 /*
498 * First we want to see if the MII Status Register reports
499 * link. If so, then we want to get the current speed/duplex
500 * of the PHY.
501 */
502 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
503 if (ret_val)
504 goto out;
505
506 if (!link)
507 goto out; /* No link detected */
508
509 mac->get_link_status = false;
510
511 if (hw->phy.type == e1000_phy_82578) {
512 ret_val = e1000_link_stall_workaround_hv(hw);
513 if (ret_val)
514 goto out;
515 }
516
517 /*
518 * Check if there was DownShift, must be checked
519 * immediately after link-up
520 */
521 e1000e_check_downshift(hw);
522
523 /*
524 * If we are forcing speed/duplex, then we simply return since
525 * we have already determined whether we have link or not.
526 */
527 if (!mac->autoneg) {
528 ret_val = -E1000_ERR_CONFIG;
529 goto out;
530 }
531
532 /*
533 * Auto-Neg is enabled. Auto Speed Detection takes care
534 * of MAC speed/duplex configuration. So we only need to
535 * configure Collision Distance in the MAC.
536 */
537 e1000e_config_collision_dist(hw);
538
539 /*
540 * Configure Flow Control now that Auto-Neg has completed.
541 * First, we need to restore the desired flow control
542 * settings because we may have had to re-autoneg with a
543 * different link partner.
544 */
545 ret_val = e1000e_config_fc_after_link_up(hw);
546 if (ret_val)
547 hw_dbg(hw, "Error configuring flow control\n");
548
549out:
550 return ret_val;
551}
552
449static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) 553static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
450{ 554{
451 struct e1000_hw *hw = &adapter->hw; 555 struct e1000_hw *hw = &adapter->hw;
@@ -694,6 +798,38 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
694} 798}
695 799
696/** 800/**
801 * e1000_lan_init_done_ich8lan - Check for PHY config completion
802 * @hw: pointer to the HW structure
803 *
804 * Check the appropriate indication the MAC has finished configuring the
805 * PHY after a software reset.
806 **/
807static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
808{
809 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
810
811 /* Wait for basic configuration completes before proceeding */
812 do {
813 data = er32(STATUS);
814 data &= E1000_STATUS_LAN_INIT_DONE;
815 udelay(100);
816 } while ((!data) && --loop);
817
818 /*
819 * If basic configuration is incomplete before the above loop
820 * count reaches 0, loading the configuration from NVM will
821 * leave the PHY in a bad state possibly resulting in no link.
822 */
823 if (loop == 0)
824 hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n");
825
826 /* Clear the Init Done bit for the next init event */
827 data = er32(STATUS);
828 data &= ~E1000_STATUS_LAN_INIT_DONE;
829 ew32(STATUS, data);
830}
831
832/**
697 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset 833 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
698 * @hw: pointer to the HW structure 834 * @hw: pointer to the HW structure
699 * 835 *
@@ -707,13 +843,15 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
707 u32 i; 843 u32 i;
708 u32 data, cnf_size, cnf_base_addr, sw_cfg_mask; 844 u32 data, cnf_size, cnf_base_addr, sw_cfg_mask;
709 s32 ret_val; 845 s32 ret_val;
710 u16 loop = E1000_ICH8_LAN_INIT_TIMEOUT;
711 u16 word_addr, reg_data, reg_addr, phy_page = 0; 846 u16 word_addr, reg_data, reg_addr, phy_page = 0;
712 847
713 ret_val = e1000e_phy_hw_reset_generic(hw); 848 ret_val = e1000e_phy_hw_reset_generic(hw);
714 if (ret_val) 849 if (ret_val)
715 return ret_val; 850 return ret_val;
716 851
852 /* Allow time for h/w to get to a quiescent state after reset */
853 mdelay(10);
854
717 if (hw->mac.type == e1000_pchlan) { 855 if (hw->mac.type == e1000_pchlan) {
718 ret_val = e1000_hv_phy_workarounds_ich8lan(hw); 856 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
719 if (ret_val) 857 if (ret_val)
@@ -741,26 +879,8 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
741 if (!(data & sw_cfg_mask)) 879 if (!(data & sw_cfg_mask))
742 return 0; 880 return 0;
743 881
744 /* Wait for basic configuration completes before proceeding*/ 882 /* Wait for basic configuration completes before proceeding */
745 do { 883 e1000_lan_init_done_ich8lan(hw);
746 data = er32(STATUS);
747 data &= E1000_STATUS_LAN_INIT_DONE;
748 udelay(100);
749 } while ((!data) && --loop);
750
751 /*
752 * If basic configuration is incomplete before the above loop
753 * count reaches 0, loading the configuration from NVM will
754 * leave the PHY in a bad state possibly resulting in no link.
755 */
756 if (loop == 0) {
757 hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n");
758 }
759
760 /* Clear the Init Done bit for the next init event */
761 data = er32(STATUS);
762 data &= ~E1000_STATUS_LAN_INIT_DONE;
763 ew32(STATUS, data);
764 884
765 /* 885 /*
766 * Make sure HW does not configure LCD from PHY 886 * Make sure HW does not configure LCD from PHY
@@ -961,12 +1081,14 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
961 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; 1081 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
962 ew32(PHY_CTRL, phy_ctrl); 1082 ew32(PHY_CTRL, phy_ctrl);
963 1083
1084 if (phy->type != e1000_phy_igp_3)
1085 return 0;
1086
964 /* 1087 /*
965 * Call gig speed drop workaround on LPLU before accessing 1088 * Call gig speed drop workaround on LPLU before accessing
966 * any PHY registers 1089 * any PHY registers
967 */ 1090 */
968 if ((hw->mac.type == e1000_ich8lan) && 1091 if (hw->mac.type == e1000_ich8lan)
969 (hw->phy.type == e1000_phy_igp_3))
970 e1000e_gig_downshift_workaround_ich8lan(hw); 1092 e1000e_gig_downshift_workaround_ich8lan(hw);
971 1093
972 /* When LPLU is enabled, we should disable SmartSpeed */ 1094 /* When LPLU is enabled, we should disable SmartSpeed */
@@ -979,6 +1101,9 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
979 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; 1101 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
980 ew32(PHY_CTRL, phy_ctrl); 1102 ew32(PHY_CTRL, phy_ctrl);
981 1103
1104 if (phy->type != e1000_phy_igp_3)
1105 return 0;
1106
982 /* 1107 /*
983 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 1108 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
984 * during Dx states where the power conservation is most 1109 * during Dx states where the power conservation is most
@@ -1038,6 +1163,10 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1038 if (!active) { 1163 if (!active) {
1039 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; 1164 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
1040 ew32(PHY_CTRL, phy_ctrl); 1165 ew32(PHY_CTRL, phy_ctrl);
1166
1167 if (phy->type != e1000_phy_igp_3)
1168 return 0;
1169
1041 /* 1170 /*
1042 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 1171 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
1043 * during Dx states where the power conservation is most 1172 * during Dx states where the power conservation is most
@@ -1073,12 +1202,14 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1073 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; 1202 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
1074 ew32(PHY_CTRL, phy_ctrl); 1203 ew32(PHY_CTRL, phy_ctrl);
1075 1204
1205 if (phy->type != e1000_phy_igp_3)
1206 return 0;
1207
1076 /* 1208 /*
1077 * Call gig speed drop workaround on LPLU before accessing 1209 * Call gig speed drop workaround on LPLU before accessing
1078 * any PHY registers 1210 * any PHY registers
1079 */ 1211 */
1080 if ((hw->mac.type == e1000_ich8lan) && 1212 if (hw->mac.type == e1000_ich8lan)
1081 (hw->phy.type == e1000_phy_igp_3))
1082 e1000e_gig_downshift_workaround_ich8lan(hw); 1213 e1000e_gig_downshift_workaround_ich8lan(hw);
1083 1214
1084 /* When LPLU is enabled, we should disable SmartSpeed */ 1215 /* When LPLU is enabled, we should disable SmartSpeed */
@@ -1905,7 +2036,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
1905 break; 2036 break;
1906 case 1: 2037 case 1:
1907 sector_size = ICH_FLASH_SEG_SIZE_4K; 2038 sector_size = ICH_FLASH_SEG_SIZE_4K;
1908 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K; 2039 iteration = 1;
1909 break; 2040 break;
1910 case 2: 2041 case 2:
1911 if (hw->mac.type == e1000_ich9lan) { 2042 if (hw->mac.type == e1000_ich9lan) {
@@ -1917,7 +2048,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
1917 break; 2048 break;
1918 case 3: 2049 case 3:
1919 sector_size = ICH_FLASH_SEG_SIZE_64K; 2050 sector_size = ICH_FLASH_SEG_SIZE_64K;
1920 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K; 2051 iteration = 1;
1921 break; 2052 break;
1922 default: 2053 default:
1923 return -E1000_ERR_NVM; 2054 return -E1000_ERR_NVM;
@@ -2143,6 +2274,12 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2143 ctrl = er32(CTRL); 2274 ctrl = er32(CTRL);
2144 2275
2145 if (!e1000_check_reset_block(hw)) { 2276 if (!e1000_check_reset_block(hw)) {
2277 /* Clear PHY Reset Asserted bit */
2278 if (hw->mac.type >= e1000_pchlan) {
2279 u32 status = er32(STATUS);
2280 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
2281 }
2282
2146 /* 2283 /*
2147 * PHY HW reset requires MAC CORE reset at the same 2284 * PHY HW reset requires MAC CORE reset at the same
2148 * time to make sure the interface between MAC and the 2285 * time to make sure the interface between MAC and the
@@ -2156,23 +2293,34 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2156 ew32(CTRL, (ctrl | E1000_CTRL_RST)); 2293 ew32(CTRL, (ctrl | E1000_CTRL_RST));
2157 msleep(20); 2294 msleep(20);
2158 2295
2159 if (!ret_val) { 2296 if (!ret_val)
2160 /* release the swflag because it is not reset by
2161 * hardware reset
2162 */
2163 e1000_release_swflag_ich8lan(hw); 2297 e1000_release_swflag_ich8lan(hw);
2164 }
2165 2298
2166 ret_val = e1000e_get_auto_rd_done(hw); 2299 if (ctrl & E1000_CTRL_PHY_RST)
2167 if (ret_val) { 2300 ret_val = hw->phy.ops.get_cfg_done(hw);
2168 /* 2301
2169 * When auto config read does not complete, do not 2302 if (hw->mac.type >= e1000_ich10lan) {
2170 * return with an error. This can happen in situations 2303 e1000_lan_init_done_ich8lan(hw);
2171 * where there is no eeprom and prevents getting link. 2304 } else {
2172 */ 2305 ret_val = e1000e_get_auto_rd_done(hw);
2173 hw_dbg(hw, "Auto Read Done did not complete\n"); 2306 if (ret_val) {
2307 /*
2308 * When auto config read does not complete, do not
2309 * return with an error. This can happen in situations
2310 * where there is no eeprom and prevents getting link.
2311 */
2312 hw_dbg(hw, "Auto Read Done did not complete\n");
2313 }
2174 } 2314 }
2175 2315
2316 /*
2317 * For PCH, this write will make sure that any noise
2318 * will be detected as a CRC error and be dropped rather than show up
2319 * as a bad packet to the DMA engine.
2320 */
2321 if (hw->mac.type == e1000_pchlan)
2322 ew32(CRC_OFFSET, 0x65656565);
2323
2176 ew32(IMC, 0xffffffff); 2324 ew32(IMC, 0xffffffff);
2177 icr = er32(ICR); 2325 icr = er32(ICR);
2178 2326
@@ -2222,6 +2370,18 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
2222 for (i = 0; i < mac->mta_reg_count; i++) 2370 for (i = 0; i < mac->mta_reg_count; i++)
2223 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); 2371 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
2224 2372
2373 /*
2374 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2375 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2376 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2377 */
2378 if (hw->phy.type == e1000_phy_82578) {
2379 hw->phy.ops.read_phy_reg(hw, BM_WUC, &i);
2380 ret_val = e1000_phy_hw_reset_ich8lan(hw);
2381 if (ret_val)
2382 return ret_val;
2383 }
2384
2225 /* Setup link and flow control */ 2385 /* Setup link and flow control */
2226 ret_val = e1000_setup_link_ich8lan(hw); 2386 ret_val = e1000_setup_link_ich8lan(hw);
2227 2387
@@ -2254,16 +2414,6 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
2254 ew32(CTRL_EXT, ctrl_ext); 2414 ew32(CTRL_EXT, ctrl_ext);
2255 2415
2256 /* 2416 /*
2257 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2258 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2259 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2260 */
2261 if (hw->phy.type == e1000_phy_82578) {
2262 e1e_rphy(hw, BM_WUC, &i);
2263 e1000e_phy_hw_reset_generic(hw);
2264 }
2265
2266 /*
2267 * Clear all of the statistics registers (clear on read). It is 2417 * Clear all of the statistics registers (clear on read). It is
2268 * important that we do this after we have tried to establish link 2418 * important that we do this after we have tried to establish link
2269 * because the symbol error count will increment wildly if there 2419 * because the symbol error count will increment wildly if there
@@ -2485,6 +2635,14 @@ static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
2485 if (ret_val) 2635 if (ret_val)
2486 return ret_val; 2636 return ret_val;
2487 2637
2638 if ((hw->mac.type == e1000_pchlan) && (*speed == SPEED_1000)) {
2639 ret_val = e1000e_write_kmrn_reg(hw,
2640 E1000_KMRNCTRLSTA_K1_CONFIG,
2641 E1000_KMRNCTRLSTA_K1_DISABLE);
2642 if (ret_val)
2643 return ret_val;
2644 }
2645
2488 if ((hw->mac.type == e1000_ich8lan) && 2646 if ((hw->mac.type == e1000_ich8lan) &&
2489 (hw->phy.type == e1000_phy_igp_3) && 2647 (hw->phy.type == e1000_phy_igp_3) &&
2490 (*speed == SPEED_1000)) { 2648 (*speed == SPEED_1000)) {
@@ -2850,6 +3008,16 @@ static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
2850{ 3008{
2851 u32 bank = 0; 3009 u32 bank = 0;
2852 3010
3011 if (hw->mac.type >= e1000_pchlan) {
3012 u32 status = er32(STATUS);
3013
3014 if (status & E1000_STATUS_PHYRA)
3015 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
3016 else
3017 hw_dbg(hw,
3018 "PHY Reset Asserted not set - needs delay\n");
3019 }
3020
2853 e1000e_get_cfg_done(hw); 3021 e1000e_get_cfg_done(hw);
2854 3022
2855 /* If EEPROM is not marked present, init the IGP 3 PHY manually */ 3023 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
@@ -2921,7 +3089,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
2921static struct e1000_mac_operations ich8_mac_ops = { 3089static struct e1000_mac_operations ich8_mac_ops = {
2922 .id_led_init = e1000e_id_led_init, 3090 .id_led_init = e1000e_id_led_init,
2923 .check_mng_mode = e1000_check_mng_mode_ich8lan, 3091 .check_mng_mode = e1000_check_mng_mode_ich8lan,
2924 .check_for_link = e1000e_check_for_copper_link, 3092 .check_for_link = e1000_check_for_copper_link_ich8lan,
2925 /* cleanup_led dependent on mac type */ 3093 /* cleanup_led dependent on mac type */
2926 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, 3094 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
2927 .get_bus_info = e1000_get_bus_info_ich8lan, 3095 .get_bus_info = e1000_get_bus_info_ich8lan,
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index be6d9e990374..99ba2b8a2a05 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -378,12 +378,6 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
378 378
379 mac->get_link_status = 0; 379 mac->get_link_status = 0;
380 380
381 if (hw->phy.type == e1000_phy_82578) {
382 ret_val = e1000_link_stall_workaround_hv(hw);
383 if (ret_val)
384 return ret_val;
385 }
386
387 /* 381 /*
388 * Check if there was DownShift, must be checked 382 * Check if there was DownShift, must be checked
389 * immediately after link-up 383 * immediately after link-up
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
index e23459cf3d0e..994401fd0664 100644
--- a/drivers/net/e1000e/phy.c
+++ b/drivers/net/e1000e/phy.c
@@ -1531,7 +1531,12 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
1531 */ 1531 */
1532 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); 1532 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
1533 if (ret_val) 1533 if (ret_val)
1534 break; 1534 /*
1535 * If the first read fails, another entity may have
1536 * ownership of the resources, wait and try again to
1537 * see if they have relinquished the resources yet.
1538 */
1539 udelay(usec_interval);
1535 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); 1540 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
1536 if (ret_val) 1541 if (ret_val)
1537 break; 1542 break;
@@ -2737,6 +2742,11 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)
2737 if (hw->phy.type != e1000_phy_82578) 2742 if (hw->phy.type != e1000_phy_82578)
2738 goto out; 2743 goto out;
2739 2744
2745 /* Do not apply workaround if in PHY loopback bit 14 set */
2746 hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &data);
2747 if (data & PHY_CONTROL_LB)
2748 goto out;
2749
2740 /* check if link is up and at 1Gbps */ 2750 /* check if link is up and at 1Gbps */
2741 ret_val = hw->phy.ops.read_phy_reg(hw, BM_CS_STATUS, &data); 2751 ret_val = hw->phy.ops.read_phy_reg(hw, BM_CS_STATUS, &data);
2742 if (ret_val) 2752 if (ret_val)
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 1094d292630f..3b4e0766c7b2 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -3514,11 +3514,13 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
3514 nv_msi_workaround(np); 3514 nv_msi_workaround(np);
3515 3515
3516#ifdef CONFIG_FORCEDETH_NAPI 3516#ifdef CONFIG_FORCEDETH_NAPI
3517 napi_schedule(&np->napi); 3517 if (napi_schedule_prep(&np->napi)) {
3518 3518 /*
3519 /* Disable furthur irq's 3519 * Disable further irq's (msix not enabled with napi)
3520 (msix not enabled with napi) */ 3520 */
3521 writel(0, base + NvRegIrqMask); 3521 writel(0, base + NvRegIrqMask);
3522 __napi_schedule(&np->napi);
3523 }
3522 3524
3523#else 3525#else
3524 do 3526 do
@@ -3615,12 +3617,13 @@ static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
3615 nv_msi_workaround(np); 3617 nv_msi_workaround(np);
3616 3618
3617#ifdef CONFIG_FORCEDETH_NAPI 3619#ifdef CONFIG_FORCEDETH_NAPI
3618 napi_schedule(&np->napi); 3620 if (napi_schedule_prep(&np->napi)) {
3619 3621 /*
3620 /* Disable furthur irq's 3622 * Disable further irq's (msix not enabled with napi)
3621 (msix not enabled with napi) */ 3623 */
3622 writel(0, base + NvRegIrqMask); 3624 writel(0, base + NvRegIrqMask);
3623 3625 __napi_schedule(&np->napi);
3626 }
3624#else 3627#else
3625 do 3628 do
3626 { 3629 {
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 0f7b6a3a2e68..2a978008fd6e 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -1830,7 +1830,6 @@ static int ixgbe_wol_exclusion(struct ixgbe_adapter *adapter,
1830 break; 1830 break;
1831 default: 1831 default:
1832 wol->supported = 0; 1832 wol->supported = 0;
1833 retval = 0;
1834 } 1833 }
1835 1834
1836 return retval; 1835 return retval;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 5588ef493a3d..a3061aacffd8 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2697,19 +2697,23 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
2697 2697
2698 /* 2698 /*
2699 * For hot-pluggable SFP+ devices, a new SFP+ module may have 2699 * For hot-pluggable SFP+ devices, a new SFP+ module may have
2700 * arrived before interrupts were enabled. We need to kick off 2700 * arrived before interrupts were enabled but after probe. Such
2701 * the SFP+ module setup first, then try to bring up link. 2701 * devices wouldn't have their type identified yet. We need to
2702 * kick off the SFP+ module setup first, then try to bring up link.
2702 * If we're not hot-pluggable SFP+, we just need to configure link 2703 * If we're not hot-pluggable SFP+, we just need to configure link
2703 * and bring it up. 2704 * and bring it up.
2704 */ 2705 */
2705 err = hw->phy.ops.identify(hw); 2706 if (hw->phy.type == ixgbe_phy_unknown) {
2706 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { 2707 err = hw->phy.ops.identify(hw);
2707 dev_err(&adapter->pdev->dev, "failed to initialize because " 2708 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
2708 "an unsupported SFP+ module type was detected.\n" 2709 /*
2709 "Reload the driver after installing a supported " 2710 * Take the device down and schedule the sfp tasklet
2710 "module.\n"); 2711 * which will unregister_netdev and log it.
2711 ixgbe_down(adapter); 2712 */
2712 return err; 2713 ixgbe_down(adapter);
2714 schedule_work(&adapter->sfp_config_module_task);
2715 return err;
2716 }
2713 } 2717 }
2714 2718
2715 if (ixgbe_is_sfp(hw)) { 2719 if (ixgbe_is_sfp(hw)) {
@@ -3724,7 +3728,7 @@ static void ixgbe_sfp_task(struct work_struct *work)
3724 if ((hw->phy.type == ixgbe_phy_nl) && 3728 if ((hw->phy.type == ixgbe_phy_nl) &&
3725 (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) { 3729 (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) {
3726 s32 ret = hw->phy.ops.identify_sfp(hw); 3730 s32 ret = hw->phy.ops.identify_sfp(hw);
3727 if (ret) 3731 if (ret == IXGBE_ERR_SFP_NOT_PRESENT)
3728 goto reschedule; 3732 goto reschedule;
3729 ret = hw->phy.ops.reset(hw); 3733 ret = hw->phy.ops.reset(hw);
3730 if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) { 3734 if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) {
@@ -4534,13 +4538,17 @@ static void ixgbe_sfp_config_module_task(struct work_struct *work)
4534 u32 err; 4538 u32 err;
4535 4539
4536 adapter->flags |= IXGBE_FLAG_IN_SFP_MOD_TASK; 4540 adapter->flags |= IXGBE_FLAG_IN_SFP_MOD_TASK;
4541
4542 /* Time for electrical oscillations to settle down */
4543 msleep(100);
4537 err = hw->phy.ops.identify_sfp(hw); 4544 err = hw->phy.ops.identify_sfp(hw);
4545
4538 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { 4546 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
4539 dev_err(&adapter->pdev->dev, "failed to initialize because " 4547 dev_err(&adapter->pdev->dev, "failed to initialize because "
4540 "an unsupported SFP+ module type was detected.\n" 4548 "an unsupported SFP+ module type was detected.\n"
4541 "Reload the driver after installing a supported " 4549 "Reload the driver after installing a supported "
4542 "module.\n"); 4550 "module.\n");
4543 ixgbe_down(adapter); 4551 unregister_netdev(adapter->netdev);
4544 return; 4552 return;
4545 } 4553 }
4546 hw->mac.ops.setup_sfp(hw); 4554 hw->mac.ops.setup_sfp(hw);
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 453e966762f0..9ecad17522c3 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -60,6 +60,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
60 60
61 if (hw->phy.type == ixgbe_phy_unknown) { 61 if (hw->phy.type == ixgbe_phy_unknown) {
62 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) { 62 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
63 hw->phy.mdio.prtad = phy_addr;
63 if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) { 64 if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) {
64 ixgbe_get_phy_id(hw); 65 ixgbe_get_phy_id(hw);
65 hw->phy.type = 66 hw->phy.type =
@@ -68,6 +69,8 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
68 break; 69 break;
69 } 70 }
70 } 71 }
72 /* clear value if nothing found */
73 hw->phy.mdio.prtad = 0;
71 } else { 74 } else {
72 status = 0; 75 status = 0;
73 } 76 }
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 970cedeb5f37..e1cdba752e09 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -60,7 +60,18 @@
60#define _NETXEN_NIC_LINUX_SUBVERSION 30 60#define _NETXEN_NIC_LINUX_SUBVERSION 30
61#define NETXEN_NIC_LINUX_VERSIONID "4.0.30" 61#define NETXEN_NIC_LINUX_VERSIONID "4.0.30"
62 62
63#define NETXEN_VERSION_CODE(a, b, c) (((a) << 16) + ((b) << 8) + (c)) 63#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
64#define _major(v) (((v) >> 24) & 0xff)
65#define _minor(v) (((v) >> 16) & 0xff)
66#define _build(v) ((v) & 0xffff)
67
68/* version in image has weird encoding:
69 * 7:0 - major
70 * 15:8 - minor
71 * 31:16 - build (little endian)
72 */
73#define NETXEN_DECODE_VERSION(v) \
74 NETXEN_VERSION_CODE(((v) & 0xff), (((v) >> 8) & 0xff), ((v) >> 16))
64 75
65#define NETXEN_NUM_FLASH_SECTORS (64) 76#define NETXEN_NUM_FLASH_SECTORS (64)
66#define NETXEN_FLASH_SECTOR_SIZE (64 * 1024) 77#define NETXEN_FLASH_SECTOR_SIZE (64 * 1024)
@@ -614,6 +625,7 @@ struct netxen_new_user_info {
614#define NX_P2_MN_ROMIMAGE 0 625#define NX_P2_MN_ROMIMAGE 0
615#define NX_P3_CT_ROMIMAGE 1 626#define NX_P3_CT_ROMIMAGE 1
616#define NX_P3_MN_ROMIMAGE 2 627#define NX_P3_MN_ROMIMAGE 2
628#define NX_FLASH_ROMIMAGE 3
617 629
618#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */ 630#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */
619 631
@@ -1243,7 +1255,7 @@ struct netxen_adapter {
1243 u32 resv3; 1255 u32 resv3;
1244 1256
1245 u8 has_link_events; 1257 u8 has_link_events;
1246 u8 resv1; 1258 u8 fw_type;
1247 u16 tx_context_id; 1259 u16 tx_context_id;
1248 u16 mtu; 1260 u16 mtu;
1249 u16 is_up; 1261 u16 is_up;
@@ -1387,6 +1399,7 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1387int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); 1399int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
1388int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); 1400int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
1389int netxen_load_firmware(struct netxen_adapter *adapter); 1401int netxen_load_firmware(struct netxen_adapter *adapter);
1402int netxen_need_fw_reset(struct netxen_adapter *adapter);
1390void netxen_request_firmware(struct netxen_adapter *adapter); 1403void netxen_request_firmware(struct netxen_adapter *adapter);
1391void netxen_release_firmware(struct netxen_adapter *adapter); 1404void netxen_release_firmware(struct netxen_adapter *adapter);
1392int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); 1405int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 3cc047844af3..824103675648 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -853,6 +853,7 @@ enum {
853#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c)) 853#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c))
854 854
855#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14) 855#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14)
856#define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0))
856 857
857#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC))) 858#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
858#define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) 859#define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200)
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 055bb61d6e77..b899bd51fcd8 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -684,11 +684,84 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
684} 684}
685 685
686int 686int
687netxen_need_fw_reset(struct netxen_adapter *adapter)
688{
689 u32 count, old_count;
690 u32 val, version, major, minor, build;
691 int i, timeout;
692 u8 fw_type;
693
694 /* NX2031 firmware doesn't support heartbit */
695 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
696 return 1;
697
698 /* last attempt had failed */
699 if (NXRD32(adapter, CRB_CMDPEG_STATE) == PHAN_INITIALIZE_FAILED)
700 return 1;
701
702 old_count = count = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
703
704 for (i = 0; i < 10; i++) {
705
706 timeout = msleep_interruptible(200);
707 if (timeout) {
708 NXWR32(adapter, CRB_CMDPEG_STATE,
709 PHAN_INITIALIZE_FAILED);
710 return -EINTR;
711 }
712
713 count = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
714 if (count != old_count)
715 break;
716 }
717
718 /* firmware is dead */
719 if (count == old_count)
720 return 1;
721
722 /* check if we have got newer or different file firmware */
723 if (adapter->fw) {
724
725 const struct firmware *fw = adapter->fw;
726
727 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
728 version = NETXEN_DECODE_VERSION(val);
729
730 major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
731 minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
732 build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
733
734 if (version > NETXEN_VERSION_CODE(major, minor, build))
735 return 1;
736
737 if (version == NETXEN_VERSION_CODE(major, minor, build)) {
738
739 val = NXRD32(adapter, NETXEN_MIU_MN_CONTROL);
740 fw_type = (val & 0x4) ?
741 NX_P3_CT_ROMIMAGE : NX_P3_MN_ROMIMAGE;
742
743 if (adapter->fw_type != fw_type)
744 return 1;
745 }
746 }
747
748 return 0;
749}
750
751static char *fw_name[] = {
752 "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin", "flash",
753};
754
755int
687netxen_load_firmware(struct netxen_adapter *adapter) 756netxen_load_firmware(struct netxen_adapter *adapter)
688{ 757{
689 u64 *ptr64; 758 u64 *ptr64;
690 u32 i, flashaddr, size; 759 u32 i, flashaddr, size;
691 const struct firmware *fw = adapter->fw; 760 const struct firmware *fw = adapter->fw;
761 struct pci_dev *pdev = adapter->pdev;
762
763 dev_info(&pdev->dev, "loading firmware from %s\n",
764 fw_name[adapter->fw_type]);
692 765
693 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) 766 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
694 NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1); 767 NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1);
@@ -756,7 +829,7 @@ static int
756netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname) 829netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
757{ 830{
758 __le32 val; 831 __le32 val;
759 u32 major, minor, build, ver, min_ver, bios; 832 u32 ver, min_ver, bios;
760 struct pci_dev *pdev = adapter->pdev; 833 struct pci_dev *pdev = adapter->pdev;
761 const struct firmware *fw = adapter->fw; 834 const struct firmware *fw = adapter->fw;
762 835
@@ -768,21 +841,18 @@ netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
768 return -EINVAL; 841 return -EINVAL;
769 842
770 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]); 843 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
771 major = (__force u32)val & 0xff;
772 minor = ((__force u32)val >> 8) & 0xff;
773 build = (__force u32)val >> 16;
774 844
775 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 845 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
776 min_ver = NETXEN_VERSION_CODE(4, 0, 216); 846 min_ver = NETXEN_VERSION_CODE(4, 0, 216);
777 else 847 else
778 min_ver = NETXEN_VERSION_CODE(3, 4, 216); 848 min_ver = NETXEN_VERSION_CODE(3, 4, 216);
779 849
780 ver = NETXEN_VERSION_CODE(major, minor, build); 850 ver = NETXEN_DECODE_VERSION(val);
781 851
782 if ((major > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) { 852 if ((_major(ver) > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) {
783 dev_err(&pdev->dev, 853 dev_err(&pdev->dev,
784 "%s: firmware version %d.%d.%d unsupported\n", 854 "%s: firmware version %d.%d.%d unsupported\n",
785 fwname, major, minor, build); 855 fwname, _major(ver), _minor(ver), _build(ver));
786 return -EINVAL; 856 return -EINVAL;
787 } 857 }
788 858
@@ -798,22 +868,21 @@ netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
798 if (netxen_rom_fast_read(adapter, 868 if (netxen_rom_fast_read(adapter,
799 NX_FW_VERSION_OFFSET, (int *)&val)) 869 NX_FW_VERSION_OFFSET, (int *)&val))
800 return -EIO; 870 return -EIO;
801 major = (__force u32)val & 0xff; 871 val = NETXEN_DECODE_VERSION(val);
802 minor = ((__force u32)val >> 8) & 0xff; 872 if (val > ver) {
803 build = (__force u32)val >> 16; 873 dev_info(&pdev->dev, "%s: firmware is older than flash\n",
804 if (NETXEN_VERSION_CODE(major, minor, build) > ver) 874 fwname);
805 return -EINVAL; 875 return -EINVAL;
876 }
806 877
807 NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); 878 NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
808 return 0; 879 return 0;
809} 880}
810 881
811static char *fw_name[] = { "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin" };
812
813void netxen_request_firmware(struct netxen_adapter *adapter) 882void netxen_request_firmware(struct netxen_adapter *adapter)
814{ 883{
815 u32 capability, flashed_ver; 884 u32 capability, flashed_ver;
816 int fw_type; 885 u8 fw_type;
817 struct pci_dev *pdev = adapter->pdev; 886 struct pci_dev *pdev = adapter->pdev;
818 int rc = 0; 887 int rc = 0;
819 888
@@ -830,6 +899,8 @@ request_mn:
830 899
831 netxen_rom_fast_read(adapter, 900 netxen_rom_fast_read(adapter,
832 NX_FW_VERSION_OFFSET, (int *)&flashed_ver); 901 NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
902 flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
903
833 if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) { 904 if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
834 capability = NXRD32(adapter, NX_PEG_TUNE_CAPABILITY); 905 capability = NXRD32(adapter, NX_PEG_TUNE_CAPABILITY);
835 if (capability & NX_PEG_TUNE_MN_PRESENT) { 906 if (capability & NX_PEG_TUNE_MN_PRESENT) {
@@ -838,6 +909,10 @@ request_mn:
838 } 909 }
839 } 910 }
840 911
912 fw_type = NX_FLASH_ROMIMAGE;
913 adapter->fw = NULL;
914 goto done;
915
841request_fw: 916request_fw:
842 rc = request_firmware(&adapter->fw, fw_name[fw_type], &pdev->dev); 917 rc = request_firmware(&adapter->fw, fw_name[fw_type], &pdev->dev);
843 if (rc != 0) { 918 if (rc != 0) {
@@ -846,6 +921,7 @@ request_fw:
846 goto request_mn; 921 goto request_mn;
847 } 922 }
848 923
924 fw_type = NX_FLASH_ROMIMAGE;
849 adapter->fw = NULL; 925 adapter->fw = NULL;
850 goto done; 926 goto done;
851 } 927 }
@@ -859,16 +935,13 @@ request_fw:
859 goto request_mn; 935 goto request_mn;
860 } 936 }
861 937
938 fw_type = NX_FLASH_ROMIMAGE;
862 adapter->fw = NULL; 939 adapter->fw = NULL;
863 goto done; 940 goto done;
864 } 941 }
865 942
866done: 943done:
867 if (adapter->fw) 944 adapter->fw_type = fw_type;
868 dev_info(&pdev->dev, "loading firmware from file %s\n",
869 fw_name[fw_type]);
870 else
871 dev_info(&pdev->dev, "loading firmware from flash\n");
872} 945}
873 946
874 947
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 2919a2d12bf4..27539ddf94c4 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -718,6 +718,10 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
718 if (request_fw) 718 if (request_fw)
719 netxen_request_firmware(adapter); 719 netxen_request_firmware(adapter);
720 720
721 err = netxen_need_fw_reset(adapter);
722 if (err <= 0)
723 return err;
724
721 if (first_boot != 0x55555555) { 725 if (first_boot != 0x55555555) {
722 NXWR32(adapter, CRB_CMDPEG_STATE, 0); 726 NXWR32(adapter, CRB_CMDPEG_STATE, 0);
723 netxen_pinit_from_rom(adapter, 0); 727 netxen_pinit_from_rom(adapter, 0);
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 652a36888361..9ef1c1bfa83d 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1727,6 +1727,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
1727 PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10BaseT 3.3V", 0xebf91155, 0x7f5a4f50), 1727 PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10BaseT 3.3V", 0xebf91155, 0x7f5a4f50),
1728 PCMCIA_DEVICE_PROD_ID12("Psion Dacom", "Gold Card Ethernet", 0xf5f025c2, 0x3a30e110), 1728 PCMCIA_DEVICE_PROD_ID12("Psion Dacom", "Gold Card Ethernet", 0xf5f025c2, 0x3a30e110),
1729 PCMCIA_DEVICE_PROD_ID12("=RELIA==", "Ethernet", 0xcdd0644a, 0x00b2e941), 1729 PCMCIA_DEVICE_PROD_ID12("=RELIA==", "Ethernet", 0xcdd0644a, 0x00b2e941),
1730 PCMCIA_DEVICE_PROD_ID12("RIOS Systems Co.", "PC CARD3 ETHERNET", 0x7dd33481, 0x10b41826),
1730 PCMCIA_DEVICE_PROD_ID12("RP", "1625B Ethernet NE2000 Compatible", 0xe3e66e22, 0xb96150df), 1731 PCMCIA_DEVICE_PROD_ID12("RP", "1625B Ethernet NE2000 Compatible", 0xe3e66e22, 0xb96150df),
1731 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP400 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4a7e2ae0), 1732 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP400 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4a7e2ae0),
1732 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP401 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4bcbd7fd), 1733 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP401 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4bcbd7fd),
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 61755cbd978e..eda94fcd4065 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -928,13 +928,32 @@ static void phy_state_machine(struct work_struct *work)
928 * Otherwise, it's 0, and we're 928 * Otherwise, it's 0, and we're
929 * still waiting for AN */ 929 * still waiting for AN */
930 if (err > 0) { 930 if (err > 0) {
931 phydev->state = PHY_RUNNING; 931 err = phy_read_status(phydev);
932 if (err)
933 break;
934
935 if (phydev->link) {
936 phydev->state = PHY_RUNNING;
937 netif_carrier_on(phydev->attached_dev);
938 } else
939 phydev->state = PHY_NOLINK;
940 phydev->adjust_link(phydev->attached_dev);
932 } else { 941 } else {
933 phydev->state = PHY_AN; 942 phydev->state = PHY_AN;
934 phydev->link_timeout = PHY_AN_TIMEOUT; 943 phydev->link_timeout = PHY_AN_TIMEOUT;
935 } 944 }
936 } else 945 } else {
937 phydev->state = PHY_RUNNING; 946 err = phy_read_status(phydev);
947 if (err)
948 break;
949
950 if (phydev->link) {
951 phydev->state = PHY_RUNNING;
952 netif_carrier_on(phydev->attached_dev);
953 } else
954 phydev->state = PHY_NOLINK;
955 phydev->adjust_link(phydev->attached_dev);
956 }
938 break; 957 break;
939 } 958 }
940 959
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 156e02e8905d..6ed5317ab1c0 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -1607,6 +1607,8 @@ int ql_mb_get_fw_state(struct ql_adapter *qdev);
1607int ql_cam_route_initialize(struct ql_adapter *qdev); 1607int ql_cam_route_initialize(struct ql_adapter *qdev);
1608int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data); 1608int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data);
1609int ql_mb_about_fw(struct ql_adapter *qdev); 1609int ql_mb_about_fw(struct ql_adapter *qdev);
1610void ql_link_on(struct ql_adapter *qdev);
1611void ql_link_off(struct ql_adapter *qdev);
1610 1612
1611#if 1 1613#if 1
1612#define QL_ALL_DUMP 1614#define QL_ALL_DUMP
diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index 37c99fe79770..eb6a9ee640ed 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -59,7 +59,7 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
59 cqicb->pkt_delay = 59 cqicb->pkt_delay =
60 cpu_to_le16(qdev->tx_max_coalesced_frames); 60 cpu_to_le16(qdev->tx_max_coalesced_frames);
61 cqicb->flags = FLAGS_LI; 61 cqicb->flags = FLAGS_LI;
62 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 62 status = ql_write_cfg(qdev, cqicb, sizeof(*cqicb),
63 CFG_LCQ, rx_ring->cq_id); 63 CFG_LCQ, rx_ring->cq_id);
64 if (status) { 64 if (status) {
65 QPRINTK(qdev, IFUP, ERR, 65 QPRINTK(qdev, IFUP, ERR,
@@ -82,7 +82,7 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
82 cqicb->pkt_delay = 82 cqicb->pkt_delay =
83 cpu_to_le16(qdev->rx_max_coalesced_frames); 83 cpu_to_le16(qdev->rx_max_coalesced_frames);
84 cqicb->flags = FLAGS_LI; 84 cqicb->flags = FLAGS_LI;
85 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 85 status = ql_write_cfg(qdev, cqicb, sizeof(*cqicb),
86 CFG_LCQ, rx_ring->cq_id); 86 CFG_LCQ, rx_ring->cq_id);
87 if (status) { 87 if (status) {
88 QPRINTK(qdev, IFUP, ERR, 88 QPRINTK(qdev, IFUP, ERR,
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 90d1f76c0e8b..5768af17f168 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -214,6 +214,10 @@ int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
214 return -ENOMEM; 214 return -ENOMEM;
215 } 215 }
216 216
217 status = ql_sem_spinlock(qdev, SEM_ICB_MASK);
218 if (status)
219 return status;
220
217 status = ql_wait_cfg(qdev, bit); 221 status = ql_wait_cfg(qdev, bit);
218 if (status) { 222 if (status) {
219 QPRINTK(qdev, IFUP, ERR, 223 QPRINTK(qdev, IFUP, ERR,
@@ -221,12 +225,8 @@ int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
221 goto exit; 225 goto exit;
222 } 226 }
223 227
224 status = ql_sem_spinlock(qdev, SEM_ICB_MASK);
225 if (status)
226 goto exit;
227 ql_write32(qdev, ICB_L, (u32) map); 228 ql_write32(qdev, ICB_L, (u32) map);
228 ql_write32(qdev, ICB_H, (u32) (map >> 32)); 229 ql_write32(qdev, ICB_H, (u32) (map >> 32));
229 ql_sem_unlock(qdev, SEM_ICB_MASK); /* does flush too */
230 230
231 mask = CFG_Q_MASK | (bit << 16); 231 mask = CFG_Q_MASK | (bit << 16);
232 value = bit | (q_id << CFG_Q_SHIFT); 232 value = bit | (q_id << CFG_Q_SHIFT);
@@ -237,6 +237,7 @@ int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
237 */ 237 */
238 status = ql_wait_cfg(qdev, bit); 238 status = ql_wait_cfg(qdev, bit);
239exit: 239exit:
240 ql_sem_unlock(qdev, SEM_ICB_MASK); /* does flush too */
240 pci_unmap_single(qdev->pdev, map, size, direction); 241 pci_unmap_single(qdev->pdev, map, size, direction);
241 return status; 242 return status;
242} 243}
@@ -412,6 +413,57 @@ exit:
412 return status; 413 return status;
413} 414}
414 415
416/* Set or clear MAC address in hardware. We sometimes
417 * have to clear it to prevent wrong frame routing
418 * especially in a bonding environment.
419 */
420static int ql_set_mac_addr(struct ql_adapter *qdev, int set)
421{
422 int status;
423 char zero_mac_addr[ETH_ALEN];
424 char *addr;
425
426 if (set) {
427 addr = &qdev->ndev->dev_addr[0];
428 QPRINTK(qdev, IFUP, DEBUG,
429 "Set Mac addr %02x:%02x:%02x:%02x:%02x:%02x\n",
430 addr[0], addr[1], addr[2], addr[3],
431 addr[4], addr[5]);
432 } else {
433 memset(zero_mac_addr, 0, ETH_ALEN);
434 addr = &zero_mac_addr[0];
435 QPRINTK(qdev, IFUP, DEBUG,
436 "Clearing MAC address on %s\n",
437 qdev->ndev->name);
438 }
439 status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
440 if (status)
441 return status;
442 status = ql_set_mac_addr_reg(qdev, (u8 *) addr,
443 MAC_ADDR_TYPE_CAM_MAC, qdev->func * MAX_CQ);
444 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
445 if (status)
446 QPRINTK(qdev, IFUP, ERR, "Failed to init mac "
447 "address.\n");
448 return status;
449}
450
451void ql_link_on(struct ql_adapter *qdev)
452{
453 QPRINTK(qdev, LINK, ERR, "%s: Link is up.\n",
454 qdev->ndev->name);
455 netif_carrier_on(qdev->ndev);
456 ql_set_mac_addr(qdev, 1);
457}
458
459void ql_link_off(struct ql_adapter *qdev)
460{
461 QPRINTK(qdev, LINK, ERR, "%s: Link is down.\n",
462 qdev->ndev->name);
463 netif_carrier_off(qdev->ndev);
464 ql_set_mac_addr(qdev, 0);
465}
466
415/* Get a specific frame routing value from the CAM. 467/* Get a specific frame routing value from the CAM.
416 * Used for debug and reg dump. 468 * Used for debug and reg dump.
417 */ 469 */
@@ -1628,7 +1680,7 @@ static void ql_process_mac_tx_intr(struct ql_adapter *qdev,
1628 tx_ring = &qdev->tx_ring[mac_rsp->txq_idx]; 1680 tx_ring = &qdev->tx_ring[mac_rsp->txq_idx];
1629 tx_ring_desc = &tx_ring->q[mac_rsp->tid]; 1681 tx_ring_desc = &tx_ring->q[mac_rsp->tid];
1630 ql_unmap_send(qdev, tx_ring_desc, tx_ring_desc->map_cnt); 1682 ql_unmap_send(qdev, tx_ring_desc, tx_ring_desc->map_cnt);
1631 qdev->stats.tx_bytes += tx_ring_desc->map_cnt; 1683 qdev->stats.tx_bytes += (tx_ring_desc->skb)->len;
1632 qdev->stats.tx_packets++; 1684 qdev->stats.tx_packets++;
1633 dev_kfree_skb(tx_ring_desc->skb); 1685 dev_kfree_skb(tx_ring_desc->skb);
1634 tx_ring_desc->skb = NULL; 1686 tx_ring_desc->skb = NULL;
@@ -1660,13 +1712,13 @@ static void ql_process_mac_tx_intr(struct ql_adapter *qdev,
1660/* Fire up a handler to reset the MPI processor. */ 1712/* Fire up a handler to reset the MPI processor. */
1661void ql_queue_fw_error(struct ql_adapter *qdev) 1713void ql_queue_fw_error(struct ql_adapter *qdev)
1662{ 1714{
1663 netif_carrier_off(qdev->ndev); 1715 ql_link_off(qdev);
1664 queue_delayed_work(qdev->workqueue, &qdev->mpi_reset_work, 0); 1716 queue_delayed_work(qdev->workqueue, &qdev->mpi_reset_work, 0);
1665} 1717}
1666 1718
1667void ql_queue_asic_error(struct ql_adapter *qdev) 1719void ql_queue_asic_error(struct ql_adapter *qdev)
1668{ 1720{
1669 netif_carrier_off(qdev->ndev); 1721 ql_link_off(qdev);
1670 ql_disable_interrupts(qdev); 1722 ql_disable_interrupts(qdev);
1671 /* Clear adapter up bit to signal the recovery 1723 /* Clear adapter up bit to signal the recovery
1672 * process that it shouldn't kill the reset worker 1724 * process that it shouldn't kill the reset worker
@@ -2104,7 +2156,7 @@ static int qlge_send(struct sk_buff *skb, struct net_device *ndev)
2104 } 2156 }
2105 tx_ring_desc = &tx_ring->q[tx_ring->prod_idx]; 2157 tx_ring_desc = &tx_ring->q[tx_ring->prod_idx];
2106 mac_iocb_ptr = tx_ring_desc->queue_entry; 2158 mac_iocb_ptr = tx_ring_desc->queue_entry;
2107 memset((void *)mac_iocb_ptr, 0, sizeof(mac_iocb_ptr)); 2159 memset((void *)mac_iocb_ptr, 0, sizeof(*mac_iocb_ptr));
2108 2160
2109 mac_iocb_ptr->opcode = OPCODE_OB_MAC_IOCB; 2161 mac_iocb_ptr->opcode = OPCODE_OB_MAC_IOCB;
2110 mac_iocb_ptr->tid = tx_ring_desc->index; 2162 mac_iocb_ptr->tid = tx_ring_desc->index;
@@ -2743,7 +2795,7 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring)
2743 2795
2744 ql_init_tx_ring(qdev, tx_ring); 2796 ql_init_tx_ring(qdev, tx_ring);
2745 2797
2746 err = ql_write_cfg(qdev, wqicb, sizeof(wqicb), CFG_LRQ, 2798 err = ql_write_cfg(qdev, wqicb, sizeof(*wqicb), CFG_LRQ,
2747 (u16) tx_ring->wq_id); 2799 (u16) tx_ring->wq_id);
2748 if (err) { 2800 if (err) {
2749 QPRINTK(qdev, IFUP, ERR, "Failed to load tx_ring.\n"); 2801 QPRINTK(qdev, IFUP, ERR, "Failed to load tx_ring.\n");
@@ -3008,7 +3060,7 @@ static int ql_start_rss(struct ql_adapter *qdev)
3008 int i; 3060 int i;
3009 u8 *hash_id = (u8 *) ricb->hash_cq_id; 3061 u8 *hash_id = (u8 *) ricb->hash_cq_id;
3010 3062
3011 memset((void *)ricb, 0, sizeof(ricb)); 3063 memset((void *)ricb, 0, sizeof(*ricb));
3012 3064
3013 ricb->base_cq = qdev->rss_ring_first_cq_id | RSS_L4K; 3065 ricb->base_cq = qdev->rss_ring_first_cq_id | RSS_L4K;
3014 ricb->flags = 3066 ricb->flags =
@@ -3030,7 +3082,7 @@ static int ql_start_rss(struct ql_adapter *qdev)
3030 3082
3031 QPRINTK(qdev, IFUP, DEBUG, "Initializing RSS.\n"); 3083 QPRINTK(qdev, IFUP, DEBUG, "Initializing RSS.\n");
3032 3084
3033 status = ql_write_cfg(qdev, ricb, sizeof(ricb), CFG_LR, 0); 3085 status = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0);
3034 if (status) { 3086 if (status) {
3035 QPRINTK(qdev, IFUP, ERR, "Failed to load RICB.\n"); 3087 QPRINTK(qdev, IFUP, ERR, "Failed to load RICB.\n");
3036 return status; 3088 return status;
@@ -3039,25 +3091,40 @@ static int ql_start_rss(struct ql_adapter *qdev)
3039 return status; 3091 return status;
3040} 3092}
3041 3093
3042/* Initialize the frame-to-queue routing. */ 3094static int ql_clear_routing_entries(struct ql_adapter *qdev)
3043static int ql_route_initialize(struct ql_adapter *qdev)
3044{ 3095{
3045 int status = 0; 3096 int i, status = 0;
3046 int i;
3047 3097
3048 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK); 3098 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
3049 if (status) 3099 if (status)
3050 return status; 3100 return status;
3051
3052 /* Clear all the entries in the routing table. */ 3101 /* Clear all the entries in the routing table. */
3053 for (i = 0; i < 16; i++) { 3102 for (i = 0; i < 16; i++) {
3054 status = ql_set_routing_reg(qdev, i, 0, 0); 3103 status = ql_set_routing_reg(qdev, i, 0, 0);
3055 if (status) { 3104 if (status) {
3056 QPRINTK(qdev, IFUP, ERR, 3105 QPRINTK(qdev, IFUP, ERR,
3057 "Failed to init routing register for CAM packets.\n"); 3106 "Failed to init routing register for CAM "
3058 goto exit; 3107 "packets.\n");
3108 break;
3059 } 3109 }
3060 } 3110 }
3111 ql_sem_unlock(qdev, SEM_RT_IDX_MASK);
3112 return status;
3113}
3114
3115/* Initialize the frame-to-queue routing. */
3116static int ql_route_initialize(struct ql_adapter *qdev)
3117{
3118 int status = 0;
3119
3120 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
3121 if (status)
3122 return status;
3123
3124 /* Clear all the entries in the routing table. */
3125 status = ql_clear_routing_entries(qdev);
3126 if (status)
3127 goto exit;
3061 3128
3062 status = ql_set_routing_reg(qdev, RT_IDX_ALL_ERR_SLOT, RT_IDX_ERR, 1); 3129 status = ql_set_routing_reg(qdev, RT_IDX_ALL_ERR_SLOT, RT_IDX_ERR, 1);
3063 if (status) { 3130 if (status) {
@@ -3096,14 +3163,15 @@ exit:
3096 3163
3097int ql_cam_route_initialize(struct ql_adapter *qdev) 3164int ql_cam_route_initialize(struct ql_adapter *qdev)
3098{ 3165{
3099 int status; 3166 int status, set;
3100 3167
3101 status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); 3168 /* If check if the link is up and use to
3102 if (status) 3169 * determine if we are setting or clearing
3103 return status; 3170 * the MAC address in the CAM.
3104 status = ql_set_mac_addr_reg(qdev, (u8 *) qdev->ndev->perm_addr, 3171 */
3105 MAC_ADDR_TYPE_CAM_MAC, qdev->func * MAX_CQ); 3172 set = ql_read32(qdev, STS);
3106 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); 3173 set &= qdev->port_link_up;
3174 status = ql_set_mac_addr(qdev, set);
3107 if (status) { 3175 if (status) {
3108 QPRINTK(qdev, IFUP, ERR, "Failed to init mac address.\n"); 3176 QPRINTK(qdev, IFUP, ERR, "Failed to init mac address.\n");
3109 return status; 3177 return status;
@@ -3210,9 +3278,17 @@ static int ql_adapter_reset(struct ql_adapter *qdev)
3210{ 3278{
3211 u32 value; 3279 u32 value;
3212 int status = 0; 3280 int status = 0;
3213 unsigned long end_jiffies = jiffies + 3281 unsigned long end_jiffies;
3214 max((unsigned long)1, usecs_to_jiffies(30));
3215 3282
3283 /* Clear all the entries in the routing table. */
3284 status = ql_clear_routing_entries(qdev);
3285 if (status) {
3286 QPRINTK(qdev, IFUP, ERR, "Failed to clear routing bits.\n");
3287 return status;
3288 }
3289
3290 end_jiffies = jiffies +
3291 max((unsigned long)1, usecs_to_jiffies(30));
3216 ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR); 3292 ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR);
3217 3293
3218 do { 3294 do {
@@ -3252,7 +3328,7 @@ static int ql_adapter_down(struct ql_adapter *qdev)
3252 int i, status = 0; 3328 int i, status = 0;
3253 struct rx_ring *rx_ring; 3329 struct rx_ring *rx_ring;
3254 3330
3255 netif_carrier_off(qdev->ndev); 3331 ql_link_off(qdev);
3256 3332
3257 /* Don't kill the reset worker thread if we 3333 /* Don't kill the reset worker thread if we
3258 * are in the process of recovery. 3334 * are in the process of recovery.
@@ -3319,8 +3395,12 @@ static int ql_adapter_up(struct ql_adapter *qdev)
3319 } 3395 }
3320 set_bit(QL_ADAPTER_UP, &qdev->flags); 3396 set_bit(QL_ADAPTER_UP, &qdev->flags);
3321 ql_alloc_rx_buffers(qdev); 3397 ql_alloc_rx_buffers(qdev);
3322 if ((ql_read32(qdev, STS) & qdev->port_init)) 3398 /* If the port is initialized and the
3323 netif_carrier_on(qdev->ndev); 3399 * link is up the turn on the carrier.
3400 */
3401 if ((ql_read32(qdev, STS) & qdev->port_init) &&
3402 (ql_read32(qdev, STS) & qdev->port_link_up))
3403 ql_link_on(qdev);
3324 ql_enable_interrupts(qdev); 3404 ql_enable_interrupts(qdev);
3325 ql_enable_all_completion_interrupts(qdev); 3405 ql_enable_all_completion_interrupts(qdev);
3326 netif_tx_start_all_queues(qdev->ndev); 3406 netif_tx_start_all_queues(qdev->ndev);
@@ -3346,11 +3426,6 @@ static int ql_get_adapter_resources(struct ql_adapter *qdev)
3346 return -ENOMEM; 3426 return -ENOMEM;
3347 } 3427 }
3348 status = ql_request_irq(qdev); 3428 status = ql_request_irq(qdev);
3349 if (status)
3350 goto err_irq;
3351 return status;
3352err_irq:
3353 ql_free_mem_resources(qdev);
3354 return status; 3429 return status;
3355} 3430}
3356 3431
@@ -3414,7 +3489,7 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3414 3489
3415 for (i = 0; i < qdev->tx_ring_count; i++) { 3490 for (i = 0; i < qdev->tx_ring_count; i++) {
3416 tx_ring = &qdev->tx_ring[i]; 3491 tx_ring = &qdev->tx_ring[i];
3417 memset((void *)tx_ring, 0, sizeof(tx_ring)); 3492 memset((void *)tx_ring, 0, sizeof(*tx_ring));
3418 tx_ring->qdev = qdev; 3493 tx_ring->qdev = qdev;
3419 tx_ring->wq_id = i; 3494 tx_ring->wq_id = i;
3420 tx_ring->wq_len = qdev->tx_ring_size; 3495 tx_ring->wq_len = qdev->tx_ring_size;
@@ -3430,7 +3505,7 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3430 3505
3431 for (i = 0; i < qdev->rx_ring_count; i++) { 3506 for (i = 0; i < qdev->rx_ring_count; i++) {
3432 rx_ring = &qdev->rx_ring[i]; 3507 rx_ring = &qdev->rx_ring[i];
3433 memset((void *)rx_ring, 0, sizeof(rx_ring)); 3508 memset((void *)rx_ring, 0, sizeof(*rx_ring));
3434 rx_ring->qdev = qdev; 3509 rx_ring->qdev = qdev;
3435 rx_ring->cq_id = i; 3510 rx_ring->cq_id = i;
3436 rx_ring->cpu = i % cpu_cnt; /* CPU to run handler on. */ 3511 rx_ring->cpu = i % cpu_cnt; /* CPU to run handler on. */
@@ -3789,7 +3864,7 @@ static int __devinit ql_init_device(struct pci_dev *pdev,
3789 int pos, err = 0; 3864 int pos, err = 0;
3790 u16 val16; 3865 u16 val16;
3791 3866
3792 memset((void *)qdev, 0, sizeof(qdev)); 3867 memset((void *)qdev, 0, sizeof(*qdev));
3793 err = pci_enable_device(pdev); 3868 err = pci_enable_device(pdev);
3794 if (err) { 3869 if (err) {
3795 dev_err(&pdev->dev, "PCI device enable failed.\n"); 3870 dev_err(&pdev->dev, "PCI device enable failed.\n");
@@ -3976,7 +4051,7 @@ static int __devinit qlge_probe(struct pci_dev *pdev,
3976 pci_disable_device(pdev); 4051 pci_disable_device(pdev);
3977 return err; 4052 return err;
3978 } 4053 }
3979 netif_carrier_off(ndev); 4054 ql_link_off(qdev);
3980 ql_display_dev_info(ndev); 4055 ql_display_dev_info(ndev);
3981 cards_found++; 4056 cards_found++;
3982 return 0; 4057 return 0;
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c
index 71afbf8b9c50..6685bd97da91 100644
--- a/drivers/net/qlge/qlge_mpi.c
+++ b/drivers/net/qlge/qlge_mpi.c
@@ -238,7 +238,7 @@ static void ql_link_up(struct ql_adapter *qdev, struct mbox_params *mbcp)
238 &qdev->mpi_port_cfg_work, 0); 238 &qdev->mpi_port_cfg_work, 0);
239 } 239 }
240 240
241 netif_carrier_on(qdev->ndev); 241 ql_link_on(qdev);
242} 242}
243 243
244static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp) 244static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp)
@@ -251,7 +251,7 @@ static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp)
251 if (status) 251 if (status)
252 QPRINTK(qdev, DRV, ERR, "Link down AEN broken!\n"); 252 QPRINTK(qdev, DRV, ERR, "Link down AEN broken!\n");
253 253
254 netif_carrier_off(qdev->ndev); 254 ql_link_off(qdev);
255} 255}
256 256
257static int ql_sfp_in(struct ql_adapter *qdev, struct mbox_params *mbcp) 257static int ql_sfp_in(struct ql_adapter *qdev, struct mbox_params *mbcp)
@@ -849,7 +849,7 @@ void ql_mpi_idc_work(struct work_struct *work)
849 case MB_CMD_PORT_RESET: 849 case MB_CMD_PORT_RESET:
850 case MB_CMD_SET_PORT_CFG: 850 case MB_CMD_SET_PORT_CFG:
851 case MB_CMD_STOP_FW: 851 case MB_CMD_STOP_FW:
852 netif_carrier_off(qdev->ndev); 852 ql_link_off(qdev);
853 /* Signal the resulting link up AEN 853 /* Signal the resulting link up AEN
854 * that the frame routing and mac addr 854 * that the frame routing and mac addr
855 * needs to be set. 855 * needs to be set.
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index b60639bd181b..66067f9d91c0 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -1938,7 +1938,7 @@ static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
1938 if (!res) 1938 if (!res)
1939 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1939 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1940 1940
1941 release_mem_region(res->start, res->end - res->start); 1941 release_mem_region(res->start, resource_size(res));
1942 1942
1943 iounmap(pdata->ioaddr); 1943 iounmap(pdata->ioaddr);
1944 1944
@@ -1976,7 +1976,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
1976 retval = -ENODEV; 1976 retval = -ENODEV;
1977 goto out_0; 1977 goto out_0;
1978 } 1978 }
1979 res_size = res->end - res->start + 1; 1979 res_size = resource_size(res);
1980 1980
1981 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1981 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1982 if (!irq_res) { 1982 if (!irq_res) {
@@ -2104,7 +2104,7 @@ out_unmap_io_3:
2104out_free_netdev_2: 2104out_free_netdev_2:
2105 free_netdev(dev); 2105 free_netdev(dev);
2106out_release_io_1: 2106out_release_io_1:
2107 release_mem_region(res->start, res->end - res->start); 2107 release_mem_region(res->start, resource_size(res));
2108out_0: 2108out_0:
2109 return retval; 2109 return retval;
2110} 2110}
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 11a0ba47b677..b393536012fb 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1324,20 +1324,22 @@ static int tun_chr_close(struct inode *inode, struct file *file)
1324 struct tun_file *tfile = file->private_data; 1324 struct tun_file *tfile = file->private_data;
1325 struct tun_struct *tun; 1325 struct tun_struct *tun;
1326 1326
1327
1328 rtnl_lock();
1329 tun = __tun_get(tfile); 1327 tun = __tun_get(tfile);
1330 if (tun) { 1328 if (tun) {
1331 DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); 1329 struct net_device *dev = tun->dev;
1330
1331 DBG(KERN_INFO "%s: tun_chr_close\n", dev->name);
1332 1332
1333 __tun_detach(tun); 1333 __tun_detach(tun);
1334 1334
1335 /* If desireable, unregister the netdevice. */ 1335 /* If desireable, unregister the netdevice. */
1336 if (!(tun->flags & TUN_PERSIST)) 1336 if (!(tun->flags & TUN_PERSIST)) {
1337 unregister_netdevice(tun->dev); 1337 rtnl_lock();
1338 1338 if (dev->reg_state == NETREG_REGISTERED)
1339 unregister_netdevice(dev);
1340 rtnl_unlock();
1341 }
1339 } 1342 }
1340 rtnl_unlock();
1341 1343
1342 tun = tfile->tun; 1344 tun = tfile->tun;
1343 if (tun) 1345 if (tun)