]> git.neil.brown.name Git - history.git/commitdiff
Linux 2.2.15pre13 2.2.15pre13
authorAlan Cox <alan@lxorguk.ukuu.org.uk>
Fri, 23 Nov 2007 20:21:00 +0000 (15:21 -0500)
committerAlan Cox <alan@lxorguk.ukuu.org.uk>
Fri, 23 Nov 2007 20:21:00 +0000 (15:21 -0500)
o Revert some of the MM changes and drop in the
more proven trashing heuristic code and bits (Andrea Arcangeli)
o Always probe all luns on AMI MegaRAID (Doug Ledford)
o IBM lanstreamer driver merged (Mike Sullivan)
\ cleaned up (tho I hope not broken) by Alan Cox
[Please check]
o COMX update, remove experimental (Gergely Madarasz)
o Fix a region release bug in the eepro100 (Andrey Savochkin)
o Add write ordering to ppc *bit functions (Paul Mackerras)
on SMP boxen
o Fix timer irq bug on ultrasparc (Dave Miller)
o Further sparc dcache page flush fixes (Dave Miller)
o Bring 3ware driver up to 1.0 (Adam Radford)
o List 2.2.x pre-patch locations in MAINTAINERS (David Forrest)
o UMSDOS update (Matija Nalis)
o Support SRM on nautilus Alpha (Soohoon Lee)
o Fix maintainers - Scott Murray has moved (Scott Murray)
o EV4 emulation trap fix (Carsten Jacobi)
o Alter the TLB IPI spin timeout for faster chips (based on the Reiserfs
 hack)

50 files changed:
Documentation/Configure.help
Documentation/sound/ALS [new file with mode: 0644]
Documentation/sound/ALS007 [deleted file]
MAINTAINERS
Makefile
arch/alpha/config.in
arch/alpha/kernel/sys_nautilus.c
arch/alpha/kernel/traps.c
arch/i386/kernel/smp.c
arch/i386/mm/fault.c
arch/ppc/kernel/bitops.c
arch/ppc/kernel/misc.S
arch/sparc64/kernel/irq.c
arch/sparc64/kernel/smp.c
arch/sparc64/kernel/time.c
drivers/char/mixcomwd.c
drivers/i2o/i2o_config.c
drivers/net/Config.in
drivers/net/Space.c
drivers/net/comx-hw-comx.c
drivers/net/comx-hw-mixcom.c
drivers/net/comx-proto-ppp.c
drivers/net/comx.c
drivers/net/comxhw.h
drivers/net/eepro100.c
drivers/net/lance.c
drivers/net/lanstreamer.c [new file with mode: 0644]
drivers/net/lanstreamer.h [new file with mode: 0644]
drivers/net/syncppp.c
drivers/scsi/3w-xxxx.c
drivers/scsi/Config.in
drivers/scsi/scsi.c
fs/dquot.c
fs/umsdos/README-WIP.txt
fs/umsdos/check.c
fs/umsdos/dir.c
fs/umsdos/emd.c
fs/umsdos/inode.c
fs/umsdos/namei.c
fs/umsdos/rdir.c
include/asm-ppc/atomic.h
include/asm-ppc/bitops.h
include/linux/mm.h
include/linux/sched.h
kernel/ksyms.c
mm/Makefile
mm/filemap.c
mm/oom_kill.c [deleted file]
mm/page_alloc.c
mm/vmscan.c

index b97393c82de00b2a64e913a6d199b3fbbf392ae0..2d60f93179bbf4477ca2ff3cefadf26c4d792c86 100644 (file)
@@ -6767,6 +6767,19 @@ CONFIG_IBMOL
   Linux Token Ring Project site for the latest information at
   http://www.linuxtr.net
 
+IBM Lanstreamer chipset PCI adapter support
+CONFIG_IBMLS
+  This is support for IBM Lanstreamer PCI Token Ring Cards.
+
+  If you have such an adapter, say Y and read the Token-Ring mini-HOWTO
+  available via FTP (user:anonymous) from
+  ftp://metalab.unc/edu/pub/Linux/docs/HOWTO.
+
+  This driver is also available as a modules ( = code which can be
+  inserted in and removed from the running kernel whenever you want).
+  The modules will be called lanstreamer.o. If you want to compile it as
+  a module, say M here and read Documentation/modules.txt.
+
 SysKonnect adapter support
 CONFIG_SKTR
   This is support for all SysKonnect Token Ring cards, specifically
diff --git a/Documentation/sound/ALS b/Documentation/sound/ALS
new file mode 100644 (file)
index 0000000..db98daf
--- /dev/null
@@ -0,0 +1,43 @@
+ALS-007/ALS-100/ALS-200 based sound cards
+=========================================
+
+Support for sound cards based around the Avance Logic
+ALS-007/ALS-100/ALS-200 chip is included.  These chips are a single
+chip PnP sound solution which is mostly hardware compatible with the
+Sound Blaster 16 card, with most differences occurring in the use of
+the mixer registers.  For this reason the ALS code is integrated
+as part of the Sound Blaster 16 driver (adding only 800 bytes to the
+SB16 driver).
+
+To use an ALS sound card under Linux, enable the following options in the
+sound configuration section of the kernel config:
+  - 100% Sound Blaster compatibles (SB16/32/64, ESS, Jazz16) support
+  - FM synthesizer (YM3812/OPL-3) support 
+Since the ALS-007/100/200 is a PnP card, the sound driver probably should be
+compiled as a module, with the isapnptools used to wake up the sound card.
+Set the "I/O base for SB", "Sound Blaster IRQ" and "Sound Blaster DMA" (8 bit -
+either 0, 1 or 3) to the values used in your particular installation (they
+should match the values used to configure the card using isapnp).  The
+ALS-007 does NOT implement 16 bit DMA, so the "Sound Blaster 16 bit DMA"
+should be set to -1.  If you wish to use the external MPU-401 interface on
+the card, "MPU401 I/O base of SB16" and "SB MPU401 IRQ" should be set to
+the appropriate values for your installation.  (Note that the ALS-007
+requires a separate IRQ for the MPU-401, so don't specify -1 here).  (Note
+that the base port of the internal FM synth is fixed at 0x388 on the ALS007; 
+in any case the FM synth location cannot be set in the kernel configuration).
+
+The resulting sound driver will provide the following capabilities:
+  - 8 and 16 bit audio playback
+  - 8 and 16 bit audio recording
+  - Software selection of record source (line in, CD, FM, mic, master)
+  - Record and playback of midi data via the external MPU-401
+  - Playback of midi data using inbuilt FM synthesizer
+  - Control of the ALS-007 mixer via any OSS-compatible mixer programs. 
+    Controls available are Master (L&R), Line in (L&R), CD (L&R), 
+    DSP/PCM/audio out (L&R), FM (L&R) and Mic in (mono).
+
+Jonathan Woithe
+jwoithe@physics.adelaide.edu.au
+30 March 1998
+
+Modified 2000-02-26 by Dave Forrest, drf5n@virginia.edu to add ALS100/ALS200
diff --git a/Documentation/sound/ALS007 b/Documentation/sound/ALS007
deleted file mode 100644 (file)
index c62e241..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-ALS-007/ALS-100/ALS-200 based sound cards
-=========================
-
-Support for sound cards based around the Avance Logic
-ALS-007/ALS-100/ALS-200 chip is included.  These chips are a single
-chip PnP sound solution which is mostly hardware compatible with the
-Sound Blaster 16 card, with most differences occurring in the use of
-the mixer registers.  For this reason the ALS code is integrated
-as part of the Sound Blaster 16 driver (adding only 800 bytes to the
-SB16 driver).
-
-To use an ALS sound card under Linux, enable the following options in the
-sound configuration section of the kernel config:
-  - 100% Sound Blaster compatibles (SB16/32/64, ESS, Jazz16) support
-  - FM synthesizer (YM3812/OPL-3) support 
-Since the ALS-007/100/200 is a PnP card, the sound driver probably should be
-compiled as a module, with the isapnptools used to wake up the sound card.
-Set the "I/O base for SB", "Sound Blaster IRQ" and "Sound Blaster DMA" (8 bit -
-either 0, 1 or 3) to the values used in your particular installation (they
-should match the values used to configure the card using isapnp).  The
-ALS-007 does NOT implement 16 bit DMA, so the "Sound Blaster 16 bit DMA"
-should be set to -1.  If you wish to use the external MPU-401 interface on
-the card, "MPU401 I/O base of SB16" and "SB MPU401 IRQ" should be set to
-the appropriate values for your installation.  (Note that the ALS-007
-requires a separate IRQ for the MPU-401, so don't specify -1 here).  (Note
-that the base port of the internal FM synth is fixed at 0x388 on the ALS007; 
-in any case the FM synth location cannot be set in the kernel configuration).
-
-The resulting sound driver will provide the following capabilities:
-  - 8 and 16 bit audio playback
-  - 8 and 16 bit audio recording
-  - Software selection of record source (line in, CD, FM, mic, master)
-  - Record and playback of midi data via the external MPU-401
-  - Playback of midi data using inbuilt FM synthesizer
-  - Control of the ALS-007 mixer via any OSS-compatible mixer programs. 
-    Controls available are Master (L&R), Line in (L&R), CD (L&R), 
-    DSP/PCM/audio out (L&R), FM (L&R) and Mic in (mono).
-
-Jonathan Woithe
-jwoithe@physics.adelaide.edu.au
-30 March 1998
-
-Modified 2000-02-26 by Dave Forrest, drf5n@virginia.edu to add ALS100/ALS200
index cddb56077cd361cffc926377bc091556c25d5c5f..432622ff486109e991914811ae8c3a3ca938a68c 100644 (file)
@@ -304,6 +304,11 @@ M: mike@i-Connect.Net
 L:     linux-eata@i-connect.net, linux-scsi@vger.rutgers.edu
 S:     Maintained
 
+EEPRO100 NETWORK DRIVER
+P:     Andrey V. Savochkin
+M:     saw@saw.sw.com.sg
+S:     Maintained
+
 ETHEREXPRESS-16 NETWORK DRIVER
 P:     Philip Blundell
 M:     Philip.Blundell@pobox.com
@@ -469,6 +474,13 @@ M: jpr@f6fbb.org
 L:     linux-hams@vger.rutgers.edu
 S:     Maintained
 
+KERNEL  (2.2.XX TREE)
+P:      Alan Cox
+M:     Alan.Cox@linux.org
+L:      linux-kernel@vger.rutgers.edu
+W:      http://www.kernel.org/pub/linux/kernel/alan/
+S:      Maintained
+
 KERNEL AUTOMOUNTER (AUTOFS)
 P:     H. Peter Anvin
 M:     hpa@zytor.com
@@ -644,7 +656,7 @@ S:  Maintained
 
 OPL3-SA2, SA3, and SAx DRIVER
 P:     Scott Murray
-M:     scottm@interlog.com
+M:     scott@spiteful.org
 L:     linux-sound@vger.rutgers.edu
 S:     Maintained
 
index 9c70163c174e0b9816f02431eb8ed752300b1178..777f7d061b2e6552c61b2b7fe922a5038b0e7e09 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 2
 SUBLEVEL = 15
-EXTRAVERSION = pre11
+EXTRAVERSION = pre13
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 
index a229e6b4aeb98c1e4a9e398c47da04af8c73c894..fdfab4aef937bd2f80c56eb3feb41d8d4d737ba2 100644 (file)
@@ -157,7 +157,7 @@ if [ "$CONFIG_ALPHA_CABRIOLET" = "y" -o "$CONFIG_ALPHA_AVANTI" = "y" \
        -o "$CONFIG_ALPHA_NORITAKE" = "y" -o "$CONFIG_ALPHA_PC164" = "y" \
        -o "$CONFIG_ALPHA_LX164" = "y" -o "$CONFIG_ALPHA_SX164" = "y" \
        -o "$CONFIG_ALPHA_DP264" = "y" -o "$CONFIG_ALPHA_RAWHIDE" = "y" \
-       -o "$CONFIG_ALPHA_EIGER" = "y" ]
+       -o "$CONFIG_ALPHA_EIGER" = "y" -o "$CONFIG_ALPHA_NAUTILUS" = "y" ]
 then
   bool 'Use SRM as bootloader' CONFIG_ALPHA_SRM
   if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
index 9c7792f09b0d261b5de7aa4cfbb49630b420f831..95539f811416836817ea34cc8f1874471c7c6aac 100644 (file)
@@ -69,6 +69,11 @@ nautilus_init_irq(void)
 {
        STANDARD_INIT_IRQ_PROLOG;
 
+       if (alpha_using_srm) {
+               alpha_mv.device_interrupt = srm_device_interrupt;
+               alpha_mv.kill_arch = generic_kill_arch;
+       }
+
        enable_irq(2);                  /* enable cascade */
        disable_irq(8);
 }
@@ -111,7 +116,7 @@ nautilus_kill_arch (int mode, char *restart_cmd)
        case LINUX_REBOOT_CMD_RESTART:
                {
                        int v;
-                       irongate_hose_write_config_byte(0, 0x07<<3, 0x43, &v, 0);
+                       irongate_hose_read_config_byte(0, 0x07<<3, 0x43, &v, 0);
                        irongate_hose_write_config_byte(0, 0x07<<3, 0x43, v | 0x80, 0);
                        outb(1, 0x92);
                        outb(0, 0x92);
index 03225a5d6ae628ab760a2e046ab850c4c8ddf5ff..15395d2b6c53bb43bef9ff643e4ac458eb56901c 100644 (file)
@@ -417,8 +417,13 @@ do_entIF(unsigned long type, unsigned long a1,
                        /* EV4 does not implement anything except normal
                           rounding.  Everything else will come here as
                           an illegal instruction.  Emulate them.  */
-                       if (alpha_fp_emul(regs.pc - 4))
+                       if (alpha_fp_emul(regs.pc))
+                       {
+                               /* Increment the PC so that the program in
+                                  user space continues */
+                               regs.pc += 4;
                                return;
+                       }
                }
                send_sig(SIGILL, current, 1);
                break;
index 71d47accf0806d7a981914d903ee5458be77d3dc..ada67e07e6bcb8be209b3a98209f8e414db49f9a 100644 (file)
@@ -1846,15 +1846,20 @@ void smp_flush_tlb(void)
 
                /*
                 * Spin waiting for completion
+                *
+                * It turns out Intel seem to have been tuning their chips
+                * a little. The PIII-500+ seem to execute this little bit
+                * way faster than their older silicon. We now add on a factor
+                * guessed from the TSC calibration.
                 */
 
-               stuck = 50000000;
+               stuck = 50000000 + cpu_data[cpu].loops_per_sec/2;
                while (smp_invalidate_needed) {
                        /*
                         * Take care of "crossing" invalidates
                         */
                        if (test_bit(cpu, &smp_invalidate_needed))
-                       clear_bit(cpu, &smp_invalidate_needed);
+                               clear_bit(cpu, &smp_invalidate_needed);
                        --stuck;
                        if (!stuck) {
                                printk("stuck on TLB IPI wait (CPU#%d)\n",cpu);
index 6a8d26b6fd754cb9a8f3ced2ece4c76293d95d13..fd9b1dc4ffeada1b0916d633833a1b2dafb9abe7 100644 (file)
@@ -291,7 +291,8 @@ out_of_memory:
        up(&mm->mmap_sem);
        if (error_code & 4)
        {
-               if (!((regs->eflags >> 12) & 3))
+               if (tsk->oom_kill_try++ > 10 ||
+                   !((regs->eflags >> 12) & 3))
                {
                        printk("VM: killing process %s\n", tsk->comm);
                        do_exit(SIGKILL);
@@ -304,6 +305,11 @@ out_of_memory:
                         */
                        printk("VM: terminating process %s\n", tsk->comm);
                        force_sig(SIGTERM, current);
+                       if (tsk->oom_kill_try > 1)
+                       {
+                               tsk->policy |= SCHED_YIELD;
+                               schedule();
+                       }
                        return;
                }
        }
index fb5a19e3a3e054677d38787911548f851676060c..654b21745aad534fa8a45b695bb3456a469f4284 100644 (file)
@@ -1,10 +1,24 @@
 /*
  * Copyright (C) 1996 Paul Mackerras.
  */
-
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <asm/bitops.h>
 
+/*
+ * The atomic bit operations here generally act as memory barriers also
+ * on SMP, since the code that calls them expects them to in many cases.
+ * (x86 processors don't move loads past lock instructions and don't
+ * reorder stores.)
+ */
+#ifdef CONFIG_SMP
+#define SMP_WMB                __asm__ __volatile__("eieio")
+#define SMP_MB         __asm__ __volatile__("sync")
+#else
+#define SMP_WMB                do { } while (0)
+#define SMP_MB         do { } while (0)
+#endif /* CONFIG_SMP */
+
 /*
  * I left these here since the problems with "cc" make it difficult to keep
  * them in bitops.h -- Cort
@@ -17,6 +31,7 @@ void set_bit(int nr, volatile void *addr)
 
        if ((unsigned long)addr & 3)
                printk(KERN_ERR "set_bit(%x, %p)\n", nr, addr);
+       SMP_WMB;
        __asm__ __volatile__("\n\
 1:     lwarx   %0,0,%2
        or      %0,%0,%1
@@ -25,6 +40,7 @@ void set_bit(int nr, volatile void *addr)
        : "=&r" (t)             /*, "=m" (*p)*/
        : "r" (mask), "r" (p)
        : "cc");
+       SMP_MB;
 }
 
 void clear_bit(int nr, volatile void *addr)
@@ -35,6 +51,7 @@ void clear_bit(int nr, volatile void *addr)
 
        if ((unsigned long)addr & 3)
                printk(KERN_ERR "clear_bit(%x, %p)\n", nr, addr);
+       SMP_WMB;
        __asm__ __volatile__("\n\
 1:     lwarx   %0,0,%2
        andc    %0,%0,%1
@@ -43,6 +60,7 @@ void clear_bit(int nr, volatile void *addr)
        : "=&r" (t)             /*, "=m" (*p)*/
        : "r" (mask), "r" (p)
        : "cc");
+       SMP_MB;
 }
 
 void change_bit(int nr, volatile void *addr)
@@ -53,6 +71,7 @@ void change_bit(int nr, volatile void *addr)
 
        if ((unsigned long)addr & 3)
                printk(KERN_ERR "change_bit(%x, %p)\n", nr, addr);
+       SMP_WMB;
        __asm__ __volatile__("\n\
 1:     lwarx   %0,0,%2
        xor     %0,%0,%1
@@ -61,6 +80,7 @@ void change_bit(int nr, volatile void *addr)
        : "=&r" (t)             /*, "=m" (*p)*/
        : "r" (mask), "r" (p)
        : "cc");
+       SMP_MB;
 }
 
 int test_and_set_bit(int nr, volatile void *addr)
@@ -71,6 +91,7 @@ int test_and_set_bit(int nr, volatile void *addr)
 
        if ((unsigned long)addr & 3)
                printk(KERN_ERR "test_and_set_bit(%x, %p)\n", nr, addr);
+       SMP_WMB;
        __asm__ __volatile__("\n\
 1:     lwarx   %0,0,%3
        or      %1,%0,%2
@@ -79,6 +100,7 @@ int test_and_set_bit(int nr, volatile void *addr)
        : "=&r" (old), "=&r" (t)        /*, "=m" (*p)*/
        : "r" (mask), "r" (p)
        : "cc");
+       SMP_MB;
 
        return (old & mask) != 0;
 }
@@ -91,6 +113,7 @@ int test_and_clear_bit(int nr, volatile void *addr)
 
        if ((unsigned long)addr & 3)
                printk(KERN_ERR "test_and_clear_bit(%x, %p)\n", nr, addr);
+       SMP_WMB;
        __asm__ __volatile__("\n\
 1:     lwarx   %0,0,%3
        andc    %1,%0,%2
@@ -99,6 +122,7 @@ int test_and_clear_bit(int nr, volatile void *addr)
        : "=&r" (old), "=&r" (t)        /*, "=m" (*p)*/
        : "r" (mask), "r" (p)
        : "cc");
+       SMP_MB;
 
        return (old & mask) != 0;
 }
@@ -111,6 +135,7 @@ int test_and_change_bit(int nr, volatile void *addr)
 
        if ((unsigned long)addr & 3)
                printk(KERN_ERR "test_and_change_bit(%x, %p)\n", nr, addr);
+       SMP_WMB;
        __asm__ __volatile__("\n\
 1:     lwarx   %0,0,%3
        xor     %1,%0,%2
@@ -119,6 +144,7 @@ int test_and_change_bit(int nr, volatile void *addr)
        : "=&r" (old), "=&r" (t)        /*, "=m" (*p)*/
        : "r" (mask), "r" (p)
        : "cc");
+       SMP_MB;
 
        return (old & mask) != 0;
 }
index 51b8ff6c7b0a0bad2c20548b7b5ec1f19caec789..9425127147e5c6a0016fc5b78476938226c830b7 100644 (file)
@@ -146,6 +146,19 @@ _GLOBAL(_tlbie)
 #endif
        blr
 
+/*
+ * The atomic operations here generally act as memory barriers too on SMP.
+ * The general usage of them assumes this since x86 processors won't
+ * move a load past a lock instruction and don't reorder stores.
+ */
+#ifdef __SMP__
+#define SMP_WMB        eieio
+#define SMP_MB sync
+#else
+#define SMP_WMB
+#define SMP_MB
+#endif /* CONFIG_SMP */
+
 /*
  * Atomic [test&set] exchange
  *
@@ -155,9 +168,11 @@ _GLOBAL(_tlbie)
  */
 _GLOBAL(xchg_u32)
        mr      r5,r3           /* Save pointer */
+       SMP_WMB
 10:    lwarx   r3,0,r5         /* Fetch old value & reserve */
        stwcx.  r4,0,r5         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
+       SMP_MB
        blr
 
 /*
@@ -169,14 +184,14 @@ _GLOBAL(xchg_u32)
  */
 _GLOBAL(__spin_trylock)
        mr      r4,r3
-       eieio                   /* prevent reordering of stores */
+       SMP_WMB                 /* prevent reordering of stores */
        li      r5,-1
        lwarx   r3,0,r4         /* fetch old value, establish reservation */
        cmpwi   0,r3,0          /* is it 0? */
        bnelr-                  /* return failure if not */
        stwcx.  r5,0,r4         /* try to update with new value */
        bne-    1f              /* if we failed */
-       eieio                   /* prevent reordering of stores */
+       SMP_WMB                 /* prevent reordering of stores */
        blr
 1:     li      r3,1            /* return non-zero for failure */
        blr
@@ -195,71 +210,91 @@ _GLOBAL(__spin_trylock)
  * void atomic_set_mask(atomic_t mask, atomic_t *addr);
  */
 _GLOBAL(atomic_add)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r4         /* Fetch old value & reserve */
        add     r5,r5,r3        /* Perform 'add' operation */
        stwcx.  r5,0,r4         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
+       SMP_MB
        blr
 _GLOBAL(atomic_add_return)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r4         /* Fetch old value & reserve */
        add     r5,r5,r3        /* Perform 'add' operation */
        stwcx.  r5,0,r4         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
        mr      r3,r5
+       SMP_MB
        blr
 _GLOBAL(atomic_sub)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r4         /* Fetch old value & reserve */
        sub     r5,r5,r3        /* Perform 'add' operation */
        stwcx.  r5,0,r4         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
+       SMP_MB
        blr
 _GLOBAL(atomic_inc)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r3         /* Fetch old value & reserve */
        addi    r5,r5,1         /* Perform 'add' operation */
        stwcx.  r5,0,r3         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
+       SMP_MB
        blr
 _GLOBAL(atomic_inc_return)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r3         /* Fetch old value & reserve */
        addi    r5,r5,1         /* Perform 'add' operation */
        stwcx.  r5,0,r3         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
        mr      r3,r5           /* Return new value */
+       SMP_MB
        blr
 _GLOBAL(atomic_dec)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r3         /* Fetch old value & reserve */
        subi    r5,r5,1         /* Perform 'add' operation */
        stwcx.  r5,0,r3         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
