]> err.no Git - linux-2.6/blobdiff - drivers/net/r6040.c
netxen: fix promisc mode, mtu setting
[linux-2.6] / drivers / net / r6040.c
index 973f1e81667a01874b1cc686d02b0284ca24ceac..6531ff565c545bd02841fc2d15942f3e4896d65f 100644 (file)
@@ -50,8 +50,8 @@
 #include <asm/processor.h>
 
 #define DRV_NAME       "r6040"
-#define DRV_VERSION    "0.16"
-#define DRV_RELDATE    "10Nov2007"
+#define DRV_VERSION    "0.18"
+#define DRV_RELDATE    "13Jul2008"
 
 /* PHY CHIP Address */
 #define PHY1_ADDR      1       /* For MAC1 */
@@ -163,9 +163,9 @@ MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver");
 
 /* RX and TX interrupts that we handle */
-#define RX_INT                 (RX_FINISH)
-#define TX_INT                 (TX_FINISH)
-#define INT_MASK               (RX_INT | TX_INT)
+#define RX_INTS                        (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
+#define TX_INTS                        (TX_FINISH)
+#define INT_MASK               (RX_INTS | TX_INTS)
 
 struct r6040_descriptor {
        u16     status, len;            /* 0-3 */
@@ -388,8 +388,8 @@ static void r6040_init_mac_regs(struct net_device *dev)
        iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1);
 
        /* Set interrupt waiting time and packet numbers */
-       iowrite16(0x0F06, ioaddr + MT_ICR);
-       iowrite16(0x0F06, ioaddr + MR_ICR);
+       iowrite16(0, ioaddr + MT_ICR);
+       iowrite16(0, ioaddr + MR_ICR);
 
        /* Enable interrupts */
        iowrite16(INT_MASK, ioaddr + MIER);
@@ -671,7 +671,7 @@ static int r6040_poll(struct napi_struct *napi, int budget)
        if (work_done < budget) {
                netif_rx_complete(dev, napi);
                /* Enable RX interrupt */
-               iowrite16(ioread16(ioaddr + MIER) | RX_INT, ioaddr + MIER);
+               iowrite16(ioread16(ioaddr + MIER) | RX_INTS, ioaddr + MIER);
        }
        return work_done;
 }
@@ -693,14 +693,22 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id)
                return IRQ_NONE;
 
        /* RX interrupt request */
-       if (status & 0x01) {
+       if (status & RX_INTS) {
+               if (status & RX_NO_DESC) {
+                       /* RX descriptor unavailable */
+                       dev->stats.rx_dropped++;
+                       dev->stats.rx_missed_errors++;
+               }
+               if (status & RX_FIFO_FULL)
+                       dev->stats.rx_fifo_errors++;
+
                /* Mask off RX interrupt */
-               iowrite16(ioread16(ioaddr + MIER) & ~RX_INT, ioaddr + MIER);
+               iowrite16(ioread16(ioaddr + MIER) & ~RX_INTS, ioaddr + MIER);
                netif_rx_schedule(dev, &lp->napi);
        }
 
        /* TX interrupt request */
-       if (status & 0x10)
+       if (status & TX_INTS)
                r6040_tx(dev);
 
        return IRQ_HANDLED;
@@ -1046,24 +1054,27 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 
        err = pci_enable_device(pdev);
        if (err)
-               return err;
+               goto err_out;
 
        /* this should always be supported */
-       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
+       err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+       if (err) {
                printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses"
                                "not supported by the card\n");
-               return -ENODEV;
+               goto err_out;
        }
-       if (pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
+       err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+       if (err) {
                printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses"
                                "not supported by the card\n");
-               return -ENODEV;
+               goto err_out;
        }
 
        /* IO Size check */
        if (pci_resource_len(pdev, 0) < io_size) {
-               printk(KERN_ERR "Insufficient PCI resources, aborting\n");
-               return -EIO;
+               printk(KERN_ERR DRV_NAME "Insufficient PCI resources, aborting\n");
+               err = -EIO;
+               goto err_out;
        }
 
        pioaddr = pci_resource_start(pdev, 0);  /* IO map base address */
@@ -1071,23 +1082,26 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 
        dev = alloc_etherdev(sizeof(struct r6040_private));
        if (!dev) {
-               printk(KERN_ERR "Failed to allocate etherdev\n");
-               return -ENOMEM;
+               printk(KERN_ERR DRV_NAME "Failed to allocate etherdev\n");
+               err = -ENOMEM;
+               goto err_out;
        }
        SET_NETDEV_DEV(dev, &pdev->dev);
        lp = netdev_priv(dev);
 
-       if (pci_request_regions(pdev, DRV_NAME)) {
+       err = pci_request_regions(pdev, DRV_NAME);
+
+       if (err) {
                printk(KERN_ERR DRV_NAME ": Failed to request PCI regions\n");
-               err = -ENODEV;
-               goto err_out_disable;
+               goto err_out_free_dev;
        }
 
        ioaddr = pci_iomap(pdev, bar, io_size);
        if (!ioaddr) {
                printk(KERN_ERR "ioremap failed for device %s\n",
                        pci_name(pdev));
-               return -EIO;
+               err = -EIO;
+               goto err_out_free_res;
        }
 
        /* Init system & device */
@@ -1139,17 +1153,17 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
        err = register_netdev(dev);
        if (err) {
                printk(KERN_ERR DRV_NAME ": Failed to register net device\n");
-               goto err_out_res;
+               goto err_out_unmap;
        }
        return 0;
 
-err_out_res:
+err_out_unmap:
+       pci_iounmap(pdev, ioaddr);
+err_out_free_res:
        pci_release_regions(pdev);
-err_out_disable:
-       pci_disable_device(pdev);
-       pci_set_drvdata(pdev, NULL);
+err_out_free_dev:
        free_netdev(dev);
-
+err_out:
        return err;
 }