locks: allow lockd to process blocked locks during grace period
[safe/jmp/linux-2.6] / drivers / net / 82596.c
index 7e2ca95..da292e6 100644 (file)
@@ -57,6 +57,7 @@
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/pgtable.h>
+#include <asm/cacheflush.h>
 
 static char version[] __initdata =
        "82596.c $Revision: 1.5 $\n";
@@ -325,7 +326,6 @@ struct i596_private {
        struct i596_cmd *cmd_head;
        int cmd_backlog;
        unsigned long last_cmd;
-       struct net_device_stats stats;
        struct i596_rfd rfds[RX_RING_SIZE];
        struct i596_rbd rbds[RX_RING_SIZE];
        struct tx_cmd tx_cmds[TX_RING_SIZE];
@@ -357,9 +357,8 @@ static char init_setup[] =
 
 static int i596_open(struct net_device *dev);
 static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t i596_interrupt(int irq, void *dev_id);
 static int i596_close(struct net_device *dev);
-static struct net_device_stats *i596_get_stats(struct net_device *dev);
 static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd);
 static void i596_tx_timeout (struct net_device *dev);
 static void print_eth(unsigned char *buf, char *str);
@@ -444,7 +443,7 @@ static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int
 static inline int wait_cfg(struct net_device *dev, struct i596_cmd *cmd, int delcnt, char *str)
 {
        volatile struct i596_cmd *c = cmd;
-       
+
        while (--delcnt && c->command)
                udelay(10);
        if (!delcnt) {
@@ -455,7 +454,7 @@ static inline int wait_cfg(struct net_device *dev, struct i596_cmd *cmd, int del
                return 0;
 }
 
+
 static void i596_display_data(struct net_device *dev)
 {
        struct i596_private *lp = dev->priv;
@@ -501,7 +500,7 @@ static void i596_display_data(struct net_device *dev)
 
 
 #if defined(ENABLE_MVME16x_NET) || defined(ENABLE_BVME6000_NET)
-static irqreturn_t i596_error(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i596_error(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
 #ifdef ENABLE_MVME16x_NET
@@ -787,7 +786,7 @@ static inline int i596_rx(struct net_device *dev)
                }
                DEB(DEB_RXFRAME, printk(KERN_DEBUG "  rfd %p, rfd.rbd %p, rfd.stat %04x\n",
                        rfd, rfd->rbd, rfd->stat));
-               
+
                if (rbd != I596_NULL && ((rfd->stat) & STAT_OK)) {
                        /* a good frame */
                        int pkt_len = rbd->count & 0x3fff;
@@ -827,10 +826,9 @@ memory_squeeze:
                        if (skb == NULL) {
                                /* XXX tulip.c can defer packets here!! */
                                printk(KERN_WARNING "%s: i596_rx Memory squeeze, dropping packet.\n", dev->name);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                        }
                        else {
-                               skb->dev = dev;
                                if (!rx_in_place) {
                                        /* 16 byte align the data fields */
                                        skb_reserve(skb, 2);
@@ -844,28 +842,28 @@ memory_squeeze:
 #endif
                                netif_rx(skb);
                                dev->last_rx = jiffies;
-                               lp->stats.rx_packets++;
-                               lp->stats.rx_bytes+=pkt_len;
+                               dev->stats.rx_packets++;
+                               dev->stats.rx_bytes+=pkt_len;
                        }
                }
                else {
                        DEB(DEB_ERRORS, printk(KERN_DEBUG "%s: Error, rfd.stat = 0x%04x\n",
                                        dev->name, rfd->stat));
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                        if ((rfd->stat) & 0x0001)
-                               lp->stats.collisions++;
+                               dev->stats.collisions++;
                        if ((rfd->stat) & 0x0080)
-                               lp->stats.rx_length_errors++;
+                               dev->stats.rx_length_errors++;
                        if ((rfd->stat) & 0x0100)
-                               lp->stats.rx_over_errors++;
+                               dev->stats.rx_over_errors++;
                        if ((rfd->stat) & 0x0200)
-                               lp->stats.rx_fifo_errors++;
+                               dev->stats.rx_fifo_errors++;
                        if ((rfd->stat) & 0x0400)
-                               lp->stats.rx_frame_errors++;
+                               dev->stats.rx_frame_errors++;
                        if ((rfd->stat) & 0x0800)
-                               lp->stats.rx_crc_errors++;
+                               dev->stats.rx_crc_errors++;
                        if ((rfd->stat) & 0x1000)
-                               lp->stats.rx_length_errors++;
+                               dev->stats.rx_length_errors++;
                }
 
                /* Clear the buffer descriptor count and EOF + F flags */
@@ -899,7 +897,7 @@ memory_squeeze:
 }
 
 
-static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private *lp)
+static void i596_cleanup_cmd(struct net_device *dev, struct i596_private *lp)
 {
        struct i596_cmd *ptr;
 
@@ -916,8 +914,8 @@ static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private
 
                                dev_kfree_skb(skb);
 
-                               lp->stats.tx_errors++;
-                               lp->stats.tx_aborted_errors++;
+                               dev->stats.tx_errors++;
+                               dev->stats.tx_aborted_errors++;
 
                                ptr->v_next = ptr->b_next = I596_NULL;
                                tx_cmd->cmd.command = 0;  /* Mark as free */
@@ -932,7 +930,8 @@ static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private
        lp->scb.cmd = I596_NULL;
 }
 
-static inline void i596_reset(struct net_device *dev, struct i596_private *lp, int ioaddr)
+static void i596_reset(struct net_device *dev, struct i596_private *lp,
+                       int ioaddr)
 {
        unsigned long flags;
 
@@ -1037,10 +1036,10 @@ static void i596_tx_timeout (struct net_device *dev)
        DEB(DEB_ERRORS,printk(KERN_ERR "%s: transmit timed out, status resetting.\n",
                        dev->name));
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
 
        /* Try to restart the adaptor */
-       if (lp->last_restart == lp->stats.tx_packets) {
+       if (lp->last_restart == dev->stats.tx_packets) {
                DEB(DEB_ERRORS,printk(KERN_ERR "Resetting board.\n"));
                /* Shutdown and restart */
                i596_reset (dev, lp, ioaddr);
@@ -1049,7 +1048,7 @@ static void i596_tx_timeout (struct net_device *dev)
                DEB(DEB_ERRORS,printk(KERN_ERR "Kicking board.\n"));
                lp->scb.command = CUC_START | RX_START;
                CA (dev);
-               lp->last_restart = lp->stats.tx_packets;
+               lp->last_restart = dev->stats.tx_packets;
        }
 
        dev->trans_start = jiffies;
@@ -1065,8 +1064,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
        short length = skb->len;
        dev->trans_start = jiffies;
 
-       DEB(DEB_STARTTX,printk(KERN_DEBUG "%s: i596_start_xmit(%x,%x) called\n", dev->name,
-                               skb->len, (unsigned int)skb->data));
+       DEB(DEB_STARTTX,printk(KERN_DEBUG "%s: i596_start_xmit(%x,%p) called\n",
+                               dev->name, skb->len, skb->data));
 
        if (skb->len < ETH_ZLEN) {
                if (skb_padto(skb, ETH_ZLEN))
@@ -1081,7 +1080,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (tx_cmd->cmd.command) {
                printk(KERN_NOTICE "%s: xmit ring full, dropping packet.\n",
                                dev->name);
-               lp->stats.tx_dropped++;
+               dev->stats.tx_dropped++;
 
                dev_kfree_skb(skb);
        } else {
@@ -1106,8 +1105,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
                DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued"));
                i596_add_cmd(dev, &tx_cmd->cmd);
 
-               lp->stats.tx_packets++;
-               lp->stats.tx_bytes += length;
+               dev->stats.tx_packets++;
+               dev->stats.tx_bytes += length;
        }
 
        netif_start_queue(dev);
@@ -1117,15 +1116,12 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 static void print_eth(unsigned char *add, char *str)
 {
-       int i;
+       DECLARE_MAC_BUF(mac);
+       DECLARE_MAC_BUF(mac2);
 
-       printk(KERN_DEBUG "i596 0x%p, ", add);
-       for (i = 0; i < 6; i++)
-               printk(" %02X", add[i + 6]);
-       printk(" -->");
-       for (i = 0; i < 6; i++)
-               printk(" %02X", add[i]);
-       printk(" %02X%02X, %s\n", add[12], add[13], str);
+       printk(KERN_DEBUG "i596 0x%p, %s --> %s %02X%02X, %s\n",
+              add, print_mac(mac, add + 6), print_mac(mac2, add),
+              add[12], add[13], str);
 }
 
 static int io = 0x300;
@@ -1166,6 +1162,7 @@ struct net_device * __init i82596_probe(int unit)
                memcpy(eth_addr, (void *) 0xfffc1f2c, 6);       /* YUCK! Get addr from NOVRAM */
                dev->base_addr = MVME_I596_BASE;
                dev->irq = (unsigned) MVME16x_IRQ_I596;
+               goto found;
        }
 #endif
 #ifdef ENABLE_BVME6000_NET
@@ -1180,6 +1177,7 @@ struct net_device * __init i82596_probe(int unit)
                rtc[3] = msr;
                dev->base_addr = BVME_I596_BASE;
                dev->irq = (unsigned) BVME_IRQ_I596;
+               goto found;
        }
 #endif
 #ifdef ENABLE_APRICOT
@@ -1196,6 +1194,8 @@ struct net_device * __init i82596_probe(int unit)
                        goto out;
                }
 
+               dev->base_addr = ioaddr;
+
                for (i = 0; i < 8; i++) {
                        eth_addr[i] = inb(ioaddr + 8 + i);
                        checksum += eth_addr[i];
@@ -1207,16 +1207,20 @@ struct net_device * __init i82596_probe(int unit)
                   Some other boards trip the checksum.. but then appear as
                   ether address 0. Trap these - AC */
 
-               if ((checksum % 0x100) || 
+               if ((checksum % 0x100) ||
                    (memcmp(eth_addr, "\x00\x00\x49", 3) != 0)) {
                        err = -ENODEV;
                        goto out1;
                }
 
-               dev->base_addr = ioaddr;
                dev->irq = 10;
+               goto found;
        }
 #endif
+       err = -ENODEV;
+       goto out;
+
+found:
        dev->mem_start = (int)__get_free_pages(GFP_ATOMIC, 0);
        if (!dev->mem_start) {
                err = -ENOMEM;
@@ -1233,11 +1237,9 @@ struct net_device * __init i82596_probe(int unit)
        DEB(DEB_PROBE,printk(KERN_INFO "%s", version));
 
        /* The 82596-specific entries in the device structure. */
-       SET_MODULE_OWNER(dev);
        dev->open = i596_open;
        dev->stop = i596_close;
        dev->hard_start_xmit = i596_start_xmit;
-       dev->get_stats = i596_get_stats;
        dev->set_multicast_list = set_multicast_list;
        dev->tx_timeout = i596_tx_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
@@ -1245,7 +1247,8 @@ struct net_device * __init i82596_probe(int unit)
        dev->priv = (void *)(dev->mem_start);
 
        lp = dev->priv;
-       DEB(DEB_INIT,printk(KERN_DEBUG "%s: lp at 0x%08lx (%d bytes), lp->scb at 0x%08lx\n",
+       DEB(DEB_INIT,printk(KERN_DEBUG "%s: lp at 0x%08lx (%zd bytes), "
+                       "lp->scb at 0x%08lx\n",
                        dev->name, (unsigned long)lp,
                        sizeof(struct i596_private), (unsigned long)&lp->scb));
        memset((void *) lp, 0, sizeof(struct i596_private));
@@ -1282,7 +1285,7 @@ out:
        return ERR_PTR(err);
 }
 
-static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t i596_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
        struct i596_private *lp;
@@ -1293,7 +1296,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 #ifdef ENABLE_BVME6000_NET
        if (MACH_IS_BVME6000) {
                if (*(char *) BVME_LOCAL_IRQ_STAT & BVME_ETHERR) {
-                       i596_error(irq, dev_id, regs);
+                       i596_error(irq, dev_id);
                        return IRQ_HANDLED;
                }
        }
@@ -1342,17 +1345,17 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                                if ((ptr->status) & STAT_OK) {
                                        DEB(DEB_TXADDR,print_eth(skb->data, "tx-done"));
                                } else {
-                                       lp->stats.tx_errors++;
+                                       dev->stats.tx_errors++;
                                        if ((ptr->status) & 0x0020)
-                                               lp->stats.collisions++;
+                                               dev->stats.collisions++;
                                        if (!((ptr->status) & 0x0040))
-                                               lp->stats.tx_heartbeat_errors++;
+                                               dev->stats.tx_heartbeat_errors++;
                                        if ((ptr->status) & 0x0400)
-                                               lp->stats.tx_carrier_errors++;
+                                               dev->stats.tx_carrier_errors++;
                                        if ((ptr->status) & 0x0800)
-                                               lp->stats.collisions++;
+                                               dev->stats.collisions++;
                                        if ((ptr->status) & 0x1000)
-                                               lp->stats.tx_aborted_errors++;
+                                               dev->stats.tx_aborted_errors++;
                                }
 
                                dev_kfree_skb_irq(skb);
@@ -1407,8 +1410,8 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                        if (netif_running(dev)) {
                                DEB(DEB_ERRORS,printk(KERN_ERR "%s: i596 interrupt receive unit inactive, status 0x%x\n", dev->name, status));
                                ack_cmd |= RX_START;
-                               lp->stats.rx_errors++;
-                               lp->stats.rx_fifo_errors++;
+                               dev->stats.rx_errors++;
+                               dev->stats.rx_fifo_errors++;
                                rebuild_rx_bufs(dev);
                        }
                }
@@ -1491,14 +1494,6 @@ static int i596_close(struct net_device *dev)
        return 0;
 }
 
-static struct net_device_stats *
- i596_get_stats(struct net_device *dev)
-{
-       struct i596_private *lp = dev->priv;
-
-       return &lp->stats;
-}
-
 /*
  *    Set or clear the multicast filter for this adaptor.
  */
@@ -1544,11 +1539,12 @@ static void set_multicast_list(struct net_device *dev)
                printk(KERN_ERR "%s: Only %d multicast addresses supported",
                        dev->name, cnt);
        }
-       
+
        if (dev->mc_count > 0) {
                struct dev_mc_list *dmi;
                unsigned char *cp;
                struct mc_cmd *cmd;
+               DECLARE_MAC_BUF(mac);
 
                if (wait_cfg(dev, &lp->mc_cmd.cmd, 1000, "multicast list change request timed out"))
                        return;
@@ -1559,8 +1555,8 @@ static void set_multicast_list(struct net_device *dev)
                for (dmi = dev->mc_list; cnt && dmi != NULL; dmi = dmi->next, cnt--, cp += 6) {
                        memcpy(cp, dmi->dmi_addr, 6);
                        if (i596_debug > 1)
-                               DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
-                                               dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
+                               DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %s\n",
+                                               dev->name, print_mac(mac, cp)));
                }
                i596_add_cmd(dev, &cmd->cmd);
        }
@@ -1578,7 +1574,7 @@ static int debug = -1;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "i82596 debug mask");
 
-int init_module(void)
+int __init init_module(void)
 {
        if (debug >= 0)
                i596_debug = debug;
@@ -1588,7 +1584,7 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(dev_82596);
 #ifdef __mc68000__
@@ -1608,7 +1604,7 @@ void cleanup_module(void)
 }
 
 #endif                         /* MODULE */
-\f
+
 /*
  * Local variables:
  *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c 82596.c"