+       SMP_MB
        blr
 _GLOBAL(atomic_dec_return)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r3         /* Fetch old value & reserve */
        subi    r5,r5,1         /* Perform 'add' operation */
        stwcx.  r5,0,r3         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
        mr      r3,r5           /* Return new value */
+       SMP_MB
        blr
 _GLOBAL(atomic_dec_and_test)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r3         /* Fetch old value & reserve */
        subi    r5,r5,1         /* Perform 'add' operation */
        stwcx.  r5,0,r3         /* Update with new value */
        bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
+       SMP_MB
        cmpi    0,r5,0          /* Return 'true' IFF 0 */
        li      r3,1
        beqlr
        li      r3,0
        blr
 _GLOBAL(atomic_clear_mask)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r4
        andc    r5,r5,r3
        stwcx.  r5,0,r4
        bne-    10b
+       SMP_MB
        blr
 _GLOBAL(atomic_set_mask)
+       SMP_WMB                 /* wmb() */
 10:    lwarx   r5,0,r4
        or      r5,r5,r3
        stwcx.  r5,0,r4
        bne-    10b
+       SMP_MB
        blr
 
 /*
index 7049348f169edac51294e71ba5b4066298c45e18..4e605a57fcc0c52bfb895ae2253d5252e8e793cc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: irq.c,v 1.76.2.2 2000/02/17 18:05:36 davem Exp $
+/* $Id: irq.c,v 1.76.2.3 2000/03/02 02:03:27 davem Exp $
  * irq.c: UltraSparc IRQ handling/init/registry.
  *
  * Copyright (C) 1997  David S. Miller  (davem@caip.rutgers.edu)
@@ -1230,7 +1230,7 @@ int probe_irq_off(unsigned long mask)
 void init_timers(void (*cfunc)(int, void *, struct pt_regs *),
                 unsigned long *clock)
 {
-       unsigned long flags;
+       unsigned long pstate;
        extern unsigned long timer_tick_offset;
        int node, err;
 #ifdef __SMP__
@@ -1253,31 +1253,57 @@ void init_timers(void (*cfunc)(int, void *, struct pt_regs *),
                prom_halt();
        }
 
-       save_and_cli(flags);
+       /* Guarentee that the following sequences execute
+        * uninterrupted.
+        */
+       __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
+                            "wrpr      %0, %1, %%pstate"
+                            : "=r" (pstate)
+                            : "i" (PSTATE_IE));
 
        /* Set things up so user can access tick register for profiling
-        * purposes.
+        * purposes.  Also workaround BB_ERRATA_1 by doing a dummy
+        * read back of %tick after writing it.
         */
        __asm__ __volatile__("
                sethi   %%hi(0x80000000), %%g1
-               sllx    %%g1, 32, %%g1
-               rd      %%tick, %%g2
+               ba,pt   %%xcc, 1f
+                sllx   %%g1, 32, %%g1
+               .align  64
+       1:      rd      %%tick, %%g2
                add     %%g2, 6, %%g2
                andn    %%g2, %%g1, %%g2
                wrpr    %%g2, 0, %%tick
-"      : /* no outputs */
+               rdpr    %%tick, %%g0"
+       : /* no outputs */
        : /* no inputs */
        : "g1", "g2");
 
+       /* Workaround for Spitfire Errata (#54 I think??), I discovered
+        * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch
+        * number 103640.
+        *
+        * On Blackbird writes to %tick_cmpr can fail, the
+        * workaround seems to be to execute the wr instruction
+        * at the start of an I-cache line, and perform a dummy
+        * read back from %tick_cmpr right after writing to it. -DaveM
+        */
        __asm__ __volatile__("
                rd      %%tick, %%g1
-               add     %%g1, %0, %%g1
-               wr      %%g1, 0x0, %%tick_cmpr"
+               ba,pt   %%xcc, 1f
+                add    %%g1, %0, %%g1
+               .align  64
+       1:      wr      %%g1, 0x0, %%tick_cmpr
+               rd      %%tick_cmpr, %%g0"
        : /* no outputs */
        : "r" (timer_tick_offset)
        : "g1");
 
-       restore_flags(flags);
+       /* Restore PSTATE_IE. */
+       __asm__ __volatile__("wrpr      %0, 0x0, %%pstate"
+                            : /* no outputs */
+                            : "r" (pstate));
+
        sti();
 }
 
index 741fcb790f430fdf4bef34802e96b0f972c9105e..a8e74d94cecf21ed7fc8de0e0546d761cb5e427a 100644 (file)
@@ -119,6 +119,7 @@ extern void cpu_probe(void);
 __initfunc(void smp_callin(void))
 {
        int cpuid = hard_smp_processor_id();
+       unsigned long pstate;
 
        inherit_locked_prom_mappings(0);
 
@@ -127,18 +128,37 @@ __initfunc(void smp_callin(void))
 
        cpu_probe();
 
-       /* Master did this already, now is the time for us to do it. */
+       /* Guarentee that the following sequences execute
+        * uninterrupted.
+        */
+       __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
+                            "wrpr      %0, %1, %%pstate"
+                            : "=r" (pstate)
+                            : "i" (PSTATE_IE));
+
+       /* Set things up so user can access tick register for profiling
+        * purposes.  Also workaround BB_ERRATA_1 by doing a dummy
+        * read back of %tick after writing it.
+        */
        __asm__ __volatile__("
        sethi   %%hi(0x80000000), %%g1
-       sllx    %%g1, 32, %%g1
-       rd      %%tick, %%g2
+       ba,pt   %%xcc, 1f
+        sllx   %%g1, 32, %%g1
+       .align  64
+1:     rd      %%tick, %%g2
        add     %%g2, 6, %%g2
        andn    %%g2, %%g1, %%g2
        wrpr    %%g2, 0, %%tick
-"      : /* no outputs */
+       rdpr    %%tick, %%g0"
+       : /* no outputs */
        : /* no inputs */
        : "g1", "g2");
 
+       /* Restore PSTATE_IE. */
+       __asm__ __volatile__("wrpr      %0, 0x0, %%pstate"
+                            : /* no outputs */
+                            : "r" (pstate));
+
        smp_setup_percpu_timer();
 
        __sti();
@@ -590,7 +610,7 @@ extern void update_one_process(struct task_struct *p, unsigned long ticks,
 
 void smp_percpu_timer_interrupt(struct pt_regs *regs)
 {
-       unsigned long compare, tick;
+       unsigned long compare, tick, pstate;
        int cpu = smp_processor_id();
        int user = user_mode(regs);
 
@@ -656,27 +676,87 @@ do {      hardirq_enter(cpu);                     \
                        prof_counter(cpu) = prof_multiplier(cpu);
                }
 
+               /* Guarentee that the following sequences execute
+                * uninterrupted.
+                */
+               __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
+                                    "wrpr      %0, %1, %%pstate"
+                                    : "=r" (pstate)
+                                    : "i" (PSTATE_IE));
+
+               /* Workaround for Spitfire Errata (#54 I think??), I discovered
+                * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch
+                * number 103640.
+                *
+                * On Blackbird writes to %tick_cmpr can fail, the
+                * workaround seems to be to execute the wr instruction
+                * at the start of an I-cache line, and perform a dummy
+                * read back from %tick_cmpr right after writing to it. -DaveM
+                *
+                * Just to be anal we add a workaround for Spitfire
+                * Errata 50 by preventing pipeline bypasses on the
+                * final read of the %tick register into a compare
+                * instruction.  The Errata 50 description states
+                * that %tick is not prone to this bug, but I am not
+                * taking any chances.
+                */
                __asm__ __volatile__("rd        %%tick_cmpr, %0\n\t"
-                                    "add       %0, %2, %0\n\t"
-                                    "wr        %0, 0x0, %%tick_cmpr\n\t"
-                                    "rd        %%tick, %1"
+                                    "ba,pt     %%xcc, 1f\n\t"
+                                    " add      %0, %2, %0\n\t"
+                                    ".align    64\n"
+                                 "1: wr        %0, 0x0, %%tick_cmpr\n\t"
+                                    "rd        %%tick_cmpr, %%g0\n\t"
+                                    "rd        %%tick, %1\n\t"
+                                    "mov       %1, %1"
                                     : "=&r" (compare), "=r" (tick)
                                     : "r" (current_tick_offset));
+
+               /* Restore PSTATE_IE. */
+               __asm__ __volatile__("wrpr      %0, 0x0, %%pstate"
+                                    : /* no outputs */
+                                    : "r" (pstate));
        } while (tick >= compare);
 }
 
 __initfunc(static void smp_setup_percpu_timer(void))
 {
        int cpu = smp_processor_id();
+       unsigned long pstate;
 
        prof_counter(cpu) = prof_multiplier(cpu) = 1;
 
-       __asm__ __volatile__("rd        %%tick, %%g1\n\t"
-                            "add       %%g1, %0, %%g1\n\t"
-                            "wr        %%g1, 0x0, %%tick_cmpr"
+       /* Guarentee that the following sequences execute
+        * uninterrupted.
+        */
+       __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
+                            "wrpr      %0, %1, %%pstate"
+                            : "=r" (pstate)
+                            : "i" (PSTATE_IE));
+
+       /* Workaround for Spitfire Errata (#54 I think??), I discovered
+        * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch
+        * number 103640.
+        *
+        * On Blackbird writes to %tick_cmpr can fail, the
+        * workaround seems to be to execute the wr instruction
+        * at the start of an I-cache line, and perform a dummy
+        * read back from %tick_cmpr right after writing to it. -DaveM
+        */
+       __asm__ __volatile__("
+               rd      %%tick, %%g1
+               ba,pt   %%xcc, 1f
+                add    %%g1, %0, %%g1
+               .align  64
+       1:      wr      %%g1, 0x0, %%tick_cmpr
+               rd      %%tick_cmpr, %%g0"
+       : /* no outputs */
+       : "r" (current_tick_offset)
+       : "g1");
+
+       /* Restore PSTATE_IE. */
+       __asm__ __volatile__("wrpr      %0, 0x0, %%pstate"
                             : /* no outputs */
-                            : "r" (current_tick_offset)
-                            : "g1");
+                            : "r" (pstate));
 }
 
 __initfunc(void smp_tick_init(void))
index dcf9571d8dec18ac10d44b450565ea42b26f12d5..b76100267789049737e50f55fc13a9eb77bc1f94 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.20.2.1 1999/10/09 06:03:23 davem Exp $
+/* $Id: time.c,v 1.20.2.2 2000/03/02 02:03:31 davem Exp $
  * time.c: UltraSparc timer and TOD clock support.
  *
  * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
@@ -69,20 +69,53 @@ static __inline__ void timer_check_rtc(void)
 
 static void timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
-       unsigned long ticks;
+       unsigned long ticks, pstate;
 
        write_lock(&xtime_lock);
 
        do {
                do_timer(regs);
 
+               /* Guarentee that the following sequences execute
+                * uninterrupted.
+                */
+               __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
+                                    "wrpr      %0, %1, %%pstate"
+                                    : "=r" (pstate)
+                                    : "i" (PSTATE_IE));
+
+               /* Workaround for Spitfire Errata (#54 I think??), I discovered
+                * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch
+                * number 103640.
+                *
+                * On Blackbird writes to %tick_cmpr can fail, the
+                * workaround seems to be to execute the wr instruction
+                * at the start of an I-cache line, and perform a dummy
+                * read back from %tick_cmpr right after writing to it. -DaveM
+                *
+                * Just to be anal we add a workaround for Spitfire
+                * Errata 50 by preventing pipeline bypasses on the
+                * final read of the %tick register into a compare
+                * instruction.  The Errata 50 description states
+                * that %tick is not prone to this bug, but I am not
+                * taking any chances.
+                */
                __asm__ __volatile__("
                        rd      %%tick_cmpr, %0
-                       add     %0, %2, %0
-                       wr      %0, 0, %%tick_cmpr
-                       rd      %%tick, %1"
+                       ba,pt   %%xcc, 1f
+                        add    %0, %2, %0
+                       .align  64
+                    1: wr      %0, 0, %%tick_cmpr
+                       rd      %%tick_cmpr, %%g0
+                       rd      %%tick, %1
+                       mov     %1, %1"
                        : "=&r" (timer_tick_compare), "=r" (ticks)
                        : "r" (timer_tick_offset));
+
+               /* Restore PSTATE_IE. */
+               __asm__ __volatile__("wrpr      %0, 0x0, %%pstate"
+                                    : /* no outputs */
+                                    : "r" (pstate));
        } while (ticks >= timer_tick_compare);
 
        timer_check_rtc();
index e4bc1dc90da7dfc24d9a57af0ce692ce4213e9fa..477b89718b58ba7303c50549614e75de59757121 100644 (file)
  * Version 0.3.1 (99/06/22):
  *             - allow module removal while internal timer is active,
  *               print warning about probable reset
+ *
+ * Version 0.4 (99/11/15):
+ *             - support for one more type board
  *     
  */
 
-#define VERSION "0.3.1
+#define VERSION "0.4
   
 #include <linux/module.h>
 #include <linux/config.h>
 static int mixcomwd_ioports[] = { 0x180, 0x280, 0x380, 0x000 };
 
 #define MIXCOM_WATCHDOG_OFFSET 0xc10
-#define MIXCOM_ID1 0x11
-#define MIXCOM_ID2 0x13
+#define MIXCOM_ID 0x11
+#define FLASHCOM_WATCHDOG_OFFSET 0x4
+#define FLASHCOM_ID 0x18
 
 static int mixcomwd_opened;
-static int mixcomwd_port;
+
+static int watchdog_port;
 
 #ifndef CONFIG_WATCHDOG_NOWAYOUT
 static int mixcomwd_timer_alive;
@@ -59,7 +64,7 @@ static struct timer_list mixcomwd_timer;
 
 static void mixcomwd_ping(void)
 {
-       outb_p(55,mixcomwd_port+MIXCOM_WATCHDOG_OFFSET);
+       outb_p(55,watchdog_port);
        return;
 }
 
@@ -187,16 +192,31 @@ static struct miscdevice mixcomwd_miscdev=
        &mixcomwd_fops
 };
 
-__initfunc(static int mixcomwd_checkcard(int port))
+__initfunc(static int mixcom_checkcard(int port))
 {
        int id;
 
-       if(check_region(port,1)) {
+       if(check_region(port + MIXCOM_WATCHDOG_OFFSET,1)) {
                return 0;
        }
        
-       id=inb_p(port + MIXCOM_WATCHDOG_OFFSET) & 0x3f;
-       if(id!=MIXCOM_ID1 && id!=MIXCOM_ID2) {
+       id=inb_p(port + MIXCOM_WATCHDOG_OFFSET);
+       if(id!=MIXCOM_ID) {
+               return 0;
+       }
+       return 1;
+}
+
+__initfunc(static int flashcom_checkcard(int port))
+{
+       int id;
+       
+       if(check_region(port + FLASHCOM_WATCHDOG_OFFSET,1)) {
+               return 0;
+       }
+       
+       id=inb_p(port + FLASHCOM_WATCHDOG_OFFSET);
+       if(id!=FLASHCOM_ID) {
                return 0;
        }
        return 1;
@@ -208,23 +228,30 @@ __initfunc(void mixcomwd_init(void))
        int i;
        int found=0;
 
-       for (i = 0; mixcomwd_ioports[i] != 0; i++) {
-               if (mixcomwd_checkcard(mixcomwd_ioports[i])) {
+       for (i = 0; !found && mixcomwd_ioports[i] != 0; i++) {
+               if (mixcom_checkcard(mixcomwd_ioports[i])) {
                        found = 1;
-                       mixcomwd_port = mixcomwd_ioports[i];
-                       break;
+                       watchdog_port = mixcomwd_ioports[i] + MIXCOM_WATCHDOG_OFFSET;
                }
        }
-
+       
+       /* The FlashCOM card can be set up at 0x300 -> 0x378, in 0x8 jumps */
+       for (i = 0x300; !found && i < 0x380; i+=0x8) {
+               if (flashcom_checkcard(i)) {
+                       found = 1;
+                       watchdog_port = i + FLASHCOM_WATCHDOG_OFFSET;
+               }
+       }
+       
        if (!found) {
                printk("mixcomwd: No card detected, or port not available.\n");
                return;
        }
 
-       request_region(mixcomwd_port+MIXCOM_WATCHDOG_OFFSET,1,"MixCOM watchdog");
-       
+       request_region(watchdog_port,1,"MixCOM watchdog");
+               
        misc_register(&mixcomwd_miscdev);
-       printk("MixCOM watchdog driver v%s, MixCOM card at 0x%3x\n",VERSION,mixcomwd_port);
+       printk("MixCOM watchdog driver v%s, watchdog port at 0x%3x\n",VERSION,watchdog_port);
 }      
 
 #ifdef MODULE
@@ -244,7 +271,7 @@ void cleanup_module(void)
                mixcomwd_timer_alive=0;
        }
 #endif
-       release_region(mixcomwd_port+MIXCOM_WATCHDOG_OFFSET,1);
+       release_region(watchdog_port,1);
        misc_deregister(&mixcomwd_miscdev);
 }
 #endif
index 5fc764e9602657dba3ae44e83dbcdd750496351a..72089f4811ca3d3962e7f478573af91cbd476916 100644 (file)
@@ -902,8 +902,8 @@ int init_module(void)
 int __init i2o_config_init(void)
 #endif
 {
-       printk(KERN_INFO "I2O configuration manager v 0.04.\n");
-       printk(KERN_INFO "  (C) Copyright 1999 Red Hat Software");
+       printk(KERN_INFO "I2O configuration manager v 0.04\n");
+       printk(KERN_INFO "(C) Copyright 1999 Red Hat Software\n");
        
        if((page_buf = kmalloc(4096, GFP_KERNEL))==NULL)
        {
index be750fb56ba8737c015f8ad402809eea76716fa8..58ffe70f7a6681245cff01591b35a5e08131838f 100644 (file)
@@ -243,7 +243,7 @@ comment 'Token ring devices'
 bool 'Token Ring driver support' CONFIG_TR
 if [ "$CONFIG_TR" = "y" ]; then
   tristate 'IBM Tropic chipset based adaptor support' CONFIG_IBMTR
-#  tristate 'IBM Lanstreamer PCI adaptor support' CONFIG_IBMLS
+  tristate 'IBM Lanstreamer PCI adaptor support' CONFIG_IBMLS
   tristate 'IBM Olympic chipset PCI adapter support' CONFIG_IBMOL
   tristate 'SysKonnect adapter support' CONFIG_SKTR
 fi
@@ -291,9 +291,7 @@ tristate 'LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards' CONFIG_LANMEDIA
 
 tristate 'MultiGate (COMX) synchronous serial boards support' CONFIG_COMX
    if [ "$CONFIG_COMX" != "n" ]; then
-   if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
-      dep_tristate '  Support for COMX/CMX/HiCOMX boards' CONFIG_COMX_HW_COMX $CONFIG_COMX
-   fi
+   dep_tristate '  Support for COMX/CMX/HiCOMX boards' CONFIG_COMX_HW_COMX $CONFIG_COMX
    dep_tristate '  Support for LoCOMX board' CONFIG_COMX_HW_LOCOMX $CONFIG_COMX
    dep_tristate '  Support for MixCOM board' CONFIG_COMX_HW_MIXCOM $CONFIG_COMX
    dep_tristate '  Support for HDLC and syncPPP protocols on MultiGate boards' CONFIG_COMX_PROTO_PPP $CONFIG_COMX
index 5a0e026a0eba505bf84321e8e306687404ac5be3..612157848a87006872b9952b16d4f678ff7d3055 100644 (file)
@@ -791,6 +791,7 @@ struct device eql_dev = {
 /* Token-ring device probe */
 extern int ibmtr_probe(struct device *);
 extern int olympic_probe(struct device *);
+extern int streamer_probe(struct device *);
 
 static int
 trif_probe(struct device *dev)
@@ -802,6 +803,9 @@ trif_probe(struct device *dev)
 #ifdef CONFIG_IBMOL
        && olympic_probe(dev)
 #endif
+#ifdef CONFIG_IBMLS
+       && streamer_probe(dev)
+#endif 
 #ifdef CONFIG_SKTR
        && sktr_probe(dev)
 #endif
index 1e1bd6d974490bddb06a43fe7a3cb14ce584b7a2..644007f6503453c0090c64941e9adf077cba4183 100644 (file)
@@ -7,7 +7,7 @@
  * Rewritten by: Tivadar Szemethy <tiv@itc.hu>
  * Currently maintained by: Gergely Madarasz <gorgo@itc.hu>
  *
- * Copyright (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>
+ * Copyright (C) 1995-2000 ITConsult-Pro Co. <info@itc.hu>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  *
  * Version 0.82 (99/08/24):
  *             - fix multiple board support
+ *
+ * Version 0.83 (99/11/30):
+ *             - interrupt handling and locking fixes during initalization
+ *             - really fix multiple board support
  * 
+ * Version 0.84 (99/12/02):
+ *             - some workarounds for problematic hardware/firmware
+ *
+ * Version 0.85 (00/01/14):
+ *             - some additional workarounds :/
+ *             - printk cleanups
  */
 
-#define VERSION "0.82"
+#define VERSION "0.85"
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -76,7 +86,7 @@ struct comx_privdata {
        u_long  histogram[5];
 };
 
-struct device *memory_used[(COMX_MEM_MAX - COMX_MEM_MIN) / 0x10000];
+static struct device *memory_used[(COMX_MEM_MAX - COMX_MEM_MIN) / 0x10000];
 extern struct comx_hardware hicomx_hw;
 extern struct comx_hardware comx_hw;
 extern struct comx_hardware cmx_hw;
@@ -122,21 +132,22 @@ static struct device *COMX_access_board(struct device *dev)
        int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
        unsigned long flags;
 
+
        save_flags(flags); cli();
-       if (memory_used[mempos] == dev) {
-               restore_flags(flags);
-               return dev;
-       }
-
-       if (ch->twin && memory_used[mempos] == ch->twin) {
-               memory_used[mempos] = dev;
-               ret = ch->twin;
-       } else {        
-               ret = memory_used[mempos];
-               if (ret) ch->HW_board_off(ret);
-               memory_used[mempos] = dev;
+       
+       ret = memory_used[mempos];
+
+       if(ret == dev) {
+               goto out;
+       }
+
+       memory_used[mempos] = dev;
+
+       if (!ch->twin || ret != ch->twin) {
+               if (ret) ((struct comx_channel *)ret->priv)->HW_board_off(ret);
                ch->HW_board_on(dev);
        }
+out:
        restore_flags(flags);
        return ret;
 }
@@ -148,16 +159,17 @@ static void COMX_release_board(struct device *dev, struct device *savep)
        struct comx_channel *ch = dev->priv;
 
        save_flags(flags); cli();
+
        if (memory_used[mempos] == savep) {
-               restore_flags(flags);
-               return;
+               goto out;
        }
 
        memory_used[mempos] = savep;
        if (!ch->twin || ch->twin != savep) {
                ch->HW_board_off(dev);
-               if (savep) ch->HW_board_on(savep);
+               if (savep) ((struct comx_channel*)savep->priv)->HW_board_on(savep);
        }
+out:
        restore_flags(flags);
 }
 
@@ -170,8 +182,11 @@ static int COMX_txe(struct device *dev)
        savep = ch->HW_access_board(dev);
        if (COMX_readw(dev,OFF_A_L2_LINKUP) == LINKUP_READY) {
                rc = COMX_readw(dev,OFF_A_L2_TxEMPTY);
-       }
+       } 
        ch->HW_release_board(dev,savep);
+       if(rc==0xffff) {
+               printk(KERN_ERR "%s, OFF_A_L2_TxEMPTY is %d\n",dev->name, rc);
+       }
        return rc;
 }
 
@@ -181,6 +196,7 @@ static int COMX_send_packet(struct device *dev, struct sk_buff *skb)
        struct comx_channel *ch = dev->priv;
        struct comx_privdata *hw = ch->HW_privdata;
        int ret = FRAME_DROPPED;
+       word tmp;
 
        savep = ch->HW_access_board(dev);       
 
@@ -189,15 +205,22 @@ static int COMX_send_packet(struct device *dev, struct sk_buff *skb)
        }
 
        if (skb->len > COMX_MAX_TX_SIZE) {
-               dev_kfree_skb(skb);
-               return FRAME_DROPPED;
+               ret=FRAME_DROPPED;
+               goto out;
        }
 
-       if ((ch->line_status & LINE_UP) && COMX_readw(dev, OFF_A_L2_TxEMPTY)) {
+       tmp=COMX_readw(dev, OFF_A_L2_TxEMPTY);
+       if ((ch->line_status & LINE_UP) && tmp==1) {
                int lensave = skb->len;
                int dest = COMX_readw(dev, OFF_A_L2_TxBUFP);
                word *data = (word *)skb->data;
 
+               if(dest==0xffff) {
+                       printk(KERN_ERR "%s: OFF_A_L2_TxBUFP is %d\n", dev->name, dest);
+                       ret=FRAME_DROPPED;
+                       goto out;
+               }
+                                       
                writew((unsigned short)skb->len, dev->mem_start + dest);
                dest += 2;
                while (skb->len > 1) {
@@ -215,8 +238,12 @@ static int COMX_send_packet(struct device *dev, struct sk_buff *skb)
        } else {
                ch->stats.tx_dropped++;
                printk(KERN_INFO "%s: frame dropped\n",dev->name);
+               if(tmp) {
+                       printk(KERN_ERR "%s: OFF_A_L2_TxEMPTY is %d\n",dev->name,tmp);
+               }
        }
        
+out:
        ch->HW_release_board(dev, savep);
        dev_kfree_skb(skb);
        return ret;
@@ -233,7 +260,15 @@ static inline int comx_read_buffer(struct device *dev)
 
        i = 0;
        rbuf_offs = COMX_readw(dev, OFF_A_L2_RxBUFP);
+       if(rbuf_offs == 0xffff) {
+               printk(KERN_ERR "%s: OFF_A_L2_RxBUFP is %d\n",dev->name,rbuf_offs);
+               return 0;
+       }
        len = readw(dev->mem_start + rbuf_offs);
+       if(len > COMX_MAX_RX_SIZE) {
+               printk(KERN_ERR "%s: packet length is %d\n",dev->name,len);
+               return 0;
+       }
        if ((skb = dev_alloc_skb(len + 16)) == NULL) {
                ch->stats.rx_dropped++;
                COMX_WRITE(dev, OFF_A_L2_DAV, 0);
@@ -314,13 +349,13 @@ static void COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        if (dev->interrupt) {
                printk(KERN_ERR "%s: re-entering interrupt handler!\n", dev->name);
                return;
-       }
+               }
 
-       printk("%s: entering interrupt handler\n", dev->name);
 
        jiffs = jiffies;
 
        dev->interrupt = 1;
+
        interrupted = ch->HW_access_board(dev);
 
        while (!idle && count < 5000) {
@@ -355,22 +390,43 @@ static void COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                        /* Collect stats */
                        tmp = COMX_readw(dev, OFF_A_L1_ABOREC);
                        COMX_WRITE(dev, OFF_A_L1_ABOREC, 0);
-                       ch->stats.rx_missed_errors += (tmp >> 8) & 0xff;
-                       ch->stats.rx_over_errors += tmp & 0xff;
+                       if(tmp==0xffff) {
+                               printk(KERN_ERR "%s: OFF_A_L1_ABOREC is %d\n",dev->name,tmp);
+                               break;
+                       } else {
+                               ch->stats.rx_missed_errors += (tmp >> 8) & 0xff;
+                               ch->stats.rx_over_errors += tmp & 0xff;
+                       }
                        tmp = COMX_readw(dev, OFF_A_L1_CRCREC);
                        COMX_WRITE(dev, OFF_A_L1_CRCREC, 0);
-                       ch->stats.rx_crc_errors += (tmp >> 8) & 0xff;
-                       ch->stats.rx_missed_errors += tmp & 0xff;
-
+                       if(tmp==0xffff) {
+                               printk(KERN_ERR "%s: OFF_A_L1_CRCREC is %d\n",dev->name,tmp);
+                               break;
+                       } else {
+                               ch->stats.rx_crc_errors += (tmp >> 8) & 0xff;
+                               ch->stats.rx_missed_errors += tmp & 0xff;
+                       }
+                       
                        if ((ch->line_status & LINE_UP) && ch->LINE_rx) {
-                               while (COMX_readw(dev, OFF_A_L2_DAV)) {
+                               tmp=COMX_readw(dev, OFF_A_L2_DAV); 
+                               while (tmp==1) {
                                        idle=0;
                                        buffers_emptied+=comx_read_buffer(dev);
+                                       tmp=COMX_readw(dev, OFF_A_L2_DAV); 
+                               }
+                               if(tmp) {
+                                       printk(KERN_ERR "%s: OFF_A_L2_DAV is %d\n", dev->name, tmp);
+                                       break;
                                }
                        }
 
-                       if (COMX_readw(dev, OFF_A_L2_TxEMPTY) && ch->LINE_tx) {
+                       tmp=COMX_readw(dev, OFF_A_L2_TxEMPTY);
+                       if (tmp==1 && ch->LINE_tx) {
                                ch->LINE_tx(dev);
+                       } 
+                       if(tmp==0xffff) {
+                               printk(KERN_ERR "%s: OFF_A_L2_TxEMPTY is %d\n", dev->name, tmp);
+                               break;
                        }
 
                        if (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) {
@@ -394,7 +450,6 @@ static void COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        }
 
        ch->HW_release_board(dev, interrupted);
-       printk("%s: leaving interrupt handler\n", dev->name);
        dev->interrupt = 0;
 }
 
@@ -404,18 +459,23 @@ static int COMX_open(struct device *dev)
        struct comx_privdata *hw = ch->HW_privdata;
        struct proc_dir_entry *procfile = ch->procdir->subdir;
        unsigned long jiffs;
+       int twin_open=0;
+       int retval;
        struct device *savep;
 
        if (!dev->base_addr || !dev->irq || !dev->mem_start) {
                return -ENODEV;
        }
 
-       if (!ch->twin || 
-          (!(((struct comx_channel *)(ch->twin->priv))->init_status & HW_OPEN))) {
+       if (ch->twin && (((struct comx_channel *)(ch->twin->priv))->init_status & HW_OPEN)) {
+               twin_open=1;
+       }
+
+       if (!twin_open) {
                if (check_region(dev->base_addr, hw->io_extent)) {
                        return -EAGAIN;
                }
-               if (request_irq(dev->irq, COMX_interrupt, SA_INTERRUPT, dev->name, 
+               if (request_irq(dev->irq, COMX_interrupt, 0, dev->name, 
                   (void *)dev)) {
                        printk(KERN_ERR "comx-hw-comx: unable to obtain irq %d\n", dev->irq);
                        return -EAGAIN;
@@ -423,10 +483,9 @@ static int COMX_open(struct device *dev)
                ch->init_status |= IRQ_ALLOCATED;
                request_region(dev->base_addr, hw->io_extent, dev->name);
                if (!ch->HW_load_board || ch->HW_load_board(dev)) {
-                       release_region(dev->base_addr, hw->io_extent);
-                       free_irq(dev->irq, (void *)dev);
                        ch->init_status &= ~IRQ_ALLOCATED;
-                       return -ENODEV;
+                       retval=-ENODEV;
+                       goto error;
                }
        }
 
@@ -443,19 +502,28 @@ static int COMX_open(struct device *dev)
                schedule_timeout(1);
        }
        
-       ch->HW_release_board(dev, savep);
-       if (jiffies > jiffs + HZ) {
+       if (jiffies >= jiffs + HZ) {
                printk(KERN_ERR "%s: board timeout on INIT command\n", dev->name);
-               release_region(dev->base_addr, hw->io_extent);
-               free_irq(dev->irq, (void *)dev);
-               return -EIO;
+               ch->HW_release_board(dev, savep);
+               retval=-EIO;
+               goto error;
        }
+       udelay(1000);
 
-       savep = ch->HW_access_board(dev);
-
-       /* Ide kellene irni, hogy DTE vagy DCE ? */
        COMX_CMD(dev, COMX_CMD_OPEN);
 
+       jiffs = jiffies;
+       while (COMX_readw(dev, OFF_A_L2_LINKUP) != 3 && jiffies < jiffs + HZ) {
+               schedule_timeout(1);
+       }
+       
+       if (jiffies >= jiffs + HZ) {
+               printk(KERN_ERR "%s: board timeout on OPEN command\n", dev->name);
+               ch->HW_release_board(dev, savep);
+               retval=-EIO;
+               goto error;
+       }
+       
        ch->init_status |= HW_OPEN;
        
        /* Ez eleg ciki, de ilyen a rendszer */
@@ -484,6 +552,14 @@ static int COMX_open(struct device *dev)
        }       
        
        return 0;       
+
+error:
+       if(!twin_open) {
+               release_region(dev->base_addr, hw->io_extent);
+               free_irq(dev->irq, (void *)dev);
+       }
+       return retval;
+
 }
 
 static int COMX_close(struct device *dev)
@@ -571,8 +647,12 @@ static int COMX_load_board(struct device *dev)
        struct comx_privdata *hw = ch->HW_privdata;
        struct comx_firmware *fw = hw->firmware;
        word board_segment = dev->mem_start >> 16;
-       unsigned long jiff;
+       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
+       unsigned long flags;
        unsigned char id1, id2;
+       struct device *saved;
+       int retval;
+       int loopcount;
        int len;
        byte *COMX_address;
 
@@ -611,33 +691,43 @@ static int COMX_load_board(struct device *dev)
        outb_p(board_segment | COMX_BOARD_RESET, dev->base_addr);
        /* 10 usec should be enough here */
        udelay(100);
+
+       save_flags(flags); cli();
+       saved=memory_used[mempos];
+       if(saved) {
+               ((struct comx_channel *)saved->priv)->HW_board_off(saved);
+       }
+       memory_used[mempos]=dev;
+
        outb_p(board_segment | COMX_ENABLE_BOARD_MEM, dev->base_addr);
 
        writeb(0, dev->mem_start + COMX_JAIL_OFFSET);   
-       jiff=jiffies;
-       while(jiffies < jiff + HZ && readb(dev->mem_start + COMX_JAIL_OFFSET) 
-           != COMX_JAIL_VALUE) {
-               schedule_timeout(1);
+
+       loopcount=0;
+       while(loopcount++ < 10000 && 
+           readb(dev->mem_start + COMX_JAIL_OFFSET) != COMX_JAIL_VALUE) {
+               udelay(100);
        }       
        
        if (readb(dev->mem_start + COMX_JAIL_OFFSET) != COMX_JAIL_VALUE) {
                printk(KERN_ERR "%s: Can't reset board, JAIL value is %02x\n",
                        dev->name, readb(dev->mem_start + COMX_JAIL_OFFSET));
-               outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-               return -ENODEV;
+               retval=-ENODEV;
+               goto out;
        }
 
        writeb(0x55, dev->mem_start + 0x18ff);
-       jiff=jiffies;
-       while(jiffies < jiff + 3*HZ && readb(dev->mem_start + 0x18ff) != 0) {
-               schedule_timeout(1);
+       
+       loopcount=0;
+       while(loopcount++ < 10000 && readb(dev->mem_start + 0x18ff) != 0) {
+               udelay(100);
        }
 
        if(readb(dev->mem_start + 0x18ff) != 0) {
                printk(KERN_ERR "%s: Can't reset board, reset timeout\n",
                        dev->name);
-               outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-               return -ENODEV;
+               retval=-ENODEV;
+               goto out;
        }               
 
        len = 0;
@@ -656,27 +746,36 @@ static int COMX_load_board(struct device *dev)
                printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
                        "instead of 0x%02x\n", dev->name, len, 
                        readb(COMX_address - 1), fw->data[len]);
-               outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-               return -EAGAIN;
+               retval=-EAGAIN;
+               goto out;
        }
 
        writeb(0, dev->mem_start + COMX_JAIL_OFFSET);
 
-       jiff = jiffies;
-       while ( COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && jiffies < jiff + 3*HZ ) {
-               schedule_timeout(1);
+       loopcount = 0;
+       while ( loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
+               udelay(100);
        }
 
-       if (jiffies > jiff + 3*HZ) {
+       if (COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
                printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
                        dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
-               outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-               return -EAGAIN;
+               retval=-EAGAIN;
+               goto out;
        }
 
-       outb_p(board_segment | COMX_DISABLE_BOARD_MEM, dev->base_addr);
+
        ch->init_status |= FW_LOADED;
-       return 0;
+       retval=0;
+
+out: 
+       outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
+       if(saved) {
+               ((struct comx_channel *)saved->priv)->HW_board_on(saved);
+       }
+       memory_used[mempos]=saved;
+       restore_flags(flags);
+       return retval;
 }
 
 static int CMX_load_board(struct device *dev)
@@ -685,10 +784,14 @@ static int CMX_load_board(struct device *dev)
        struct comx_privdata *hw = ch->HW_privdata;
        struct comx_firmware *fw = hw->firmware;
        word board_segment = dev->mem_start >> 16;
-       unsigned long jiff;
+       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
        #if 0
        unsigned char id1, id2;
        #endif
+       struct device *saved;
+       unsigned long flags;
+       int retval;
+       int loopcount;
        int len;
        byte *COMX_address;
 
@@ -716,6 +819,13 @@ static int CMX_load_board(struct device *dev)
        printk(KERN_INFO "%s: Loading CMX Layer 1 firmware %s\n", dev->name, 
                (char *)(fw->data + OFF_FW_L1_ID + 2));
 
+       save_flags(flags); cli();
+       saved=memory_used[mempos];
+       if(saved) {
+               ((struct comx_channel *)saved->priv)->HW_board_off(saved);
+       }
+       memory_used[mempos]=dev;
+       
        outb_p(board_segment | COMX_ENABLE_BOARD_MEM | COMX_BOARD_RESET, 
                dev->base_addr);
 
@@ -737,25 +847,33 @@ static int CMX_load_board(struct device *dev)
                printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
                        "instead of 0x%02x\n", dev->name, len, 
                        readb(COMX_address - 1), fw->data[len]);
-               outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-               return -EAGAIN;
+               retval=-EAGAIN;
+               goto out;
        }
 
-       jiff = jiffies;
-       while ( COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && jiffies < jiff + 3*HZ ) {
-               schedule_timeout(1);
+       loopcount=0;
+       while( loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
+               udelay(100);
        }
 
-       if (jiffies > jiff + 3*HZ) {
+       if (COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
                printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
                        dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
-               outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
-               return -EAGAIN;
+               retval=-EAGAIN;
+               goto out;
        }
 
-       outb_p(board_segment | COMX_DISABLE_BOARD_MEM, dev->base_addr);
        ch->init_status |= FW_LOADED;
-       return 0;
+       retval=0;
+
+out: 
+       outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
+       if(saved) {
+               ((struct comx_channel *)saved->priv)->HW_board_on(saved);
+       }
+       memory_used[mempos]=saved;
+       restore_flags(flags);
+       return retval;
 }
 
 static int HICOMX_load_board(struct device *dev)
@@ -764,8 +882,12 @@ static int HICOMX_load_board(struct device *dev)
        struct comx_privdata *hw = ch->HW_privdata;
        struct comx_firmware *fw = hw->firmware;
        word board_segment = dev->mem_start >> 12;
-       unsigned long jiff;
+       int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
+       struct device *saved;
        unsigned char id1, id2;
+       unsigned long flags;
+       int retval;
+       int loopcount;
        int len;
        word *HICOMX_address;
        char id = 1;
@@ -815,6 +937,14 @@ static int HICOMX_load_board(struct device *dev)
 
        outb_p(board_segment | HICOMX_BOARD_RESET, dev->base_addr);
        udelay(10);     
+
+       save_flags(flags); cli();
+       saved=memory_used[mempos];
+       if(saved) {
+               ((struct comx_channel *)saved->priv)->HW_board_off(saved);
+       }
+       memory_used[mempos]=dev;
+
        outb_p(board_segment | HICOMX_ENABLE_BOARD_MEM, dev->base_addr);
        outb_p(HICOMX_PRG_MEM, dev->base_addr + 1);
 
@@ -834,30 +964,40 @@ static int HICOMX_load_board(struct device *dev)
                printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
                        "instead of 0x%02x\n", dev->name, len, 
                        readw(HICOMX_address - 1) & 0xff, fw->data[len]);
-               outb_p(board_segment | HICOMX_DISABLE_ALL, dev->base_addr);
-               outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
-               return -EAGAIN;
+               retval=-EAGAIN;
+               goto out;
        }
 
        outb_p(board_segment | HICOMX_BOARD_RESET, dev->base_addr);
        outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
+
        outb_p(board_segment | HICOMX_ENABLE_BOARD_MEM, dev->base_addr);
 
-       jiff = jiffies;
-       while ( COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && jiffies < jiff + 3*HZ ) {
-               schedule_timeout(1);
+       loopcount=0;
+       while(loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
+               udelay(100);
        }
 
        if ( COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
                printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
                        dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
-               outb_p(board_segment | HICOMX_DISABLE_ALL, dev->base_addr);
-               return -EAGAIN;
+               retval=-EAGAIN;
+               goto out;
        }
 
-       outb_p(board_segment | HICOMX_DISABLE_ALL, dev->base_addr);
        ch->init_status |= FW_LOADED;
-       return 0;
+       retval=0;
+
+out:
+       outb_p(board_segment | HICOMX_DISABLE_ALL, dev->base_addr);
+       outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
+
+       if(saved) {
+               ((struct comx_channel *)saved->priv)->HW_board_on(saved);
+       }
+       memory_used[mempos]=saved;
+       restore_flags(flags);
+       return retval;
 }
 
 static struct device *comx_twin_check(struct device *dev)
index 67237df431b4054d049fccc746ab11450104d8d1..7153e1ee4af278c90e416a009791cba571c6b70b 100644 (file)
  *
  * Version 0.63 (99/09/21):
  *             - line status report fixes
+ *
+ * Version 0.64 (99/12/01):
+ *             - some more cosmetical fixes
  */
 
-#define VERSION "0.63"
+#define VERSION "0.64"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -167,7 +170,7 @@ static int mixcom_probe(struct device *dev)
 
        save_flags(flags); cli();
 
-       id=inb_p(MIXCOM_BOARD_BASE(dev) + MIXCOM_ID_OFFSET);
+       id=inb_p(MIXCOM_BOARD_BASE(dev) + MIXCOM_ID_OFFSET) & 0x7f;
 
        if (id != MIXCOM_ID ) {
                ret=-ENODEV;
@@ -522,7 +525,6 @@ static int MIXCOM_open(struct device *dev)
 
        mixcom_on(dev);
 
-       restore_flags(flags);
 
        hw->status=inb(MIXCOM_BOARD_BASE(dev) + MIXCOM_STATUS_OFFSET);
        if(hw->status != 0xff) {
@@ -539,6 +541,8 @@ static int MIXCOM_open(struct device *dev)
                ch->line_status &= ~LINE_UP;
        }
 
+       restore_flags(flags);
+
        ch->LINE_status(dev, ch->line_status);
 
        for (; procfile ; procfile = procfile->next) {
index c80fedf7caf4fd2eb39b32593c54a74fa3047afd..7501045198ba50b189010a72aac03416c0950683 100644 (file)
  *
  * Version 0.22 (99/08/05):
  *             - don't test IFF_RUNNING but the pp_link_state of the sppp
+ * 
+ * Version 0.23 (99/12/02):
+ *             - tbusy fixes
  *
  */
 
-#define VERSION "0.22"
+#define VERSION "0.23"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -74,8 +77,12 @@ static void syncppp_status_timerfun(unsigned long d) {
 
 static int syncppp_tx(struct device *dev) 
 {
-       clear_bit(0, &dev->tbusy);
-       mark_bh(NET_BH);
+       struct comx_channel *ch=dev->priv;
+       
+       if(ch->line_status & LINE_UP) {
+               clear_bit(0, &dev->tbusy);
+               mark_bh(NET_BH);
+       }
        return 0;
 }
 
@@ -87,6 +94,7 @@ static void syncppp_status(struct device *dev, unsigned short status)
                sppp_open(dev);
        } else  {
                /* Line went down */
+               dev->tbusy = 1;
                sppp_close(dev);
        }
        comx_status(dev, status);
index baedc359edb2f4b654c015820bd07e04c3d5143b..83a376ecf129fcbd28e849ae48a6086145c138d2 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Device driver framework for the COMX line of synchronous serial boards
  * 
  * for Linux kernel 2.2.X
  * Version 0.83 (99/07/15):
  *             - reset line_status when interface is down
  *
+ * Version 0.84 (99/12/01):
+ *             - comx_status should not check for IFF_UP (to report
+ *               line status from dev->open())
  */
 
-#define VERSION "0.82"
+#define VERSION "0.84"
 
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kmod.h>
 #endif
 
-#ifndef CONFIG_PROC_FS
-#error For now, COMX really needs the /proc filesystem
-#endif
-
 #include "comx.h"
 #include "syncppp.h"
 
@@ -321,12 +320,10 @@ void comx_status(struct device *dev, int status)
        }
 #endif
 
-       if (dev->flags & IFF_UP) {
-               printk(KERN_NOTICE "Interface %s: modem status %s, line protocol %s\n",
+       printk(KERN_NOTICE "Interface %s: modem status %s, line protocol %s\n",
                    dev->name, status & LINE_UP ? "UP" : "DOWN", 
                    status & PROTO_LOOP ? "LOOP" : status & PROTO_UP ? 
                    "UP" : "DOWN");
-       }
        
        ch->line_status = status;
 }
index 5749c3471dd4d7e85085003e41718948be0f4671..15230dc1f435df835e94e24bad0f8a8dd2987c9b 100644 (file)
@@ -20,6 +20,7 @@
 #define        HICOMX_IO_EXTENT        16
 
 #define COMX_MAX_TX_SIZE       1600
+#define COMX_MAX_RX_SIZE       2048
 
 #define COMX_JAIL_OFFSET       0xffff
 #define COMX_JAIL_VALUE                0xfe
index 5e89f10cf7c3177f9c0d28597144cde3ce0a7aa9..3341e03062a2e1f931d2829d293994e82142bdc9 100644 (file)
@@ -1,6 +1,6 @@
 /* drivers/net/eepro100.c: An Intel i82557-559 Ethernet driver for Linux. */
 /*
-   NOTICE: this version tested with kernels 1.3.72 and later only!
+   NOTICE: this version of the driver is supposed to work with 2.2 kernels.
        Written 1996-1999 by Donald Becker.
 
        This software may be used and distributed according to the terms
        There is a Majordomo mailing list based at
                linux-eepro100@cesdis.gsfc.nasa.gov
        
-       This driver also contains updates by Andrey Savochkin and others.
-       For this specific driver variant please use linux-kernel for 
-       bug reports.
-
+       The driver also contains updates by different kernel developers.
+       This driver clone is maintained by Andrey V. Savochkin <saw@saw.sw.com.sg>.
+       Please use this email address and linux-kernel mailing list for bug reports.
 */
 
 static const char *version =
 "eepro100.c:v1.09j-t 9/29/99 Donald Becker http://cesdis.gsfc.nasa.gov/linux/drivers/eepro100.html\n"
-"eepro100.c: $Revision: 1.20 $ 1999/12/29 Modified by Andrey V. Savochkin <saw@msu.ru>\n";
+"eepro100.c: $Revision: 1.20.2.3 $ 2000/03/02 Modified by Andrey V. Savochkin <saw@saw.sw.com.sg> and others\n";
 
 /* A few user-configurable values that apply to all boards.
    First set is undocumented and spelled per Intel recommendations. */
@@ -589,7 +588,7 @@ int eepro100_init(void)
                        if (check_region(ioaddr, 32))
                                continue;
                } else if ((ioaddr = (long)ioremap(pciaddr & ~0xfUL, 0x1000)) == 0) {
-                       printk(KERN_INFO "Failed to map PCI address %#x.\n",
+                       printk(KERN_INFO "Failed to map PCI address %#lx.\n",
                                   pciaddr);
                        continue;
                }
@@ -2159,9 +2158,8 @@ cleanup_module(void)
        while (root_speedo_dev) {
                struct speedo_private *sp = (void *)root_speedo_dev->priv;
                unregister_netdev(root_speedo_dev);
-#ifdef USE_IO
                release_region(root_speedo_dev->base_addr, SPEEDO3_TOTAL_SIZE);
-#else
+#ifndef USE_IO
                iounmap((char *)root_speedo_dev->base_addr);
 #endif
 #if defined(HAS_PCI_NETIF)
index 91cd040bc255f699961d85f379dae7d0c3131cc9..7dacd42096da322262913e6c8c251e5b245daf12 100644 (file)
        Center of Excellence in Space Data and Information Sciences
           Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
 
-       Fixing alignment problem with 1.3.* kernel and some minor changes
-       by Andrey V. Savochkin, 1996.
-
-       Problems or questions may be send to Donald Becker (see above) or to
-       Andrey Savochkin -- saw@shade.msu.ru or
-               Laboratory of Computation Methods, 
-               Department of Mathematics and Mechanics,
-               Moscow State University,
-               Leninskye Gory, Moscow 119899
-
-       But I should to inform you that I'm not an expert in the LANCE card
-       and it may occurs that you will receive no answer on your mail
-       to Donald Becker. I didn't receive any answer on all my letters
-       to him. Who knows why... But may be you are more lucky?  ;->
-                                                          SAW
-
+       Andrey V. Savochkin:
+       - alignment problem with 1.3.* kernel and some minor changes.
        Thomas Bogendoerfer (tsbogend@bigbug.franken.de):
        - added support for Linux/Alpha, but removed most of it, because
         it worked only for the PCI chip. 
diff --git a/drivers/net/lanstreamer.c b/drivers/net/lanstreamer.c
new file mode 100644 (file)
index 0000000..bd0c3fd
--- /dev/null
@@ -0,0 +1,1792 @@
+/*
+ *   lanstreamer.c -- driver for the IBM Auto LANStreamer PCI Adapter
+ *
+ *  Written By: Mike Sullivan, IBM Corporation
+ *
+ *  Copyright (C) 1999 IBM Corporation
+ *
+ *  Linux driver for IBM PCI tokenring cards based on the LanStreamer MPC
+ *  chipset. 
+ *
+ *  This driver is based on the olympic driver for IBM PCI TokenRing cards (Pit/Pit-Phy/Olympic
+ *  chipsets) written  by:
+ *      1999 Peter De Schrijver All Rights Reserved
+ *     1999 Mike Phillips (phillim@amtrak.com)
+ *
+ *  Base Driver Skeleton:
+ *      Written 1993-94 by Donald Becker.
+ *
+ *      Copyright 1993 United States Government as represented by the
+ *      Director, National Security Agency.
+ *
+ * This program is free software; you can redistribute it and/or modify      
+ * it under the terms of the GNU General Public License as published by      
+ * the Free Software Foundation; either version 2 of the License, or         
+ * (at your option) any later version.                                       
+ *                                                                           
+ * This program is distributed in the hope that it will be useful,           
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of            
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             
+ * GNU General Public License for more details.                              
+ *                                                                           
+ * NO WARRANTY                                                               
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR        
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT      
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,      
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is    
+ * solely responsible for determining the appropriateness of using and       
+ * distributing the Program and assumes all risks associated with its        
+ * exercise of rights under this Agreement, including but not limited to     
+ * the risks and costs of program errors, damage to or loss of data,         
+ * programs or equipment, and unavailability or interruption of operations.  
+ *                                                                           
+ * DISCLAIMER OF LIABILITY                                                   
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY   
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL        
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND   
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR     
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE    
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED  
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES             
+ *                                                                           
+ * You should have received a copy of the GNU General Public License         
+ * along with this program; if not, write to the Free Software               
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ *                                                                           
+ * 
+ *  12/10/99 - Alpha Release 0.1.0
+ *            First release to the public
+ *  03/03/00 - Merged to kernel, indented -kr -i8 -bri0, fixed some missing
+ *             malloc free checks, reviewed code. <alan@redhat.com>
+ *  
+ *  To Do:
+ *
+ *  1) Test Network Monitor Mode
+ *  2) Add auto reset logic on adapter errors
+ *  3) Test with varying options
+ *
+ *  If Problems do Occur
+ *  Most problems can be rectified by either closing and opening the interface
+ *  (ifconfig down and up) or rmmod and insmod'ing the driver (a bit difficult
+ *  if compiled into the kernel).
+ */
+
+/* Change STREAMER_DEBUG to 1 to get verbose, and I mean really verbose, messages */
+
+#define STREAMER_DEBUG 0
+#define STREAMER_DEBUG_PACKETS 0
+
+/* Change STREAMER_NETWORK_MONITOR to receive mac frames through the arb channel.
+ * Will also create a /proc/net/streamer_tr entry if proc_fs is compiled into the
+ * kernel.
+ * Intended to be used to create a ring-error reporting network module 
+ * i.e. it will give you the source address of beaconers on the ring 
+ */
+
+#define STREAMER_NETWORK_MONITOR 0
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/timer.h>
+#include <linux/in.h>
+#include <linux/ioport.h>
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+#include <linux/ptrace.h>
+#include <linux/skbuff.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/netdevice.h>
+#include <linux/trdevice.h>
+#include <linux/stddef.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <net/checksum.h>
+
+#include <asm/io.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+
+#include "lanstreamer.h"
+
+/* I've got to put some intelligence into the version number so that Peter and I know
+ * which version of the code somebody has got. 
+ * Version Number = a.b.c.d  where a.b.c is the level of code and d is the latest author.
+ * So 0.0.1.pds = Peter, 0.0.1.mlp = Mike
+ * 
+ * Official releases will only have an a.b.c version number format.
+ */
+
+static char *version = "LanStreamer.c v0.1.0 12/10/99 - Mike Sullivan";
+
+static char *open_maj_error[] = {
+       "No error", "Lobe Media Test", "Physical Insertion",
+       "Address Verification", "Neighbor Notification (Ring Poll)",
+       "Request Parameters", "FDX Registration Request",
+       "FDX Lobe Media Test", "FDX Duplicate Address Check",
+       "Unknown stage"
+};
+
+static char *open_min_error[] = {
+       "No error", "Function Failure", "Signal Lost", "Wire Fault",
+       "Ring Speed Mismatch", "Timeout", "Ring Failure", "Ring Beaconing",
+       "Duplicate Node Address", "Request Parameters", "Remove Received",
+       "Reserved", "Reserved", "No Monitor Detected for RPL",
+       "Monitor Contention failer for RPL", "FDX Protocol Error"
+};
+
+/* Module paramters */
+
+/* Ring Speed 0,4,16
+ * 0 = Autosense         
+ * 4,16 = Selected speed only, no autosense
+ * This allows the card to be the first on the ring
+ * and become the active monitor.
+ *
+ * WARNING: Some hubs will allow you to insert
+ * at the wrong speed
+ */
+
+static int ringspeed[STREAMER_MAX_ADAPTERS] = { 0, };
+
+MODULE_PARM(ringspeed, "1-" __MODULE_STRING(STREAMER_MAX_ADAPTERS) "i");
+
+/* Packet buffer size */
+
+static int pkt_buf_sz[STREAMER_MAX_ADAPTERS] = { 0, };
+
+MODULE_PARM(pkt_buf_sz, "1-" __MODULE_STRING(STREAMER_MAX_ADAPTERS) "i");
+
+/* Message Level */
+
+static int message_level[STREAMER_MAX_ADAPTERS] = { 1, };
+
+MODULE_PARM(message_level,
+           "1-" __MODULE_STRING(STREAMER_MAX_ADAPTERS) "i");
+
+static int streamer_scan(struct device *dev);
+static int streamer_init(struct device *dev);
+static int streamer_open(struct device *dev);
+static int streamer_xmit(struct sk_buff *skb, struct device *dev);
+static int streamer_close(struct device *dev);
+static void streamer_set_rx_mode(struct device *dev);
+static void streamer_interrupt(int irq, void *dev_id,
+                              struct pt_regs *regs);
+static struct net_device_stats *streamer_get_stats(struct device *dev);
+static int streamer_set_mac_address(struct device *dev, void *addr);
+static void streamer_arb_cmd(struct device *dev);
+static int streamer_change_mtu(struct device *dev, int mtu);
+static void streamer_srb_bh(struct device *dev);
+static void streamer_asb_bh(struct device *dev);
+#if STREAMER_NETWORK_MONITOR
+#ifdef CONFIG_PROC_FS
+static int sprintf_info(char *buffer, struct device *dev);
+#endif
+#endif
+
+int __init streamer_probe(struct device *dev)
+{
+       int cards_found;
+
+       cards_found = streamer_scan(dev);
+       return cards_found ? 0 : -ENODEV;
+}
+
+static int __init streamer_scan(struct device *dev)
+{
+       struct pci_dev *pci_device = NULL;
+       struct streamer_private *streamer_priv;
+       int card_no = 0;
+       if (pci_present()) 
+       {
+               while ((pci_device = pci_find_device(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_TR, pci_device))) 
+               {
+                       pci_set_master(pci_device);
+
+                       /* Check to see if io has been allocated, if so, we've already done this card,
+                          so continue on the card discovery loop  */
+
+                       if (check_region(pci_device->base_address[0] & (~3), STREAMER_IO_SPACE)) 
+                       {
+                               card_no++;
+                               continue;
+                       }
+
+                       streamer_priv = kmalloc(sizeof(struct streamer_private), GFP_KERNEL);
+                       if(streamer_priv==NULL)
+                       {
+                               printk(KERN_ERR "lanstreamer: out of memory.\n");
+                               break;
+                       }
+                       memset(streamer_priv, 0, sizeof(struct streamer_private));
+#ifndef MODULE
+                       dev = init_trdev(dev, 0);
+                       if(dev==NULL)
+                       {
+                               kfree(streamer_priv);
+                               printk(KERN_ERR "lanstreamer: out of memory.\n");
+                               break;
+                       }
+#endif
+                       dev->priv = (void *) streamer_priv;
+#if STREAMER_DEBUG
+                       printk("pci_device: %p, dev:%p, dev->priv: %p\n",
+                              pci_device, dev, dev->priv);
+#endif
+                       dev->irq = pci_device->irq;
+                       dev->base_addr = pci_device->base_address[0] & (~3);
+                       dev->init = &streamer_init;
+                       streamer_priv->streamer_mmio = ioremap(pci_device->base_address[1], 256);
+
+                       if ((pkt_buf_sz[card_no] < 100) || (pkt_buf_sz[card_no] > 18000))
+                               streamer_priv->pkt_buf_sz = PKT_BUF_SZ;
+                       else
+                               streamer_priv->pkt_buf_sz = pkt_buf_sz[card_no];
+
+                       streamer_priv->streamer_ring_speed = ringspeed[card_no];
+                       streamer_priv->streamer_message_level = message_level[card_no];
+                       streamer_priv->streamer_multicast_set = 0;
+
+                       if (streamer_init(dev) == -1) {
+                               unregister_netdevice(dev);
+                               kfree(dev->priv);
+                               return 0;
+                       }
+
+                       dev->open = &streamer_open;
+                       dev->hard_start_xmit = &streamer_xmit;
+                       dev->change_mtu = &streamer_change_mtu;
+
+                       dev->stop = &streamer_close;
+                       dev->do_ioctl = NULL;
+                       dev->set_multicast_list = &streamer_set_rx_mode;
+                       dev->get_stats = &streamer_get_stats;
+                       dev->set_mac_address = &streamer_set_mac_address;
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+
+static int __init streamer_init(struct device *dev)
+{
+       struct streamer_private *streamer_priv;
+       __u8 *streamer_mmio;
+       unsigned long t;
+       unsigned int uaa_addr;
+       struct sk_buff *skb = 0;
+       __u16 misr;
+
+       streamer_priv = (struct streamer_private *) dev->priv;
+       streamer_mmio = streamer_priv->streamer_mmio;
+
+       printk("%s \n", version);
+       printk(KERN_INFO "%s: IBM PCI tokenring card. I/O at %hx, MMIO at %p, using irq %d\n",
+                       dev->name, (unsigned int) dev->base_addr,
+                       streamer_priv->streamer_mmio, dev->irq);
+
+       request_region(dev->base_addr, STREAMER_IO_SPACE, "streamer");
+       writew(readw(streamer_mmio + BCTL) | BCTL_SOFTRESET, streamer_mmio + BCTL);
+       t = jiffies;
+       /* Hold soft reset bit for a while */
+       current->state = TASK_UNINTERRUPTIBLE;
+       schedule_timeout(HZ);
+       
+       writew(readw(streamer_mmio + BCTL) & ~BCTL_SOFTRESET,
+              streamer_mmio + BCTL);
+
+#if STREAMER_DEBUG
+       printk("BCTL: %x\n", readw(streamer_mmio + BCTL));
+       printk("GPR: %x\n", readw(streamer_mmio + GPR));
+       printk("SISRMASK: %x\n", readw(streamer_mmio + SISR_MASK));
+#endif
+
+       if (streamer_priv->streamer_ring_speed == 0) {  /* Autosense */
+               writew(readw(streamer_mmio + GPR) | GPR_AUTOSENSE,
+                      streamer_mmio + GPR);
+               if (streamer_priv->streamer_message_level)
+                       printk(KERN_INFO "%s: Ringspeed autosense mode on\n",
+                              dev->name);
+       } else if (streamer_priv->streamer_ring_speed == 16) {
+               if (streamer_priv->streamer_message_level)
+                       printk(KERN_INFO "%s: Trying to open at 16 Mbps as requested\n",
+                              dev->name);
+               writew(GPR_16MBPS, streamer_mmio + GPR);
+       } else if (streamer_priv->streamer_ring_speed == 4) {
+               if (streamer_priv->streamer_message_level)
+                       printk(KERN_INFO "%s: Trying to open at 4 Mbps as requested\n",
+                              dev->name);
+               writew(0, streamer_mmio + GPR);
+       }
+
+       skb = dev_alloc_skb(streamer_priv->pkt_buf_sz);
+       if (!skb) {
+               printk(KERN_INFO "%s: skb allocation for diagnostics failed...proceeding\n",
+                      dev->name);
+       } else {
+               streamer_priv->streamer_rx_ring[0].forward = 0;
+               streamer_priv->streamer_rx_ring[0].status = 0;
+               streamer_priv->streamer_rx_ring[0].buffer = virt_to_bus(skb->data);
+               streamer_priv->streamer_rx_ring[0].framelen_buflen = 512;       /* streamer_priv->pkt_buf_sz; */
+               writel(virt_to_bus(&streamer_priv->streamer_rx_ring[0]), streamer_mmio + RXBDA);
+       }
+
+#if STREAMER_DEBUG
+       printk("GPR = %x\n", readw(streamer_mmio + GPR));
+#endif
+       /* start solo init */
+       writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
+
+       while (!((readw(streamer_mmio + SISR)) & SISR_SRB_REPLY)) {
+               current->state = TASK_INTERRUPTIBLE;
+               schedule_timeout(HZ/10);
+               if (jiffies - t > 40 * HZ) {
+                       printk(KERN_ERR
+                              "IBM PCI tokenring card not responding\n");
+                       release_region(dev->base_addr, STREAMER_IO_SPACE);
+                       return -1;
+               }
+       }
+       writew(~SISR_SRB_REPLY, streamer_mmio + SISR_RUM);
+       misr = readw(streamer_mmio + MISR_RUM);
+       writew(~misr, streamer_mmio + MISR_RUM);
+
+       if (skb)
+               dev_kfree_skb(skb);     /* release skb used for diagnostics */
+
+#if STREAMER_DEBUG
+       printk("LAPWWO: %x, LAPA: %x LAPE:  %x\n",
+              readw(streamer_mmio + LAPWWO), readw(streamer_mmio + LAPA),
+              readw(streamer_mmio + LAPE));
+#endif
+
+#if STREAMER_DEBUG
+       {
+               int i;
+               writew(readw(streamer_mmio + LAPWWO),
+                      streamer_mmio + LAPA);
+               printk("initialization response srb dump: ");
+               for (i = 0; i < 10; i++)
+                       printk("%x:",
+                              ntohs(readw(streamer_mmio + LAPDINC)));
+               printk("\n");
+       }
+#endif
+
+       writew(readw(streamer_mmio + LAPWWO) + 6, streamer_mmio + LAPA);
+       if (readw(streamer_mmio + LAPD)) {
+               printk(KERN_INFO "tokenring card intialization failed. errorcode : %x\n",
+                      readw(streamer_mmio + LAPD));
+               release_region(dev->base_addr, STREAMER_IO_SPACE);
+               return -1;
+       }
+
+       writew(readw(streamer_mmio + LAPWWO) + 8, streamer_mmio + LAPA);
+       uaa_addr = ntohs(readw(streamer_mmio + LAPDINC));
+       readw(streamer_mmio + LAPDINC); /* skip over Level.Addr field */
+       streamer_priv->streamer_addr_table_addr = ntohs(readw(streamer_mmio + LAPDINC));
+       streamer_priv->streamer_parms_addr = ntohs(readw(streamer_mmio + LAPDINC));
+
+#if STREAMER_DEBUG
+       printk("UAA resides at %x\n", uaa_addr);
+#endif
+
+       /* setup uaa area for access with LAPD */
+       writew(uaa_addr, streamer_mmio + LAPA);
+
+       /* setup uaa area for access with LAPD */
+       {
+               int i;
+               __u16 addr;
+               writew(uaa_addr, streamer_mmio + LAPA);
+               for (i = 0; i < 6; i += 2) {
+                       addr = readw(streamer_mmio + LAPDINC);
+                       dev->dev_addr[i] = addr & 0xff;
+                       dev->dev_addr[i + 1] = (addr >> 8) & 0xff;
+               }
+#if STREAMER_DEBUG
+               printk("Adapter address: ");
+               for (i = 0; i < 6; i++) {
+                       printk("%02x:", dev->dev_addr[i]);
+               }
+               printk("\n");
+#endif
+       }
+       return 0;
+}
+
+static int streamer_open(struct device *dev)
+{
+       struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       unsigned long flags;
+       char open_error[255];
+       int i, open_finished = 1;
+       __u16 srb_word;
+       __u16 srb_open;
+
+
+       if (request_irq(dev->irq, &streamer_interrupt, SA_SHIRQ, "streamer", dev)) {
+               return -EAGAIN;
+       }
+#if STREAMER_DEBUG
+       printk("BMCTL: %x\n", readw(streamer_mmio + BMCTL_SUM));
+       printk("pending ints: %x\n", readw(streamer_mmio + SISR));
+#endif
+
+       writew(SISR_MI | SISR_SRB_REPLY, streamer_mmio + SISR_MASK);    /* more ints later, doesn't stop arb cmd interrupt */
+       writew(LISR_LIE, streamer_mmio + LISR); /* more ints later */
+
+       /* adapter is closed, so SRB is pointed to by LAPWWO */
+       writew(readw(streamer_mmio + LAPWWO), streamer_mmio + LAPA);
+
+#if STREAMER_DEBUG
+       printk("LAPWWO: %x, LAPA: %x\n", readw(streamer_mmio + LAPWWO),
+              readw(streamer_mmio + LAPA));
+       printk("LAPE: %x\n", readw(streamer_mmio + LAPE));
+       printk("SISR Mask = %04x\n", readw(streamer_mmio + SISR_MASK));
+#endif
+       do {
+               int i;
+
+               save_flags(flags);
+               cli();
+               for (i = 0; i < SRB_COMMAND_SIZE; i += 2) {
+                       writew(0, streamer_mmio + LAPDINC);
+               }
+
+               writew(readw(streamer_mmio + LAPWWO), streamer_mmio + LAPA);
+               writew(SRB_OPEN_ADAPTER, streamer_mmio + LAPDINC);      /* open */
+               writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
+
+               writew(readw(streamer_mmio + LAPWWO) + 8, streamer_mmio + LAPA);
+#if STREAMER_NETWORK_MONITOR
+               /* If Network Monitor, instruct card to copy MAC frames through the ARB */
+               writew(ntohs(OPEN_ADAPTER_ENABLE_FDX | OPEN_ADAPTER_PASS_ADC_MAC | OPEN_ADAPTER_PASS_ATT_MAC | OPEN_ADAPTER_PASS_BEACON), streamer_mmio + LAPDINC);     /* offset 8 word contains open options */
+#else
+               writew(ntohs(OPEN_ADAPTER_ENABLE_FDX), streamer_mmio + LAPDINC);        /* Offset 8 word contains Open.Options */
+#endif
+
+               if (streamer_priv->streamer_laa[0]) {
+                       writew(readw(streamer_mmio + LAPWWO) + 12, streamer_mmio + LAPA);
+                       writew(((__u16 *) (streamer_priv->streamer_laa))[0], streamer_mmio + LAPDINC);  /* offset 12 word */
+                       writew(((__u16 *) (streamer_priv->streamer_laa))[2], streamer_mmio + LAPDINC);  /* offset 14 word */
+                       writew(((__u16 *) (streamer_priv->streamer_laa))[4], streamer_mmio + LAPDINC);  /* offset 16 word */
+                       memcpy(dev->dev_addr, streamer_priv->streamer_laa, dev->addr_len);
+               }
+
+               /* save off srb open offset */
+               srb_open = readw(streamer_mmio + LAPWWO);
+#if STREAMER_DEBUG
+               writew(readw(streamer_mmio + LAPWWO),
+                      streamer_mmio + LAPA);
+               printk("srb open request: \n");
+               for (i = 0; i < 16; i++) {
+                       printk("%x:", ntohs(readw(streamer_mmio + LAPDINC)));
+               }
+               printk("\n");
+#endif
+
+               streamer_priv->srb_queued = 1;
+
+               /* signal solo that SRB command has been issued */
+               writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+
+               while (streamer_priv->srb_queued) {
+                       interruptible_sleep_on_timeout(&streamer_priv->srb_wait, 5 * HZ);
+                       if (signal_pending(current)) {
+                               printk(KERN_WARNING "%s: SRB timed out.\n", dev->name);
+                               printk(KERN_WARNING "SISR=%x MISR=%x, LISR=%x\n",
+                                      readw(streamer_mmio + SISR),
+                                      readw(streamer_mmio + MISR_RUM),
+                                      readw(streamer_mmio + LISR));
+                               streamer_priv->srb_queued = 0;
+                               break;
+                       }
+               }
+               restore_flags(flags);
+
+#if STREAMER_DEBUG
+               printk("SISR_MASK: %x\n", readw(streamer_mmio + SISR_MASK));
+               printk("srb open response:\n");
+               writew(srb_open, streamer_mmio + LAPA);
+               for (i = 0; i < 10; i++) {
+                       printk("%x:",
+                              ntohs(readw(streamer_mmio + LAPDINC)));
+               }
+#endif
+
+               /* If we get the same return response as we set, the interrupt wasn't raised and the open
+                * timed out.
+                */
+               writew(srb_open + 2, streamer_mmio + LAPA);
+               srb_word = readw(streamer_mmio + LAPD) & 0xFF;
+               if (srb_word == STREAMER_CLEAR_RET_CODE) {
+                       printk(KERN_WARNING "%s: Adapter Open time out or error.\n",
+                              dev->name);
+                       return -EIO;
+               }
+
+               if (srb_word != 0) {
+                       if (srb_word == 0x07) {
+                               if (!streamer_priv->streamer_ring_speed && open_finished) {     /* Autosense , first time around */
+                                       printk(KERN_WARNING "%s: Retrying at different ring speed \n",
+                                              dev->name);
+                                       open_finished = 0;
+                               } else {
+                                       __u16 error_code;
+
+                                       writew(srb_open + 6, streamer_mmio + LAPA);
+                                       error_code = ntohs(readw(streamer_mmio + LAPD));
+                                       strcpy(open_error, open_maj_error[(error_code & 0xf0) >> 4]);
+                                       strcat(open_error, " - ");
+                                       strcat(open_error, open_min_error[(error_code & 0x0f)]);
+
+                                       if (!streamer_priv->streamer_ring_speed
+                                           && ((error_code & 0x0f) == 0x0d)) 
+                                       {
+                                               printk(KERN_WARNING "%s: Tried to autosense ring speed with no monitors present\n", dev->name);
+                                               printk(KERN_WARNING "%s: Please try again with a specified ring speed \n", dev->name);
+                                               free_irq(dev->irq, dev);
+                                               return -EIO;
+                                       }
+
+                                       printk(KERN_WARNING "%s: %s\n",
+                                              dev->name, open_error);
+                                       free_irq(dev->irq, dev);
+                                       return -EIO;
+
+                               }       /* if autosense && open_finished */
+                       } else {
+                               printk(KERN_WARNING "%s: Bad OPEN response: %x\n",
+                                      dev->name, srb_word);
+                               free_irq(dev->irq, dev);
+                               return -EIO;
+                       }
+               } else
+                       open_finished = 1;
+       } while (!(open_finished));     /* Will only loop if ring speed mismatch re-open attempted && autosense is on */
+
+       writew(srb_open + 18, streamer_mmio + LAPA);
+       srb_word = readw(streamer_mmio + LAPD) & 0xFF;
+       if (srb_word & (1 << 3))
+               if (streamer_priv->streamer_message_level)
+                       printk(KERN_INFO "%s: Opened in FDX Mode\n", dev->name);
+
+       if (srb_word & 1)
+               streamer_priv->streamer_ring_speed = 16;
+       else
+               streamer_priv->streamer_ring_speed = 4;
+
+       if (streamer_priv->streamer_message_level)
+               printk(KERN_INFO "%s: Opened in %d Mbps mode\n", 
+                       dev->name,
+                       streamer_priv->streamer_ring_speed);
+
+       writew(srb_open + 8, streamer_mmio + LAPA);
+       streamer_priv->asb = ntohs(readw(streamer_mmio + LAPDINC));
+       streamer_priv->srb = ntohs(readw(streamer_mmio + LAPDINC));
+       streamer_priv->arb = ntohs(readw(streamer_mmio + LAPDINC));
+       readw(streamer_mmio + LAPDINC); /* offset 14 word is rsvd */
+       streamer_priv->trb = ntohs(readw(streamer_mmio + LAPDINC));
+
+       streamer_priv->streamer_receive_options = 0x00;
+       streamer_priv->streamer_copy_all_options = 0;
+
+       /* setup rx ring */
+       /* enable rx channel */
+       writew(~BMCTL_RX_DIS, streamer_mmio + BMCTL_RUM);
+
+       /* setup rx descriptors */
+       for (i = 0; i < STREAMER_RX_RING_SIZE; i++) {
+               struct sk_buff *skb;
+
+               skb = dev_alloc_skb(streamer_priv->pkt_buf_sz);
+               if (skb == NULL)
+                       break;
+
+               skb->dev = dev;
+
+               streamer_priv->streamer_rx_ring[i].forward = virt_to_bus(&streamer_priv->streamer_rx_ring[i + 1]);
+               streamer_priv->streamer_rx_ring[i].status = 0;
+               streamer_priv->streamer_rx_ring[i].buffer = virt_to_bus(skb->data);
+               streamer_priv->streamer_rx_ring[i].framelen_buflen = streamer_priv->pkt_buf_sz;
+               streamer_priv->rx_ring_skb[i] = skb;
+       }
+       streamer_priv->streamer_rx_ring[STREAMER_RX_RING_SIZE - 1].forward =
+                               virt_to_bus(&streamer_priv->streamer_rx_ring[0]);
+
+       if (i == 0) {
+               printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers. Adapter disabled\n", dev->name);
+               free_irq(dev->irq, dev);
+               return -EIO;
+       }
+
+       streamer_priv->rx_ring_last_received = STREAMER_RX_RING_SIZE - 1;       /* last processed rx status */
+
+       writel(virt_to_bus(&streamer_priv->streamer_rx_ring[0]), streamer_mmio + RXBDA);
+       writel(virt_to_bus(&streamer_priv->streamer_rx_ring[STREAMER_RX_RING_SIZE - 1]), streamer_mmio + RXLBDA);
+
+       /* set bus master interrupt event mask */
+       writew(MISR_RX_NOBUF | MISR_RX_EOF, streamer_mmio + MISR_MASK);
+
+
+       /* setup tx ring */
+       writew(~BMCTL_TX2_DIS, streamer_mmio + BMCTL_RUM);      /* Enables TX channel 2 */
+       for (i = 0; i < STREAMER_TX_RING_SIZE; i++) {
+               streamer_priv->streamer_tx_ring[i].forward = virt_to_bus(&streamer_priv->streamer_tx_ring[i + 1]);
+               streamer_priv->streamer_tx_ring[i].status = 0;
+               streamer_priv->streamer_tx_ring[i].bufcnt_framelen = 0;
+               streamer_priv->streamer_tx_ring[i].buffer = 0;
+               streamer_priv->streamer_tx_ring[i].buflen = 0;
+       }
+       streamer_priv->streamer_tx_ring[STREAMER_TX_RING_SIZE - 1].forward =
+                                       virt_to_bus(&streamer_priv->streamer_tx_ring[0]);;
+
+       streamer_priv->free_tx_ring_entries = STREAMER_TX_RING_SIZE;
+       streamer_priv->tx_ring_free = 0;        /* next entry in tx ring to use */
+       streamer_priv->tx_ring_last_status = STREAMER_TX_RING_SIZE - 1;
+
+       /* set Busmaster interrupt event mask (handle receives on interrupt only */
+       writew(MISR_TX2_EOF | MISR_RX_NOBUF | MISR_RX_EOF, streamer_mmio + MISR_MASK);
+       /* set system event interrupt mask */
+       writew(SISR_ADAPTER_CHECK | SISR_ARB_CMD | SISR_TRB_REPLY | SISR_ASB_FREE, streamer_mmio + SISR_MASK_SUM);
+
+#if STREAMER_DEBUG
+       printk("BMCTL: %x\n", readw(streamer_mmio + BMCTL_SUM));
+       printk("SISR MASK: %x\n", readw(streamer_mmio + SISR_MASK));
+#endif
+
+#if STREAMER_NETWORK_MONITOR
+
+       writew(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA);
+       printk("%s: Node Address: %04x:%04x:%04x\n", dev->name,
+               ntohs(readw(streamer_mmio + LAPDINC)),
+               ntohs(readw(streamer_mmio + LAPDINC)),
+               ntohs(readw(streamer_mmio + LAPDINC)));
+       readw(streamer_mmio + LAPDINC);
+       readw(streamer_mmio + LAPDINC);
+       printk("%s: Functional Address: %04x:%04x\n", dev->name,
+               ntohs(readw(streamer_mmio + LAPDINC)),
+               ntohs(readw(streamer_mmio + LAPDINC)));
+
+       writew(streamer_priv->streamer_parms_addr + 4,
+               streamer_mmio + LAPA);
+       printk("%s: NAUN Address: %04x:%04x:%04x\n", dev->name,
+               ntohs(readw(streamer_mmio + LAPDINC)),
+               ntohs(readw(streamer_mmio + LAPDINC)),
+               ntohs(readw(streamer_mmio + LAPDINC)));
+#endif
+
+       dev->start = 1;
+       dev->interrupt = 0;
+       dev->tbusy = 0;
+
+       MOD_INC_USE_COUNT;
+       return 0;
+}
+
+/*
+ *     When we enter the rx routine we do not know how many frames have been 
+ *     queued on the rx channel.  Therefore we start at the next rx status
+ *     position and travel around the receive ring until we have completed
+ *     all the frames.
+ *
+ *     This means that we may process the frame before we receive the end
+ *     of frame interrupt. This is why we always test the status instead
+ *     of blindly processing the next frame.
+ *     
+ */
+static void streamer_rx(struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       struct streamer_rx_desc *rx_desc;
+       int rx_ring_last_received, length, frame_length, buffer_cnt = 0;
+       struct sk_buff *skb, *skb2;
+
+       /* setup the next rx descriptor to be received */
+       rx_desc = &streamer_priv->streamer_rx_ring[(streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1)];
+       rx_ring_last_received = streamer_priv->rx_ring_last_received;
+
+       while (rx_desc->status & 0x01000000) {  /* While processed descriptors are available */
+               if (rx_ring_last_received != streamer_priv->rx_ring_last_received) 
+               {
+                       printk(KERN_WARNING "RX Error 1 rx_ring_last_received not the same %x %x\n",
+                               rx_ring_last_received, streamer_priv->rx_ring_last_received);
+               }
+               streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1);
+               rx_ring_last_received = streamer_priv->rx_ring_last_received;
+
+               length = rx_desc->framelen_buflen & 0xffff;     /* buffer length */
+               frame_length = (rx_desc->framelen_buflen >> 16) & 0xffff;
+
+               if (rx_desc->status & 0x7E830000) {     /* errors */
+                       if (streamer_priv->streamer_message_level) {
+                               printk(KERN_WARNING "%s: Rx Error %x \n",
+                                      dev->name, rx_desc->status);
+                       }
+               } else {        /* received without errors */
+                       if (rx_desc->status & 0x80000000) {     /* frame complete */
+                               buffer_cnt = 1;
+                               skb = dev_alloc_skb(streamer_priv->pkt_buf_sz);
+                       } else {
+                               skb = dev_alloc_skb(frame_length);
+                       }
+
+                       if (skb == NULL) 
+                       {
+                               printk(KERN_WARNING "%s: Not enough memory to copy packet to upper layers. \n", dev->name);
+                               streamer_priv->streamer_stats.rx_dropped++;
+                       } else {        /* we allocated an skb OK */
+                               skb->dev = dev;
+
+                               if (buffer_cnt == 1) {
+                                       skb2 = streamer_priv->rx_ring_skb[rx_ring_last_received];
+#if STREAMER_DEBUG_PACKETS
+                                       {
+                                               int i;
+                                               printk("streamer_rx packet print: skb->data2 %p  skb->head %p\n", skb2->data, skb2->head);
+                                               for (i = 0; i < frame_length; i++) 
+                                               {
+                                                       printk("%x:", skb2->data[i]);
+                                                       if (((i + 1) % 16) == 0)
+                                                               printk("\n");
+                                               }
+                                               printk("\n");
+                                       }
+#endif
+                                       skb_put(skb2, length);
+                                       skb2->protocol = tr_type_trans(skb2, dev);
+                                       /* recycle this descriptor */
+                                       streamer_priv->streamer_rx_ring[rx_ring_last_received].status = 0;
+                                       streamer_priv->streamer_rx_ring[rx_ring_last_received].framelen_buflen = streamer_priv->pkt_buf_sz;
+                                       streamer_priv->streamer_rx_ring[rx_ring_last_received].buffer = virt_to_bus(skb->data);
+                                       streamer_priv-> rx_ring_skb[rx_ring_last_received] = skb;
+                                       /* place recycled descriptor back on the adapter */
+                                       writel(virt_to_bus(&streamer_priv->streamer_rx_ring[rx_ring_last_received]),streamer_mmio + RXLBDA);
+                                       /* pass the received skb up to the protocol */
+                                       netif_rx(skb2);
+                               } else {
+                                       do {    /* Walk the buffers */
+                                               memcpy(skb_put(skb, length),bus_to_virt(rx_desc->buffer), length);      /* copy this fragment */
+                                               streamer_priv->streamer_rx_ring[rx_ring_last_received].status = 0;
+                                               streamer_priv->streamer_rx_ring[rx_ring_last_received].framelen_buflen = streamer_priv->pkt_buf_sz;
+                                               streamer_priv->streamer_rx_ring[rx_ring_last_received].buffer = virt_to_bus(skb->data);
+                                               /* give descriptor back to the adapter */
+                                               writel(virt_to_bus(&streamer_priv->streamer_rx_ring[rx_ring_last_received]), streamer_mmio + RXLBDA);
+
+                                               if (rx_desc->status & 0x80000000)
+                                                       break;  /* this descriptor completes the frame */
+
+                                               /* else get the next pending descriptor */
+                                               if (rx_ring_last_received!= streamer_priv->rx_ring_last_received)
+                                               {
+                                                       printk("RX Error rx_ring_last_received not the same %x %x\n",
+                                                               rx_ring_last_received,
+                                                               streamer_priv->rx_ring_last_received);
+                                               }
+                                               rx_desc = &streamer_priv->streamer_rx_ring[(streamer_priv->rx_ring_last_received+1) & (STREAMER_RX_RING_SIZE-1)];
+
+                                               length = rx_desc->framelen_buflen & 0xffff;     /* buffer length */
+                                               streamer_priv->rx_ring_last_received =  (streamer_priv->rx_ring_last_received+1) & (STREAMER_RX_RING_SIZE - 1);
+                                               rx_ring_last_received = streamer_priv->rx_ring_last_received;
+                                       } while (1);
+
+                                       skb->protocol = tr_type_trans(skb, dev);
+                                       /* send up to the protocol */
+                                       netif_rx(skb);
+                               }
+                               streamer_priv->streamer_stats.rx_packets++;
+                               streamer_priv->streamer_stats.rx_bytes += length;
+                       }       /* if skb == null */
+               }               /* end received without errors */
+
+               /* try the next one */
+               rx_desc = &streamer_priv->streamer_rx_ring[(rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1)];
+       }                       /* end for all completed rx descriptors */
+}
+
+static void streamer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+       struct device *dev = (struct device *) dev_id;
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       __u16 sisr;
+       __u16 misr;
+       __u16 sisrmask;
+
+       sisrmask = SISR_MI;
+       writew(~sisrmask, streamer_mmio + SISR_MASK_RUM);
+       sisr = readw(streamer_mmio + SISR);
+       writew(~sisr, streamer_mmio + SISR_RUM);
+       misr = readw(streamer_mmio + MISR_RUM);
+       writew(~misr, streamer_mmio + MISR_RUM);
+
+       if (!sisr) {            /* Interrupt isn't for us */
+               return;
+       }
+
+       if (dev->interrupt)
+               printk(KERN_WARNING "%s: Re-entering interrupt \n", dev->name);
+
+       dev->interrupt = 1;
+
+       if ((sisr & (SISR_SRB_REPLY | SISR_ADAPTER_CHECK | SISR_ASB_FREE | SISR_ARB_CMD | SISR_TRB_REPLY))
+           || (misr & (MISR_TX2_EOF | MISR_RX_NOBUF | MISR_RX_EOF))) {
+               if (sisr & SISR_SRB_REPLY) {
+                       if (streamer_priv->srb_queued == 1) {
+                               wake_up_interruptible(&streamer_priv->srb_wait);
+                       } else if (streamer_priv->srb_queued == 2) {
+                               streamer_srb_bh(dev);
+                       }
+                       streamer_priv->srb_queued = 0;
+               }
+               /* SISR_SRB_REPLY */
+               if (misr & MISR_TX2_EOF) {
+                       while (streamer_priv->streamer_tx_ring[(streamer_priv->tx_ring_last_status + 1) & (STREAMER_TX_RING_SIZE - 1)].status) 
+                       {
+                               streamer_priv->tx_ring_last_status = (streamer_priv->tx_ring_last_status + 1) & (STREAMER_TX_RING_SIZE - 1);
+                               streamer_priv->free_tx_ring_entries++;
+                               streamer_priv->streamer_stats.tx_bytes += streamer_priv->tx_ring_skb[streamer_priv->tx_ring_last_status]->len;
+                               streamer_priv->streamer_stats.tx_packets++;
+                               dev_kfree_skb(streamer_priv->tx_ring_skb[streamer_priv->tx_ring_last_status]);
+                               streamer_priv-> streamer_tx_ring[streamer_priv->tx_ring_last_status].buffer = 0xdeadbeef;
+                               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].status = 0;
+                               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].bufcnt_framelen = 0;
+                               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_last_status].buflen = 0;
+                       }
+                       if (dev->tbusy) {
+                               dev->tbusy = 0;
+                               mark_bh(NET_BH);
+                       }
+               }
+
+               if (misr & MISR_RX_EOF) {
+                       streamer_rx(dev);
+               }
+               /* MISR_RX_EOF */
+               if (sisr & SISR_ADAPTER_CHECK) {
+                       printk(KERN_WARNING "%s: Adapter Check Interrupt Raised, 8 bytes of information follow:\n", dev->name);
+                       writel(readl(streamer_mmio + LAPWWO), streamer_mmio + LAPA);
+                       printk(KERN_WARNING "%s: Words %x:%x:%x:%x:\n",
+                              dev->name, readw(streamer_mmio + LAPDINC),
+                              readw(streamer_mmio + LAPDINC),
+                              readw(streamer_mmio + LAPDINC),
+                              readw(streamer_mmio + LAPDINC));
+                       dev->interrupt = 0;
+                       free_irq(dev->irq, dev);
+               }
+
+               /* SISR_ADAPTER_CHECK */
+               if (sisr & SISR_ASB_FREE) {
+                       /* Wake up anything that is waiting for the asb response */
+                       if (streamer_priv->asb_queued) {
+                               streamer_asb_bh(dev);
+                       }
+               }
+               /* SISR_ASB_FREE */
+               if (sisr & SISR_ARB_CMD) {
+                       streamer_arb_cmd(dev);
+               }
+               /* SISR_ARB_CMD */
+               if (sisr & SISR_TRB_REPLY) {
+                       /* Wake up anything that is waiting for the trb response */
+                       if (streamer_priv->trb_queued) {
+                               wake_up_interruptible(&streamer_priv->
+                                                     trb_wait);
+                       }
+                       streamer_priv->trb_queued = 0;
+               }
+               /* SISR_TRB_REPLY */
+               if (misr & MISR_RX_NOBUF) {
+                       /* According to the documentation, we don't have to do anything, but trapping it keeps it out of
+                          /var/log/messages.  */
+               }               /* SISR_RX_NOBUF */
+       } else {
+               printk(KERN_WARNING "%s: Unexpected interrupt: %x\n",
+                      dev->name, sisr);
+               printk(KERN_WARNING "%s: SISR_MASK: %x\n", dev->name,
+                      readw(streamer_mmio + SISR_MASK));
+       }                       /* One if the interrupts we want */
+
+       dev->interrupt = 0;
+       writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
+}
+
+
+static int streamer_xmit(struct sk_buff *skb, struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+
+       if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) {
+               return 1;
+       }
+
+       if (streamer_priv->free_tx_ring_entries) {
+               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].status = 0;
+               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].bufcnt_framelen = 0x00010000 | skb->len;
+               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].buffer = virt_to_bus(skb->data);
+               streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].buflen = skb->len;
+               streamer_priv->tx_ring_skb[streamer_priv->tx_ring_free] = skb;
+               streamer_priv->free_tx_ring_entries--;
+#if STREAMER_DEBUG_PACKETS
+               {
+                       int i;
+                       printk("streamer_xmit packet print:\n");
+                       for (i = 0; i < skb->len; i++) {
+                               printk("%x:", skb->data[i]);
+                               if (((i + 1) % 16) == 0)
+                                       printk("\n");
+                       }
+                       printk("\n");
+               }
+#endif
+
+               writel(virt_to_bus (&streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free]),streamer_mmio + TX2LFDA);
+
+               streamer_priv->tx_ring_free = (streamer_priv->tx_ring_free + 1) & (STREAMER_TX_RING_SIZE - 1);
+               dev->tbusy = 0;
+               return 0;
+       } else {
+               return 1;
+       }
+}
+
+
+static int streamer_close(struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       unsigned long flags;
+       int i;
+
+       writew(streamer_priv->srb, streamer_mmio + LAPA);
+       writew(SRB_CLOSE_ADAPTER, streamer_mmio + LAPDINC);
+       writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
+
+       save_flags(flags);
+       cli();
+
+       streamer_priv->srb_queued = 1;
+       writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+
+       while (streamer_priv->srb_queued) 
+       {
+               interruptible_sleep_on_timeout(&streamer_priv->srb_wait,
+                                              jiffies + 60 * HZ);
+               if (signal_pending(current)) 
+               {
+                       printk(KERN_WARNING "%s: SRB timed out.\n", dev->name);
+                       printk(KERN_WARNING "SISR=%x MISR=%x LISR=%x\n",
+                              readw(streamer_mmio + SISR),
+                              readw(streamer_mmio + MISR_RUM),
+                              readw(streamer_mmio + LISR));
+                       streamer_priv->srb_queued = 0;
+                       break;
+               }
+       }
+
+       restore_flags(flags);
+       streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1);
+
+       for (i = 0; i < STREAMER_RX_RING_SIZE; i++) {
+               dev_kfree_skb(streamer_priv->rx_ring_skb[streamer_priv->rx_ring_last_received]);
+               streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1);
+       }
+
+       /* reset tx/rx fifo's and busmaster logic */
+
+       /* TBD. Add graceful way to reset the LLC channel without doing a soft reset. 
+          writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
+          udelay(1);
+          writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL);
+        */
+
+#if STREAMER_DEBUG
+       writew(streamer_priv->srb, streamer_mmio + LAPA);
+       printk("srb): ");
+       for (i = 0; i < 2; i++) {
+               printk("%x ", htons(readw(streamer_mmio + LAPDINC)));
+       }
+       printk("\n");
+#endif
+       dev->start = 0;
+       free_irq(dev->irq, dev);
+
+       MOD_DEC_USE_COUNT;
+       return 0;
+}
+
+static void streamer_set_rx_mode(struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       __u8 options = 0, set_mc_list = 0;
+       __u16 ata1, ata2;
+       struct dev_mc_list *dmi;
+
+       writel(streamer_priv->srb, streamer_mmio + LAPA);
+       options = streamer_priv->streamer_copy_all_options;
+
+       if (dev->flags & IFF_PROMISC)
+               options |= (3 << 5);    /* All LLC and MAC frames, all through the main rx channel */
+       else
+               options &= ~(3 << 5);
+
+       if (dev->mc_count) {
+               set_mc_list = 1;
+       }
+
+       /* Only issue the srb if there is a change in options */
+
+       if ((options ^ streamer_priv->streamer_copy_all_options)) 
+       {
+               /* Now to issue the srb command to alter the copy.all.options */
+
+               writew(SRB_MODIFY_RECEIVE_OPTIONS,
+                      streamer_mmio + LAPDINC);
+               writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
+               writew(streamer_priv->streamer_receive_options | (options << 8), streamer_mmio + LAPDINC);
+               writew(0x414a, streamer_mmio + LAPDINC);
+               writew(0x454d, streamer_mmio + LAPDINC);
+               writew(0x2053, streamer_mmio + LAPDINC);
+               writew(0x2020, streamer_mmio + LAPDINC);
+
+               streamer_priv->srb_queued = 2;  /* Can't sleep, use srb_bh */
+
+               writel(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+
+               streamer_priv->streamer_copy_all_options = options;
+               return;
+       }
+
+       if (set_mc_list ^ streamer_priv->streamer_multicast_set)
+       {       /* Multicast options have changed */
+               dmi = dev->mc_list;
+
+               writel(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA);
+               ata1 = readw(streamer_mmio + LAPDINC);
+               ata2 = readw(streamer_mmio + LAPD);
+
+               writel(streamer_priv->srb, streamer_mmio + LAPA);
+
+               if (set_mc_list) 
+               {
+                       /* Turn multicast on */
+
+                       /* RFC 1469 Says we must support using the functional address C0 00 00 04 00 00
+                        * We do this with a set functional address mask.
+                        */
+
+                       if (!(ata1 & 0x0400)) { /* need to set functional mask */
+                               writew(SRB_SET_FUNC_ADDRESS, streamer_mmio + LAPDINC);
+                               writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
+                               writew(0, streamer_mmio + LAPDINC);
+                               writew(ata1 | 0x0400, streamer_mmio + LAPDINC);
+                               writew(ata2, streamer_mmio + LAPD);
+
+                               streamer_priv->srb_queued = 2;
+                               writel(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+
+                               streamer_priv->streamer_multicast_set = 1;
+                       }
+
+               } else {        /* Turn multicast off */
+
+                       if ((ata1 & 0x0400)) {  /* Hmmm, need to reset the functional mask */
+                               writew(SRB_SET_FUNC_ADDRESS, streamer_mmio + LAPDINC);
+                               writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
+                               writew(0, streamer_mmio + LAPDINC);
+                               writew(ata1 & ~0x0400, streamer_mmio + LAPDINC);
+                               writew(ata2, streamer_mmio + LAPD);
+
+                               streamer_priv->srb_queued = 2;
+                               writel(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+
+                               streamer_priv->streamer_multicast_set = 0;
+                       }
+               }
+
+       }
+}
+
+static void streamer_srb_bh(struct device *dev)
+{
+       struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       __u16 srb_word;
+
+       writew(streamer_priv->srb, streamer_mmio + LAPA);
+       srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+
+       switch (srb_word) {
+
+               /* SRB_MODIFY_RECEIVE_OPTIONS i.e. set_multicast_list options (promiscuous) 
+                * At some point we should do something if we get an error, such as
+                * resetting the IFF_PROMISC flag in dev
+                */
+
+       case SRB_MODIFY_RECEIVE_OPTIONS:
+               srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+               switch (srb_word) {
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized srb command\n", dev->name);
+                       break;
+               case 0x04:
+                       printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
+                       break;
+               default:
+                       if (streamer_priv->streamer_message_level)
+                               printk(KERN_WARNING "%s: Receive Options Modified to %x,%x\n",
+                                      dev->name,
+                                      streamer_priv->streamer_copy_all_options,
+                                      streamer_priv->streamer_receive_options);
+                       break;
+               }               /* switch srb[2] */
+               break;
+
+
+               /* SRB_SET_GROUP_ADDRESS - Multicast group setting 
+                */
+       case SRB_SET_GROUP_ADDRESS:
+               srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+               switch (srb_word) {
+               case 0x00:
+                       streamer_priv->streamer_multicast_set = 1;
+                       break;
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name);
+                       break;
+               case 0x04:
+                       printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
+                       break;
+               case 0x3c:
+                       printk(KERN_WARNING "%s: Group/Functional address indicator bits not set correctly\n", dev->name);
+                       break;
+               case 0x3e:      /* If we ever implement individual multicast addresses, will need to deal with this */
+                       printk(KERN_WARNING "%s: Group address registers full\n", dev->name);
+                       break;
+               case 0x55:
+                       printk(KERN_INFO "%s: Group Address already set.\n", dev->name);
+                       break;
+               default:
+                       break;
+               }               /* switch srb[2] */
+               break;
+
+
+               /* SRB_RESET_GROUP_ADDRESS - Remove a multicast address from group list
+                */
+       case SRB_RESET_GROUP_ADDRESS:
+               srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+               switch (srb_word) {
+               case 0x00:
+                       streamer_priv->streamer_multicast_set = 0;
+                       break;
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
+                       break;
+               case 0x04:
+                       printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
+                       break;
+               case 0x39:      /* Must deal with this if individual multicast addresses used */
+                       printk(KERN_INFO "%s: Group address not found \n", dev->name);
+                       break;
+               default:
+                       break;
+               }               /* switch srb[2] */
+               break;
+
+
+               /* SRB_SET_FUNC_ADDRESS - Called by the set_rx_mode 
+                */
+
+       case SRB_SET_FUNC_ADDRESS:
+               srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+               switch (srb_word) {
+               case 0x00:
+                       if (streamer_priv->streamer_message_level)
+                               printk(KERN_INFO "%s: Functional Address Mask Set \n", dev->name);
+                       break;
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
+                       break;
+               case 0x04:
+                       printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
+                       break;
+               default:
+                       break;
+               }               /* switch srb[2] */
+               break;
+
+               /* SRB_READ_LOG - Read and reset the adapter error counters
+                */
+
+       case SRB_READ_LOG:
+               srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+               switch (srb_word) {
+               case 0x00:
+                       {
+                               int i;
+                               if (streamer_priv->streamer_message_level)
+                                       printk(KERN_INFO "%s: Read Log command complete\n", dev->name);
+                               printk("Read Log statistics: ");
+                               writew(streamer_priv->srb + 6,
+                                      streamer_mmio + LAPA);
+                               for (i = 0; i < 5; i++) {
+                                       printk("%x:", ntohs(readw(streamer_mmio + LAPDINC)));
+                               }
+                               printk("\n");
+                       }
+                       break;
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
+                       break;
+               case 0x04:
+                       printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
+                       break;
+
+               }               /* switch srb[2] */
+               break;
+
+               /* SRB_READ_SR_COUNTERS - Read and reset the source routing bridge related counters */
+
+       case SRB_READ_SR_COUNTERS:
+               srb_word = readw(streamer_mmio + LAPDINC) & 0xFF;
+               switch (srb_word) {
+               case 0x00:
+                       if (streamer_priv->streamer_message_level)
+                               printk(KERN_INFO "%s: Read Source Routing Counters issued\n", dev->name);
+                       break;
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name);
+                       break;
+               case 0x04:
+                       printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
+                       break;
+               default:
+                       break;
+               }               /* switch srb[2] */
+               break;
+
+       default:
+               printk(KERN_WARNING "%s: Unrecognized srb bh return value.\n", dev->name);
+               break;
+       }                       /* switch srb[0] */
+}
+
+static struct net_device_stats *streamer_get_stats(struct device *dev)
+{
+       struct streamer_private *streamer_priv;
+       streamer_priv = (struct streamer_private *) dev->priv;
+       return (struct net_device_stats *) &streamer_priv->streamer_stats;
+}
+
+static int streamer_set_mac_address(struct device *dev, void *addr)
+{
+       struct sockaddr *saddr = addr;
+       struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
+
+       if (dev->start) {
+               printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name);
+               return -EIO;
+       }
+
+       memcpy(streamer_priv->streamer_laa, saddr->sa_data, dev->addr_len);
+
+       if (streamer_priv->streamer_message_level) {
+               printk(KERN_INFO "%s: MAC/LAA Set to  = %x.%x.%x.%x.%x.%x\n",
+                      dev->name, streamer_priv->streamer_laa[0],
+                      streamer_priv->streamer_laa[1],
+                      streamer_priv->streamer_laa[2],
+                      streamer_priv->streamer_laa[3],
+                      streamer_priv->streamer_laa[4],
+                      streamer_priv->streamer_laa[5]);
+       }
+       return 0;
+}
+
+static void streamer_arb_cmd(struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       __u8 header_len;
+       __u16 frame_len, buffer_len;
+       struct sk_buff *mac_frame;
+       __u8 frame_data[256];
+       __u16 buff_off;
+       __u16 lan_status = 0, lan_status_diff;  /* Initialize to stop compiler warning */
+       __u8 fdx_prot_error;
+       __u16 next_ptr;
+       __u16 arb_word;
+
+#if STREAMER_NETWORK_MONITOR
+       struct trh_hdr *mac_hdr;
+#endif
+
+       writew(streamer_priv->arb, streamer_mmio + LAPA);
+       arb_word = readw(streamer_mmio + LAPD) & 0xFF;
+
+       if (arb_word == ARB_RECEIVE_DATA) {     /* Receive.data, MAC frames */
+               writew(streamer_priv->arb + 6, streamer_mmio + LAPA);
+               streamer_priv->mac_rx_buffer = buff_off = ntohs(readw(streamer_mmio + LAPDINC));
+               header_len = readw(streamer_mmio + LAPDINC) & 0xff;     /* 802.5 Token-Ring Header Length */
+               frame_len = ntohs(readw(streamer_mmio + LAPDINC));
+
+#if STREAMER_DEBUG
+               {
+                       int i;
+                       __u16 next;
+                       __u8 status;
+                       __u16 len;
+
+                       writew(ntohs(buff_off), streamer_mmio + LAPA);  /*setup window to frame data */
+                       next = ntohs(readw(streamer_mmio + LAPDINC));
+                       status =
+                           ntohs(readw(streamer_mmio + LAPDINC)) & 0xff;
+                       len = ntohs(readw(streamer_mmio + LAPDINC));
+
+                       /* print out 1st 14 bytes of frame data */
+                       for (i = 0; i < 7; i++) {
+                               printk("Loc %d = %04x\n", i,
+                                      ntohs(readw
+                                            (streamer_mmio + LAPDINC)));
+                       }
+
+                       printk("next %04x, fs %02x, len %04x \n", next,
+                              status, len);
+               }
+#endif
+               mac_frame = dev_alloc_skb(frame_len);
+
+               /* Walk the buffer chain, creating the frame */
+
+               do {
+                       int i;
+                       __u16 rx_word;
+
+                       writew(ntohs(buff_off), streamer_mmio + LAPA);  /* setup window to frame data */
+                       next_ptr = ntohs(readw(streamer_mmio + LAPDINC));
+                       readw(streamer_mmio + LAPDINC); /* read thru status word */
+                       buffer_len = ntohs(readw(streamer_mmio + LAPDINC));
+
+                       if (buffer_len > 256)
+                               break;
+
+                       i = 0;
+                       while (i < buffer_len) {
+                               rx_word = readw(streamer_mmio + LAPDINC);
+                               frame_data[i] = rx_word & 0xff;
+                               frame_data[i + 1] = (rx_word >> 8) & 0xff;
+                               i += 2;
+                       }
+
+                       memcpy_fromio(skb_put(mac_frame, buffer_len),
+                                     frame_data, buffer_len);
+               } while (next_ptr && (buff_off = next_ptr));
+
+#if STREAMER_NETWORK_MONITOR
+               printk(KERN_WARNING "%s: Received MAC Frame, details: \n",
+                      dev->name);
+               mac_hdr = (struct trh_hdr *) mac_frame->data;
+               printk(KERN_WARNING
+                      "%s: MAC Frame Dest. Addr: %02x:%02x:%02x:%02x:%02x:%02x \n",
+                      dev->name, mac_hdr->daddr[0], mac_hdr->daddr[1],
+                      mac_hdr->daddr[2], mac_hdr->daddr[3],
+                      mac_hdr->daddr[4], mac_hdr->daddr[5]);
+               printk(KERN_WARNING
+                      "%s: MAC Frame Srce. Addr: %02x:%02x:%02x:%02x:%02x:%02x \n",
+                      dev->name, mac_hdr->saddr[0], mac_hdr->saddr[1],
+                      mac_hdr->saddr[2], mac_hdr->saddr[3],
+                      mac_hdr->saddr[4], mac_hdr->saddr[5]);
+#endif
+               mac_frame->dev = dev;
+               mac_frame->protocol = tr_type_trans(mac_frame, dev);
+               netif_rx(mac_frame);
+
+               /* Now tell the card we have dealt with the received frame */
+
+               /* Set LISR Bit 1 */
+               writel(LISR_ARB_FREE, streamer_priv->streamer_mmio + LISR_SUM);
+
+               /* Is the ASB free ? */
+
+               if (!(readl(streamer_priv->streamer_mmio + SISR) & SISR_ASB_FREE)) 
+               {
+                       streamer_priv->asb_queued = 1;
+                       writel(LISR_ASB_FREE_REQ, streamer_priv->streamer_mmio + LISR_SUM);
+                       return;
+                       /* Drop out and wait for the bottom half to be run */
+               }
+
+
+               writew(streamer_priv->asb, streamer_mmio + LAPA);
+               writew(ASB_RECEIVE_DATA, streamer_mmio + LAPDINC);      /* Receive data */
+               writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);       /* Necessary ?? */
+               writew(0, streamer_mmio + LAPDINC);
+               writew(ntohs(streamer_priv->mac_rx_buffer), streamer_mmio + LAPD);
+
+               writel(LISR_ASB_REPLY | LISR_ASB_FREE_REQ, streamer_priv->streamer_mmio + LISR_SUM);
+
+               streamer_priv->asb_queued = 2;
+               return;
+
+       } else if (arb_word == ARB_LAN_CHANGE_STATUS) { /* Lan.change.status */
+               writew(streamer_priv->arb + 6, streamer_mmio + LAPA);
+               lan_status = ntohs(readw(streamer_mmio + LAPDINC));
+               fdx_prot_error = readw(streamer_mmio + LAPD) & 0xFF;
+
+               /* Issue ARB Free */
+               writew(LISR_ARB_FREE, streamer_priv->streamer_mmio + LISR_SUM);
+
+               lan_status_diff = streamer_priv->streamer_lan_status ^ lan_status;
+
+               if (lan_status_diff & (LSC_LWF | LSC_ARW | LSC_FPE | LSC_RR)) 
+               {
+                       if (lan_status_diff & LSC_LWF)
+                               printk(KERN_WARNING "%s: Short circuit detected on the lobe\n", dev->name);
+                       if (lan_status_diff & LSC_ARW)
+                               printk(KERN_WARNING "%s: Auto removal error\n", dev->name);
+                       if (lan_status_diff & LSC_FPE)
+                               printk(KERN_WARNING "%s: FDX Protocol Error\n", dev->name);
+                       if (lan_status_diff & LSC_RR)
+                               printk(KERN_WARNING "%s: Force remove MAC frame received\n", dev->name);
+
+                       /* Adapter has been closed by the hardware */
+
+                       /* reset tx/rx fifo's and busmaster logic */
+
+                       /* @TBD. no llc reset on autostreamer writel(readl(streamer_mmio+BCTL)|(3<<13),streamer_mmio+BCTL);
+                          udelay(1);
+                          writel(readl(streamer_mmio+BCTL)&~(3<<13),streamer_mmio+BCTL); */
+                       dev->tbusy = 1;
+                       dev->interrupt = 1;
+                       dev->start = 0;
+                       free_irq(dev->irq, dev);
+
+                       printk(KERN_WARNING "%s: Adapter has been closed \n", dev->name);
+
+               }
+               /* If serious error */
+               if (streamer_priv->streamer_message_level) {
+                       if (lan_status_diff & LSC_SIG_LOSS)
+                               printk(KERN_WARNING "%s: No receive signal detected \n", dev->name);
+                       if (lan_status_diff & LSC_HARD_ERR) 
+                               printk(KERN_INFO "%s: Beaconing \n", dev->name);
+                       if (lan_status_diff & LSC_SOFT_ERR)
+                               printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame \n", dev->name);
+                       if (lan_status_diff & LSC_TRAN_BCN)
+                               printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n", dev->name);
+                       if (lan_status_diff & LSC_SS)
+                               printk(KERN_INFO "%s: Single Station on the ring \n", dev->name);
+                       if (lan_status_diff & LSC_RING_REC)
+                               printk(KERN_INFO "%s: Ring recovery ongoing\n", dev->name);
+                       if (lan_status_diff & LSC_FDX_MODE)
+                               printk(KERN_INFO "%s: Operating in FDX mode\n", dev->name);
+               }
+
+               if (lan_status_diff & LSC_CO) {
+                       if (streamer_priv->streamer_message_level)
+                               printk(KERN_INFO "%s: Counter Overflow \n", dev->name);
+
+                       /* Issue READ.LOG command */
+
+                       writew(streamer_priv->srb, streamer_mmio + LAPA);
+                       writew(SRB_READ_LOG, streamer_mmio + LAPDINC);
+                       writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);
+                       writew(0, streamer_mmio + LAPDINC);
+                       streamer_priv->srb_queued = 2;  /* Can't sleep, use srb_bh */
+
+                       writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+               }
+
+               if (lan_status_diff & LSC_SR_CO) {
+                       if (streamer_priv->streamer_message_level)
+                               printk(KERN_INFO "%s: Source routing counters overflow\n", dev->name);
+
+                       /* Issue a READ.SR.COUNTERS */
+                       writew(streamer_priv->srb, streamer_mmio + LAPA);
+                       writew(SRB_READ_SR_COUNTERS,
+                              streamer_mmio + LAPDINC);
+                       writew(STREAMER_CLEAR_RET_CODE,
+                              streamer_mmio + LAPDINC);
+                       streamer_priv->srb_queued = 2;  /* Can't sleep, use srb_bh */
+                       writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM);
+
+               }
+               streamer_priv->streamer_lan_status = lan_status;
+       } /* Lan.change.status */
+       else
+               printk(KERN_WARNING "%s: Unknown arb command \n", dev->name);
+}
+
+static void streamer_asb_bh(struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+
+       if (streamer_priv->asb_queued == 1) 
+       {
+               /* Dropped through the first time */
+
+               writew(streamer_priv->asb, streamer_mmio + LAPA);
+               writew(ASB_RECEIVE_DATA, streamer_mmio + LAPDINC);      /* Receive data */
+               writew(STREAMER_CLEAR_RET_CODE, streamer_mmio + LAPDINC);       /* Necessary ?? */
+               writew(0, streamer_mmio + LAPDINC);
+               writew(ntohs(streamer_priv->mac_rx_buffer), streamer_mmio + LAPD);
+
+               writel(LISR_ASB_REPLY | LISR_ASB_FREE_REQ, streamer_priv->streamer_mmio + LISR_SUM);
+               streamer_priv->asb_queued = 2;
+
+               return;
+       }
+
+       if (streamer_priv->asb_queued == 2) {
+               __u8 rc;
+               writew(streamer_priv->asb + 2, streamer_mmio + LAPA);
+               rc = readw(streamer_mmio + LAPD) & 0xff;
+               switch (rc) {
+               case 0x01:
+                       printk(KERN_WARNING "%s: Unrecognized command code \n", dev->name);
+                       break;
+               case 0x26:
+                       printk(KERN_WARNING "%s: Unrecognized buffer address \n", dev->name);
+                       break;
+               case 0xFF:
+                       /* Valid response, everything should be ok again */
+                       break;
+               default:
+                       printk(KERN_WARNING "%s: Invalid return code in asb\n", dev->name);
+                       break;
+               }
+       }
+       streamer_priv->asb_queued = 0;
+}
+
+static int streamer_change_mtu(struct device *dev, int mtu)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u16 max_mtu;
+
+       if (streamer_priv->streamer_ring_speed == 4)
+               max_mtu = 4500;
+       else
+               max_mtu = 18000;
+
+       if (mtu > max_mtu)
+               return -EINVAL;
+       if (mtu < 100)
+               return -EINVAL;
+
+       dev->mtu = mtu;
+       streamer_priv->pkt_buf_sz = mtu + TR_HLEN;
+
+       return 0;
+}
+
+#if STREAMER_NETWORK_MONITOR
+#ifdef CONFIG_PROC_FS
+static int streamer_proc_info(char *buffer, char **start, off_t offset,
+                             int length, int *eof, void *data)
+{
+       struct pci_dev *pci_device = NULL;
+       int len = 0;
+       off_t begin = 0;
+       off_t pos = 0;
+       int size;
+
+       struct device *dev;
+
+
+       size = sprintf(buffer, "IBM LanStreamer/MPC Chipset Token Ring Adapters\n");
+
+       pos += size;
+       len += size;
+
+       while ((pci_device = pci_find_device(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_TR, pci_device))) 
+       {
+
+               for (dev = dev_base; dev != NULL; dev = dev->next) 
+               {
+                       if (dev->base_addr == (pci_device->base_address[0] & (~3))) 
+                       {       /* Yep, a Streamer device */
+                               size = sprintf_info(buffer + len, dev);
+                               len += size;
+                               pos = begin + len;
+
+                               if (pos < offset) {
+                                       len = 0;
+                                       begin = pos;
+                               }
+                               if (pos > offset + length)
+                                       break;
+                       }       /* if */
+               }               /* for */
+       }                       /* While */
+
+       *start = buffer + (offset - begin);     /* Start of wanted data */
+       len -= (offset - begin);        /* Start slop */
+       if (len > length)
+               len = length;   /* Ending slop */
+       return len;
+}
+
+static int sprintf_info(char *buffer, struct device *dev)
+{
+       struct streamer_private *streamer_priv =
+           (struct streamer_private *) dev->priv;
+       __u8 *streamer_mmio = streamer_priv->streamer_mmio;
+       struct streamer_adapter_addr_table sat;
+       struct streamer_parameters_table spt;
+       int size = 0;
+       int i;
+
+       writew(streamer_priv->streamer_addr_table_addr, streamer_mmio + LAPA);
+       for (i = 0; i < 14; i += 2) {
+               __u16 io_word;
+               __u8 *datap = (__u8 *) & sat;
+               io_word = readw(streamer_mmio + LAPDINC);
+               datap[size] = io_word & 0xff;
+               datap[size + 1] = (io_word >> 8) & 0xff;
+       }
+       writew(streamer_priv->streamer_parms_addr, streamer_mmio + LAPA);
+       for (i = 0; i < 68; i += 2) {
+               __u16 io_word;
+               __u8 *datap = (__u8 *) & spt;
+               io_word = readw(streamer_mmio + LAPDINC);
+               datap[size] = io_word & 0xff;
+               datap[size + 1] = (io_word >> 8) & 0xff;
+       }
+
+
+       size = sprintf(buffer, "\n%6s: Adapter Address   : Node Address      : Functional Addr\n", dev->name);
+
+       size += sprintf(buffer + size,
+                   "%6s: %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x\n",
+                   dev->name, dev->dev_addr[0], dev->dev_addr[1],
+                   dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4],
+                   dev->dev_addr[5], sat.node_addr[0], sat.node_addr[1],
+                   sat.node_addr[2], sat.node_addr[3], sat.node_addr[4],
+                   sat.node_addr[5], sat.func_addr[0], sat.func_addr[1],
+                   sat.func_addr[2], sat.func_addr[3]);
+
+       size += sprintf(buffer + size, "\n%6s: Token Ring Parameters Table:\n", dev->name);
+
+       size += sprintf(buffer + size, "%6s: Physical Addr : Up Node Address   : Poll Address      : AccPri : Auth Src : Att Code :\n", dev->name);
+
+       size += sprintf(buffer + size,
+                   "%6s: %02x:%02x:%02x:%02x   : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x:%02x:%02x : %04x   : %04x     :  %04x    :\n",
+                   dev->name, spt.phys_addr[0], spt.phys_addr[1],
+                   spt.phys_addr[2], spt.phys_addr[3],
+                   spt.up_node_addr[0], spt.up_node_addr[1],
+                   spt.up_node_addr[2], spt.up_node_addr[3],
+                   spt.up_node_addr[4], spt.up_node_addr[4],
+                   spt.poll_addr[0], spt.poll_addr[1], spt.poll_addr[2],
+                   spt.poll_addr[3], spt.poll_addr[4], spt.poll_addr[5],
+                   ntohs(spt.acc_priority), ntohs(spt.auth_source_class),
+                   ntohs(spt.att_code));
+
+       size += sprintf(buffer + size, "%6s: Source Address    : Bcn T : Maj. V : Lan St : Lcl Rg : Mon Err : Frame Correl : \n", dev->name);
+
+       size += sprintf(buffer + size,
+                   "%6s: %02x:%02x:%02x:%02x:%02x:%02x : %04x  : %04x   : %04x   : %04x   : %04x    :     %04x     : \n",
+                   dev->name, spt.source_addr[0], spt.source_addr[1],
+                   spt.source_addr[2], spt.source_addr[3],
+                   spt.source_addr[4], spt.source_addr[5],
+                   ntohs(spt.beacon_type), ntohs(spt.major_vector),
+                   ntohs(spt.lan_status), ntohs(spt.local_ring),
+                   ntohs(spt.mon_error), ntohs(spt.frame_correl));
+
+       size += sprintf(buffer + size, "%6s: Beacon Details :  Tx  :  Rx  : NAUN Node Address : NAUN Node Phys : \n",
+                   dev->name);
+
+       size += sprintf(buffer + size,
+                   "%6s:                :  %02x  :  %02x  : %02x:%02x:%02x:%02x:%02x:%02x : %02x:%02x:%02x:%02x    : \n",
+                   dev->name, ntohs(spt.beacon_transmit),
+                   ntohs(spt.beacon_receive), spt.beacon_naun[0],
+                   spt.beacon_naun[1], spt.beacon_naun[2],
+                   spt.beacon_naun[3], spt.beacon_naun[4],
+                   spt.beacon_naun[5], spt.beacon_phys[0],
+                   spt.beacon_phys[1], spt.beacon_phys[2],
+                   spt.beacon_phys[3]);
+       return size;
+}
+#endif
+#endif
+
+#ifdef MODULE
+
+static struct device *dev_streamer[STREAMER_MAX_ADAPTERS];
+
+int init_module(void)
+{
+       int i;
+
+#if STREAMER_NETWORK_MONITOR
+#ifdef CONFIG_PROC_FS
+       struct proc_dir_entry *ent;
+
+       ent = create_proc_entry("net/streamer_tr", 0, 0);
+       ent->read_proc = &streamer_proc_info;
+#endif
+#endif
+       for (i = 0; (i < STREAMER_MAX_ADAPTERS); i++) 
+       {
+               dev_streamer[i] = NULL;
+               dev_streamer[i] = init_trdev(dev_streamer[i], 0);
+               if (dev_streamer[i] == NULL)
+                       return -ENOMEM;
+
+               dev_streamer[i]->init = &streamer_probe;
+
+               if (register_trdev(dev_streamer[i]) != 0) {
+                       kfree_s(dev_streamer[i], sizeof(struct device));
+                       dev_streamer[i] = NULL;
+                       if (i == 0) 
+                       {
+                               printk(KERN_INFO "Streamer: No IBM LanStreamer PCI Token Ring cards found in system.\n");
+                               return -EIO;
+                       } else {
+                               printk(KERN_INFO "Streamer: %d IBM LanStreamer PCI Token Ring card(s) found in system.\n", i);
+                               return 0;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+void cleanup_module(void)
+{
+       int i;
+
+       for (i = 0; i < STREAMER_MAX_ADAPTERS; i++)
+               if (dev_streamer[i]) {
+                       unregister_trdev(dev_streamer[i]);
+                       release_region(dev_streamer[i]->base_addr, STREAMER_IO_SPACE);
+                       kfree_s(dev_streamer[i]->priv, sizeof(struct streamer_private));
+                       kfree_s(dev_streamer[i], sizeof(struct device));
+                       dev_streamer[i] = NULL;
+               }
+#if STREAMER_NETWORK_MONITOR
+#ifdef CONFIG_PROC_FS
+       remove_proc_entry("net/streamer_tr", NULL);
+#endif
+#endif
+}
+#endif                         /* MODULE */
diff --git a/drivers/net/lanstreamer.h b/drivers/net/lanstreamer.h
new file mode 100644 (file)
index 0000000..f880333
--- /dev/null
@@ -0,0 +1,319 @@
+/*
+ *   lanstreamer.h -- driver for the IBM Auto LANStreamer PCI Adapter
+ *
+ *  Written By: Mike Sullivan, IBM Corporation
+ *
+ *  Copyright (C) 1999 IBM Corporation
+ *
+ *  Linux driver for IBM PCI tokenring cards based on the LanStreamer MPC
+ *  chipset. 
+ *
+ *  This driver is based on the olympic driver for IBM PCI TokenRing cards (Pit/Pit-Phy/Olympic
+ *  chipsets) written  by:
+ *      1999 Peter De Schrijver All Rights Reserved
+ *     1999 Mike Phillips (phillim@amtrak.com)
+ *
+ *  Base Driver Skeleton:
+ *      Written 1993-94 by Donald Becker.
+ *
+ *      Copyright 1993 United States Government as represented by the
+ *      Director, National Security Agency.
+ *
+ * This program is free software; you can redistribute it and/or modify      
+ * it under the terms of the GNU General Public License as published by      
+ * the Free Software Foundation; either version 2 of the License, or         
+ * (at your option) any later version.                                       
+ *                                                                           
+ * This program is distributed in the hope that it will be useful,           
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of            
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             
+ * GNU General Public License for more details.                              
+ *                                                                           
+ * NO WARRANTY                                                               
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR        
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT      
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,      
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is    
+ * solely responsible for determining the appropriateness of using and       
+ * distributing the Program and assumes all risks associated with its        
+ * exercise of rights under this Agreement, including but not limited to     
+ * the risks and costs of program errors, damage to or loss of data,         
+ * programs or equipment, and unavailability or interruption of operations.  
+ *                                                                           
+ * DISCLAIMER OF LIABILITY                                                   
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY   
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL        
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND   
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR     
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE    
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED  
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES             
+ *                                                                           
+ * You should have received a copy of the GNU General Public License         
+ * along with this program; if not, write to the Free Software               
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ *                                                                           
+ * 
+ *  12/10/99 - Alpha Release 0.1.0
+ *            First release to the public
+ *
+ */
+
+#define BCTL 0x60
+#define BCTL_SOFTRESET (1<<15)
+
+#define GPR 0x4a
+#define GPR_AUTOSENSE (1<<2)
+#define GPR_16MBPS (1<<3)
+
+#define LISR 0x10
+#define LISR_SUM 0x12
+#define LISR_RUM 0x14
+
+#define LISR_LIE (1<<15)
+#define LISR_SLIM (1<<13)
+#define LISR_SLI (1<<12)
+#define LISR_BPEI (1<<9)
+#define LISR_BPE (1<<8)
+#define LISR_SRB_CMD (1<<5)
+#define LISR_ASB_REPLY (1<<4)
+#define LISR_ASB_FREE_REQ (1<<2)
+#define LISR_ARB_FREE (1<<1)
+#define LISR_TRB_FRAME (1<<0)
+
+#define SISR 0x16
+#define SISR_SUM 0x18
+#define SISR_RUM 0x1A
+#define SISR_MASK 0x54
+#define SISR_MASK_SUM 0x56
+#define SISR_MASK_RUM 0x58
+
+#define SISR_MI (1<<15)
+#define SISR_TIMER (1<<11)
+#define SISR_LAP_PAR_ERR (1<<10)
+#define SISR_LAP_ACC_ERR (1<<9)
+#define SISR_PAR_ERR (1<<8)
+#define SISR_ADAPTER_CHECK (1<<6)
+#define SISR_SRB_REPLY (1<<5)
+#define SISR_ASB_FREE (1<<4)
+#define SISR_ARB_CMD (1<<3)
+#define SISR_TRB_REPLY (1<<2)
+
+#define MISR_RUM 0x5A
+#define MISR_MASK 0x5C
+#define MISR_MASK_RUM 0x5E
+
+#define MISR_TX2_IDLE (1<<15)
+#define MISR_TX2_NO_STATUS (1<<14)
+#define MISR_TX2_HALT (1<<13)
+#define MISR_TX2_EOF (1<<12)
+#define MISR_TX1_IDLE (1<<11)
+#define MISR_TX1_NO_STATUS (1<<10)
+#define MISR_TX1_HALT (1<<9)
+#define MISR_TX1_EOF (1<<8)
+#define MISR_RX_NOBUF (1<<5)
+#define MISR_RX_EOB (1<<4)
+#define MISR_RX_NO_STATUS (1<<2)
+#define MISR_RX_HALT (1<<1)
+#define MISR_RX_EOF (1<<0)
+
+#define LAPA 0x62
+#define LAPE 0x64
+#define LAPD 0x66
+#define LAPDINC 0x68
+#define LAPWWO 0x6A
+#define LAPWWC 0x6C
+#define LAPCTL 0x6E
+
+#define TIMER 0x4E4
+
+#define BMCTL_SUM 0x50
+#define BMCTL_RUM 0x52
+#define BMCTL_TX1_DIS (1<<14)
+#define BMCTL_TX2_DIS (1<<10)
+#define BMCTL_RX_DIS (1<<6)
+
+#define RXLBDA  0x90
+#define RXBDA   0x94
+#define RXSTAT  0x98
+#define RXDBA   0x9C
+
+#define TX1LFDA 0xA0
+#define TX1FDA  0xA4
+#define TX1STAT 0xA8
+#define TX1DBA  0xAC
+#define TX2LFDA 0xB0
+#define TX2FDA  0xB4
+#define TX2STAT 0xB8
+#define TX2DBA  0xBC
+
+#define STREAMER_IO_SPACE 256
+
+#define SRB_COMMAND_SIZE 50
+
+#define STREAMER_MAX_ADAPTERS 8        /* 0x08 __MODULE_STRING can't hand 0xnn */
+
+/* Defines for LAN STATUS CHANGE reports */
+#define LSC_SIG_LOSS 0x8000
+#define LSC_HARD_ERR 0x4000
+#define LSC_SOFT_ERR 0x2000
+#define LSC_TRAN_BCN 0x1000
+#define LSC_LWF      0x0800
+#define LSC_ARW      0x0400
+#define LSC_FPE      0x0200
+#define LSC_RR       0x0100
+#define LSC_CO       0x0080
+#define LSC_SS       0x0040
+#define LSC_RING_REC 0x0020
+#define LSC_SR_CO    0x0010
+#define LSC_FDX_MODE 0x0004
+
+/* Defines for OPEN ADAPTER command */
+
+#define OPEN_ADAPTER_EXT_WRAP (1<<15)
+#define OPEN_ADAPTER_DIS_HARDEE (1<<14)
+#define OPEN_ADAPTER_DIS_SOFTERR (1<<13)
+#define OPEN_ADAPTER_PASS_ADC_MAC (1<<12)
+#define OPEN_ADAPTER_PASS_ATT_MAC (1<<11)
+#define OPEN_ADAPTER_ENABLE_EC (1<<10)
+#define OPEN_ADAPTER_CONTENDER (1<<8)
+#define OPEN_ADAPTER_PASS_BEACON (1<<7)
+#define OPEN_ADAPTER_ENABLE_FDX (1<<6)
+#define OPEN_ADAPTER_ENABLE_RPL (1<<5)
+#define OPEN_ADAPTER_INHIBIT_ETR (1<<4)
+#define OPEN_ADAPTER_INTERNAL_WRAP (1<<3)
+
+
+/* Defines for SRB Commands */
+#define SRB_CLOSE_ADAPTER 0x04
+#define SRB_CONFIGURE_BRIDGE 0x0c
+#define SRB_CONFIGURE_HP_CHANNEL 0x13
+#define SRB_MODIFY_BRIDGE_PARMS 0x15
+#define SRB_MODIFY_OPEN_OPTIONS 0x01
+#define SRB_MODIFY_RECEIVE_OPTIONS 0x17
+#define SRB_NO_OPERATION 0x00
+#define SRB_OPEN_ADAPTER 0x03
+#define SRB_READ_LOG 0x08
+#define SRB_READ_SR_COUNTERS 0x16
+#define SRB_RESET_GROUP_ADDRESS 0x02
+#define SRB_RESET_TARGET_SEGMETN 0x14
+#define SRB_SAVE_CONFIGURATION 0x1b
+#define SRB_SET_BRIDGE_PARMS 0x09
+#define SRB_SET_FUNC_ADDRESS 0x07
+#define SRB_SET_GROUP_ADDRESS 0x06
+#define SRB_SET_TARGET_SEGMENT 0x05
+
+/* Clear return code */
+#define STREAMER_CLEAR_RET_CODE 0xfe
+
+/* ARB Commands */
+#define ARB_RECEIVE_DATA 0x81
+#define ARB_LAN_CHANGE_STATUS 0x84
+
+/* ASB Response commands */
+#define ASB_RECEIVE_DATA 0x81
+
+
+/* Streamer defaults for buffers */
+
+#define STREAMER_RX_RING_SIZE 16       /* should be a power of 2 */
+#define STREAMER_TX_RING_SIZE 8        /* should be a power of 2 */
+
+#define PKT_BUF_SZ 4096                /* Default packet size */
+
+/* Streamer data structures */
+
+struct streamer_tx_desc {
+       __u32 forward;
+       __u32 status;
+       __u32 bufcnt_framelen;
+       __u32 buffer;
+       __u32 buflen;
+       __u32 rsvd1;
+       __u32 rsvd2;
+       __u32 rsvd3;
+};
+
+struct streamer_rx_desc {
+       __u32 forward;
+       __u32 status;
+       __u32 buffer;
+       __u32 framelen_buflen;
+};
+
+struct mac_receive_buffer {
+       __u16 next;
+       __u8 padding;
+       __u8 frame_status;
+       __u16 buffer_length;
+       __u8 frame_data;
+};
+
+struct streamer_private {
+
+       __u16 srb;
+       __u16 trb;
+       __u16 arb;
+       __u16 asb;
+
+       __u8 *streamer_mmio;
+
+       volatile int srb_queued;        /* True if an SRB is still posted */
+       struct wait_queue *srb_wait;
+
+       volatile int asb_queued;        /* True if an ASB is posted */
+
+       volatile int trb_queued;        /* True if a TRB is posted */
+       struct wait_queue *trb_wait;
+
+       struct streamer_rx_desc streamer_rx_ring[STREAMER_RX_RING_SIZE];
+       struct streamer_tx_desc streamer_tx_ring[STREAMER_TX_RING_SIZE];
+       struct sk_buff *tx_ring_skb[STREAMER_TX_RING_SIZE],
+           *rx_ring_skb[STREAMER_RX_RING_SIZE];
+       int tx_ring_free, tx_ring_last_status, rx_ring_last_received,
+           free_tx_ring_entries;
+
+       struct net_device_stats streamer_stats;
+       __u16 streamer_lan_status;
+       __u8 streamer_ring_speed;
+       __u16 pkt_buf_sz;
+       __u8 streamer_receive_options, streamer_copy_all_options,
+           streamer_message_level;
+       __u8 streamer_multicast_set;
+       __u16 streamer_addr_table_addr, streamer_parms_addr;
+       __u16 mac_rx_buffer;
+       __u8 streamer_laa[6];
+};
+
+struct streamer_adapter_addr_table {
+
+       __u8 node_addr[6];
+       __u8 reserved[4];
+       __u8 func_addr[4];
+};
+
+struct streamer_parameters_table {
+
+       __u8 phys_addr[4];
+       __u8 up_node_addr[6];
+       __u8 up_phys_addr[4];
+       __u8 poll_addr[6];
+       __u16 reserved;
+       __u16 acc_priority;
+       __u16 auth_source_class;
+       __u16 att_code;
+       __u8 source_addr[6];
+       __u16 beacon_type;
+       __u16 major_vector;
+       __u16 lan_status;
+       __u16 soft_error_time;
+       __u16 reserved1;
+       __u16 local_ring;
+       __u16 mon_error;
+       __u16 beacon_transmit;
+       __u16 beacon_receive;
+       __u16 frame_correl;
+       __u8 beacon_naun[6];
+       __u32 reserved2;
+       __u8 beacon_phys[4];
+};
index 79b8ee0e10383d15f6a5b3c1f5be7523d36edbea..06ab0406e10d22f54ea2c24f1bf9b59f3b5efadc 100644 (file)
@@ -145,6 +145,8 @@ static void sppp_print_bytes (u8 *p, u16 len);
 
 static int debug = 0;
 
+MODULE_PARM(debug,"1i");
+
 /*
  *     Interface down stub
  */    
index a548e2ee6581247dffd55b84a3d8ffbeddf8b71a..8b13508090db1ddf105f0c8500e0797a75503dc8 100644 (file)
@@ -91,7 +91,7 @@ struct proc_dir_entry tw_scsi_proc_entry = {
 };
 
 /* Globals */
-char *tw_driver_version="0.4.001";
+char *tw_driver_version="1.0.000";
 TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
 int tw_device_extension_count = 0;
 
@@ -2053,6 +2053,11 @@ int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id)
        command_packet->status = 0;
        command_packet->flags = 0;
 
+        if ((srb->cmnd[0] == WRITE_6) || (srb->cmnd[0] == WRITE_10)) {
+         if ((srb->cmnd[1] & 0x8) || (srb->cmnd[1] & 0x10))
+           command_packet->flags = 1;
+        }
+
        if (srb->cmnd[0] == READ_6 || srb->cmnd[0] == WRITE_6) {
                lba = ((u32)srb->cmnd[1] << 16) | ((u32)srb->cmnd[2] << 8) | (u32)srb->cmnd[3];
                num_sectors = (u32)srb->cmnd[4];
index f18655b3fd1a28f63840e93ee7c77c68fa0091c5..3bb592e48c03492eae2ae6384a4ba7c3a686e3fe 100644 (file)
@@ -19,7 +19,7 @@ mainmenu_option next_comment
 comment 'SCSI low-level drivers'
 
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
-   dep_tristate '3Ware Hardware ATA-RAID support (EXPERIMENTAL)' CONFIG_BLK_DEV_3W_XXXX_RAID $CONFIG_SCSI
+   dep_tristate '3ware Hardware ATA-RAID support (EXPERIMENTAL)' CONFIG_BLK_DEV_3W_XXXX_RAID $CONFIG_SCSI
 fi
 dep_tristate '7000FASST SCSI support' CONFIG_SCSI_7000FASST $CONFIG_SCSI
 dep_tristate 'ACARD SCSI support' CONFIG_SCSI_ACARD $CONFIG_SCSI
index 6447d544028757c5fbfe7d973fbec19bfc9c6a90..e6d093c2f32da60d59e53d6d570de8247fa7bd60 100644 (file)
@@ -312,6 +312,7 @@ static struct dev_info device_list[] =
 {"TOSHIBA","CDROM","*", BLIST_ISROM},
 {"TOSHIBA","DVD-RAM SD-W1101","*", BLIST_GHOST},
 {"TOSHIBA","DVD-RAM SD-W1111","*", BLIST_GHOST},
+{"MegaRAID", "LD", "*", BLIST_FORCELUN},
 /*
  * Must be at end of list...
  */
index 31db348815ff33c288a3dcf63e725444926ae790..5fee0c18ae1a000bc211596b84d96b6646c1ea21 100644 (file)
@@ -569,7 +569,7 @@ pressure:
        /*
         * Try pruning the dcache to free up some dquots ...
         */
-       printk(KERN_DEBUG "get_empty_dquot: pruning %d\n", count);
+//     printk(KERN_DEBUG "get_empty_dquot: pruning %d\n", count);
        if (prune_dcache(0, 128))
        {
                free_inode_memory(count);
index 832b8d4626c9f221436c5840fc38bf27eac72a03..79347c2dc732396419374c0150e084f431501a90 100644 (file)
@@ -18,7 +18,7 @@ at http://cvs.linux.hr/
 Legend: those lines marked with '+' on the beggining of line indicates it
 passed all of my tests, and performed perfect in all of them.
 
-Current status (990202) - UMSDOS 0.85:
+Current status (000123) - UMSDOS 0.85g:
 
 (1) pure MSDOS (no --linux-.--- EMD file):
 
@@ -60,13 +60,13 @@ READ:
 
 WRITE:
 + create symlink               - works
-- create hardlink              - works
+- create hardlink              - works for same DIR (see notes)
 + create file                  - works
 + create special file          - works
 + write to file                        - works
 + rename file (same dir)       - works
 + rename file (dif. dir)       - works
-- rename hardlink (same dir)   -
++ rename hardlink (same dir)   - works
 - rename hardlink (dif. dir)   -
 + rename symlink (same dir)    - works
 + rename symlink (dif. dir)    - works
@@ -74,7 +74,7 @@ WRITE:
 + rename dir (dif. dir)                - works
 + delete file                  - works
 + notify_change (chown,perms)  - works
-+ delete hardlink              - works
+- delete hardlink              - works for same DIR (see notes)
 + mkdir                                - works
 + rmdir                        - works
 + umssyncing (many ioctls)     - works
index 6516fb57dd403418475a94e313cb82475a027eb4..1ed528ced153285cb1b0513db757a715d34f911d 100644 (file)
@@ -81,11 +81,11 @@ extern struct inode_operations umsdos_rdir_inode_operations;
 void check_inode (struct inode *inode)
 {
        if (inode) {
-               printk (KERN_DEBUG "*   inode is %lu (i_count=%d)",
-                        inode->i_ino, inode->i_count);
+               printk (KERN_DEBUG "*   inode is %lu (i_count=%d, pos=%lu)",
+                        inode->i_ino, inode->i_count, inode->u.umsdos_i.pos);
                check_sb (inode->i_sb, 'i');
                
-               if (inode->i_dentry.next) {     /* FIXME: does this work ? */
+               if (!list_empty(&inode->i_dentry)) {
                        printk (" (has i_dentry)");
                } else {
                        printk (" (NO i_dentry)");
index a780a95871a81223b12281e2df0ab007f4d6c500..2ec38cde30485c40a0a28fce7eaffc614282d741 100644 (file)
@@ -597,6 +597,13 @@ struct dentry *UMSDOS_lookup (struct inode *dir, struct dentry *dentry)
        return ret;
 }
 
+/*
+ * looks up REAL DOS filename and returns result dentry
+ *
+ * NOTE: since it is looked via UMSDOS_rlookup, it will not have i_patched,
+ * umsdos_i.pos and other EMD-related stuff ! Moreover, it will destroy them
+ * if such dentry was pre-existant.
+ */
 struct dentry *umsdos_covered(struct dentry *parent, char *name, int len)
 {
        struct dentry *result, *dentry;
@@ -674,7 +681,7 @@ char * umsdos_d_path(struct dentry *dentry, char * buffer, int len)
        if (*path == '/')
                path++; /* skip leading '/' */
 
-       if (old_root->d_inode == pseudo_root)
+       if (current->fs->root->d_inode == pseudo_root)
        {
                *(path-1) = '/';
                path -= (UMSDOS_PSDROOT_LEN+1);
@@ -718,6 +725,7 @@ hlink->d_parent->d_name.name, hlink->d_name.name);
        filp.f_flags = O_RDONLY;
 
        len = umsdos_file_read_kmem (&filp, path, hlink->d_inode->i_size);
+       if ((len > 0) && (len < PATH_MAX)) path[len] = '\0';
        if (len != hlink->d_inode->i_size)
                goto out_noread;
 #ifdef UMSDOS_DEBUG_VERBOSE
index d5a7a95788204464abb03503de58f452c2eeb24c..1cd61bfda293b6c6dfd7dcbceb760e474e65f345 100644 (file)
@@ -287,6 +287,7 @@ recsize, UMSDOS_REC_SIZE));
        }
        Printk (("umsdos_emd_dir_readentry /mn/: ret=%d.\n", ret));
        if (entry && ret == 0) {
+               entry->name[entry->name_len]='\0';
 Printk (("umsdos_emd_dir_readentry /mn/: returning len=%d,name=%.*s\n",
 (int) entry->name_len, (int) entry->name_len, entry->name));
        }
index 9ce891dd288ad98360acff9b79a00257e3838725..6aaa5002ec32795c2216dc1ee5a3fe85da77995a 100644 (file)
@@ -68,7 +68,7 @@ void UMSDOS_put_inode (struct inode *inode)
 void UMSDOS_put_super (struct super_block *sb)
 {
        Printk ((KERN_DEBUG "UMSDOS_put_super: entering\n"));
-       if (saved_root) {
+       if (saved_root && pseudo_root && sb->s_dev == ROOT_DEV) {
                shrink_dcache_parent(saved_root);
 printk("UMSDOS_put_super: freeing saved root, d_count=%d\n",
 saved_root->d_count);
@@ -356,7 +356,7 @@ struct super_block *UMSDOS_read_super (struct super_block *sb, void *data,
        if (!res)
                goto out_fail;
 
-       printk (KERN_INFO "UMSDOS 0.85b "
+       printk (KERN_INFO "UMSDOS 0.85g "
                "(compatibility level %d.%d, fast msdos)\n", 
                UMSDOS_VERSION, UMSDOS_RELEASE);
 
index 444e9ffae2cde57f30ab5320dea5f427934d5720..ef64d7268f9b78ba9368266d15ac955d56dddea2 100644 (file)
@@ -404,8 +404,15 @@ static int umsdos_rename_f (struct inode *old_dir, struct dentry *old_dentry,
                goto out_unlock;
        /* make sure it's the same inode! */
        ret = -ENOENT;
-       if (old->d_inode != old_inode)
-               goto out_dput;
+       /*
+        * note: for hardlinks they will be different!
+        *  old_inode will contain inode of .LINKxxx file containing data, and
+        *  old->d_inode will contain inode of file containing path to .LINKxxx file
+        */
+       if (!(old_info.entry.flags & UMSDOS_HLINK)) {
+               if (old->d_inode != old_inode)
+                       goto out_dput;
+       }
 
        new = umsdos_covered(new_dentry->d_parent, new_info.fake.fname, 
                                        new_info.fake.len);
index 3f5d109533a0906a26b6169d85a43ae95d0d7f5e..fb616e5beced8d063fb67f226924e880e8677bcf 100644 (file)
@@ -110,7 +110,10 @@ struct dentry *umsdos_rlookup_x ( struct inode *dir, struct dentry *dentry, int
                 */
 Printk ((KERN_DEBUG "umsdos_rlookup_x: patch_dentry_inode %s/%s\n",
 dentry->d_parent->d_name.name, dentry->d_name.name));
-               umsdos_patch_dentry_inode(dentry, 0);
+/* only patch if needed (because we get called even for lookup
+   (not only rlookup) stuff sometimes, like in umsdos_covered() */
+               if (dentry->d_inode->u.umsdos_i.i_patched == 0) 
+                       umsdos_patch_dentry_inode(dentry, 0);
 
        }
 out:
index 01911bee92b43872e2ccb2007f932069bed6615d..6d4d4ff18ad2b28e687010b4cd065148af8d385f 100644 (file)
@@ -28,94 +28,4 @@ extern int  atomic_dec_and_test(atomic_t *v);
 extern void atomic_clear_mask(unsigned long mask, unsigned long *addr);
 extern void atomic_set_mask(unsigned long mask, unsigned long *addr);
 
-#if 0  /* for now */
-extern __inline__ void atomic_add(atomic_t a, atomic_t *v)
-{
-       atomic_t t;
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%3\n\
-       add     %0,%2,%0\n\
-       stwcx.  %0,0,%3\n\
-       bne     1b"
-       : "=&r" (t), "=m" (*v)
-       : "r" (a), "r" (v)
-       : "cc");
-}
-
-extern __inline__ void atomic_sub(atomic_t a, atomic_t *v)
-{
-       atomic_t t;
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%3\n\
-       subf    %0,%2,%0\n\
-       stwcx.  %0,0,%3\n\
-       bne     1b"
-       : "=&r" (t), "=m" (*v)
-       : "r" (a), "r" (v)
-       : "cc");
-}
-
-extern __inline__ int atomic_sub_and_test(atomic_t a, atomic_t *v)
-{
-       atomic_t t;
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%3\n\
-       subf    %0,%2,%0\n\
-       stwcx.  %0,0,%3\n\
-       bne     1b"
-       : "=&r" (t), "=m" (*v)
-       : "r" (a), "r" (v)
-       : "cc");
-
-       return t == 0;
-}
-
-extern __inline__ void atomic_inc(atomic_t *v)
-{
-       atomic_t t;
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%2\n\
-       addic   %0,%0,1\n\
-       stwcx.  %0,0,%2\n\
-       bne     1b"
-       : "=&r" (t), "=m" (*v)
-       : "r" (v)
-       : "cc");
-}
-
-extern __inline__ void atomic_dec(atomic_t *v)
-{
-       atomic_t t;
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%2\n\
-       addic   %0,%0,-1\n\
-       stwcx.  %0,0,%2\n\
-       bne     1b"
-       : "=&r" (t), "=m" (*v)
-       : "r" (v)
-       : "cc");
-}
-
-extern __inline__ int atomic_dec_and_test(atomic_t *v)
-{
-       atomic_t t;
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%2\n\
-       addic   %0,%0,-1\n\
-       stwcx.  %0,0,%2\n\
-       bne     1b"
-       : "=&r" (t), "=m" (*v)
-       : "r" (v)
-       : "cc");
-
-       return t == 0;
-}
-#endif /* 0 */
-
 #endif /* _ASM_PPC_ATOMIC_H_ */
index 95b59cafc5df6a5f2b5cd84cba3953209222d576..3b8c00bc5bba2a9f3dedc1aeb91de1ec96be7dbd 100644 (file)
@@ -26,68 +26,6 @@ extern __inline__  int cntlzw(int bits)
        return lz;
 }
 
-/*
- * These are if'd out here because using : "cc" as a constraint
- * results in errors from gcc. -- Cort
- * Besides, they need to be changed so we have both set_bit
- * and test_and_set_bit, etc.
- */
-#if 0
-extern __inline__ int set_bit(int nr, void * addr)
-{
-       unsigned long old, t;
-       unsigned long mask = 1 << (nr & 0x1f);
-       unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-       
-       __asm__ __volatile__(
-               "1:lwarx %0,0,%3 \n\t"
-               "or     %1,%0,%2 \n\t"
-               "stwcx. %1,0,%3 \n\t"
-               "bne    1b \n\t"
-               : "=&r" (old), "=&r" (t)        /*, "=m" (*p)*/
-               : "r" (mask), "r" (p)
-               /*: "cc" */);
-
-       return (old & mask) != 0;
-}
-
-extern __inline__  unsigned long clear_bit(unsigned long nr, void *addr)
-{
-       unsigned long old, t;
-       unsigned long mask = 1 << (nr & 0x1f);
-       unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%3
-       andc    %1,%0,%2
-       stwcx.  %1,0,%3
-       bne     1b"
-       : "=&r" (old), "=&r" (t)        /*, "=m" (*p)*/
-       : "r" (mask), "r" (p)
-      /*: "cc"*/);
-
-       return (old & mask) != 0;
-}
-
-extern __inline__ unsigned long change_bit(unsigned long nr, void *addr)
-{
-       unsigned long old, t;
-       unsigned long mask = 1 << (nr & 0x1f);
-       unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-
-       __asm__ __volatile__("\n\
-1:     lwarx   %0,0,%3
-       xor     %1,%0,%2
-       stwcx.  %1,0,%3
-       bne     1b"
-       : "=&r" (old), "=&r" (t)        /*, "=m" (*p)*/
-       : "r" (mask), "r" (p)
-      /*: "cc"*/);
-
-       return (old & mask) != 0;
-}
-#endif
-
 extern __inline__ unsigned long test_bit(int nr, __const__ volatile void *addr)
 {
        __const__ unsigned int *p = (__const__ unsigned int *) addr;
@@ -116,17 +54,6 @@ extern __inline__ int ffz(unsigned int x)
 
 #define ffs(x) generic_ffs(x)
 
-#if 0
-/* untested, someone with PPC knowledge? */
-/* From Alexander Kjeldaas <astor@guardian.no> */
-extern __inline__ int ffs(int x)
-{
-        int result;
-        asm ("cntlzw %0,%1" : "=r" (result) : "r" (x));
-        return 32 - result; /* IBM backwards ordering of bits */
-}
-#endif
-
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
index 232c53dcb32959afa52cc007aa952135f7d6f891..259e7b7bea023399157121732da1ab8a881f3aa2 100644 (file)
@@ -275,7 +275,8 @@ extern int low_on_memory;
 
 #define free_page(addr) free_pages((addr),0)
 extern void FASTCALL(free_pages(unsigned long addr, unsigned long order));
-extern void FASTCALL(__free_page(struct page *));
+#define __free_page(page) __free_pages((page),0)
+extern void FASTCALL(__free_pages(struct page *, unsigned long));
 
 extern void show_free_areas(void);
 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
@@ -334,7 +335,7 @@ extern void put_cached_page(unsigned long);
 
 #define __GFP_DMA      0x80
 
-#define GFP_BUFFER     (__GFP_LOW | __GFP_WAIT)
+#define GFP_BUFFER     (__GFP_MED | __GFP_WAIT)
 #define GFP_ATOMIC     (__GFP_HIGH)
 #define GFP_USER       (__GFP_LOW | __GFP_WAIT | __GFP_IO)
 #define GFP_KERNEL     (__GFP_MED | __GFP_WAIT | __GFP_IO)
index d983c17ebf1dcf2702b7869c18131741884476c1..d801727aa213fee2321a512fadb8e5892e4a721f 100644 (file)
@@ -291,6 +291,7 @@ struct task_struct {
 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
        unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
        int swappable:1;
+       int trashing_mem:1;
 /* process credentials */
        uid_t uid,euid,suid,fsuid;
        gid_t gid,egid,sgid,fsgid;
@@ -328,6 +329,9 @@ struct task_struct {
 /* Thread group tracking */
        u32 parent_exec_id;
        u32 self_exec_id;
+
+/* oom handling */
+       int oom_kill_try;
 };
 
 /*
@@ -378,7 +382,7 @@ struct task_struct {
 /* utime */    {0,0,0,0},0, \
 /* per CPU times */ {0, }, {0, }, \
 /* flt */      0,0,0,0,0,0, \
-/* swp */      0, \
+/* swp */      0,0, \
 /* process credentials */                                      \
 /* uid etc */  0,0,0,0,0,0,0,0,                                \
 /* suppl grps*/ 0, {0,},                                       \
@@ -395,6 +399,7 @@ struct task_struct {
 /* mm */       &init_mm, \
 /* signals */  SPIN_LOCK_UNLOCKED, &init_signals, {{0}}, {{0}}, NULL, &init_task.sigqueue, 0, 0, \
 /* exec cts */ 0,0, \
+/* oom */      0, \
 }
 
 union task_union {
index 6509c0b0ba2d5b86892143e582af1a19f4dd7e57..9d8dc89c2524ddc36303305a5d8958bb237db28e 100644 (file)
@@ -93,7 +93,7 @@ EXPORT_SYMBOL(exit_sighand);
 /* internal kernel memory management */
 EXPORT_SYMBOL(__get_free_pages);
 EXPORT_SYMBOL(free_pages);
-EXPORT_SYMBOL(__free_page);
+EXPORT_SYMBOL(__free_pages);
 EXPORT_SYMBOL(kmem_find_general_cachep);
 EXPORT_SYMBOL(kmem_cache_create);
 EXPORT_SYMBOL(kmem_cache_shrink);
index f8e82f3ff61105a867f4bfe2e2a2f167daca7240..c64eefbd2ed3c7ae0618646b46f17ed149590559 100644 (file)
@@ -9,7 +9,7 @@
 
 O_TARGET := mm.o
 O_OBJS  := memory.o mmap.o filemap.o mprotect.o mlock.o mremap.o \
-           vmalloc.o slab.o oom_kill.o \
+           vmalloc.o slab.o \
            swap.o vmscan.o page_io.o page_alloc.o swap_state.o swapfile.o
 
 include $(TOPDIR)/Rules.make
index b3d764c888940d44f1ee36818c2f5d1c50dab34f..72572e83edb08bea07ee922647820374425009f0 100644 (file)
@@ -164,6 +164,10 @@ int shrink_mmap(int priority, int gfp_mask)
                        clock = page - mem_map;
                }
                
+               /* We can't free pages unless there's just one user */
+               if (atomic_read(&page->count) != 1)
+                       continue;
+
                referenced = test_and_clear_bit(PG_referenced, &page->flags);
 
                if (PageLocked(page))
@@ -172,10 +176,6 @@ int shrink_mmap(int priority, int gfp_mask)
                if ((gfp_mask & __GFP_DMA) && !PageDMA(page))
                        continue;
 
-               /* We can't free pages unless there's just one user */
-               if (atomic_read(&page->count) != 1)
-                       continue;
-
                count--;
 
                /*
@@ -254,6 +254,7 @@ void update_vm_cache_conditional(struct inode * inode, unsigned long pos, const
                        if ((unsigned long)dest != source_address) {
                                wait_on_page(page);
                                memcpy(dest, buf, len);
+                               flush_dcache_page(page_address(page));
                        }
                        page_cache_release(page);
                }
@@ -1553,8 +1554,10 @@ generic_file_write(struct file *file, const char *buf,
                 * is done with the page.
                 */
                dest = (char *) page_address(page) + offset;
-               if (dest != buf) /* See comment in update_vm_cache_cond. */
+               if (dest != buf) /* See comment in update_vm_cache_cond. */
                        bytes -= copy_from_user(dest, buf, bytes);
+                       flush_dcache_page(page_address(page));
+               }
                status = -EFAULT;
                if (bytes)
                        status = inode->i_op->updatepage(file, page, offset, bytes, sync);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
deleted file mode 100644 (file)
index 5696fd5..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- *  linux/mm/oom_kill.c
- * 
- *  Copyright (C)  1998,2000  Rik van Riel
- *     Thanks go out to Claus Fischer for some serious inspiration and
- *     for goading me into coding this file...
- *
- *  The routines in this file are used to kill a process when
- *  we're seriously out of memory. This gets called from kswapd()
- *  in linux/mm/vmscan.c when we really run out of memory.
- *
- *  Since we won't call these routines often (on a well-configured
- *  machine) this file will double as a 'coding guide' and a signpost
- *  for newbie kernel hackers. It features several pointers to major
- *  kernel subsystems and hints as to where to find out what things do.
- */
-
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/stddef.h>
-#include <linux/swap.h>
-#include <linux/swapctl.h>
-#include <linux/timex.h>
-
-/* #define DEBUG */
-#define min(a,b) (((a)<(b))?(a):(b))
-
-/*
- * A rough approximation to the sqrt() function.
- */
-inline int int_sqrt(unsigned int x)
-{
-       unsigned int out = x;
-       while (x & ~(unsigned int)1) x >>=2, out >>=1;
-       if (x) out -= out >> 2;
-       return (out ? out : 1);
-}      
-
-/*
- * Basically, points = size / (sqrt(CPU_used) * sqrt(sqrt(time_running)))
- * with some bonusses/penalties.
- *
- * We try to chose our `guilty' task in such a way that we free
- * up the maximum amount of memory and lose the minimum amount of
- * done work.
- *
- * The definition of the task_struct, the structure describing the state
- * of each process, can be found in include/linux/sched.h. For
- * capability info, you should read include/linux/capability.h.
- */
-
-inline int badness(struct task_struct *p)
-{
-       int points = p->mm->total_vm;
-       points /= int_sqrt((p->times.tms_utime + p->times.tms_stime) >> (SHIFT_HZ + 3));
-       points /= int_sqrt(int_sqrt((jiffies - p->start_time) >> (SHIFT_HZ + 10)));
-/*
- * Niced processes are probably less important; kernel/sched.c
- * and include/linux/sched.h contain most info on scheduling.
- */
-       if (p->priority < DEF_PRIORITY)
-               points <<= 1;
-/*
- * p->(e)uid is the process User ID, ID 0 is root, the super user.
- * The super user usually only runs (important) system services
- * and properly checked programs which we don't want to kill.
- */
-       if (p->uid == 0 || p->euid == 0 || cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_ADMIN))
-               points >>= 2;
-/*
- * We don't want to kill a process with direct hardware access.
- * Not only could this mess up the hardware, but these processes
- * are usually fairly important too.
- */
-       if (cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_RAWIO))
-               points >>= 1;
-#ifdef DEBUG
-       printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n",
-       p->pid, p->comm, points);
-#endif
-       return points;
-}
-
-/*
- * Simple selection loop. We chose the process with the highest
- * number of 'points'. We need the locks to make sure that the
- * list of task structs doesn't change while we look the other way.
- */
-inline struct task_struct * select_bad_process(void)
-{
-       int points = 0, maxpoints = 0;
-       struct task_struct *p = NULL;
-       struct task_struct *chosen = NULL;
-
-       read_lock(&tasklist_lock);
-       for_each_task(p)
-       {
-               if (p->pid)
-                       points = badness(p);
-               if (points > maxpoints) {
-                       chosen = p;
-                       maxpoints = points;
-               }
-       }
-       read_unlock(&tasklist_lock);
-       return chosen;
-}
-
-/*
- * We kill the 'best' process and print a message to userspace.
- * The only things to be careful about are:
- *  - don't SIGKILL a process with direct hardware access.
- *  - are we killing ourselves?
- *  - when we kill someone else, can we sleep and get out of the way?
- */
-void oom_kill(unsigned long gfp_mask)
-{
-
-       struct task_struct *p = select_bad_process();
-
-       if (p == NULL)
-               return;
-
-       if (p == current) {
-               printk(KERN_ERR "Out of Memory: Killed process %d (%s).",
-                        p->pid, p->comm);
-       } else {
-               printk(KERN_ERR "Out of Memory: Killed process %d (%s), "
-                       "saved process %d (%s).",
-                       p->pid, p->comm, current->pid, current->comm);
-       }
-
-       /* This process has hardware access, be more careful */
-       if (cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_RAWIO)) {
-               force_sig(SIGTERM, p);
-       } else {
-               force_sig(SIGKILL, p);
-       }
-
-       /* Get out of the way so that p can die */
-       if (p != current && (gfp_mask & __GFP_WAIT) && current->state == TASK_RUNNING) {
-               p->counter = 2 * DEF_PRIORITY;
-               current->policy |= SCHED_YIELD;
-               schedule();
-       }
-       return;
-}
-
-/*
- * We are called when __get_free_pages() thinks the system may
- * be out of memory. If we really are out of memory, we can do
- * nothing except freeing up memory by killing a process...
- */
-
-int out_of_memory(unsigned long gfp_mask)
-{
-       int count = page_cluster;
-       int loop = 0;
-       int freed = 0;
-
-again:
-       if (gfp_mask & __GFP_WAIT) {
-               /* Try to free up some memory */
-               current->flags |= PF_MEMALLOC;
-               do {
-                       freed += try_to_free_pages(gfp_mask);
-                       run_task_queue(&tq_disk);
-                       if (freed && nr_free_pages > freepages.min) {
-                               current->flags &= ~PF_MEMALLOC;
-                               return 0;
-                       }
-               } while (--count);
-               current->flags &= ~PF_MEMALLOC;
-       }
-
-       /* Darn, we failed. Now we have to kill something */
-       if (!loop)
-               oom_kill(gfp_mask);
-
-       if (nr_free_pages > freepages.min)
-               return 0;
-       if (!loop) {
-               loop = 1;
-               goto again;
-       }
-       /* Still out of memory, let the caller deal with it */
-       return 1;
-}
index 893dd1a3ef1904b17a3547bb87ca74d8f818ccbc..ecd56b04235ad795f127a67d106c68969a11725a 100644 (file)
@@ -20,9 +20,6 @@
 
 int nr_swap_pages = 0;
 int nr_free_pages = 0;
