virtio: fix tx_ stats in virtio_net
[safe/jmp/linux-2.6] / drivers / net / arcnet / arcnet.c
index 409d61d..bdc4c0b 100644 (file)
  *     <jojo@repas.de>
  */
 
-#define VERSION "arcnet: v3.93 BETA 2000/04/29 - by Avery Pennarun et al.\n"
+#define VERSION "arcnet: v3.94 BETA 2007/02/08 - by Avery Pennarun et al.\n"
 
 #include <linux/module.h>
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
@@ -62,6 +61,7 @@ static int null_build_header(struct sk_buff *skb, struct net_device *dev,
 static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
                           int length, int bufnum);
 
+static void arcnet_rx(struct net_device *dev, int bufnum);
 
 /*
  * one ArcProto per possible proto ID.  None of the elements of
@@ -72,7 +72,7 @@ static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
  struct ArcProto *arc_proto_map[256], *arc_proto_default,
    *arc_bcast_proto, *arc_raw_proto;
 
-struct ArcProto arc_proto_null =
+static struct ArcProto arc_proto_null =
 {
        .suffix         = '?',
        .mtu            = XMTU,
@@ -91,7 +91,6 @@ EXPORT_SYMBOL(arc_proto_map);
 EXPORT_SYMBOL(arc_proto_default);
 EXPORT_SYMBOL(arc_bcast_proto);
 EXPORT_SYMBOL(arc_raw_proto);
-EXPORT_SYMBOL(arc_proto_null);
 EXPORT_SYMBOL(arcnet_unregister_proto);
 EXPORT_SYMBOL(arcnet_debug);
 EXPORT_SYMBOL(alloc_arcdev);
@@ -103,8 +102,8 @@ static int arcnet_close(struct net_device *dev);
 static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev);
 static void arcnet_timeout(struct net_device *dev);
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
-                        unsigned short type, void *daddr, void *saddr,
-                        unsigned len);
+                        unsigned short type, const void *daddr,
+                        const void *saddr, unsigned len);
 static int arcnet_rebuild_header(struct sk_buff *skb);
 static struct net_device_stats *arcnet_get_stats(struct net_device *dev);
 static int go_tx(struct net_device *dev);
@@ -119,7 +118,7 @@ static int __init arcnet_init(void)
 
        arcnet_debug = debug;
 
-       printk(VERSION);
+       printk("arcnet loaded.\n");
 
 #ifdef ALPHA_WARNING
        BUGLVL(D_EXTRA) {
@@ -179,8 +178,8 @@ EXPORT_SYMBOL(arcnet_dump_skb);
  * Dump the contents of an ARCnet buffer
  */
 #if (ARCNET_DEBUG_MAX & (D_RX | D_TX))
-void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc,
-                       int take_arcnet_lock)
+static void arcnet_dump_packet(struct net_device *dev, int bufnum,
+                              char *desc, int take_arcnet_lock)
 {
        struct arcnet_local *lp = dev->priv;
        int i, length;
@@ -209,7 +208,10 @@ void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc,
 
 }
 
-EXPORT_SYMBOL(arcnet_dump_packet);
+#else
+
+#define arcnet_dump_packet(dev, bufnum, desc,take_arcnet_lock) do { } while (0)
+
 #endif
 
 
@@ -315,11 +317,17 @@ static int choose_mtu(void)
        return mtu == 65535 ? XMTU : mtu;
 }
 
+static const struct header_ops arcnet_header_ops = {
+       .create = arcnet_header,
+       .rebuild = arcnet_rebuild_header,
+};
+
 
 /* Setup a struct device for ARCnet. */
 static void arcdev_setup(struct net_device *dev)
 {
        dev->type = ARPHRD_ARCNET;
+       dev->header_ops = &arcnet_header_ops;
        dev->hard_header_len = sizeof(struct archdr);
        dev->mtu = choose_mtu();
 
@@ -340,8 +348,6 @@ static void arcdev_setup(struct net_device *dev)
        dev->hard_start_xmit = arcnet_send_packet;
        dev->tx_timeout = arcnet_timeout;
        dev->get_stats = arcnet_get_stats;
-       dev->hard_header = arcnet_header;
-       dev->rebuild_header = arcnet_rebuild_header;
 }
 
 struct net_device *alloc_arcdev(char *name)
