Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / arcnet / arcnet.c
index 4f9f69e..fabc060 100644 (file)
@@ -52,6 +52,7 @@
 #include <net/arp.h>
 #include <linux/init.h>
 #include <linux/arcdevice.h>
+#include <linux/jiffies.h>
 
 /* "do nothing" functions for protocol drivers */
 static void null_rx(struct net_device *dev, int bufnum,
@@ -61,6 +62,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
@@ -71,7 +73,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,
@@ -90,7 +92,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);
@@ -118,7 +119,7 @@ static int __init arcnet_init(void)
 
        arcnet_debug = debug;
 
-       printk(VERSION);
+       printk("arcnet loaded.\n");
 
 #ifdef ALPHA_WARNING
        BUGLVL(D_EXTRA) {
@@ -178,8 +179,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;
@@ -208,7 +209,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
 
 
@@ -597,7 +601,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
        struct ArcProto *proto;
        int txbuf;
        unsigned long flags;
-       int freeskb = 0;
+       int freeskb, retval;
 
        BUGMSG(D_DURING,
               "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, protocol %x)\n",
@@ -615,7 +619,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
        if (skb->len - ARC_HDR_SIZE > XMTU && !proto->continue_tx) {
                BUGMSG(D_NORMAL, "fixme: packet too large: compensating badly!\n");
                dev_kfree_skb(skb);
-               return 0;       /* don't try again */
+               return NETDEV_TX_OK;    /* don't try again */
        }
 
        /* We're busy transmitting a packet... */
@@ -623,8 +627,11 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
 
        spin_lock_irqsave(&lp->lock, flags);
        AINTMASK(0);
-
-       txbuf = get_arcbuf(dev);
+       if(lp->next_tx == -1)
+               txbuf = get_arcbuf(dev);
+       else {
+               txbuf = -1;
+       }
        if (txbuf != -1) {
                if (proto->prepare_tx(dev, pkt, skb->len, txbuf) &&
                    !proto->ack_tx) {
@@ -638,6 +645,8 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
                        lp->outgoing.skb = skb;
                        lp->outgoing.pkt = pkt;
 
+                       freeskb = 0;
+
                        if (proto->continue_tx &&
                            proto->continue_tx(dev, txbuf)) {
                          BUGMSG(D_NORMAL,
@@ -645,10 +654,12 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
                                 "(proto='%c')\n", proto->suffix);
                        }
                }
-
+               retval = NETDEV_TX_OK;
+               dev->trans_start = jiffies;
                lp->next_tx = txbuf;
        } else {
-               freeskb = 1;
+               retval = NETDEV_TX_BUSY;
+               freeskb = 0;
        }
 
        BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__FUNCTION__,ASTATUS());
@@ -664,7 +675,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev)
        if (freeskb) {
                dev_kfree_skb(skb);
        }
-       return 0;               /* no need to try again */
+       return retval;          /* no need to try again */
 }
 
 
@@ -690,7 +701,6 @@ static int go_tx(struct net_device *dev)
        /* start sending */
        ACOMMAND(TXcmd | (lp->cur_tx << 3));
 
-       dev->trans_start = jiffies;
        lp->stats.tx_packets++;
        lp->lasttrans_dest = lp->lastload_dest;
        lp->lastload_dest = 0;
@@ -727,7 +737,7 @@ static void arcnet_timeout(struct net_device *dev)
        
        spin_unlock_irqrestore(&lp->lock, flags);
 
-       if (jiffies - lp->last_timeout > 10*HZ) {
+       if (time_after(jiffies, lp->last_timeout + 10*HZ)) {
                BUGMSG(D_EXTRA, "tx timed out%s (status=%Xh, intmask=%Xh, dest=%02Xh)\n",
                       msg, status, lp->intmask, lp->lasttrans_dest);
                lp->last_timeout = jiffies;
@@ -755,8 +765,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);
 
@@ -917,6 +926,9 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
                        BUGMSG(D_RECON, "Network reconfiguration detected (status=%Xh)\n",
                               status);
+                       /* MYRECON bit is at bit 7 of diagstatus */
+                       if(diagstatus & 0x80)
+                               BUGMSG(D_RECON,"Put out that recon myself\n");
 
                        /* is the RECON info empty or old? */
                        if (!lp->first_recon || !lp->last_recon ||
@@ -987,7 +999,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;