]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/3c523.c
r6040: completely rework the RX path
[linux-2.6-omap-h63xx.git] / drivers / net / 3c523.c
index 5dfd97f0ba9ea1b7efc15b856ddf7e0006021a0d..dc6e474229b1fae95923ce733b5647d9ac4be771 100644 (file)
@@ -83,7 +83,7 @@
        Stuart Adamson <stuart.adamson@compsoc.net>
    Nov 2001
    added support for ethtool (jgarzik)
-       
+
    $Header: /fsys2/home/chrisb/linux-1.3.59-MCA/drivers/net/RCS/3c523.c,v 1.1 1996/02/05 01:53:46 chrisb Exp chrisb $
  */
 
@@ -180,7 +180,7 @@ sizeof(nop_cmd) = 8;
        dev->name,__LINE__); \
       elmc_id_reset586(); } } }
 
-static irqreturn_t elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr);
+static irqreturn_t elmc_interrupt(int irq, void *dev_id);
 static int elmc_open(struct net_device *dev);
 static int elmc_close(struct net_device *dev);
 static int elmc_send_packet(struct sk_buff *, struct net_device *);
@@ -189,7 +189,7 @@ static void elmc_timeout(struct net_device *dev);
 #ifdef ELMC_MULTICAST
 static void set_multicast_list(struct net_device *dev);
 #endif
-static struct ethtool_ops netdev_ethtool_ops;
+static const struct ethtool_ops netdev_ethtool_ops;
 
 /* helper-functions */
 static int init586(struct net_device *dev);
@@ -202,7 +202,6 @@ static void elmc_xmt_int(struct net_device *dev);
 static void elmc_rnr_int(struct net_device *dev);
 
 struct priv {
-       struct net_device_stats stats;
        unsigned long base;
        char *memtop;
        unsigned long mapped_start;             /* Start of ioremap */
@@ -383,8 +382,8 @@ void alloc586(struct net_device *dev)
 static int elmc_getinfo(char *buf, int slot, void *d)
 {
        int len = 0;
-       struct net_device *dev = (struct net_device *) d;
-       int i;
+       struct net_device *dev = d;
+       DECLARE_MAC_BUF(mac);
 
        if (dev == NULL)
                return len;
@@ -399,12 +398,8 @@ static int elmc_getinfo(char *buf, int slot, void *d)
        len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ?
                       "External" : "Internal");
        len += sprintf(buf + len, "Device: %s\n", dev->name);
-       len += sprintf(buf + len, "Hardware Address:");
-       for (i = 0; i < 6; i++) {
-               len += sprintf(buf + len, " %02x", dev->dev_addr[i]);
-       }
-       buf[len++] = '\n';
-       buf[len] = 0;
+       len += sprintf(buf + len, "Hardware Address: %s\n",
+                      print_mac(mac, dev->dev_addr));
 
        return len;
 }                              /* elmc_getinfo() */
@@ -422,8 +417,8 @@ static int __init do_elmc_probe(struct net_device *dev)
        unsigned int size = 0;
        int retval;
        struct priv *pr = dev->priv;
+       DECLARE_MAC_BUF(mac);
 
-       SET_MODULE_OWNER(dev);
        if (MCA_bus == 0) {
                return -ENODEV;
        }
@@ -434,14 +429,14 @@ static int __init do_elmc_probe(struct net_device *dev)
 
                dev->irq=irq_table[(status & ELMC_STATUS_IRQ_SELECT) >> 6];
                dev->base_addr=csr_table[(status & ELMC_STATUS_CSR_SELECT) >> 1];
-               
+
                /*
                   If we're trying to match a specified irq or IO address,
                   we'll reject a match unless it's what we're looking for.
                   Also reject it if the card is already in use.
                 */
 