@@ -486,10 +492,10 @@ static int arcnet_close(struct net_device *dev)
 
 
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
-                        unsigned short type, void *daddr, void *saddr,
-                        unsigned len)
+                        unsigned short type, const void *daddr,
+                        const void *saddr, unsigned len)
 {
-       struct arcnet_local *lp = dev->priv;
+       const struct arcnet_local *lp = netdev_priv(dev);
        uint8_t _daddr, proto_num;
        struct ArcProto *proto;
 
@@ -517,9 +523,12 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
                 * real header when we do rebuild_header.
                 */
                *(uint16_t *) skb_push(skb, 2) = type;
-               if (skb->nh.raw - skb->mac.raw != 2)
+               /*
+                * XXX: Why not use skb->mac_len?
+                */
+               if (skb->network_header - skb->mac_header != 2)
                        BUGMSG(D_NORMAL, "arcnet_header: Yikes!  diff (%d) is not 2!\n",
-                              (int)(skb->nh.raw - skb->mac.raw));
+                              (int)(skb->network_header - skb->mac_header));
                return -2;      /* return error -- can't transmit yet! */
        }
        else {
@@ -552,11 +561,13 @@ static int arcnet_rebuild_header(struct sk_buff *skb)
        unsigned short type;
        uint8_t daddr=0;
        struct ArcProto *proto;
-
-       if (skb->nh.raw - skb->mac.raw != 2) {
+       /*
+        * XXX: Why not use skb->mac_len?
+        */
+       if (skb->network_header - skb->mac_header != 2) {
                BUGMSG(D_NORMAL,
-                    "rebuild_header: shouldn't be here! (hdrsize=%d)\n",
-                    (int)(skb->nh.raw - skb->mac.raw));
+                      "rebuild_header: shouldn't be here! (hdrsize=%d)\n",
+                      (int)(skb->network_header - skb->mac_header));
                return 0;
        }
        type = *(uint16_t *) skb_pull(skb, 2);
@@ -750,7 +761,7 @@ static void arcnet_timeout(struct net_device *dev)
  * interrupts. Establish which device needs attention, and call the correct
  * chipset interrupt handler.
  */
-irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
        struct arcnet_local *lp;
@@ -762,8 +773,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        BUGMSG(D_DURING, "in arcnet_interrupt\n");
        
        lp = dev->priv;
-       if (!lp)
-               BUG();
+       BUG_ON(!lp);
                
        spin_lock(&lp->lock);
 
@@ -930,7 +940,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
                        /* is the RECON info empty or old? */
                        if (!lp->first_recon || !lp->last_recon ||
-                           jiffies - lp->last_recon > HZ * 10) {
+                           time_after(jiffies, lp->last_recon + HZ * 10)) {
                                if (lp->network_down)
                                        BUGMSG(D_NORMAL, "reconfiguration detected: cabling restored?\n");
                                lp->first_recon = lp->last_recon = jiffies;
@@ -964,7 +974,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                                        lp->num_recons = 1;
                                }
                        }
-               } else if (lp->network_down && jiffies - lp->last_recon > HZ * 10) {
+               } else if (lp->network_down &&
+                               time_after(jiffies, lp->last_recon + HZ * 10)) {
                        if (lp->network_down)
                                BUGMSG(D_NORMAL, "cabling restored?\n");
                        lp->first_recon = lp->last_recon = 0;
@@ -997,7 +1008,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  * This is a generic packet receiver that calls arcnet??_rx depending on the
  * protocol ID found.
  */
-void arcnet_rx(struct net_device *dev, int bufnum)
+static void arcnet_rx(struct net_device *dev, int bufnum)
 {
        struct arcnet_local *lp = dev->priv;
        struct archdr pkt;