root/drivers/net/3c501.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. el1_probe
  2. el1_probe1
  3. el_open
  4. el_start_xmit
  5. el_interrupt
  6. el_receive
  7. el_reset
  8. el1_close
  9. el1_get_stats
  10. set_multicast_list
  11. init_module
  12. cleanup_module

   1 /* 3c501.c: A 3Com 3c501 ethernet driver for linux. */
   2 /*
   3     Written 1992,1993,1994  Donald Becker
   4 
   5     Copyright 1993 United States Government as represented by the
   6     Director, National Security Agency.  This software may be used and
   7     distributed according to the terms of the GNU Public License,
   8     incorporated herein by reference.
   9 
  10     This is a device driver for the 3Com Etherlink 3c501.
  11     Do not purchase this card, even as a joke.  It's performance is horrible,
  12     and it breaks in many ways.  
  13 
  14     The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
  15     Center of Excellence in Space Data and Information Sciences
  16        Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
  17        
  18     Fixed (again!) the missing interrupt locking on TX/RX shifting.
  19                 Alan Cox <Alan.Cox@linux.org>
  20                 
  21     Some notes on this thing if you have to hack it.  [Alan]
  22     
  23     1]  Some documentation is available from 3Com. Due to the boards age
  24         standard responses when you ask for this will range from 'be serious'
  25         to 'give it to a museum'. The documentation is incomplete and mostly
  26         of historical interest anyway.
  27         
  28     2]  The basic system is a single buffer which can be used to receive or
  29         transmit a packet. A third command mode exists when you are setting
  30         things up.
  31         
  32     3]  If its transmitting its not receiving and vice versa. In fact the 
  33         time to get the board back into useful state after an operation is
  34         quite large.
  35         
  36     4]  The driver works by keeping the board in receive mode waiting for a
  37         packet to arrive. When one arrives it is copied out of the buffer
  38         and delivered to the kernel. The card is reloaded and off we go.
  39         
  40     5]  When transmitting dev->tbusy is set and the card is reset (from
  41         receive mode) [possibly losing a packet just received] to command
  42         mode. A packet is loaded and transmit mode triggered. The interrupt
  43         handler runs different code for transmit interrupts and can handle
  44         returning to receive mode or retransmissions (yes you have to help
  45         out with those too).
  46         
  47     Problems:
  48         There are a wide variety of undocumented error returns from the card
  49     and you basically have to kick the board and pray if they turn up. Most 
  50     only occur under extreme load or if you do something the board doesn't
  51     like (eg touching a register at the wrong time).
  52     
  53         The driver is less efficient than it could be. It switches through
  54     recieve mode even if more transmits are queued. If this worries you buy
  55     a real ethernet card.
  56     
  57         The combination of slow receive restart and no real multicast
  58     filter makes the board unusable with a kernel compiled for IP
  59     multicasting in a real multicast environment. Thats down to the board, 
  60     but even with no multicast programs running a multicast IP kernel is
  61     in group 224.0.0.1 and you will therefore be listening to all multicasts.
  62     One nv conference running over that ethernet and you can give up.
  63     
  64 */
  65 
  66 static char *version =
  67     "3c501.c: 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov).\n";
  68 
  69 /*
  70   Braindamage remaining:
  71   The 3c501 board.
  72   */
  73 
  74 #include <linux/kernel.h>
  75 #include <linux/sched.h>
  76 #include <linux/ptrace.h>
  77 #include <linux/fcntl.h>
  78 #include <linux/ioport.h>
  79 #include <linux/interrupt.h>
  80 #include <linux/malloc.h>
  81 #include <linux/string.h>
  82 #include <linux/ioport.h>
  83 #include <linux/errno.h>
  84 
  85 #include <asm/bitops.h>
  86 #include <asm/io.h>
  87 
  88 #include <linux/netdevice.h>
  89 #include <linux/etherdevice.h>
  90 #include <linux/skbuff.h>
  91 
  92 #ifdef MODULE
  93 #include <linux/module.h>
  94 #include <linux/version.h>
  95 #endif
  96 
  97 extern struct device *init_etherdev(struct device *dev, int sizeof_private,
  98                                     unsigned long *mem_startp);
  99 
 100 /* A zero-terminated list of I/O addresses to be probed.
 101    The 3c501 can be at many locations, but here are the popular ones. */
 102 static unsigned int netcard_portlist[] =
 103    { 0x280, 0x300, 0};
 104 
 105 
 106 /* Index to functions. */
 107 int el1_probe(struct device *dev);
 108 static int  el1_probe1(struct device *dev, int ioaddr);
 109 static int  el_open(struct device *dev);
 110 static int  el_start_xmit(struct sk_buff *skb, struct device *dev);
 111 static void el_interrupt(int reg_ptr);
 112 static void el_receive(struct device *dev);
 113 static void el_reset(struct device *dev);
 114 static int  el1_close(struct device *dev);
 115 static struct enet_statistics *el1_get_stats(struct device *dev);
 116 static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
 117 
 118 #define EL1_IO_EXTENT   16
 119 
 120 #ifndef EL_DEBUG
 121 #define EL_DEBUG  2     /* use 0 for production, 1 for devel., >2 for debug */
 122 #endif                  /* Anything above 5 is wordy death! */
 123 static int el_debug = EL_DEBUG;
 124  
 125 /* Board-specific info in dev->priv. */
 126 struct net_local {
 127     struct enet_statistics stats;
 128     int tx_pkt_start;           /* The length of the current Tx packet. */
 129     int collisions;             /* Tx collisions this packet */
 130 };
 131 
 132 
 133 #define RX_STATUS (ioaddr + 0x06)
 134 #define RX_CMD    RX_STATUS
 135 #define TX_STATUS (ioaddr + 0x07)
 136 #define TX_CMD    TX_STATUS
 137 #define GP_LOW    (ioaddr + 0x08)
 138 #define GP_HIGH   (ioaddr + 0x09)
 139 #define RX_BUF_CLR (ioaddr + 0x0A)
 140 #define RX_LOW    (ioaddr + 0x0A)
 141 #define RX_HIGH   (ioaddr + 0x0B)
 142 #define SAPROM    (ioaddr + 0x0C)
 143 #define AX_STATUS (ioaddr + 0x0E)
 144 #define AX_CMD    AX_STATUS
 145 #define DATAPORT  (ioaddr + 0x0F)
 146 #define TX_RDY 0x08             /* In TX_STATUS */
 147 
 148 #define EL1_DATAPTR     0x08
 149 #define EL1_RXPTR       0x0A
 150 #define EL1_SAPROM      0x0C
 151 #define EL1_DATAPORT    0x0f
 152 
 153 /* Writes to the ax command register. */
 154 #define AX_OFF  0x00                    /* Irq off, buffer access on */
 155 #define AX_SYS  0x40                    /* Load the buffer */
 156 #define AX_XMIT 0x44                    /* Transmit a packet */
 157 #define AX_RX   0x48                    /* Receive a packet */
 158 #define AX_LOOP 0x0C                    /* Loopback mode */
 159 #define AX_RESET 0x80
 160 
 161 /* Normal receive mode written to RX_STATUS.  We must intr on short packets
 162    to avoid bogus rx lockups. */
 163 #define RX_NORM 0xA8            /* 0x68 == all addrs, 0xA8 only to me. */
 164 #define RX_PROM 0x68            /* Senior Prom, uhmm promiscuous mode. */
 165 #define RX_MULT 0xE8            /* Accept multicast packets. */
 166 #define TX_NORM 0x0A    /* Interrupt on everything that might hang the chip */
 167 
 168 /* TX_STATUS register. */
 169 #define TX_COLLISION 0x02
 170 #define TX_16COLLISIONS 0x04
 171 #define TX_READY 0x08
 172 
 173 #define RX_RUNT 0x08
 174 #define RX_MISSED 0x01          /* Missed a packet due to 3c501 braindamage. */
 175 #define RX_GOOD 0x30            /* Good packet 0x20, or simple overflow 0x10. */
 176 
 177 
 178 /* The boilerplate probe code. */
 179 #ifdef HAVE_DEVLIST
 180 struct netdev_entry el1_drv =
 181 {"3c501", el1_probe1, EL1_IO_EXTENT, netcard_portlist};
 182 #else
 183 int
 184 el1_probe(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 185 {
 186     int i;
 187     int base_addr = dev ? dev->base_addr : 0;
 188 
 189     if (base_addr > 0x1ff)      /* Check a single specified location. */
 190         return el1_probe1(dev, base_addr);
 191     else if (base_addr != 0)    /* Don't probe at all. */
 192         return ENXIO;
 193 
 194     for (i = 0; netcard_portlist[i]; i++) {
 195         int ioaddr = netcard_portlist[i];
 196         if (check_region(ioaddr, EL1_IO_EXTENT))
 197             continue;
 198         if (el1_probe1(dev, ioaddr) == 0)
 199             return 0;
 200     }
 201 
 202     return ENODEV;
 203 }
 204 #endif
 205 
 206 /* The actual probe. */ 
 207 static int
 208 el1_probe1(struct device *dev, int ioaddr)
     /* [previous][next][first][last][top][bottom][index][help] */
 209 {
 210     char *mname;                /* Vendor name */
 211     unsigned char station_addr[6];
 212     int autoirq = 0;
 213     int i;
 214 
 215     /* Read the station address PROM data from the special port.  */
 216     for (i = 0; i < 6; i++) {
 217         outw(i, ioaddr + EL1_DATAPTR);
 218         station_addr[i] = inb(ioaddr + EL1_SAPROM);
 219     }
 220     /* Check the first three octets of the S.A. for 3Com's prefix, or
 221        for the Sager NP943 prefix. */ 
 222     if (station_addr[0] == 0x02  &&  station_addr[1] == 0x60
 223         && station_addr[2] == 0x8c) {
 224         mname = "3c501";
 225     } else if (station_addr[0] == 0x00  &&  station_addr[1] == 0x80
 226         && station_addr[2] == 0xC8) {
 227         mname = "NP943";
 228     } else
 229         return ENODEV;
 230 
 231     /* Grab the region so we can find the another board if autoIRQ fails. */
 232     register_iomem(ioaddr, EL1_IO_EXTENT,"3c501");
 233 
 234     if (dev == NULL)
 235         dev = init_etherdev(0, sizeof(struct net_local), 0);
 236 
 237     /* We auto-IRQ by shutting off the interrupt line and letting it float
 238        high. */
 239     if (dev->irq < 2) {
 240 
 241         autoirq_setup(2);
 242 
 243         inb(RX_STATUS);         /* Clear pending interrupts. */
 244         inb(TX_STATUS);
 245         outb(AX_LOOP + 1, AX_CMD);
 246 
 247         outb(0x00, AX_CMD);
 248 
 249         autoirq = autoirq_report(1);
 250 
 251         if (autoirq == 0) {
 252             printk("%s probe at %#x failed to detect IRQ line.\n",
 253                    mname, ioaddr);
 254             return EAGAIN;
 255         }
 256     }
 257 
 258     outb(AX_RESET+AX_LOOP, AX_CMD);                     /* Loopback mode. */
 259 
 260     dev->base_addr = ioaddr;
 261     memcpy(dev->dev_addr, station_addr, ETH_ALEN);
 262     if (dev->mem_start & 0xf)
 263         el_debug = dev->mem_start & 0x7;
 264     if (autoirq)
 265         dev->irq = autoirq;
 266 
 267     printk("%s: %s EtherLink at %#x, using %sIRQ %d.\n",
 268            dev->name, mname, dev->base_addr,
 269            autoirq ? "auto":"assigned ", dev->irq);
 270            
 271 #ifdef CONFIG_IP_MULTICAST
 272     printk("WARNING: Use of the 3c501 in a multicast kernel is NOT recommended.\n");
 273 #endif    
 274 
 275     if (el_debug)
 276         printk("%s", version);
 277 
 278     /* Initialize the device structure. */
 279     if (dev->priv == NULL)
 280         dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
 281     memset(dev->priv, 0, sizeof(struct net_local));
 282 
 283     /* The EL1-specific entries in the device structure. */
 284     dev->open = &el_open;
 285     dev->hard_start_xmit = &el_start_xmit;
 286     dev->stop = &el1_close;
 287     dev->get_stats = &el1_get_stats;
 288     dev->set_multicast_list = &set_multicast_list;
 289     /* Setup the generic properties */
 290     ether_setup(dev);
 291 
 292     return 0;
 293 }
 294 
 295 /* Open/initialize the board. */
 296 static int
 297 el_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 298 {
 299     int ioaddr = dev->base_addr;
 300 
 301     if (el_debug > 2)
 302         printk("%s: Doing el_open()...", dev->name);
 303 
 304     if (request_irq(dev->irq, &el_interrupt, 0, "3c501")) {
 305         return -EAGAIN;
 306     }
 307     irq2dev_map[dev->irq] = dev;
 308 
 309     el_reset(dev);
 310 
 311     dev->start = 1;
 312 
 313     outb(AX_RX, AX_CMD);        /* Aux control, irq and receive enabled */
 314 #ifdef MODULE
 315     MOD_INC_USE_COUNT;
 316 #endif       
 317     return 0;
 318 }
 319 
 320 static int
 321 el_start_xmit(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 322 {
 323     struct net_local *lp = (struct net_local *)dev->priv;
 324     int ioaddr = dev->base_addr;
 325     unsigned long flags;
 326 
 327     if (dev->tbusy) {
 328         if (jiffies - dev->trans_start < 20) {
 329             if (el_debug > 2)
 330                 printk(" transmitter busy, deferred.\n");
 331             return 1;
 332         }
 333         if (el_debug)
 334             printk ("%s: transmit timed out, txsr %#2x axsr=%02x rxsr=%02x.\n",
 335                     dev->name, inb(TX_STATUS), inb(AX_STATUS), inb(RX_STATUS));
 336         lp->stats.tx_errors++;
 337         outb(TX_NORM, TX_CMD);
 338         outb(RX_NORM, RX_CMD);
 339         outb(AX_OFF, AX_CMD);   /* Just trigger a false interrupt. */
 340         outb(AX_RX, AX_CMD);    /* Aux control, irq and receive enabled */
 341         dev->tbusy = 0;
 342         dev->trans_start = jiffies;
 343     }
 344 
 345     if (skb == NULL) {
 346         dev_tint(dev);
 347         return 0;
 348     }
 349 
 350     save_flags(flags);
 351     /* Avoid incoming interrupts between us flipping tbusy and flipping
 352        mode as the driver assumes tbusy is a faithful indicator of card
 353        state */
 354     cli();
 355     /* Avoid timer-based retransmission conflicts. */
 356     if (set_bit(0, (void*)&dev->tbusy) != 0)
 357     {
 358         restore_flags(flags);
 359         printk("%s: Transmitter access conflict.\n", dev->name);
 360     }
 361     else {
 362         int gp_start = 0x800 - (ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN);
 363         unsigned char *buf = skb->data;
 364 
 365         lp->tx_pkt_start = gp_start;
 366         lp->collisions = 0;
 367 
 368         /*
 369          *      Command mode with status cleared should [in theory]
 370          *      mean no more interrupts can be pending on the card.
 371          */
 372         outb(AX_SYS, AX_CMD);
 373         inb(RX_STATUS);
 374         inb(TX_STATUS);
 375         /* 
 376          *      Turn interrupts back on while we spend a pleasant afternoon
 377          *      loading bytes into the board 
 378          */
 379         restore_flags(flags);
 380         outw(0x00, RX_BUF_CLR);         /* Set rx packet area to 0. */
 381         outw(gp_start, GP_LOW);         /* aim - packet will be loaded into buffer start */
 382         outsb(DATAPORT,buf,skb->len);   /* load buffer (usual thing each byte increments the pointer) */
 383         outw(gp_start, GP_LOW);         /* the board reuses the same register */
 384         outb(AX_XMIT, AX_CMD);          /* fire ... Trigger xmit.  */
 385         dev->trans_start = jiffies;
 386     }
 387 
 388     if (el_debug > 2)
 389         printk(" queued xmit.\n");
 390     dev_kfree_skb (skb, FREE_WRITE);
 391     return 0;
 392 }
 393 
 394 
 395 /* The typical workload of the driver:
 396    Handle the ether interface interrupts. */
 397 static void
 398 el_interrupt(int reg_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 399 {
 400     int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
 401     struct device *dev = (struct device *)(irq2dev_map[irq]);
 402     struct net_local *lp;
 403     int ioaddr;
 404     int axsr;                   /* Aux. status reg. */
 405 
 406     if (dev == NULL  ||  dev->irq != irq) {
 407         printk ("3c501 driver: irq %d for unknown device.\n", irq);
 408         return;
 409     }
 410 
 411     ioaddr = dev->base_addr;
 412     lp = (struct net_local *)dev->priv;
 413     axsr = inb(AX_STATUS);
 414 
 415     if (el_debug > 3)
 416       printk("%s: el_interrupt() aux=%#02x", dev->name, axsr);
 417     if (dev->interrupt)
 418         printk("%s: Reentering the interrupt driver!\n", dev->name);
 419     dev->interrupt = 1;
 420 
 421     if (dev->tbusy) {
 422     
 423         /*
 424          *      Board in transmit mode.
 425          */
 426          
 427         int txsr = inb(TX_STATUS);
 428 
 429         if (el_debug > 6)
 430             printk(" txsr=%02x gp=%04x rp=%04x", txsr, inw(GP_LOW),
 431                    inw(RX_LOW));
 432 
 433         if ((axsr & 0x80) && (txsr & TX_READY) == 0) {
 434         /*
 435          *      FIXME: is there a logic to whether to keep on trying or
 436          *      reset immediately ?
 437          */
 438             printk("%s: Unusual interrupt during Tx, txsr=%02x axsr=%02x"
 439                    " gp=%03x rp=%03x.\n", dev->name, txsr, axsr,
 440                    inw(ioaddr + EL1_DATAPTR), inw(ioaddr + EL1_RXPTR));
 441             dev->tbusy = 0;
 442             mark_bh(NET_BH);
 443         } else if (txsr & TX_16COLLISIONS) {
 444         /*
 445          *      Timed out
 446          */
 447             if (el_debug)
 448                 printk("%s: Transmit failed 16 times, ethernet jammed?\n",
 449                        dev->name);
 450             outb(AX_SYS, AX_CMD);
 451             lp->stats.tx_aborted_errors++;
 452         } else if (txsr & TX_COLLISION) {       /* Retrigger xmit. */
 453             if (el_debug > 6)
 454                 printk(" retransmitting after a collision.\n");
 455         /*
 456          *      Poor little chip can't reset its own start pointer
 457          */
 458             outb(AX_SYS, AX_CMD);
 459             outw(lp->tx_pkt_start, GP_LOW);
 460             outb(AX_XMIT, AX_CMD);
 461             lp->stats.collisions++;
 462             dev->interrupt = 0;
 463             return;
 464         } else {
 465         /*
 466          *      It worked.. we will now fall through and receive
 467          */
 468             lp->stats.tx_packets++;
 469             if (el_debug > 6)
 470                 printk(" Tx succeeded %s\n",
 471                        (txsr & TX_RDY) ? "." : "but tx is busy!");
 472         /*
 473          *      This is safe the interrupt is atomic WRT itself.
 474          */
 475             dev->tbusy = 0;
 476             mark_bh(NET_BH);    /* In case more to transmit */
 477         }
 478     } else {
 479     
 480         /*
 481          *      In receive mode.
 482          */
 483          
 484         int rxsr = inb(RX_STATUS);
 485         if (el_debug > 5)
 486             printk(" rxsr=%02x txsr=%02x rp=%04x", rxsr, inb(TX_STATUS),
 487                    inw(RX_LOW));
 488 
 489         /*
 490          *      Just reading rx_status fixes most errors. 
 491          */
 492         if (rxsr & RX_MISSED)
 493             lp->stats.rx_missed_errors++;
 494         if (rxsr & RX_RUNT) {   /* Handled to avoid board lock-up. */
 495             lp->stats.rx_length_errors++;
 496             if (el_debug > 5) printk(" runt.\n");
 497         } else if (rxsr & RX_GOOD) {
 498         /*
 499          *      Receive worked.
 500          */
 501             el_receive(dev);
 502         } else {                        /* Nothing?  Something is broken! */
 503             if (el_debug > 2)
 504                 printk("%s: No packet seen, rxsr=%02x **resetting 3c501***\n",
 505                        dev->name, rxsr);
 506             el_reset(dev);
 507         }
 508         if (el_debug > 3)
 509             printk(".\n");
 510     }
 511 
 512     /*
 513      *  Move into receive mode 
 514      */
 515     outb(AX_RX, AX_CMD);
 516     outw(0x00, RX_BUF_CLR);
 517     inb(RX_STATUS);             /* Be certain that interrupts are cleared. */
 518     inb(TX_STATUS);
 519     dev->interrupt = 0;
 520     return;
 521 }
 522 
 523 
 524 /* We have a good packet. Well, not really "good", just mostly not broken.
 525    We must check everything to see if it is good. */
 526 static void
 527 el_receive(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 528 {
 529     struct net_local *lp = (struct net_local *)dev->priv;
 530     int ioaddr = dev->base_addr;
 531     int pkt_len;
 532     struct sk_buff *skb;
 533 
 534     pkt_len = inw(RX_LOW);
 535 
 536     if (el_debug > 4)
 537       printk(" el_receive %d.\n", pkt_len);
 538 
 539     if ((pkt_len < 60)  ||  (pkt_len > 1536)) {
 540         if (el_debug)
 541           printk("%s: bogus packet, length=%d\n", dev->name, pkt_len);
 542         lp->stats.rx_over_errors++;
 543         return;
 544     }
 545     
 546     /*
 547      *  Command mode so we can empty the buffer
 548      */
 549      
 550     outb(AX_SYS, AX_CMD);
 551 
 552     skb = alloc_skb(pkt_len, GFP_ATOMIC);
 553     /*
 554      *  Start of frame
 555      */
 556     outw(0x00, GP_LOW);
 557     if (skb == NULL) {
 558         printk("%s: Memory squeeze, dropping packet.\n", dev->name);
 559         lp->stats.rx_dropped++;
 560         return;
 561     } else {
 562         skb->len = pkt_len;
 563         skb->dev = dev;
 564 
 565         /*
 566          *      The read incrememts through the bytes. The interrupt
 567          *      handler will fix the pointer when it returns to 
 568          *      receive mode.
 569          */
 570          
 571         insb(DATAPORT, skb->data, pkt_len);
 572 
 573         netif_rx(skb);
 574         lp->stats.rx_packets++;
 575     }
 576     return;
 577 }
 578 
 579 static void 
 580 el_reset(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 581 {
 582     int ioaddr = dev->base_addr;
 583 
 584     if (el_debug> 2)
 585         printk("3c501 reset...");
 586     outb(AX_RESET, AX_CMD);     /* Reset the chip */
 587     outb(AX_LOOP, AX_CMD);      /* Aux control, irq and loopback enabled */
 588     {
 589         int i;
 590         for (i = 0; i < 6; i++) /* Set the station address. */
 591             outb(dev->dev_addr[i], ioaddr + i);
 592     }
 593     
 594     outw(0, RX_BUF_CLR);                /* Set rx packet area to 0. */
 595     cli();                      /* Avoid glitch on writes to CMD regs */
 596     outb(TX_NORM, TX_CMD);              /* tx irq on done, collision */
 597     outb(RX_NORM, RX_CMD);      /* Set Rx commands. */
 598     inb(RX_STATUS);             /* Clear status. */
 599     inb(TX_STATUS);
 600     dev->interrupt = 0;
 601     dev->tbusy = 0;
 602     sti();
 603 }
 604 
 605 static int
 606 el1_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 607 {
 608     int ioaddr = dev->base_addr;
 609 
 610     if (el_debug > 2)
 611         printk("%s: Shutting down ethercard at %#x.\n", dev->name, ioaddr);
 612 
 613     dev->tbusy = 1;
 614     dev->start = 0;
 615 
 616     /* Free and disable the IRQ. */
 617     free_irq(dev->irq);
 618     outb(AX_RESET, AX_CMD);     /* Reset the chip */
 619     irq2dev_map[dev->irq] = 0;
 620 
 621 #ifdef MODULE
 622     MOD_DEC_USE_COUNT;
 623 #endif    
 624     return 0;
 625 }
 626 
 627 static struct enet_statistics *
 628 el1_get_stats(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 629 {
 630     struct net_local *lp = (struct net_local *)dev->priv;
 631     return &lp->stats;
 632 }
 633 
 634 /* Set or clear the multicast filter for this adaptor.
 635    num_addrs == -1      Promiscuous mode, receive all packets
 636    num_addrs == 0       Normal mode, clear multicast list
 637    num_addrs > 0        Multicast mode, receive normal and MC packets, and do
 638                         best-effort filtering.
 639  */
 640 static void
 641 set_multicast_list(struct device *dev, int num_addrs, void *addrs)
     /* [previous][next][first][last][top][bottom][index][help] */
 642 {
 643     int ioaddr = dev->base_addr;
 644 
 645     if (num_addrs > 0) {
 646         outb(RX_MULT, RX_CMD);
 647         inb(RX_STATUS);         /* Clear status. */
 648     } else if (num_addrs < 0) {
 649         outb(RX_PROM, RX_CMD);
 650         inb(RX_STATUS);
 651     } else {
 652         outb(RX_NORM, RX_CMD);
 653         inb(RX_STATUS);
 654     }
 655 }
 656 #ifdef MODULE
 657 char kernel_version[] = UTS_RELEASE;
 658 static struct device dev_3c501 = {
 659         "        " /*"3c501"*/, 
 660                 0, 0, 0, 0,
 661                 0x280, 5,
 662                 0, 0, 0, NULL, el1_probe };
 663 
 664 int io=0x280;
 665 int irq=5;
 666         
 667 int
 668 init_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 669 {
 670         dev_3c501.irq=irq;
 671         dev_3c501.base_addr=io;
 672         if (register_netdev(&dev_3c501) != 0)
 673                 return -EIO;
 674         return 0;
 675 }
 676 
 677 void
 678 cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 679 {
 680         if (MOD_IN_USE)
 681                 printk("3c501: device busy, remove delayed\n");
 682         else
 683         {
 684                 unregister_netdev(&dev_3c501);
 685         }
 686 }
 687 #endif /* MODULE */
 688 
 689 /*
 690  * Local variables:
 691  *  compile-command: "gcc -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer  -m486 -c -o 3c501.o 3c501.c"
 692  *  kept-new-versions: 5
 693  * End:
 694  */

/* [previous][next][first][last][top][bottom][index][help] */