-               if ((irq && irq != dev->irq) || 
+               if ((irq && irq != dev->irq) ||
                    (base_addr && base_addr != dev->base_addr)) {
                        slot = mca_find_adapter(ELMC_MCA_ID, slot + 1);
                        continue;
@@ -540,17 +535,16 @@ static int __init do_elmc_probe(struct net_device *dev)
 
        /* dump all the assorted information */
        printk(KERN_INFO "%s: IRQ %d, %sternal xcvr, memory %#lx-%#lx.\n", dev->name,
-              dev->irq, dev->if_port ? "ex" : "in", 
+              dev->irq, dev->if_port ? "ex" : "in",
               dev->mem_start, dev->mem_end - 1);
 
        /* The hardware address for the 3c523 is stored in the first six
           bytes of the IO address. */
-       printk(KERN_INFO "%s: hardware address ", dev->name);
-       for (i = 0; i < 6; i++) {
+       for (i = 0; i < 6; i++)
                dev->dev_addr[i] = inb(dev->base_addr + i);
-               printk(" %02x", dev->dev_addr[i]);
-       }
-       printk("\n");
+
+       printk(KERN_INFO "%s: hardware address %s\n",
+              dev->name, print_mac(mac, dev->dev_addr));
 
        dev->open = &elmc_open;
        dev->stop = &elmc_close;
@@ -564,7 +558,7 @@ static int __init do_elmc_probe(struct net_device *dev)
        dev->set_multicast_list = NULL;
 #endif
        dev->ethtool_ops = &netdev_ethtool_ops;
-       
+
        /* note that we haven't actually requested the IRQ from the kernel.
           That gets done in elmc_open().  I'm not sure that's such a good idea,
           but it works, so I'll go with it. */
@@ -583,7 +577,7 @@ err_out:
        release_region(dev->base_addr, ELMC_IO_EXTENT);
        return retval;
 }
+
 static void cleanup_card(struct net_device *dev)
 {
        mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot, NULL, NULL);
@@ -900,16 +894,13 @@ static void *alloc_rfa(struct net_device *dev, void *ptr)
  */
 
 static irqreturn_t
-elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
+elmc_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *) dev_id;
+       struct net_device *dev = dev_id;
        unsigned short stat;
        struct priv *p;
 
-       if (dev == NULL) {
-               printk(KERN_ERR "elmc-interrupt: irq %d for unknown device.\n", (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));
-               return IRQ_NONE;
-       } else if (!netif_running(dev)) {
+       if (!netif_running(dev)) {
                /* The 3c523 has this habit of generating interrupts during the
                   reset.  I'm not sure if the ni52 has this same problem, but it's
                   really annoying if we haven't finished initializing it.  I was
@@ -926,7 +917,7 @@ elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
 
        p = (struct priv *) dev->priv;
 
-       while ((stat = p->scb->status & STAT_MASK)) 
+       while ((stat = p->scb->status & STAT_MASK))
        {
                p->scb->cmd = stat;
                elmc_attn586(); /* ack inter. */
@@ -991,25 +982,24 @@ static void elmc_rcv_int(struct net_device *dev)
                                rbd->status = 0;
                                skb = (struct sk_buff *) dev_alloc_skb(totlen + 2);
                                if (skb != NULL) {
-                                       skb->dev = dev;
                                        skb_reserve(skb, 2);    /* 16 byte alignment */
                                        skb_put(skb,totlen);
-                                       eth_copy_and_sum(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen,0);
+                                       skb_copy_to_linear_data(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen);
                                        skb->protocol = eth_type_trans(skb, dev);
                                        netif_rx(skb);
                                        dev->last_rx = jiffies;
-                                       p->stats.rx_packets++;
-                                       p->stats.rx_bytes += totlen;
+                                       dev->stats.rx_packets++;
+                                       dev->stats.rx_bytes += totlen;
                                } else {
-                                       p->stats.rx_dropped++;
+                                       dev->stats.rx_dropped++;
                                }
                        } else {
                                printk(KERN_WARNING "%s: received oversized frame.\n", dev->name);
-                               p->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                        }
                } else {        /* frame !(ok), only with 'save-bad-frames' */
                        printk(KERN_WARNING "%s: oops! rfd-error-status: %04x\n", dev->name, status);
-                       p->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                }
                p->rfd_top->status = 0;
                p->rfd_top->last = RFD_SUSP;
