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

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