aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/8139too.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/8139too.c')
-rw-r--r--drivers/net/8139too.c210
1 files changed, 92 insertions, 118 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 4a3628755026..f0d23de32967 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -89,6 +89,8 @@
89 89
90*/ 90*/
91 91
92#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
93
92#define DRV_NAME "8139too" 94#define DRV_NAME "8139too"
93#define DRV_VERSION "0.9.28" 95#define DRV_VERSION "0.9.28"
94 96
@@ -108,10 +110,10 @@
108#include <linux/crc32.h> 110#include <linux/crc32.h>
109#include <linux/io.h> 111#include <linux/io.h>
110#include <linux/uaccess.h> 112#include <linux/uaccess.h>
113#include <linux/gfp.h>
111#include <asm/irq.h> 114#include <asm/irq.h>
112 115
113#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION 116#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION
114#define PFX DRV_NAME ": "
115 117
116/* Default Message level */ 118/* Default Message level */
117#define RTL8139_DEF_MSG_ENABLE (NETIF_MSG_DRV | \ 119#define RTL8139_DEF_MSG_ENABLE (NETIF_MSG_DRV | \
@@ -130,9 +132,9 @@
130# define assert(expr) do {} while (0) 132# define assert(expr) do {} while (0)
131#else 133#else
132# define assert(expr) \ 134# define assert(expr) \
133 if(unlikely(!(expr))) { \ 135 if (unlikely(!(expr))) { \
134 pr_err("Assertion failed! %s,%s,%s,line=%d\n", \ 136 pr_err("Assertion failed! %s,%s,%s,line=%d\n", \
135 #expr, __FILE__, __func__, __LINE__); \ 137 #expr, __FILE__, __func__, __LINE__); \
136 } 138 }
137#endif 139#endif
138 140
@@ -231,7 +233,7 @@ static const struct {
231}; 233};
232 234
233 235
234static struct pci_device_id rtl8139_pci_tbl[] = { 236static DEFINE_PCI_DEVICE_TABLE(rtl8139_pci_tbl) = {
235 {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 237 {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
236 {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 238 {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
237 {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 239 {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
@@ -957,7 +959,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
957 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && 959 pdev->device == PCI_DEVICE_ID_REALTEK_8139 &&
958 pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS && 960 pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS &&
959 pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) { 961 pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) {
960 pr_info("8139too: OQO Model 2 detected. Forcing PIO\n"); 962 pr_info("OQO Model 2 detected. Forcing PIO\n");
961 use_io = 1; 963 use_io = 1;
962 } 964 }
963 965
@@ -1010,21 +1012,19 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1010 tp->mii.reg_num_mask = 0x1f; 1012 tp->mii.reg_num_mask = 0x1f;
1011 1013
1012 /* dev is fully set up and ready to use now */ 1014 /* dev is fully set up and ready to use now */
1013 pr_debug("about to register device named %s (%p)...\n", dev->name, dev); 1015 pr_debug("about to register device named %s (%p)...\n",
1016 dev->name, dev);
1014 i = register_netdev (dev); 1017 i = register_netdev (dev);
1015 if (i) goto err_out; 1018 if (i) goto err_out;
1016 1019
1017 pci_set_drvdata (pdev, dev); 1020 pci_set_drvdata (pdev, dev);
1018 1021
1019 pr_info("%s: %s at 0x%lx, %pM, IRQ %d\n", 1022 netdev_info(dev, "%s at 0x%lx, %pM, IRQ %d\n",
1020 dev->name, 1023 board_info[ent->driver_data].name,
1021 board_info[ent->driver_data].name, 1024 dev->base_addr, dev->dev_addr, dev->irq);
1022 dev->base_addr,
1023 dev->dev_addr,
1024 dev->irq);
1025 1025
1026 pr_debug("%s: Identified 8139 chip type '%s'\n", 1026 netdev_dbg(dev, "Identified 8139 chip type '%s'\n",
1027 dev->name, rtl_chip_info[tp->chipset].name); 1027 rtl_chip_info[tp->chipset].name);
1028 1028
1029 /* Find the connected MII xcvrs. 1029 /* Find the connected MII xcvrs.
1030 Doing this in open() would allow detecting external xcvrs later, but 1030 Doing this in open() would allow detecting external xcvrs later, but
@@ -1037,13 +1037,12 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1037 if (mii_status != 0xffff && mii_status != 0x0000) { 1037 if (mii_status != 0xffff && mii_status != 0x0000) {
1038 u16 advertising = mdio_read(dev, phy, 4); 1038 u16 advertising = mdio_read(dev, phy, 4);
1039 tp->phys[phy_idx++] = phy; 1039 tp->phys[phy_idx++] = phy;
1040 pr_info("%s: MII transceiver %d status 0x%4.4x advertising %4.4x.\n", 1040 netdev_info(dev, "MII transceiver %d status 0x%04x advertising %04x\n",
1041 dev->name, phy, mii_status, advertising); 1041 phy, mii_status, advertising);
1042 } 1042 }
1043 } 1043 }
1044 if (phy_idx == 0) { 1044 if (phy_idx == 0) {
1045 pr_info("%s: No MII transceivers found! Assuming SYM transceiver.\n", 1045 netdev_info(dev, "No MII transceivers found! Assuming SYM transceiver\n");
1046 dev->name);
1047 tp->phys[0] = 32; 1046 tp->phys[0] = 32;
1048 } 1047 }
1049 } else 1048 } else
@@ -1062,15 +1061,15 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1062 if (board_idx < MAX_UNITS && full_duplex[board_idx] > 0) 1061 if (board_idx < MAX_UNITS && full_duplex[board_idx] > 0)
1063 tp->mii.full_duplex = full_duplex[board_idx]; 1062 tp->mii.full_duplex = full_duplex[board_idx];
1064 if (tp->mii.full_duplex) { 1063 if (tp->mii.full_duplex) {
1065 pr_info("%s: Media type forced to Full Duplex.\n", dev->name); 1064 netdev_info(dev, "Media type forced to Full Duplex\n");
1066 /* Changing the MII-advertised media because might prevent 1065 /* Changing the MII-advertised media because might prevent
1067 re-connection. */ 1066 re-connection. */
1068 tp->mii.force_media = 1; 1067 tp->mii.force_media = 1;
1069 } 1068 }
1070 if (tp->default_port) { 1069 if (tp->default_port) {
1071 pr_info(" Forcing %dMbps %s-duplex operation.\n", 1070 netdev_info(dev, " Forcing %dMbps %s-duplex operation\n",
1072 (option & 0x20 ? 100 : 10), 1071 (option & 0x20 ? 100 : 10),
1073 (option & 0x10 ? "full" : "half")); 1072 (option & 0x10 ? "full" : "half"));
1074 mdio_write(dev, tp->phys[0], 0, 1073 mdio_write(dev, tp->phys[0], 0,
1075 ((option & 0x20) ? 0x2000 : 0) | /* 100Mbps? */ 1074 ((option & 0x20) ? 0x2000 : 0) | /* 100Mbps? */
1076 ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */ 1075 ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */
@@ -1330,12 +1329,12 @@ static int rtl8139_open (struct net_device *dev)
1330 rtl8139_hw_start (dev); 1329 rtl8139_hw_start (dev);
1331 netif_start_queue (dev); 1330 netif_start_queue (dev);
1332 1331
1333 if (netif_msg_ifup(tp)) 1332 netif_dbg(tp, ifup, dev,
1334 pr_debug("%s: rtl8139_open() ioaddr %#llx IRQ %d" 1333 "%s() ioaddr %#llx IRQ %d GP Pins %02x %s-duplex\n",
1335 " GP Pins %2.2x %s-duplex.\n", dev->name, 1334 __func__,
1336 (unsigned long long)pci_resource_start (tp->pci_dev, 1), 1335 (unsigned long long)pci_resource_start (tp->pci_dev, 1),
1337 dev->irq, RTL_R8 (MediaStatus), 1336 dev->irq, RTL_R8 (MediaStatus),
1338 tp->mii.full_duplex ? "full" : "half"); 1337 tp->mii.full_duplex ? "full" : "half");
1339 1338
1340 rtl8139_start_thread(tp); 1339 rtl8139_start_thread(tp);
1341 1340
@@ -1393,7 +1392,7 @@ static void rtl8139_hw_start (struct net_device *dev)
1393 RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic); 1392 RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic);
1394 } 1393 }
1395 1394
1396 pr_debug("init buffer addresses\n"); 1395 netdev_dbg(dev, "init buffer addresses\n");
1397 1396
1398 /* Lock Config[01234] and BMCR register writes */ 1397 /* Lock Config[01234] and BMCR register writes */
1399 RTL_W8 (Cfg9346, Cfg9346_Lock); 1398 RTL_W8 (Cfg9346, Cfg9346_Lock);
@@ -1549,20 +1548,17 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1549 mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA); 1548 mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA);
1550 1549
1551 if (!tp->mii.force_media && mii_lpa != 0xffff) { 1550 if (!tp->mii.force_media && mii_lpa != 0xffff) {
1552 int duplex = (mii_lpa & LPA_100FULL) 1551 int duplex = ((mii_lpa & LPA_100FULL) ||
1553 || (mii_lpa & 0x01C0) == 0x0040; 1552 (mii_lpa & 0x01C0) == 0x0040);
1554 if (tp->mii.full_duplex != duplex) { 1553 if (tp->mii.full_duplex != duplex) {
1555 tp->mii.full_duplex = duplex; 1554 tp->mii.full_duplex = duplex;
1556 1555
1557 if (mii_lpa) { 1556 if (mii_lpa) {
1558 pr_info("%s: Setting %s-duplex based on MII #%d link" 1557 netdev_info(dev, "Setting %s-duplex based on MII #%d link partner ability of %04x\n",
1559 " partner ability of %4.4x.\n", 1558 tp->mii.full_duplex ? "full" : "half",
1560 dev->name, 1559 tp->phys[0], mii_lpa);
1561 tp->mii.full_duplex ? "full" : "half",
1562 tp->phys[0], mii_lpa);
1563 } else { 1560 } else {
1564 pr_info("%s: media is unconnected, link down, or incompatible connection\n", 1561 netdev_info(dev, "media is unconnected, link down, or incompatible connection\n");
1565 dev->name);
1566 } 1562 }
1567#if 0 1563#if 0
1568 RTL_W8 (Cfg9346, Cfg9346_Unlock); 1564 RTL_W8 (Cfg9346, Cfg9346_Unlock);
@@ -1576,13 +1572,12 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1576 1572
1577 rtl8139_tune_twister (dev, tp); 1573 rtl8139_tune_twister (dev, tp);
1578 1574
1579 pr_debug("%s: Media selection tick, Link partner %4.4x.\n", 1575 netdev_dbg(dev, "Media selection tick, Link partner %04x\n",
1580 dev->name, RTL_R16 (NWayLPAR)); 1576 RTL_R16(NWayLPAR));
1581 pr_debug("%s: Other registers are IntMask %4.4x IntStatus %4.4x\n", 1577 netdev_dbg(dev, "Other registers are IntMask %04x IntStatus %04x\n",
1582 dev->name, RTL_R16 (IntrMask), RTL_R16 (IntrStatus)); 1578 RTL_R16(IntrMask), RTL_R16(IntrStatus));
1583 pr_debug("%s: Chip config %2.2x %2.2x.\n", 1579 netdev_dbg(dev, "Chip config %02x %02x\n",
1584 dev->name, RTL_R8 (Config0), 1580 RTL_R8(Config0), RTL_R8(Config1));
1585 RTL_R8 (Config1));
1586} 1581}
1587 1582
1588static void rtl8139_thread (struct work_struct *work) 1583static void rtl8139_thread (struct work_struct *work)
@@ -1640,17 +1635,17 @@ static void rtl8139_tx_timeout_task (struct work_struct *work)
1640 int i; 1635 int i;
1641 u8 tmp8; 1636 u8 tmp8;
1642 1637
1643 pr_debug("%s: Transmit timeout, status %2.2x %4.4x %4.4x media %2.2x.\n", 1638 netdev_dbg(dev, "Transmit timeout, status %02x %04x %04x media %02x\n",
1644 dev->name, RTL_R8 (ChipCmd), 1639 RTL_R8(ChipCmd), RTL_R16(IntrStatus),
1645 RTL_R16(IntrStatus), RTL_R16(IntrMask), RTL_R8(MediaStatus)); 1640 RTL_R16(IntrMask), RTL_R8(MediaStatus));
1646 /* Emit info to figure out what went wrong. */ 1641 /* Emit info to figure out what went wrong. */
1647 pr_debug("%s: Tx queue start entry %ld dirty entry %ld.\n", 1642 netdev_dbg(dev, "Tx queue start entry %ld dirty entry %ld\n",
1648 dev->name, tp->cur_tx, tp->dirty_tx); 1643 tp->cur_tx, tp->dirty_tx);
1649 for (i = 0; i < NUM_TX_DESC; i++) 1644 for (i = 0; i < NUM_TX_DESC; i++)
1650 pr_debug("%s: Tx descriptor %d is %8.8lx.%s\n", 1645 netdev_dbg(dev, "Tx descriptor %d is %08lx%s\n",
1651 dev->name, i, RTL_R32 (TxStatus0 + (i * 4)), 1646 i, RTL_R32(TxStatus0 + (i * 4)),
1652 i == tp->dirty_tx % NUM_TX_DESC ? 1647 i == tp->dirty_tx % NUM_TX_DESC ?
1653 " (queue head)" : ""); 1648 " (queue head)" : "");
1654 1649
1655 tp->xstats.tx_timeouts++; 1650 tp->xstats.tx_timeouts++;
1656 1651
@@ -1729,9 +1724,8 @@ static netdev_tx_t rtl8139_start_xmit (struct sk_buff *skb,
1729 netif_stop_queue (dev); 1724 netif_stop_queue (dev);
1730 spin_unlock_irqrestore(&tp->lock, flags); 1725 spin_unlock_irqrestore(&tp->lock, flags);
1731 1726
1732 if (netif_msg_tx_queued(tp)) 1727 netif_dbg(tp, tx_queued, dev, "Queued Tx packet size %u to slot %d\n",
1733 pr_debug("%s: Queued Tx packet size %u to slot %d.\n", 1728 len, entry);
1734 dev->name, len, entry);
1735 1729
1736 return NETDEV_TX_OK; 1730 return NETDEV_TX_OK;
1737} 1731}
@@ -1760,9 +1754,8 @@ static void rtl8139_tx_interrupt (struct net_device *dev,
1760 /* Note: TxCarrierLost is always asserted at 100mbps. */ 1754 /* Note: TxCarrierLost is always asserted at 100mbps. */
1761 if (txstatus & (TxOutOfWindow | TxAborted)) { 1755 if (txstatus & (TxOutOfWindow | TxAborted)) {
1762 /* There was an major error, log it. */ 1756 /* There was an major error, log it. */
1763 if (netif_msg_tx_err(tp)) 1757 netif_dbg(tp, tx_err, dev, "Transmit error, Tx status %08x\n",
1764 pr_debug("%s: Transmit error, Tx status %8.8x.\n", 1758 txstatus);
1765 dev->name, txstatus);
1766 dev->stats.tx_errors++; 1759 dev->stats.tx_errors++;
1767 if (txstatus & TxAborted) { 1760 if (txstatus & TxAborted) {
1768 dev->stats.tx_aborted_errors++; 1761 dev->stats.tx_aborted_errors++;
@@ -1792,8 +1785,8 @@ static void rtl8139_tx_interrupt (struct net_device *dev,
1792 1785
1793#ifndef RTL8139_NDEBUG 1786#ifndef RTL8139_NDEBUG
1794 if (tp->cur_tx - dirty_tx > NUM_TX_DESC) { 1787 if (tp->cur_tx - dirty_tx > NUM_TX_DESC) {
1795 pr_err("%s: Out-of-sync dirty pointer, %ld vs. %ld.\n", 1788 netdev_err(dev, "Out-of-sync dirty pointer, %ld vs. %ld\n",
1796 dev->name, dirty_tx, tp->cur_tx); 1789 dirty_tx, tp->cur_tx);
1797 dirty_tx += NUM_TX_DESC; 1790 dirty_tx += NUM_TX_DESC;
1798 } 1791 }
1799#endif /* RTL8139_NDEBUG */ 1792#endif /* RTL8139_NDEBUG */
@@ -1816,14 +1809,13 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1816 int tmp_work; 1809 int tmp_work;
1817#endif 1810#endif
1818 1811
1819 if (netif_msg_rx_err (tp)) 1812 netif_dbg(tp, rx_err, dev, "Ethernet frame had errors, status %08x\n",
1820 pr_debug("%s: Ethernet frame had errors, status %8.8x.\n", 1813 rx_status);
1821 dev->name, rx_status);
1822 dev->stats.rx_errors++; 1814 dev->stats.rx_errors++;
1823 if (!(rx_status & RxStatusOK)) { 1815 if (!(rx_status & RxStatusOK)) {
1824 if (rx_status & RxTooLong) { 1816 if (rx_status & RxTooLong) {
1825 pr_debug("%s: Oversized Ethernet frame, status %4.4x!\n", 1817 netdev_dbg(dev, "Oversized Ethernet frame, status %04x!\n",
1826 dev->name, rx_status); 1818 rx_status);
1827 /* A.C.: The chip hangs here. */ 1819 /* A.C.: The chip hangs here. */
1828 } 1820 }
1829 if (rx_status & (RxBadSymbol | RxBadAlign)) 1821 if (rx_status & (RxBadSymbol | RxBadAlign))
@@ -1855,7 +1847,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1855 break; 1847 break;
1856 } 1848 }
1857 if (tmp_work <= 0) 1849 if (tmp_work <= 0)
1858 pr_warning(PFX "rx stop wait too long\n"); 1850 netdev_warn(dev, "rx stop wait too long\n");
1859 /* restart receive */ 1851 /* restart receive */
1860 tmp_work = 200; 1852 tmp_work = 200;
1861 while (--tmp_work > 0) { 1853 while (--tmp_work > 0) {
@@ -1866,7 +1858,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1866 break; 1858 break;
1867 } 1859 }
1868 if (tmp_work <= 0) 1860 if (tmp_work <= 0)
1869 pr_warning(PFX "tx/rx enable wait too long\n"); 1861 netdev_warn(dev, "tx/rx enable wait too long\n");
1870 1862
1871 /* and reinitialize all rx related registers */ 1863 /* and reinitialize all rx related registers */
1872 RTL_W8_F (Cfg9346, Cfg9346_Unlock); 1864 RTL_W8_F (Cfg9346, Cfg9346_Unlock);
@@ -1877,7 +1869,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1877 RTL_W32 (RxConfig, tp->rx_config); 1869 RTL_W32 (RxConfig, tp->rx_config);
1878 tp->cur_rx = 0; 1870 tp->cur_rx = 0;
1879 1871
1880 pr_debug("init buffer addresses\n"); 1872 netdev_dbg(dev, "init buffer addresses\n");
1881 1873
1882 /* Lock Config[01234] and BMCR register writes */ 1874 /* Lock Config[01234] and BMCR register writes */
1883 RTL_W8 (Cfg9346, Cfg9346_Lock); 1875 RTL_W8 (Cfg9346, Cfg9346_Lock);
@@ -1931,13 +1923,12 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1931 unsigned int cur_rx = tp->cur_rx; 1923 unsigned int cur_rx = tp->cur_rx;
1932 unsigned int rx_size = 0; 1924 unsigned int rx_size = 0;
1933 1925
1934 pr_debug("%s: In rtl8139_rx(), current %4.4x BufAddr %4.4x," 1926 netdev_dbg(dev, "In %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
1935 " free to %4.4x, Cmd %2.2x.\n", dev->name, (u16)cur_rx, 1927 __func__, (u16)cur_rx,
1936 RTL_R16 (RxBufAddr), 1928 RTL_R16(RxBufAddr), RTL_R16(RxBufPtr), RTL_R8(ChipCmd));
1937 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
1938 1929
1939 while (netif_running(dev) && received < budget 1930 while (netif_running(dev) && received < budget &&
1940 && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { 1931 (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
1941 u32 ring_offset = cur_rx % RX_BUF_LEN; 1932 u32 ring_offset = cur_rx % RX_BUF_LEN;
1942 u32 rx_status; 1933 u32 rx_status;
1943 unsigned int pkt_size; 1934 unsigned int pkt_size;
@@ -1950,19 +1941,12 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1950 rx_size = rx_status >> 16; 1941 rx_size = rx_status >> 16;
1951 pkt_size = rx_size - 4; 1942 pkt_size = rx_size - 4;
1952 1943
1953 if (netif_msg_rx_status(tp)) 1944 netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n",
1954 pr_debug("%s: rtl8139_rx() status %4.4x, size %4.4x," 1945 __func__, rx_status, rx_size, cur_rx);
1955 " cur %4.4x.\n", dev->name, rx_status,
1956 rx_size, cur_rx);
1957#if RTL8139_DEBUG > 2 1946#if RTL8139_DEBUG > 2
1958 { 1947 print_hex_dump(KERN_DEBUG, "Frame contents: ",
1959 int i; 1948 DUMP_PREFIX_OFFSET, 16, 1,
1960 pr_debug("%s: Frame contents ", dev->name); 1949 &rx_ring[ring_offset], 70, true);
1961 for (i = 0; i < 70; i++)
1962 pr_cont(" %2.2x",
1963 rx_ring[ring_offset + i]);
1964 pr_cont(".\n");
1965 }
1966#endif 1950#endif
1967 1951
1968 /* Packet copy from FIFO still in progress. 1952 /* Packet copy from FIFO still in progress.
@@ -1973,14 +1957,11 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1973 if (!tp->fifo_copy_timeout) 1957 if (!tp->fifo_copy_timeout)
1974 tp->fifo_copy_timeout = jiffies + 2; 1958 tp->fifo_copy_timeout = jiffies + 2;
1975 else if (time_after(jiffies, tp->fifo_copy_timeout)) { 1959 else if (time_after(jiffies, tp->fifo_copy_timeout)) {
1976 pr_debug("%s: hung FIFO. Reset.", dev->name); 1960 netdev_dbg(dev, "hung FIFO. Reset\n");
1977 rx_size = 0; 1961 rx_size = 0;
1978 goto no_early_rx; 1962 goto no_early_rx;
1979 } 1963 }
1980 if (netif_msg_intr(tp)) { 1964 netif_dbg(tp, intr, dev, "fifo copy in progress\n");
1981 pr_debug("%s: fifo copy in progress.",
1982 dev->name);
1983 }
1984 tp->xstats.early_rx++; 1965 tp->xstats.early_rx++;
1985 break; 1966 break;
1986 } 1967 }
@@ -2004,9 +1985,8 @@ no_early_rx:
2004 /* Malloc up new buffer, compatible with net-2e. */ 1985 /* Malloc up new buffer, compatible with net-2e. */
2005 /* Omit the four octet CRC from the length. */ 1986 /* Omit the four octet CRC from the length. */
2006 1987
2007 skb = netdev_alloc_skb(dev, pkt_size + NET_IP_ALIGN); 1988 skb = netdev_alloc_skb_ip_align(dev, pkt_size);
2008 if (likely(skb)) { 1989 if (likely(skb)) {
2009 skb_reserve (skb, NET_IP_ALIGN); /* 16 byte align the IP fields. */
2010#if RX_BUF_IDX == 3 1990#if RX_BUF_IDX == 3
2011 wrap_copy(skb, rx_ring, ring_offset+4, pkt_size); 1991 wrap_copy(skb, rx_ring, ring_offset+4, pkt_size);
2012#else 1992#else
@@ -2022,8 +2002,7 @@ no_early_rx:
2022 netif_receive_skb (skb); 2002 netif_receive_skb (skb);
2023 } else { 2003 } else {
2024 if (net_ratelimit()) 2004 if (net_ratelimit())
2025 pr_warning("%s: Memory squeeze, dropping packet.\n", 2005 netdev_warn(dev, "Memory squeeze, dropping packet\n");
2026 dev->name);
2027 dev->stats.rx_dropped++; 2006 dev->stats.rx_dropped++;
2028 } 2007 }
2029 received++; 2008 received++;
@@ -2037,10 +2016,9 @@ no_early_rx:
2037 if (unlikely(!received || rx_size == 0xfff0)) 2016 if (unlikely(!received || rx_size == 0xfff0))
2038 rtl8139_isr_ack(tp); 2017 rtl8139_isr_ack(tp);
2039 2018
2040 pr_debug("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x," 2019 netdev_dbg(dev, "Done %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
2041 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, 2020 __func__, cur_rx,
2042 RTL_R16 (RxBufAddr), 2021 RTL_R16(RxBufAddr), RTL_R16(RxBufPtr), RTL_R8(ChipCmd));
2043 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
2044 2022
2045 tp->cur_rx = cur_rx; 2023 tp->cur_rx = cur_rx;
2046 2024
@@ -2061,8 +2039,7 @@ static void rtl8139_weird_interrupt (struct net_device *dev,
2061 void __iomem *ioaddr, 2039 void __iomem *ioaddr,
2062 int status, int link_changed) 2040 int status, int link_changed)
2063{ 2041{
2064 pr_debug("%s: Abnormal interrupt, status %8.8x.\n", 2042 netdev_dbg(dev, "Abnormal interrupt, status %08x\n", status);
2065 dev->name, status);
2066 2043
2067 assert (dev != NULL); 2044 assert (dev != NULL);
2068 assert (tp != NULL); 2045 assert (tp != NULL);
@@ -2090,8 +2067,7 @@ static void rtl8139_weird_interrupt (struct net_device *dev,
2090 pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status); 2067 pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status);
2091 pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status); 2068 pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status);
2092 2069
2093 pr_err("%s: PCI Bus error %4.4x.\n", 2070 netdev_err(dev, "PCI Bus error %04x\n", pci_cmd_status);
2094 dev->name, pci_cmd_status);
2095 } 2071 }
2096} 2072}
2097 2073
@@ -2184,8 +2160,8 @@ static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance)
2184 out: 2160 out:
2185 spin_unlock (&tp->lock); 2161 spin_unlock (&tp->lock);
2186 2162
2187 pr_debug("%s: exiting interrupt, intr_status=%#4.4x.\n", 2163 netdev_dbg(dev, "exiting interrupt, intr_status=%#4.4x\n",
2188 dev->name, RTL_R16 (IntrStatus)); 2164 RTL_R16(IntrStatus));
2189 return IRQ_RETVAL(handled); 2165 return IRQ_RETVAL(handled);
2190} 2166}
2191 2167
@@ -2234,9 +2210,8 @@ static int rtl8139_close (struct net_device *dev)
2234 netif_stop_queue(dev); 2210 netif_stop_queue(dev);
2235 napi_disable(&tp->napi); 2211 napi_disable(&tp->napi);
2236 2212
2237 if (netif_msg_ifdown(tp)) 2213 netif_dbg(tp, ifdown, dev, "Shutting down ethercard, status was 0x%04x\n",
2238 pr_debug("%s: Shutting down ethercard, status was 0x%4.4x.\n", 2214 RTL_R16(IntrStatus));
2239 dev->name, RTL_R16 (IntrStatus));
2240 2215
2241 spin_lock_irqsave (&tp->lock, flags); 2216 spin_lock_irqsave (&tp->lock, flags);
2242 2217
@@ -2510,11 +2485,11 @@ static void __set_rx_mode (struct net_device *dev)
2510 struct rtl8139_private *tp = netdev_priv(dev); 2485 struct rtl8139_private *tp = netdev_priv(dev);
2511 void __iomem *ioaddr = tp->mmio_addr; 2486 void __iomem *ioaddr = tp->mmio_addr;
2512 u32 mc_filter[2]; /* Multicast hash filter */ 2487 u32 mc_filter[2]; /* Multicast hash filter */
2513 int i, rx_mode; 2488 int rx_mode;
2514 u32 tmp; 2489 u32 tmp;
2515 2490
2516 pr_debug("%s: rtl8139_set_rx_mode(%4.4x) done -- Rx config %8.8lx.\n", 2491 netdev_dbg(dev, "rtl8139_set_rx_mode(%04x) done -- Rx config %08lx\n",
2517 dev->name, dev->flags, RTL_R32 (RxConfig)); 2492 dev->flags, RTL_R32(RxConfig));
2518 2493
2519 /* Note: do not reorder, GCC is clever about common statements. */ 2494 /* Note: do not reorder, GCC is clever about common statements. */
2520 if (dev->flags & IFF_PROMISC) { 2495 if (dev->flags & IFF_PROMISC) {
@@ -2522,8 +2497,8 @@ static void __set_rx_mode (struct net_device *dev)
2522 AcceptBroadcast | AcceptMulticast | AcceptMyPhys | 2497 AcceptBroadcast | AcceptMulticast | AcceptMyPhys |
2523 AcceptAllPhys; 2498 AcceptAllPhys;
2524 mc_filter[1] = mc_filter[0] = 0xffffffff; 2499 mc_filter[1] = mc_filter[0] = 0xffffffff;
2525 } else if ((dev->mc_count > multicast_filter_limit) 2500 } else if ((netdev_mc_count(dev) > multicast_filter_limit) ||
2526 || (dev->flags & IFF_ALLMULTI)) { 2501 (dev->flags & IFF_ALLMULTI)) {
2527 /* Too many to filter perfectly -- accept all multicasts. */ 2502 /* Too many to filter perfectly -- accept all multicasts. */
2528 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 2503 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
2529 mc_filter[1] = mc_filter[0] = 0xffffffff; 2504 mc_filter[1] = mc_filter[0] = 0xffffffff;
@@ -2531,8 +2506,7 @@ static void __set_rx_mode (struct net_device *dev)
2531 struct dev_mc_list *mclist; 2506 struct dev_mc_list *mclist;
2532 rx_mode = AcceptBroadcast | AcceptMyPhys; 2507 rx_mode = AcceptBroadcast | AcceptMyPhys;
2533 mc_filter[1] = mc_filter[0] = 0; 2508 mc_filter[1] = mc_filter[0] = 0;
2534 for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; 2509 netdev_for_each_mc_addr(mclist, dev) {
2535 i++, mclist = mclist->next) {
2536 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 2510 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
2537 2511
2538 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 2512 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);