@@ -1027,7 +1017,7 @@ static void elmc_rnr_int(struct net_device *dev)
 {
        struct priv *p = (struct priv *) dev->priv;
 
-       p->stats.rx_errors++;
+       dev->stats.rx_errors++;
 
        WAIT_4_SCB_CMD();       /* wait for the last cmd */
        p->scb->cmd = RUC_ABORT;        /* usually the RU is in the 'no resource'-state .. abort it now. */
@@ -1055,24 +1045,24 @@ static void elmc_xmt_int(struct net_device *dev)
                printk(KERN_WARNING "%s: strange .. xmit-int without a 'COMPLETE'\n", dev->name);
        }
        if (status & STAT_OK) {
-               p->stats.tx_packets++;
-               p->stats.collisions += (status & TCMD_MAXCOLLMASK);
+               dev->stats.tx_packets++;
+               dev->stats.collisions += (status & TCMD_MAXCOLLMASK);
        } else {
-               p->stats.tx_errors++;
+               dev->stats.tx_errors++;
                if (status & TCMD_LATECOLL) {
                        printk(KERN_WARNING "%s: late collision detected.\n", dev->name);
-                       p->stats.collisions++;
+                       dev->stats.collisions++;
                } else if (status & TCMD_NOCARRIER) {
-                       p->stats.tx_carrier_errors++;
+                       dev->stats.tx_carrier_errors++;
                        printk(KERN_WARNING "%s: no carrier detected.\n", dev->name);
                } else if (status & TCMD_LOSTCTS) {
                        printk(KERN_WARNING "%s: loss of CTS detected.\n", dev->name);
                } else if (status & TCMD_UNDERRUN) {
-                       p->stats.tx_fifo_errors++;
+                       dev->stats.tx_fifo_errors++;
                        printk(KERN_WARNING "%s: DMA underrun detected.\n", dev->name);
                } else if (status & TCMD_MAXCOLL) {
                        printk(KERN_WARNING "%s: Max. collisions exceeded.\n", dev->name);
-                       p->stats.collisions += 16;
+                       dev->stats.collisions += 16;
                }
        }
 
@@ -1102,7 +1092,7 @@ static void startrecv586(struct net_device *dev)
 /******************************************************
  * timeout
  */
+
 static void elmc_timeout(struct net_device *dev)
 {
        struct priv *p = (struct priv *) dev->priv;
@@ -1129,7 +1119,7 @@ static void elmc_timeout(struct net_device *dev)
                elmc_open(dev);
        }
 }
+
 /******************************************************
  * send frame
  */
@@ -1146,10 +1136,10 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
        netif_stop_queue(dev);
 
        len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
-       
+
        if (len != skb->len)
                memset((char *) p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN);
-       memcpy((char *) p->xmit_cbuffs[p->xmit_count], (char *) (skb->data), skb->len);
+       skb_copy_from_linear_data(skb, (char *) p->xmit_cbuffs[p->xmit_count], skb->len);
 
 #if (NUM_XMIT_BUFFS == 1)
 #ifdef NO_NOPCOMMANDS
@@ -1177,7 +1167,7 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
 #else
        next_nop = (p->nop_point + 1) & 0x1;
        p->xmit_buffs[0]->size = TBD_LAST | len;
-       
+
        p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
            = make16((p->nop_cmds[next_nop]));
        p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
@@ -1224,12 +1214,12 @@ static struct net_device_stats *elmc_get_stats(struct net_device *dev)
        ovrn = p->scb->ovrn_errs;
        p->scb->ovrn_errs -= ovrn;
 
-       p->stats.rx_crc_errors += crc;
-       p->stats.rx_fifo_errors += ovrn;
-       p->stats.rx_frame_errors += aln;
-       p->stats.rx_dropped += rsc;
+       dev->stats.rx_crc_errors += crc;
+       dev->stats.rx_fifo_errors += ovrn;
+       dev->stats.rx_frame_errors += aln;
+       dev->stats.rx_dropped += rsc;
 
-       return &p->stats;
+       return &dev->stats;
 }
 
 /********************************************************
@@ -1259,7 +1249,7 @@ static void netdev_get_drvinfo(struct net_device *dev,
        sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
 }
 
-static struct ethtool_ops netdev_ethtool_ops = {
+static const struct ethtool_ops netdev_ethtool_ops = {
        .get_drvinfo            = netdev_get_drvinfo,
 };
 
@@ -1281,7 +1271,7 @@ int __init init_module(void)
 {
        int this_dev,found = 0;
 
-       /* Loop until we either can't find any more cards, or we have MAX_3C523_CARDS */        
+       /* Loop until we either can't find any more cards, or we have MAX_3C523_CARDS */
        for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
                struct net_device *dev = alloc_etherdev(sizeof(struct priv));
                if (!dev)
@@ -1305,7 +1295,7 @@ int __init init_module(void)
        } else return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
        for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {