aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/atheros/atl1e/atl1e.h1
-rw-r--r--drivers/net/ethernet/atheros/atl1e/atl1e_main.c19
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c7
-rw-r--r--drivers/net/ethernet/calxeda/xgmac.c9
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c214
-rw-r--r--drivers/net/ethernet/davicom/dm9000.h11
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c82
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_ethtool.c14
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c7
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c7
-rw-r--r--drivers/net/ethernet/marvell/sky2.c2
-rw-r--r--drivers/net/ethernet/marvell/sky2.h2
-rw-r--r--drivers/net/ethernet/micrel/ks8851.c2
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c28
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.h2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c2
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c2
17 files changed, 232 insertions, 179 deletions
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e.h b/drivers/net/ethernet/atheros/atl1e/atl1e.h
index 829b5ad71d0d..edfdf6b950e7 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e.h
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e.h
@@ -438,7 +438,6 @@ struct atl1e_adapter {
438 struct atl1e_hw hw; 438 struct atl1e_hw hw;
439 struct atl1e_hw_stats hw_stats; 439 struct atl1e_hw_stats hw_stats;
440 440
441 bool have_msi;
442 u32 wol; 441 u32 wol;
443 u16 link_speed; 442 u16 link_speed;
444 u16 link_duplex; 443 u16 link_duplex;
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index e1f1b2a0673a..7e0a822289c3 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -1847,34 +1847,19 @@ static void atl1e_free_irq(struct atl1e_adapter *adapter)
1847 struct net_device *netdev = adapter->netdev; 1847 struct net_device *netdev = adapter->netdev;
1848 1848
1849 free_irq(adapter->pdev->irq, netdev); 1849 free_irq(adapter->pdev->irq, netdev);
1850
1851 if (adapter->have_msi)
1852 pci_disable_msi(adapter->pdev);
1853} 1850}
1854 1851
1855static int atl1e_request_irq(struct atl1e_adapter *adapter) 1852static int atl1e_request_irq(struct atl1e_adapter *adapter)
1856{ 1853{
1857 struct pci_dev *pdev = adapter->pdev; 1854 struct pci_dev *pdev = adapter->pdev;
1858 struct net_device *netdev = adapter->netdev; 1855 struct net_device *netdev = adapter->netdev;
1859 int flags = 0;
1860 int err = 0; 1856 int err = 0;
1861 1857
1862 adapter->have_msi = true; 1858 err = request_irq(pdev->irq, atl1e_intr, IRQF_SHARED, netdev->name,
1863 err = pci_enable_msi(pdev); 1859 netdev);
1864 if (err) {
1865 netdev_dbg(netdev,
1866 "Unable to allocate MSI interrupt Error: %d\n", err);
1867 adapter->have_msi = false;
1868 }
1869
1870 if (!adapter->have_msi)
1871 flags |= IRQF_SHARED;
1872 err = request_irq(pdev->irq, atl1e_intr, flags, netdev->name, netdev);
1873 if (err) { 1860 if (err) {
1874 netdev_dbg(adapter->netdev, 1861 netdev_dbg(adapter->netdev,
1875 "Unable to allocate interrupt Error: %d\n", err); 1862 "Unable to allocate interrupt Error: %d\n", err);
1876 if (adapter->have_msi)
1877 pci_disable_msi(pdev);
1878 return err; 1863 return err;
1879 } 1864 }
1880 netdev_dbg(netdev, "atl1e_request_irq OK\n"); 1865 netdev_dbg(netdev, "atl1e_request_irq OK\n");
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index dea7d7d1f730..a4416b09f209 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -14756,8 +14756,11 @@ static void tg3_read_vpd(struct tg3 *tp)
14756 if (j + len > block_end) 14756 if (j + len > block_end)
14757 goto partno; 14757 goto partno;
14758 14758
14759 memcpy(tp->fw_ver, &vpd_data[j], len); 14759 if (len >= sizeof(tp->fw_ver))
14760 strncat(tp->fw_ver, " bc ", vpdlen - len - 1); 14760 len = sizeof(tp->fw_ver) - 1;
14761 memset(tp->fw_ver, 0, sizeof(tp->fw_ver));
14762 snprintf(tp->fw_ver, sizeof(tp->fw_ver), "%.*s bc ", len,
14763 &vpd_data[j]);
14761 } 14764 }
14762 14765
14763partno: 14766partno:
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index a170065b5973..b0ebc9f6d55e 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -163,6 +163,7 @@
163#define XGMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */ 163#define XGMAC_FLOW_CTRL_FCB_BPA 0x00000001 /* Flow Control Busy ... */
164 164
165/* XGMAC_INT_STAT reg */ 165/* XGMAC_INT_STAT reg */
166#define XGMAC_INT_STAT_PMTIM 0x00800000 /* PMT Interrupt Mask */
166#define XGMAC_INT_STAT_PMT 0x0080 /* PMT Interrupt Status */ 167#define XGMAC_INT_STAT_PMT 0x0080 /* PMT Interrupt Status */
167#define XGMAC_INT_STAT_LPI 0x0040 /* LPI Interrupt Status */ 168#define XGMAC_INT_STAT_LPI 0x0040 /* LPI Interrupt Status */
168 169
@@ -960,6 +961,9 @@ static int xgmac_hw_init(struct net_device *dev)
960 writel(DMA_INTR_DEFAULT_MASK, ioaddr + XGMAC_DMA_STATUS); 961 writel(DMA_INTR_DEFAULT_MASK, ioaddr + XGMAC_DMA_STATUS);
961 writel(DMA_INTR_DEFAULT_MASK, ioaddr + XGMAC_DMA_INTR_ENA); 962 writel(DMA_INTR_DEFAULT_MASK, ioaddr + XGMAC_DMA_INTR_ENA);
962 963
964 /* Mask power mgt interrupt */
965 writel(XGMAC_INT_STAT_PMTIM, ioaddr + XGMAC_INT_STAT);
966
963 /* XGMAC requires AXI bus init. This is a 'magic number' for now */ 967 /* XGMAC requires AXI bus init. This is a 'magic number' for now */
964 writel(0x0077000E, ioaddr + XGMAC_DMA_AXI_BUS); 968 writel(0x0077000E, ioaddr + XGMAC_DMA_AXI_BUS);
965 969
@@ -1141,6 +1145,9 @@ static int xgmac_rx(struct xgmac_priv *priv, int limit)
1141 struct sk_buff *skb; 1145 struct sk_buff *skb;
1142 int frame_len; 1146 int frame_len;
1143 1147
1148 if (!dma_ring_cnt(priv->rx_head, priv->rx_tail, DMA_RX_RING_SZ))
1149 break;
1150
1144 entry = priv->rx_tail; 1151 entry = priv->rx_tail;
1145 p = priv->dma_rx + entry; 1152 p = priv->dma_rx + entry;
1146 if (desc_get_owner(p)) 1153 if (desc_get_owner(p))
@@ -1825,7 +1832,7 @@ static void xgmac_pmt(void __iomem *ioaddr, unsigned long mode)
1825 unsigned int pmt = 0; 1832 unsigned int pmt = 0;
1826 1833
1827 if (mode & WAKE_MAGIC) 1834 if (mode & WAKE_MAGIC)
1828 pmt |= XGMAC_PMT_POWERDOWN | XGMAC_PMT_MAGIC_PKT; 1835 pmt |= XGMAC_PMT_POWERDOWN | XGMAC_PMT_MAGIC_PKT_EN;
1829 if (mode & WAKE_UCAST) 1836 if (mode & WAKE_UCAST)
1830 pmt |= XGMAC_PMT_POWERDOWN | XGMAC_PMT_GLBL_UNICAST; 1837 pmt |= XGMAC_PMT_POWERDOWN | XGMAC_PMT_GLBL_UNICAST;
1831 1838
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index f38f677f8420..9105465b2a1a 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -257,6 +257,107 @@ static void dm9000_dumpblk_32bit(void __iomem *reg, int count)
257 tmp = readl(reg); 257 tmp = readl(reg);
258} 258}
259 259
260/*
261 * Sleep, either by using msleep() or if we are suspending, then
262 * use mdelay() to sleep.
263 */
264static void dm9000_msleep(board_info_t *db, unsigned int ms)
265{
266 if (db->in_suspend)
267 mdelay(ms);
268 else
269 msleep(ms);
270}
271
272/* Read a word from phyxcer */
273static int
274dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
275{
276 board_info_t *db = netdev_priv(dev);
277 unsigned long flags;
278 unsigned int reg_save;
279 int ret;
280
281 mutex_lock(&db->addr_lock);
282
283 spin_lock_irqsave(&db->lock, flags);
284
285 /* Save previous register address */
286 reg_save = readb(db->io_addr);
287
288 /* Fill the phyxcer register into REG_0C */
289 iow(db, DM9000_EPAR, DM9000_PHY | reg);
290
291 /* Issue phyxcer read command */
292 iow(db, DM9000_EPCR, EPCR_ERPRR | EPCR_EPOS);
293
294 writeb(reg_save, db->io_addr);
295 spin_unlock_irqrestore(&db->lock, flags);
296
297 dm9000_msleep(db, 1); /* Wait read complete */
298
299 spin_lock_irqsave(&db->lock, flags);
300 reg_save = readb(db->io_addr);
301
302 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer read command */
303
304 /* The read data keeps on REG_0D & REG_0E */
305 ret = (ior(db, DM9000_EPDRH) << 8) | ior(db, DM9000_EPDRL);
306
307 /* restore the previous address */
308 writeb(reg_save, db->io_addr);
309 spin_unlock_irqrestore(&db->lock, flags);
310
311 mutex_unlock(&db->addr_lock);
312
313 dm9000_dbg(db, 5, "phy_read[%02x] -> %04x\n", reg, ret);
314 return ret;
315}
316
317/* Write a word to phyxcer */
318static void
319dm9000_phy_write(struct net_device *dev,
320 int phyaddr_unused, int reg, int value)
321{
322 board_info_t *db = netdev_priv(dev);
323 unsigned long flags;
324 unsigned long reg_save;
325
326 dm9000_dbg(db, 5, "phy_write[%02x] = %04x\n", reg, value);
327 mutex_lock(&db->addr_lock);
328
329 spin_lock_irqsave(&db->lock, flags);
330
331 /* Save previous register address */
332 reg_save = readb(db->io_addr);
333
334 /* Fill the phyxcer register into REG_0C */
335 iow(db, DM9000_EPAR, DM9000_PHY | reg);
336
337 /* Fill the written data into REG_0D & REG_0E */
338 iow(db, DM9000_EPDRL, value);
339 iow(db, DM9000_EPDRH, value >> 8);
340
341 /* Issue phyxcer write command */
342 iow(db, DM9000_EPCR, EPCR_EPOS | EPCR_ERPRW);
343
344 writeb(reg_save, db->io_addr);
345 spin_unlock_irqrestore(&db->lock, flags);
346
347 dm9000_msleep(db, 1); /* Wait write complete */
348
349 spin_lock_irqsave(&db->lock, flags);
350 reg_save = readb(db->io_addr);
351
352 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */
353
354 /* restore the previous address */
355 writeb(reg_save, db->io_addr);
356
357 spin_unlock_irqrestore(&db->lock, flags);
358 mutex_unlock(&db->addr_lock);
359}
360
260/* dm9000_set_io 361/* dm9000_set_io
261 * 362 *
262 * select the specified set of io routines to use with the 363 * select the specified set of io routines to use with the
@@ -795,6 +896,9 @@ dm9000_init_dm9000(struct net_device *dev)
795 896
796 iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */ 897 iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */
797 898
899 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
900 dm9000_phy_write(dev, 0, MII_DM_DSPCR, DSPCR_INIT_PARAM); /* Init */
901
798 ncr = (db->flags & DM9000_PLATF_EXT_PHY) ? NCR_EXT_PHY : 0; 902 ncr = (db->flags & DM9000_PLATF_EXT_PHY) ? NCR_EXT_PHY : 0;
799 903
800 /* if wol is needed, then always set NCR_WAKEEN otherwise we end 904 /* if wol is needed, then always set NCR_WAKEEN otherwise we end
@@ -1201,109 +1305,6 @@ dm9000_open(struct net_device *dev)
1201 return 0; 1305 return 0;
1202} 1306}
1203 1307
1204/*
1205 * Sleep, either by using msleep() or if we are suspending, then
1206 * use mdelay() to sleep.
1207 */
1208static void dm9000_msleep(board_info_t *db, unsigned int ms)
1209{
1210 if (db->in_suspend)
1211 mdelay(ms);
1212 else
1213 msleep(ms);
1214}
1215
1216/*
1217 * Read a word from phyxcer
1218 */
1219static int
1220dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1221{
1222 board_info_t *db = netdev_priv(dev);
1223 unsigned long flags;
1224 unsigned int reg_save;
1225 int ret;
1226
1227 mutex_lock(&db->addr_lock);
1228
1229 spin_lock_irqsave(&db->lock,flags);
1230
1231 /* Save previous register address */
1232 reg_save = readb(db->io_addr);
1233
1234 /* Fill the phyxcer register into REG_0C */
1235 iow(db, DM9000_EPAR, DM9000_PHY | reg);
1236
1237 iow(db, DM9000_EPCR, EPCR_ERPRR | EPCR_EPOS); /* Issue phyxcer read command */
1238
1239 writeb(reg_save, db->io_addr);
1240 spin_unlock_irqrestore(&db->lock,flags);
1241
1242 dm9000_msleep(db, 1); /* Wait read complete */
1243
1244 spin_lock_irqsave(&db->lock,flags);
1245 reg_save = readb(db->io_addr);
1246
1247 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer read command */
1248
1249 /* The read data keeps on REG_0D & REG_0E */
1250 ret = (ior(db, DM9000_EPDRH) << 8) | ior(db, DM9000_EPDRL);
1251
1252 /* restore the previous address */
1253 writeb(reg_save, db->io_addr);
1254 spin_unlock_irqrestore(&db->lock,flags);
1255
1256 mutex_unlock(&db->addr_lock);
1257
1258 dm9000_dbg(db, 5, "phy_read[%02x] -> %04x\n", reg, ret);
1259 return ret;
1260}
1261
1262/*
1263 * Write a word to phyxcer
1264 */
1265static void
1266dm9000_phy_write(struct net_device *dev,
1267 int phyaddr_unused, int reg, int value)
1268{
1269 board_info_t *db = netdev_priv(dev);
1270 unsigned long flags;
1271 unsigned long reg_save;
1272
1273 dm9000_dbg(db, 5, "phy_write[%02x] = %04x\n", reg, value);
1274 mutex_lock(&db->addr_lock);
1275
1276 spin_lock_irqsave(&db->lock,flags);
1277
1278 /* Save previous register address */
1279 reg_save = readb(db->io_addr);
1280
1281 /* Fill the phyxcer register into REG_0C */
1282 iow(db, DM9000_EPAR, DM9000_PHY | reg);
1283
1284 /* Fill the written data into REG_0D & REG_0E */
1285 iow(db, DM9000_EPDRL, value);
1286 iow(db, DM9000_EPDRH, value >> 8);
1287
1288 iow(db, DM9000_EPCR, EPCR_EPOS | EPCR_ERPRW); /* Issue phyxcer write command */
1289
1290 writeb(reg_save, db->io_addr);
1291 spin_unlock_irqrestore(&db->lock, flags);
1292
1293 dm9000_msleep(db, 1); /* Wait write complete */
1294
1295 spin_lock_irqsave(&db->lock,flags);
1296 reg_save = readb(db->io_addr);
1297
1298 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */
1299
1300 /* restore the previous address */
1301 writeb(reg_save, db->io_addr);
1302
1303 spin_unlock_irqrestore(&db->lock, flags);
1304 mutex_unlock(&db->addr_lock);
1305}
1306
1307static void 1308static void
1308dm9000_shutdown(struct net_device *dev) 1309dm9000_shutdown(struct net_device *dev)
1309{ 1310{
@@ -1502,7 +1503,12 @@ dm9000_probe(struct platform_device *pdev)
1502 db->flags |= DM9000_PLATF_SIMPLE_PHY; 1503 db->flags |= DM9000_PLATF_SIMPLE_PHY;
1503#endif 1504#endif
1504 1505
1505 dm9000_reset(db); 1506 /* Fixing bug on dm9000_probe, takeover dm9000_reset(db),
1507 * Need 'NCR_MAC_LBK' bit to indeed stable our DM9000 fifo
1508 * while probe stage.
1509 */
1510
1511 iow(db, DM9000_NCR, NCR_MAC_LBK | NCR_RST);
1506 1512
1507 /* try multiple times, DM9000 sometimes gets the read wrong */ 1513 /* try multiple times, DM9000 sometimes gets the read wrong */
1508 for (i = 0; i < 8; i++) { 1514 for (i = 0; i < 8; i++) {
diff --git a/drivers/net/ethernet/davicom/dm9000.h b/drivers/net/ethernet/davicom/dm9000.h
index 55688bd1a3ef..9ce058adabab 100644
--- a/drivers/net/ethernet/davicom/dm9000.h
+++ b/drivers/net/ethernet/davicom/dm9000.h
@@ -69,7 +69,9 @@
69#define NCR_WAKEEN (1<<6) 69#define NCR_WAKEEN (1<<6)
70#define NCR_FCOL (1<<4) 70#define NCR_FCOL (1<<4)
71#define NCR_FDX (1<<3) 71#define NCR_FDX (1<<3)
72#define NCR_LBK (3<<1) 72
73#define NCR_RESERVED (3<<1)
74#define NCR_MAC_LBK (1<<1)
73#define NCR_RST (1<<0) 75#define NCR_RST (1<<0)
74 76
75#define NSR_SPEED (1<<7) 77#define NSR_SPEED (1<<7)
@@ -167,5 +169,12 @@
167#define ISR_LNKCHNG (1<<5) 169#define ISR_LNKCHNG (1<<5)
168#define ISR_UNDERRUN (1<<4) 170#define ISR_UNDERRUN (1<<4)
169 171
172/* Davicom MII registers.
173 */
174
175#define MII_DM_DSPCR 0x1b /* DSP Control Register */
176
177#define DSPCR_INIT_PARAM 0xE100 /* DSP init parameter */
178
170#endif /* _DM9000X_H_ */ 179#endif /* _DM9000X_H_ */
171 180
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 2b78a1ebe903..a82a70345bbf 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -344,6 +344,53 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
344 return NETDEV_TX_OK; 344 return NETDEV_TX_OK;
345} 345}
346 346
347/* Init RX & TX buffer descriptors
348 */
349static void fec_enet_bd_init(struct net_device *dev)
350{
351 struct fec_enet_private *fep = netdev_priv(dev);
352 struct bufdesc *bdp;
353 unsigned int i;
354
355 /* Initialize the receive buffer descriptors. */
356 bdp = fep->rx_bd_base;
357 for (i = 0; i < RX_RING_SIZE; i++) {
358
359 /* Initialize the BD for every fragment in the page. */
360 if (bdp->cbd_bufaddr)
361 bdp->cbd_sc = BD_ENET_RX_EMPTY;
362 else
363 bdp->cbd_sc = 0;
364 bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
365 }
366
367 /* Set the last buffer to wrap */
368 bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
369 bdp->cbd_sc |= BD_SC_WRAP;
370
371 fep->cur_rx = fep->rx_bd_base;
372
373 /* ...and the same for transmit */
374 bdp = fep->tx_bd_base;
375 fep->cur_tx = bdp;
376 for (i = 0; i < TX_RING_SIZE; i++) {
377
378 /* Initialize the BD for every fragment in the page. */
379 bdp->cbd_sc = 0;
380 if (bdp->cbd_bufaddr && fep->tx_skbuff[i]) {
381 dev_kfree_skb_any(fep->tx_skbuff[i]);
382 fep->tx_skbuff[i] = NULL;
383 }
384 bdp->cbd_bufaddr = 0;
385 bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
386 }
387
388 /* Set the last buffer to wrap */
389 bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
390 bdp->cbd_sc |= BD_SC_WRAP;
391 fep->dirty_tx = bdp;
392}
393
347/* This function is called to start or restart the FEC during a link 394/* This function is called to start or restart the FEC during a link
348 * change. This only happens when switching between half and full 395 * change. This only happens when switching between half and full
349 * duplex. 396 * duplex.
@@ -387,6 +434,8 @@ fec_restart(struct net_device *ndev, int duplex)
387 /* Set maximum receive buffer size. */ 434 /* Set maximum receive buffer size. */
388 writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE); 435 writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE);
389 436
437 fec_enet_bd_init(ndev);
438
390 /* Set receive and transmit descriptor base. */ 439 /* Set receive and transmit descriptor base. */
391 writel(fep->bd_dma, fep->hwp + FEC_R_DES_START); 440 writel(fep->bd_dma, fep->hwp + FEC_R_DES_START);
392 if (fep->bufdesc_ex) 441 if (fep->bufdesc_ex)
@@ -396,7 +445,6 @@ fec_restart(struct net_device *ndev, int duplex)
396 writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc) 445 writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc)
397 * RX_RING_SIZE, fep->hwp + FEC_X_DES_START); 446 * RX_RING_SIZE, fep->hwp + FEC_X_DES_START);
398 447
399 fep->cur_rx = fep->rx_bd_base;
400 448
401 for (i = 0; i <= TX_RING_MOD_MASK; i++) { 449 for (i = 0; i <= TX_RING_MOD_MASK; i++) {
402 if (fep->tx_skbuff[i]) { 450 if (fep->tx_skbuff[i]) {
@@ -1594,8 +1642,6 @@ static int fec_enet_init(struct net_device *ndev)
1594{ 1642{
1595 struct fec_enet_private *fep = netdev_priv(ndev); 1643 struct fec_enet_private *fep = netdev_priv(ndev);
1596 struct bufdesc *cbd_base; 1644 struct bufdesc *cbd_base;
1597 struct bufdesc *bdp;
1598 unsigned int i;
1599 1645
1600 /* Allocate memory for buffer descriptors. */ 1646 /* Allocate memory for buffer descriptors. */
1601 cbd_base = dma_alloc_coherent(NULL, PAGE_SIZE, &fep->bd_dma, 1647 cbd_base = dma_alloc_coherent(NULL, PAGE_SIZE, &fep->bd_dma,
@@ -1603,6 +1649,7 @@ static int fec_enet_init(struct net_device *ndev)
1603 if (!cbd_base) 1649 if (!cbd_base)
1604 return -ENOMEM; 1650 return -ENOMEM;
1605 1651
1652 memset(cbd_base, 0, PAGE_SIZE);
1606 spin_lock_init(&fep->hw_lock); 1653 spin_lock_init(&fep->hw_lock);
1607 1654
1608 fep->netdev = ndev; 1655 fep->netdev = ndev;
@@ -1626,35 +1673,6 @@ static int fec_enet_init(struct net_device *ndev)
1626 writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK); 1673 writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK);
1627 netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, FEC_NAPI_WEIGHT); 1674 netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, FEC_NAPI_WEIGHT);
1628 1675
1629 /* Initialize the receive buffer descriptors. */
1630 bdp = fep->rx_bd_base;
1631 for (i = 0; i < RX_RING_SIZE; i++) {
1632
1633 /* Initialize the BD for every fragment in the page. */
1634 bdp->cbd_sc = 0;
1635 bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
1636 }
1637
1638 /* Set the last buffer to wrap */
1639 bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
1640 bdp->cbd_sc |= BD_SC_WRAP;
1641
1642 /* ...and the same for transmit */
1643 bdp = fep->tx_bd_base;
1644 fep->cur_tx = bdp;
1645 for (i = 0; i < TX_RING_SIZE; i++) {
1646
1647 /* Initialize the BD for every fragment in the page. */
1648 bdp->cbd_sc = 0;
1649 bdp->cbd_bufaddr = 0;
1650 bdp = fec_enet_get_nextdesc(bdp, fep->bufdesc_ex);
1651 }
1652
1653 /* Set the last buffer to wrap */
1654 bdp = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
1655 bdp->cbd_sc |= BD_SC_WRAP;
1656 fep->dirty_tx = bdp;
1657
1658 fec_restart(ndev, 0); 1676 fec_restart(ndev, 0);
1659 1677
1660 return 0; 1678 return 0;
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
index a9f9c7906769..82a967c95598 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
@@ -1052,6 +1052,10 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1052 txdr->buffer_info[i].dma = 1052 txdr->buffer_info[i].dma =
1053 dma_map_single(&pdev->dev, skb->data, skb->len, 1053 dma_map_single(&pdev->dev, skb->data, skb->len,
1054 DMA_TO_DEVICE); 1054 DMA_TO_DEVICE);
1055 if (dma_mapping_error(&pdev->dev, txdr->buffer_info[i].dma)) {
1056 ret_val = 4;
1057 goto err_nomem;
1058 }
1055 tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma); 1059 tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
1056 tx_desc->lower.data = cpu_to_le32(skb->len); 1060 tx_desc->lower.data = cpu_to_le32(skb->len);
1057 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP | 1061 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
@@ -1068,7 +1072,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1068 rxdr->buffer_info = kcalloc(rxdr->count, sizeof(struct e1000_buffer), 1072 rxdr->buffer_info = kcalloc(rxdr->count, sizeof(struct e1000_buffer),
1069 GFP_KERNEL); 1073 GFP_KERNEL);
1070 if (!rxdr->buffer_info) { 1074 if (!rxdr->buffer_info) {
1071 ret_val = 4; 1075 ret_val = 5;
1072 goto err_nomem; 1076 goto err_nomem;
1073 } 1077 }
1074 1078
@@ -1076,7 +1080,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1076 rxdr->desc = dma_alloc_coherent(&pdev->dev, rxdr->size, &rxdr->dma, 1080 rxdr->desc = dma_alloc_coherent(&pdev->dev, rxdr->size, &rxdr->dma,
1077 GFP_KERNEL | __GFP_ZERO); 1081 GFP_KERNEL | __GFP_ZERO);
1078 if (!rxdr->desc) { 1082 if (!rxdr->desc) {
1079 ret_val = 5; 1083 ret_val = 6;
1080 goto err_nomem; 1084 goto err_nomem;
1081 } 1085 }
1082 rxdr->next_to_use = rxdr->next_to_clean = 0; 1086 rxdr->next_to_use = rxdr->next_to_clean = 0;
@@ -1099,7 +1103,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1099 1103
1100 skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, GFP_KERNEL); 1104 skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, GFP_KERNEL);
1101 if (!skb) { 1105 if (!skb) {
1102 ret_val = 6; 1106 ret_val = 7;
1103 goto err_nomem; 1107 goto err_nomem;
1104 } 1108 }
1105 skb_reserve(skb, NET_IP_ALIGN); 1109 skb_reserve(skb, NET_IP_ALIGN);
@@ -1108,6 +1112,10 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1108 rxdr->buffer_info[i].dma = 1112 rxdr->buffer_info[i].dma =
1109 dma_map_single(&pdev->dev, skb->data, 1113 dma_map_single(&pdev->dev, skb->data,
1110 E1000_RXBUFFER_2048, DMA_FROM_DEVICE); 1114 E1000_RXBUFFER_2048, DMA_FROM_DEVICE);
1115 if (dma_mapping_error(&pdev->dev, rxdr->buffer_info[i].dma)) {
1116 ret_val = 8;
1117 goto err_nomem;
1118 }
1111 rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma); 1119 rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
1112 memset(skb->data, 0x00, skb->len); 1120 memset(skb->data, 0x00, skb->len);
1113 } 1121 }
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 858d2a3b3672..b18fad5b579e 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -846,11 +846,16 @@ check_page:
846 } 846 }
847 } 847 }
848 848
849 if (!buffer_info->dma) 849 if (!buffer_info->dma) {
850 buffer_info->dma = dma_map_page(&pdev->dev, 850 buffer_info->dma = dma_map_page(&pdev->dev,
851 buffer_info->page, 0, 851 buffer_info->page, 0,
852 PAGE_SIZE, 852 PAGE_SIZE,
853 DMA_FROM_DEVICE); 853 DMA_FROM_DEVICE);
854 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
855 adapter->alloc_rx_buff_failed++;
856 break;
857 }
858 }
854 859
855 rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); 860 rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
856 rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma); 861 rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index 74464c348454..5dc119fd95a8 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -2154,6 +2154,10 @@ map_skb:
2154 skb->data, 2154 skb->data,
2155 adapter->rx_buffer_len, 2155 adapter->rx_buffer_len,
2156 DMA_FROM_DEVICE); 2156 DMA_FROM_DEVICE);
2157 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
2158 adapter->alloc_rx_buff_failed++;
2159 break;
2160 }
2157 2161
2158 rx_desc = IXGB_RX_DESC(*rx_ring, i); 2162 rx_desc = IXGB_RX_DESC(*rx_ring, i);
2159 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma); 2163 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
@@ -2163,7 +2167,8 @@ map_skb:
2163 rx_desc->status = 0; 2167 rx_desc->status = 0;
2164 2168
2165 2169
2166 if (++i == rx_ring->count) i = 0; 2170 if (++i == rx_ring->count)
2171 i = 0;
2167 buffer_info = &rx_ring->buffer_info[i]; 2172 buffer_info = &rx_ring->buffer_info[i];
2168 } 2173 }
2169 2174
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index fc07ca35721b..6a0e671fcecd 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -1067,7 +1067,7 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
1067 sky2_write32(hw, RB_ADDR(q, RB_RX_UTHP), tp); 1067 sky2_write32(hw, RB_ADDR(q, RB_RX_UTHP), tp);
1068 sky2_write32(hw, RB_ADDR(q, RB_RX_LTHP), space/2); 1068 sky2_write32(hw, RB_ADDR(q, RB_RX_LTHP), space/2);
1069 1069
1070 tp = space - 2048/8; 1070 tp = space - 8192/8;
1071 sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), tp); 1071 sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), tp);
1072 sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), space/4); 1072 sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), space/4);
1073 } else { 1073 } else {
diff --git a/drivers/net/ethernet/marvell/sky2.h b/drivers/net/ethernet/marvell/sky2.h
index 615ac63ea860..ec6dcd80152b 100644
--- a/drivers/net/ethernet/marvell/sky2.h
+++ b/drivers/net/ethernet/marvell/sky2.h
@@ -2074,7 +2074,7 @@ enum {
2074 GM_IS_RX_FF_OR = 1<<1, /* Receive FIFO Overrun */ 2074 GM_IS_RX_FF_OR = 1<<1, /* Receive FIFO Overrun */
2075 GM_IS_RX_COMPL = 1<<0, /* Frame Reception Complete */ 2075 GM_IS_RX_COMPL = 1<<0, /* Frame Reception Complete */
2076 2076
2077#define GMAC_DEF_MSK GM_IS_TX_FF_UR 2077#define GMAC_DEF_MSK (GM_IS_TX_FF_UR | GM_IS_RX_FF_OR)
2078}; 2078};
2079 2079
2080/* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */ 2080/* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 33bcb63d56a2..8fb481252e2c 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -528,7 +528,7 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
528 for (; rxfc != 0; rxfc--) { 528 for (; rxfc != 0; rxfc--) {
529 rxh = ks8851_rdreg32(ks, KS_RXFHSR); 529 rxh = ks8851_rdreg32(ks, KS_RXFHSR);
530 rxstat = rxh & 0xffff; 530 rxstat = rxh & 0xffff;
531 rxlen = rxh >> 16; 531 rxlen = (rxh >> 16) & 0xfff;
532 532
533 netif_dbg(ks, rx_status, ks->netdev, 533 netif_dbg(ks, rx_status, ks->netdev,
534 "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen); 534 "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen);
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index da604059b148..a7499cbf4503 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1517,10 +1517,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1517 if (felic_stat & ECSR_LCHNG) { 1517 if (felic_stat & ECSR_LCHNG) {
1518 /* Link Changed */ 1518 /* Link Changed */
1519 if (mdp->cd->no_psr || mdp->no_ether_link) { 1519 if (mdp->cd->no_psr || mdp->no_ether_link) {
1520 if (mdp->link == PHY_DOWN) 1520 goto ignore_link;
1521 link_stat = 0;
1522 else
1523 link_stat = PHY_ST_LINK;
1524 } else { 1521 } else {
1525 link_stat = (sh_eth_read(ndev, PSR)); 1522 link_stat = (sh_eth_read(ndev, PSR));
1526 if (mdp->ether_link_active_low) 1523 if (mdp->ether_link_active_low)
@@ -1543,6 +1540,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1543 } 1540 }
1544 } 1541 }
1545 1542
1543ignore_link:
1546 if (intr_status & EESR_TWB) { 1544 if (intr_status & EESR_TWB) {
1547 /* Write buck end. unused write back interrupt */ 1545 /* Write buck end. unused write back interrupt */
1548 if (intr_status & EESR_TABT) /* Transmit Abort int */ 1546 if (intr_status & EESR_TABT) /* Transmit Abort int */
@@ -1627,12 +1625,18 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
1627 struct sh_eth_private *mdp = netdev_priv(ndev); 1625 struct sh_eth_private *mdp = netdev_priv(ndev);
1628 struct sh_eth_cpu_data *cd = mdp->cd; 1626 struct sh_eth_cpu_data *cd = mdp->cd;
1629 irqreturn_t ret = IRQ_NONE; 1627 irqreturn_t ret = IRQ_NONE;
1630 u32 intr_status = 0; 1628 unsigned long intr_status;
1631 1629
1632 spin_lock(&mdp->lock); 1630 spin_lock(&mdp->lock);
1633 1631
1634 /* Get interrpt stat */ 1632 /* Get interrupt status */
1635 intr_status = sh_eth_read(ndev, EESR); 1633 intr_status = sh_eth_read(ndev, EESR);
1634 /* Mask it with the interrupt mask, forcing ECI interrupt to be always
1635 * enabled since it's the one that comes thru regardless of the mask,
1636 * and we need to fully handle it in sh_eth_error() in order to quench
1637 * it as it doesn't get cleared by just writing 1 to the ECI bit...
1638 */
1639 intr_status &= sh_eth_read(ndev, EESIPR) | DMAC_M_ECI;
1636 /* Clear interrupt */ 1640 /* Clear interrupt */
1637 if (intr_status & (EESR_FRC | EESR_RMAF | EESR_RRF | 1641 if (intr_status & (EESR_FRC | EESR_RMAF | EESR_RRF |
1638 EESR_RTLF | EESR_RTSF | EESR_PRE | EESR_CERF | 1642 EESR_RTLF | EESR_RTSF | EESR_PRE | EESR_CERF |
@@ -1674,7 +1678,7 @@ static void sh_eth_adjust_link(struct net_device *ndev)
1674 struct phy_device *phydev = mdp->phydev; 1678 struct phy_device *phydev = mdp->phydev;
1675 int new_state = 0; 1679 int new_state = 0;
1676 1680
1677 if (phydev->link != PHY_DOWN) { 1681 if (phydev->link) {
1678 if (phydev->duplex != mdp->duplex) { 1682 if (phydev->duplex != mdp->duplex) {
1679 new_state = 1; 1683 new_state = 1;
1680 mdp->duplex = phydev->duplex; 1684 mdp->duplex = phydev->duplex;
@@ -1688,17 +1692,21 @@ static void sh_eth_adjust_link(struct net_device *ndev)
1688 if (mdp->cd->set_rate) 1692 if (mdp->cd->set_rate)
1689 mdp->cd->set_rate(ndev); 1693 mdp->cd->set_rate(ndev);
1690 } 1694 }
1691 if (mdp->link == PHY_DOWN) { 1695 if (!mdp->link) {
1692 sh_eth_write(ndev, 1696 sh_eth_write(ndev,
1693 (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR); 1697 (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR);
1694 new_state = 1; 1698 new_state = 1;
1695 mdp->link = phydev->link; 1699 mdp->link = phydev->link;
1700 if (mdp->cd->no_psr || mdp->no_ether_link)
1701 sh_eth_rcv_snd_enable(ndev);
1696 } 1702 }
1697 } else if (mdp->link) { 1703 } else if (mdp->link) {
1698 new_state = 1; 1704 new_state = 1;
1699 mdp->link = PHY_DOWN; 1705 mdp->link = 0;
1700 mdp->speed = 0; 1706 mdp->speed = 0;
1701 mdp->duplex = -1; 1707 mdp->duplex = -1;
1708 if (mdp->cd->no_psr || mdp->no_ether_link)
1709 sh_eth_rcv_snd_disable(ndev);
1702 } 1710 }
1703 1711
1704 if (new_state && netif_msg_link(mdp)) 1712 if (new_state && netif_msg_link(mdp))
@@ -1715,7 +1723,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
1715 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, 1723 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
1716 mdp->mii_bus->id , mdp->phy_id); 1724 mdp->mii_bus->id , mdp->phy_id);
1717 1725
1718 mdp->link = PHY_DOWN; 1726 mdp->link = 0;
1719 mdp->speed = 0; 1727 mdp->speed = 0;
1720 mdp->duplex = -1; 1728 mdp->duplex = -1;
1721 1729
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index e5292973900b..1ddc9f235bcb 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -503,7 +503,7 @@ struct sh_eth_private {
503 u32 phy_id; /* PHY ID */ 503 u32 phy_id; /* PHY ID */
504 struct mii_bus *mii_bus; /* MDIO bus control */ 504 struct mii_bus *mii_bus; /* MDIO bus control */
505 struct phy_device *phydev; /* PHY device control */ 505 struct phy_device *phydev; /* PHY device control */
506 enum phy_state link; 506 int link;
507 phy_interface_t phy_interface; 507 phy_interface_t phy_interface;
508 int msg_enable; 508 int msg_enable;
509 int speed; 509 int speed;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 7aebc0cb35e1..1d740423a053 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -458,7 +458,7 @@ void cpsw_tx_handler(void *token, int len, int status)
458 * queue is stopped then start the queue as we have free desc for tx 458 * queue is stopped then start the queue as we have free desc for tx
459 */ 459 */
460 if (unlikely(netif_queue_stopped(ndev))) 460 if (unlikely(netif_queue_stopped(ndev)))
461 netif_start_queue(ndev); 461 netif_wake_queue(ndev);
462 cpts_tx_timestamp(priv->cpts, skb); 462 cpts_tx_timestamp(priv->cpts, skb);
463 priv->stats.tx_packets++; 463 priv->stats.tx_packets++;
464 priv->stats.tx_bytes += len; 464 priv->stats.tx_bytes += len;
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 8121a3d5897c..6a0b47715a84 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1053,7 +1053,7 @@ static void emac_tx_handler(void *token, int len, int status)
1053 * queue is stopped then start the queue as we have free desc for tx 1053 * queue is stopped then start the queue as we have free desc for tx
1054 */ 1054 */
1055 if (unlikely(netif_queue_stopped(ndev))) 1055 if (unlikely(netif_queue_stopped(ndev)))
1056 netif_start_queue(ndev); 1056 netif_wake_queue(ndev);
1057 ndev->stats.tx_packets++; 1057 ndev->stats.tx_packets++;
1058 ndev->stats.tx_bytes += len; 1058 ndev->stats.tx_bytes += len;
1059 dev_kfree_skb_any(skb); 1059 dev_kfree_skb_any(skb);