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

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