-int low_on_memory = 0;
-extern struct wait_queue * kswapd_wait;
-extern int out_of_memory(unsigned long);
 
 /*
  * Free area management
@@ -126,7 +123,7 @@ static inline void free_pages_ok(unsigned long map_nr, unsigned long order, unsi
        spin_unlock_irqrestore(&page_alloc_lock, flags);
 }
 
-static inline void __free_pages(struct page *page, unsigned long order)
+void __free_pages(struct page *page, unsigned long order)
 {
        if (!PageReserved(page) && atomic_dec_and_test(&page->count)) {
                if (PageSwapCache(page))
@@ -137,11 +134,6 @@ static inline void __free_pages(struct page *page, unsigned long order)
        }
 }
 
-void __free_page(struct page *page)
-{
-       __free_pages(page, 0);
-}
-
 void free_pages(unsigned long addr, unsigned long order)
 {
        unsigned long map_nr = MAP_NR(addr);
@@ -211,50 +203,30 @@ unsigned long __get_free_pages(int gfp_mask, unsigned long order)
         * further thought.
         */
        if (!(current->flags & PF_MEMALLOC)) {
-#ifdef SLEEP_MEMORY_DEBUGGING
-               if (current->state != TASK_RUNNING && (gfp_mask & __GFP_WAIT)) {
-                       printk("gfp called by non-running (%ld) task from %p!\n",
-                               current->state, __builtin_return_address(0));
-                       /* if we're not running, we can't sleep */
-                       gfp_mask &= ~__GFP_WAIT;
-               }
-#endif         
-
-               if (low_on_memory) {
-                       int freed;
-                       current->flags |= PF_MEMALLOC;
-                       freed = try_to_free_pages(gfp_mask);
-                       current->flags &= ~PF_MEMALLOC;
-                       if (time_after(jiffies, low_on_memory + 60 * HZ))
-                               out_of_memory(gfp_mask);
-                       if (freed && nr_free_pages > freepages.low)
-                               low_on_memory = 0;
+               int freed;
+               extern struct wait_queue * kswapd_wait;
+
+               if (nr_free_pages >= freepages.high)
+               {
+                       /* share RO cachelines in fast path */
+                       if (current->trashing_mem)
+                               current->trashing_mem = 0;
+                       goto ok_to_allocate;
                }
-
-               if (nr_free_pages <= freepages.low) {
-                       wake_up_interruptible(&kswapd_wait);
-                       if ((gfp_mask & __GFP_WAIT) && current->state == TASK_RUNNING) {
-                               schedule();
-                               /* kswapd couldn't save us */
-                               if (nr_free_pages <= freepages.low)
-                                       low_on_memory = jiffies;
-                       }
+               else
+               {
+                       if (nr_free_pages < freepages.low)
+                               wake_up_interruptible(&kswapd_wait);
+                       if (nr_free_pages > freepages.min && !current->trashing_mem)
+                               goto ok_to_allocate;
                }
 
-               if (nr_free_pages > freepages.min)
-                       goto ok_to_allocate;
-
-               /*
-                * out_of_memory() should usually fix the situation.
-                * If it does, we can continue like nothing happened.
-                */
-               if (!out_of_memory(gfp_mask))
-                       goto ok_to_allocate;
-
-               if ((gfp_mask & __GFP_MED) && nr_free_pages > freepages.min / 2)
-                       goto ok_to_allocate;
+               current->trashing_mem = 1;
+               current->flags |= PF_MEMALLOC;
+               freed = try_to_free_pages(gfp_mask);
+               current->flags &= ~PF_MEMALLOC;
 
-               if (!(gfp_mask & __GFP_HIGH))
+               if (!freed && !(gfp_mask & (__GFP_MED | __GFP_HIGH)))
                        goto nopage;
        }
 ok_to_allocate:
index d25098e3b7e883e2c3e57419c1725ffece2a719f..c8fbcf987c343140be60a56e7237b9e2b194585b 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/init.h>
 
 #include <asm/pgtable.h>
-extern int low_on_memory;
 
 /*
  * The swap-out functions return 1 if they successfully
@@ -64,14 +63,6 @@ static int try_to_swap_out(struct task_struct * tsk, struct vm_area_struct* vma,
            || ((gfp_mask & __GFP_DMA) && !PageDMA(page_map)))
                return 0;
 
-       /*
-        * By setting this bit shrink_mmap() will do
-        * second-chance page replacement, only do this
-        * when we are the only (non-pagecache) user.
-        */
-       if (atomic_read(&page_map->count) <= 2)
-               set_bit(PG_referenced, &page_map->flags);
-
        /*
         * Is the page already in the swap cache? If so, then
         * we can just drop our reference to it without doing
@@ -446,7 +437,7 @@ void __init kswapd_setup(void)
        printk ("Starting kswapd v%.*s\n", i, s);
 }
 
-struct wait_queue * kswapd_wait = NULL;
+struct wait_queue * kswapd_wait;
 
 /*
  * The background pageout daemon, started as a kernel thread
@@ -494,24 +485,18 @@ int kswapd(void *unused)
                 * the processes needing more memory will wake us
                 * up on a more timely basis.
                 */
+               interruptible_sleep_on(&kswapd_wait);
                while (nr_free_pages < freepages.high)
                {
-                       if (!do_try_to_free_pages(GFP_KSWAPD)) {
-                               /* out of memory? we can't do much */
-                               low_on_memory = jiffies;
-                               if (nr_free_pages < freepages.min) {
-                                       run_task_queue(&tq_disk);
-                                       tsk->state = TASK_INTERRUPTIBLE;
-                                       schedule_timeout(HZ);
-                               } else {        
-                                       break;
-                               }
+                       if (do_try_to_free_pages(GFP_KSWAPD))
+                       {
+                               if (tsk->need_resched)
+                                       schedule();
+                               continue;
                        }
-                       if (tsk->need_resched)
-                               schedule();
+                       tsk->state = TASK_INTERRUPTIBLE;
+                       schedule_timeout(10*HZ);
                }
-               run_task_queue(&tq_disk);
-               interruptible_sleep_on_timeout(&kswapd_wait, HZ);
        }
 }