]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/r8169.c
r8169: RX fifo overflow recovery
[linux-2.6-omap-h63xx.git] / drivers / net / r8169.c
index 4c2f575faad709db506ce5c250ab81eefacd2e79..ea4f9f7bd071d84ce866248b0a612d1c8d378bbc 100644 (file)
@@ -257,10 +257,11 @@ enum RTL8169_register_content {
        RxOK = 0x01,
 
        /* RxStatusDesc */
-       RxRES = 0x00200000,
-       RxCRC = 0x00080000,
-       RxRUNT = 0x00100000,
-       RxRWT = 0x00400000,
+       RxFOVF  = (1 << 23),
+       RxRWT   = (1 << 22),
+       RxRES   = (1 << 21),
+       RxRUNT  = (1 << 20),
+       RxCRC   = (1 << 19),
 
        /* ChipCmdBits */
        CmdReset = 0x10,
@@ -1382,6 +1383,41 @@ static void rtl8169_netpoll(struct net_device *dev)
 }
 #endif
 
+static void __rtl8169_set_mac_addr(struct net_device *dev, void __iomem *ioaddr)
+{
+       unsigned int i, j;
+
+       RTL_W8(Cfg9346, Cfg9346_Unlock);
+       for (i = 0; i < 2; i++) {
+               __le32 l = 0;
+
+               for (j = 0; j < 4; j++) {
+                       l <<= 8;
+                       l |= dev->dev_addr[4*i + j];
+               }
+               RTL_W32(MAC0 + 4*i, cpu_to_be32(l));
+       }
+       RTL_W8(Cfg9346, Cfg9346_Lock);
+}
+
+static int rtl8169_set_mac_addr(struct net_device *dev, void *p)
+{
+       struct rtl8169_private *tp = netdev_priv(dev);
+       struct sockaddr *addr = p;
+
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EINVAL;
+
+       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+
+       if (netif_running(dev)) {
+               spin_lock_irq(&tp->lock);
+               __rtl8169_set_mac_addr(dev, tp->mmio_addr);
+               spin_unlock_irq(&tp->lock);
+       }
+       return 0;
+}
+
 static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
                                  void __iomem *ioaddr)
 {
@@ -1609,6 +1645,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        dev->stop = rtl8169_close;
        dev->tx_timeout = rtl8169_tx_timeout;
        dev->set_multicast_list = rtl8169_set_rx_mode;
+       dev->set_mac_address = rtl8169_set_mac_addr;
        dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
        dev->irq = pdev->irq;
        dev->base_addr = (unsigned long) ioaddr;
@@ -1842,6 +1879,8 @@ rtl8169_hw_start(struct net_device *dev)
        /* Enable all known interrupts by setting the interrupt mask. */
        RTL_W16(IntrMask, rtl8169_intr_mask);
 
+       __rtl8169_set_mac_addr(dev, ioaddr);
+
        netif_start_queue(dev);
 }
 
@@ -2427,6 +2466,10 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp,
                                tp->stats.rx_length_errors++;
                        if (status & RxCRC)
                                tp->stats.rx_crc_errors++;
+                       if (status & RxFOVF) {
+                               rtl8169_schedule_work(dev, rtl8169_reset_task);
+                               tp->stats.rx_fifo_errors++;
+                       }
                        rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
                } else {
                        struct sk_buff *skb = tp->Rx_skbuff[entry];