root/drivers/net/at1700.c

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

DEFINITIONS

This source file includes following definitions.
  1. at1700_probe
  2. at1700_probe1
  3. read_eeprom
  4. net_open
  5. net_send_packet
  6. net_interrupt
  7. net_rx
  8. net_close
  9. net_get_stats
  10. set_multicast_list

   1 /* at1700.c: A network device driver for  the Allied Telesis AT1700.
   2 
   3    Written 1993 by Donald Becker.  This is a alpha test limited release.
   4    This version may only be used and distributed according to the terms of the
   5    GNU Public License, incorporated herein by reference.
   6 
   7    The author may be reached as becker@super.org or
   8    C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715
   9 
  10    This is a device driver for the Allied Telesis AT1700, which is a
  11    straightforward Fujitsu MB86965 implementation.
  12 */
  13 
  14 static char *version =
  15         "at1700.c:v0.06 3/3/94  Donald Becker (becker@super.org)\n";
  16 
  17 #include <linux/config.h>
  18 
  19 /*
  20   Sources:
  21     The Fujitsu MB86695 datasheet.
  22 
  23         After this driver was written, ATI provided their EEPROM configuration
  24         code header file.  Thanks to Gerry Sockins of ATI.
  25 */
  26 
  27 #include <linux/kernel.h>
  28 #include <linux/sched.h>
  29 #include <linux/types.h>
  30 #include <linux/fcntl.h>
  31 #include <linux/interrupt.h>
  32 #include <linux/ptrace.h>
  33 #include <linux/ioport.h>
  34 #include <linux/in.h>
  35 #include <linux/malloc.h>
  36 #include <linux/string.h>
  37 #include <asm/system.h>
  38 #include <asm/bitops.h>
  39 #include <asm/io.h>
  40 #include <asm/dma.h>
  41 #include <errno.h>
  42 
  43 #include <linux/netdevice.h>
  44 #include <linux/etherdevice.h>
  45 #include <linux/skbuff.h>
  46 
  47 #ifndef HAVE_AUTOIRQ
  48 /* From auto_irq.c, in ioport.h for later versions. */
  49 extern void autoirq_setup(int waittime);
  50 extern int autoirq_report(int waittime);
  51 /* The map from IRQ number (as passed to the interrupt handler) to
  52    'struct device'. */
  53 extern struct device *irq2dev_map[16];
  54 #endif
  55 
  56 /* use 0 for production, 1 for verification, >2 for debug */
  57 #ifndef NET_DEBUG
  58 #define NET_DEBUG 2
  59 #endif
  60 static unsigned int net_debug = NET_DEBUG;
  61 
  62 typedef unsigned char uchar;
  63 
  64 /* Information that need to be kept for each board. */
  65 struct net_local {
  66         struct enet_statistics stats;
  67         long open_time;                         /* Useless example local info. */
  68         uint tx_started:1;                      /* Number of packet on the Tx queue. */
  69         uchar tx_queue;                         /* Number of packet on the Tx queue. */
  70         ushort tx_queue_len;            /* Current length of the Tx queue. */
  71 };
  72 
  73 
  74 /* Offsets from the base address. */
  75 #define STATUS                  0
  76 #define TX_STATUS               0
  77 #define RX_STATUS               1
  78 #define TX_INTR                 2               /* Bit-mapped interrupt enable registers. */
  79 #define RX_INTR                 3
  80 #define TX_MODE                 4
  81 #define RX_MODE                 5
  82 #define CONFIG_0                6               /* Misc. configuration settings. */
  83 #define CONFIG_1                7
  84 /* Run-time register bank 2 definitions. */
  85 #define DATAPORT                8               /* Word-wide DMA or programmed-I/O dataport. */
  86 #define TX_START                10
  87 #define MODE13                  13
  88 #define EEPROM_Ctrl     16
  89 #define EEPROM_Data     17
  90 
  91 /*  EEPROM_Ctrl bits. */
  92 #define EE_SHIFT_CLK    0x40    /* EEPROM shift clock, in reg. 16. */
  93 #define EE_CS                   0x20    /* EEPROM chip select, in reg. 16. */
  94 #define EE_DATA_WRITE   0x80    /* EEPROM chip data in, in reg. 17. */
  95 #define EE_DATA_READ    0x80    /* EEPROM chip data out, in reg. 17. */
  96 
  97 /* Delay between EEPROM clock transitions. */
  98 #define eeprom_delay()  do { int _i = 40; while (--_i > 0) { __SLOW_DOWN_IO; }} while (0)
  99 
 100 /* The EEPROM commands include the alway-set leading bit. */
 101 #define EE_WRITE_CMD    (5 << 6)
 102 #define EE_READ_CMD             (6 << 6)
 103 #define EE_ERASE_CMD    (7 << 6)
 104 
 105 
 106 /* Index to functions, as function prototypes. */
 107 
 108 extern int at1700_probe(struct device *dev);
 109 
 110 static int at1700_probe1(struct device *dev, short ioaddr);
 111 static int read_eeprom(int ioaddr, int location);
 112 static int net_open(struct device *dev);
 113 static int      net_send_packet(struct sk_buff *skb, struct device *dev);
 114 static void net_interrupt(int reg_ptr);
 115 static void net_rx(struct device *dev);
 116 static int net_close(struct device *dev);
 117 static struct enet_statistics *net_get_stats(struct device *dev);
 118 static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
 119 
 120 
 121 /* Check for a network adaptor of this type, and return '0' iff one exists.
 122    If dev->base_addr == 0, probe all likely locations.
 123    If dev->base_addr == 1, always return failure.
 124    If dev->base_addr == 2, allocate space for the device and return success
 125    (detachable devices only).
 126    */
 127 int
 128 at1700_probe(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 129 {
 130         short ports[] = {0x300, 0x280, 0x380, 0x320, 0x340, 0x260, 0x2a0, 0x240, 0};
 131         short *port, base_addr = dev->base_addr;
 132 
 133         if (base_addr > 0x1ff)          /* Check a single specified location. */
 134                 return at1700_probe1(dev, base_addr);
 135         else if (base_addr > 0)         /* Don't probe at all. */
 136                 return ENXIO;
 137 
 138         for (port = &ports[0]; *port; port++) {
 139                 int ioaddr = *port;
 140                 if (check_region(ioaddr, 32))
 141                         continue;
 142                 if (at1700_probe1(dev, ioaddr) == 0)
 143                         return 0;
 144         }
 145 
 146         return ENODEV;
 147 }
 148 
 149 /* The Fujitsu datasheet suggests that the NIC be probed for by checking its
 150    "signature", the default bit pattern after a reset.  This *doesn't* work --
 151    there is no way to reset the bus interface without a complete power-cycle!
 152 
 153    It turns out that ATI came to the same conclusion I did: the only thing
 154    that can be done is checking a few bits and then diving right into an
 155    EEPROM read. */
 156 
 157 int at1700_probe1(struct device *dev, short ioaddr)
     /* [previous][next][first][last][top][bottom][index][help] */
 158 {
 159         unsigned short signature[4]         = {0xffff, 0xffff, 0x7ff7, 0xff5f};
 160         unsigned short signature_invalid[4] = {0xffff, 0xffff, 0x7ff7, 0xdf0f};
 161         char irqmap[8] = {3, 4, 5, 9, 10, 11, 14, 15};
 162         unsigned short *station_address = (unsigned short *)dev->dev_addr;
 163         unsigned int i, irq;
 164 
 165         /* Resetting the chip doesn't reset the ISA interface, so don't bother.
 166            That means we have to be careful with the register values we probe for.
 167            */
 168         for (i = 0; i < 4; i++)
 169                 if ((inw(ioaddr + 2*i) | signature_invalid[i]) != signature[i]) {
 170                         if (net_debug > 2)
 171                                 printk("AT1700 signature match failed at %d (%04x vs. %04x)\n",
 172                                            i, inw(ioaddr + 2*i), signature[i]);
 173                         return -ENODEV;
 174                 }
 175         if (read_eeprom(ioaddr, 4) != 0x0000
 176                 || read_eeprom(ioaddr, 5) & 0x00ff != 0x00F4)
 177                 return -ENODEV;
 178 
 179         /* Grab the region so that we can find another board if the IRQ request
 180            fails. */
 181         snarf_region(ioaddr, 32);
 182 
 183         irq = irqmap[(read_eeprom(ioaddr, 12)&0x04)
 184                                  | (read_eeprom(ioaddr, 0)>>14)];
 185 
 186         /* Snarf the interrupt vector now. */
 187         if (request_irq(irq, &net_interrupt, 0, "at1700")) {
 188                 printk ("AT1700 found at %#3x, but it's unusable due to a conflict on"
 189                                 "IRQ %d.\n", ioaddr, irq);
 190                 return EAGAIN;
 191         }
 192 
 193         printk("%s: AT1700 found at %#3x, IRQ %d, address ", dev->name,
 194                    ioaddr, irq);
 195 
 196         dev->base_addr = ioaddr;
 197         dev->irq = irq;
 198         irq2dev_map[irq] = dev;
 199 
 200         for(i = 0; i < 3; i++) {
 201                 unsigned short eeprom_val = read_eeprom(ioaddr, 4+i);
 202                 printk("%04x", eeprom_val);
 203                 station_address[i] = ntohs(eeprom_val);
 204         }
 205 
 206         /* The EEPROM word 12 bit 0x0400 means use regular 100 ohm 10baseT signals,
 207            rather than 150 ohm shielded twisted pair compensation.
 208            0x0000 == auto-sense the interface
 209            0x0800 == use TP interface
 210            0x1800 == use coax interface
 211            */
 212         {
 213                 char *porttype[] = {"auto-sense", "10baseT", "auto-sense", "10base2"};
 214                 ushort setup_value = read_eeprom(ioaddr, 12);
 215 
 216                 dev->if_port = setup_value >> 8;
 217                 printk(" %s interface (%04x).\n", porttype[(dev->if_port>>3) & 3],
 218                            setup_value);
 219         }
 220 
 221         /* Set the station address in bank zero. */
 222         outb(0xe0, ioaddr + 7);
 223         for (i = 0; i < 6; i++)
 224                 outb(dev->dev_addr[i], ioaddr + 8 + i);
 225 
 226         /* Switch to bank 1 and set the multicast table to accept none. */
 227         outb(0xe4, ioaddr + 7);
 228         for (i = 0; i < 8; i++)
 229                 outb(0x00, ioaddr + 8 + i);
 230 
 231         /* Set the configuration register 0 to 32K 100ns. byte-wide memory, 16 bit
 232            bus access, two 4K Tx queues, and disabled Tx and Rx. */
 233         outb(0xda, ioaddr + CONFIG_0);
 234 
 235         /* Switch to bank 2 and lock our I/O address. */
 236         outb(0xe8, ioaddr + 7);
 237         outb(dev->if_port, MODE13);
 238 
 239         /* Power-down the chip.  Aren't we green! */
 240         outb(0x00, ioaddr + CONFIG_1);
 241 
 242         if (net_debug)
 243                 printk(version);
 244 
 245         /* Initialize the device structure. */
 246         dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
 247         memset(dev->priv, 0, sizeof(struct net_local));
 248 
 249         dev->open               = net_open;
 250         dev->stop               = net_close;
 251         dev->hard_start_xmit = net_send_packet;
 252         dev->get_stats  = net_get_stats;
 253         dev->set_multicast_list = &set_multicast_list;
 254 
 255         /* Fill in the fields of the device structure with ethernet-generic values. */
 256            
 257         ether_setup(dev);
 258         return 0;
 259 }
 260 
 261 static int read_eeprom(int ioaddr, int location)
     /* [previous][next][first][last][top][bottom][index][help] */
 262 {
 263         int i;
 264         unsigned short retval = 0;
 265         short ee_addr = ioaddr + EEPROM_Ctrl;
 266         short ee_daddr = ioaddr + EEPROM_Data;
 267         int read_cmd = location | EE_READ_CMD;
 268         short ctrl_val = EE_CS;
 269         
 270         outb(ctrl_val, ee_addr);
 271         
 272         /* Shift the read command bits out. */
 273         for (i = 9; i >= 0; i--) {
 274                 short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
 275                 outb(dataval, ee_daddr);
 276                 outb(EE_CS | EE_SHIFT_CLK, ee_addr);    /* EEPROM clock tick. */
 277                 eeprom_delay();
 278                 outb(EE_CS, ee_addr);   /* Finish EEPROM a clock tick. */
 279                 eeprom_delay();
 280         }
 281         outb(EE_CS, ee_addr);
 282         
 283         for (i = 16; i > 0; i--) {
 284                 outb(EE_CS | EE_SHIFT_CLK, ee_addr);
 285                 eeprom_delay();
 286                 retval = (retval << 1) | ((inb(ee_daddr) & EE_DATA_READ) ? 1 : 0);
 287                 outb(EE_CS, ee_addr);
 288                 eeprom_delay();
 289         }
 290 
 291         /* Terminate the EEPROM access. */
 292         ctrl_val &= ~EE_CS;
 293         outb(ctrl_val | EE_SHIFT_CLK, ee_addr);
 294         eeprom_delay();
 295         outb(ctrl_val, ee_addr);
 296         eeprom_delay();
 297         return retval;
 298 }
 299 
 300 
 301 
 302 static int net_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 303 {
 304         struct net_local *lp = (struct net_local *)dev->priv;
 305         int ioaddr = dev->base_addr;
 306         int i;
 307 
 308         /* Powerup the chip, initialize config register 1, and select bank 0. */
 309         outb(0xe0, ioaddr + CONFIG_1);
 310 
 311         /* Set the station address in bank zero. */
 312         for (i = 0; i < 6; i++)
 313                 outb(dev->dev_addr[i], ioaddr + 8 + i);
 314 
 315         /* Switch to bank 1 and set the multicast table to accept none. */
 316         outb(0xe4, ioaddr + 7);
 317         for (i = 0; i < 8; i++)
 318                 outb(0x00, ioaddr + 8 + i);
 319 
 320         /* Set the configuration register 0 to 32K 100ns. byte-wide memory, 16 bit
 321            bus access, and two 4K Tx queues. */
 322         outb(0xda, ioaddr + CONFIG_0);
 323 
 324         /* Same config 0, except enable the Rx and Tx. */
 325         outb(0x5a, ioaddr + CONFIG_0);
 326         /* Switch to register bank 2 for the run-time registers. */
 327         outb(0xe8, ioaddr + CONFIG_1);
 328 
 329         /* Turn on Rx interrupts, leave Tx interrupts off until packet Tx. */
 330         outb(0x00, ioaddr + TX_INTR);
 331         outb(0x81, ioaddr + RX_INTR);
 332 
 333         lp->open_time = jiffies;
 334 
 335         dev->tbusy = 0;
 336         dev->interrupt = 0;
 337         dev->start = 1;
 338 
 339         return 0;
 340 }
 341 
 342 static int
 343 net_send_packet(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 344 {
 345         struct net_local *lp = (struct net_local *)dev->priv;
 346         int ioaddr = dev->base_addr;
 347 
 348         if (dev->tbusy) {
 349                 /* If we get here, some higher level has decided we are broken.
 350                    There should really be a "kick me" function call instead. */
 351                 int tickssofar = jiffies - dev->trans_start;
 352                 if (tickssofar < 10)
 353                         return 1;
 354                 printk("%s: transmit timed out with status %04x, %s?\n", dev->name,
 355                            inw(ioaddr + STATUS), inb(ioaddr + TX_STATUS) & 0x80
 356                            ? "IRQ conflict" : "network cable problem");
 357                 printk("%s: timeout registers: %04x %04x %04x %04x %04x %04x %04x %04x.\n",
 358                            dev->name, inw(ioaddr + 0), inw(ioaddr + 2), inw(ioaddr + 4),
 359                            inw(ioaddr + 6), inw(ioaddr + 8), inw(ioaddr + 10),
 360                            inw(ioaddr + 12), inw(ioaddr + 14));
 361                 lp->stats.tx_errors++;
 362                 /* ToDo: We should try to restart the adaptor... */
 363                 outw(0xffff, ioaddr + 24);
 364                 outw(0xffff, ioaddr + TX_STATUS);
 365                 outw(0xe85a, ioaddr + CONFIG_0);
 366                 outw(0x8100, ioaddr + TX_INTR);
 367                 dev->tbusy=0;
 368                 dev->trans_start = jiffies;
 369         }
 370 
 371         /* If some higher layer thinks we've missed an tx-done interrupt
 372            we are passed NULL. Caution: dev_tint() handles the cli()/sti()
 373            itself. */
 374         if (skb == NULL) {
 375                 dev_tint(dev);
 376                 return 0;
 377         }
 378 
 379         /* Block a timer-based transmit from overlapping.  This could better be
 380            done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
 381         if (set_bit(0, (void*)&dev->tbusy) != 0)
 382                 printk("%s: Transmitter access conflict.\n", dev->name);
 383         else {
 384                 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
 385                 unsigned char *buf = skb->data;
 386 
 387                 /* Turn off the possible Tx interrupts. */
 388                 outb(0x00, ioaddr + TX_INTR);
 389                 
 390                 outw(length, ioaddr + DATAPORT);
 391                 outsw(ioaddr + DATAPORT, buf, (length + 1) >> 1);
 392 
 393                 lp->tx_queue++;
 394                 lp->tx_queue_len += length + 2;
 395 
 396                 if (lp->tx_started == 0) {
 397                         /* If the Tx is idle, always trigger a transmit. */
 398                         outb(0x80 | lp->tx_queue, ioaddr + TX_START);
 399                         lp->tx_queue = 0;
 400                         lp->tx_queue_len = 0;
 401                         dev->trans_start = jiffies;
 402                         lp->tx_started = 1;
 403                 } else if (lp->tx_queue_len < 4096 - 1502)      /* Room for one more packet? */
 404                         dev->tbusy = 0;
 405 
 406                 /* Turn on Tx interrupts back on. */
 407                 outb(0x82, ioaddr + TX_INTR);
 408         }
 409         dev_kfree_skb (skb, FREE_WRITE);
 410 
 411         return 0;
 412 }
 413 
 414 /* The typical workload of the driver:
 415    Handle the network interface interrupts. */
 416 static void
 417 net_interrupt(int reg_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 418 {
 419         int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
 420         struct device *dev = (struct device *)(irq2dev_map[irq]);
 421         struct net_local *lp;
 422         int ioaddr, status;
 423 
 424         if (dev == NULL) {
 425                 printk ("at1700_interrupt(): irq %d for unknown device.\n", irq);
 426                 return;
 427         }
 428         dev->interrupt = 1;
 429 
 430         ioaddr = dev->base_addr;
 431         lp = (struct net_local *)dev->priv;
 432         status = inw(ioaddr + TX_STATUS);
 433         outw(status, ioaddr + TX_STATUS);
 434 
 435         if (net_debug > 4)
 436                 printk("%s: Interrupt with status %04x.\n", dev->name, status);
 437         if (status & 0xff00
 438                 ||  (inb(ioaddr + RX_MODE) & 0x40) == 0) {                      /* Got a packet(s). */
 439                 net_rx(dev);
 440         }
 441         if (status & 0x00ff) {
 442                 if (status & 0x80) {
 443                         lp->stats.tx_packets++;
 444                         if (lp->tx_queue) {
 445                                 outb(0x80 | lp->tx_queue, ioaddr + TX_START);
 446                                 lp->tx_queue = 0;
 447                                 lp->tx_queue_len = 0;
 448                                 dev->trans_start = jiffies;
 449                                 dev->tbusy = 0;
 450                                 mark_bh(NET_BH);        /* Inform upper layers. */
 451                         } else {
 452                                 lp->tx_started = 0;
 453                                 /* Turn on Tx interrupts off. */
 454                                 outb(0x00, ioaddr + TX_INTR);
 455                                 dev->tbusy = 0;
 456                         }
 457                 }
 458         }
 459 
 460         return;
 461 }
 462 
 463 /* We have a good packet(s), get it/them out of the buffers. */
 464 static void
 465 net_rx(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 466 {
 467         struct net_local *lp = (struct net_local *)dev->priv;
 468         int ioaddr = dev->base_addr;
 469         int boguscount = 5;
 470 
 471         while ((inb(ioaddr + RX_MODE) & 0x40) == 0) {
 472                 ushort status = inw(ioaddr + DATAPORT);
 473 
 474                 if (net_debug > 4)
 475                         printk("%s: Rxing packet mode %02x status %04x.\n",
 476                                    dev->name, inb(ioaddr + RX_MODE), status);
 477 #ifndef final_version
 478                 if (status == 0) {
 479                         outb(0x05, ioaddr + 14);
 480                         break;
 481                 }
 482 #endif
 483 
 484                 if ((status & 0xF0) != 0x20) {  /* There was an error. */
 485                         lp->stats.rx_errors++;
 486                         if (status & 0x08) lp->stats.rx_length_errors++;
 487                         if (status & 0x04) lp->stats.rx_frame_errors++;
 488                         if (status & 0x02) lp->stats.rx_crc_errors++;
 489                         if (status & 0x01) lp->stats.rx_over_errors++;
 490                 } else {
 491                         ushort pkt_len = inw(ioaddr + DATAPORT);
 492                         /* Malloc up new buffer. */
 493                         struct sk_buff *skb;
 494 
 495                         if (pkt_len > 1550) {
 496                                 printk("%s: The AT1700 claimed a very large packet, size %d.\n",
 497                                            dev->name, pkt_len);
 498                                 outb(0x05, ioaddr + 14);
 499                                 lp->stats.rx_errors++;
 500                                 break;
 501                         }
 502                         skb = alloc_skb(pkt_len, GFP_ATOMIC);
 503                         if (skb == NULL) {
 504                                 printk("%s: Memory squeeze, dropping packet (len %d).\n",
 505                                            dev->name, pkt_len);
 506                                 outb(0x05, ioaddr + 14);
 507                                 lp->stats.rx_dropped++;
 508                                 break;
 509                         }
 510                         skb->len = pkt_len;
 511                         skb->dev = dev;
 512 
 513                         insw(ioaddr + DATAPORT, skb->data, (pkt_len + 1) >> 1);
 514 
 515                         if (net_debug > 5) {
 516                                 int i;
 517                                 printk("%s: Rxed packet of length %d: ", dev->name, pkt_len);
 518                                 for (i = 0; i < 14; i++)
 519                                         printk(" %02x", skb->data[i]);
 520                                 printk(".\n");
 521                         }
 522 
 523                         netif_rx(skb);
 524                         lp->stats.rx_packets++;
 525                 }
 526                 if (--boguscount <= 0)
 527                         break;
 528         }
 529 
 530         /* If any worth-while packets have been received, dev_rint()
 531            has done a mark_bh(NET_BH) for us and will work on them
 532            when we get to the bottom-half routine. */
 533         {
 534                 int i;
 535                 for (i = 0; i < 20; i++) {
 536                         if ((inb(ioaddr + RX_MODE) & 0x40) == 0x40)
 537                                 break;
 538                         outb(0x05, ioaddr + 14);
 539                 }
 540 
 541                 if (net_debug > 5)
 542                         printk("%s: Exint Rx packet with mode %02x after %d ticks.\n", 
 543                                    dev->name, inb(ioaddr + RX_MODE), i);
 544         }
 545         return;
 546 }
 547 
 548 /* The inverse routine to net_open(). */
 549 static int net_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 550 {
 551         struct net_local *lp = (struct net_local *)dev->priv;
 552         int ioaddr = dev->base_addr;
 553 
 554         lp->open_time = 0;
 555 
 556         dev->tbusy = 1;
 557         dev->start = 0;
 558 
 559         /* Set configuration register 0 to disable Tx and Rx. */
 560         outb(0xda, ioaddr + CONFIG_0);
 561 
 562         /* Update the statistics -- ToDo. */
 563 
 564         /* Power-down the chip.  Green, green, green! */
 565         outb(0x00, ioaddr + CONFIG_1);
 566 
 567         return 0;
 568 }
 569 
 570 /* Get the current statistics.  This may be called with the card open or
 571    closed. */
 572 static struct enet_statistics *
 573 net_get_stats(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 574 {
 575         struct net_local *lp = (struct net_local *)dev->priv;
 576 
 577         cli();
 578         /* ToDo: Update the statistics from the device registers. */
 579         sti();
 580 
 581         return &lp->stats;
 582 }
 583 
 584 /* Set or clear the multicast filter for this adaptor.
 585    num_addrs == -1      Promiscuous mode, receive all packets
 586    num_addrs == 0       Normal mode, clear multicast list
 587    num_addrs > 0        Multicast mode, receive normal and MC packets, and do
 588                         best-effort filtering.
 589  */
 590 static void
 591 set_multicast_list(struct device *dev, int num_addrs, void *addrs)
     /* [previous][next][first][last][top][bottom][index][help] */
 592 {
 593         short ioaddr = dev->base_addr;
 594         if (num_addrs) {
 595                 outw(3, ioaddr + RX_MODE);      /* Enable promiscuous mode */
 596         } else
 597                 outw(2, ioaddr + RX_MODE);      /* Disable promiscuous, use normal mode */
 598 }
 599 
 600 /*
 601  * Local variables:
 602  *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c at1700.c"
 603  *  version-control: t
 604  *  kept-new-versions: 5
 605  *  tab-width: 4
 606  * End:
 607  */

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