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

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