]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
authorLinus Torvalds <torvalds@g5.osdl.org>
Sat, 8 Oct 2005 21:58:25 +0000 (14:58 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 8 Oct 2005 21:58:25 +0000 (14:58 -0700)
452 files changed:
Documentation/SubmittingPatches
Documentation/keys-request-key.txt [new file with mode: 0644]
Documentation/keys.txt
Documentation/networking/ip-sysctl.txt
MAINTAINERS
Makefile
arch/alpha/kernel/entry.S
arch/alpha/kernel/traps.c
arch/arm/common/gic.c
arch/arm/common/locomo.c
arch/arm/kernel/sys_arm.c
arch/arm/kernel/traps.c
arch/arm/mach-clps711x/fortunet.c
arch/arm/mach-imx/generic.c
arch/arm/mach-imx/leds-mx1ads.c
arch/arm/mach-imx/mx1ads.c
arch/arm/mach-iop3xx/common.c
arch/arm/mach-iop3xx/iop321-time.c
arch/arm/mach-iop3xx/iop331-time.c
arch/arm/mach-iop3xx/iq31244-mm.c
arch/arm/mach-iop3xx/iq80321-mm.c
arch/arm/mach-iop3xx/iq80331-mm.c
arch/arm/mach-iop3xx/iq80332-mm.c
arch/arm/mach-ixp2000/core.c
arch/arm/mach-ixp2000/pci.c
arch/arm/mach-ixp4xx/ixdp425-setup.c
arch/arm/mach-l7200/core.c
arch/arm/mach-pxa/corgi_lcd.c
arch/arm/mach-pxa/generic.c
arch/arm/mach-s3c2410/usb-simtec.c
arch/arm/mach-versatile/core.c
arch/arm/mach-versatile/pci.c
arch/arm/mm/Kconfig
arch/arm/mm/abort-ev6.S
arch/arm/mm/cache-v6.S
arch/arm/mm/flush.c
arch/arm/plat-omap/common.c
arch/arm/plat-omap/cpu-omap.c
arch/arm/plat-omap/usb.c
arch/i386/kernel/acpi/boot.c
arch/i386/kernel/cpu/amd.c
arch/i386/pci/acpi.c
arch/i386/pci/irq.c
arch/ia64/kernel/mca.c
arch/ppc/boot/ld.script
arch/ppc/platforms/4xx/bamboo.c
arch/ppc/platforms/4xx/ebony.c
arch/ppc/platforms/4xx/luan.c
arch/ppc/platforms/4xx/ocotea.c
arch/ppc/platforms/83xx/mpc834x_sys.c
arch/ppc/platforms/85xx/mpc8540_ads.c
arch/ppc/platforms/85xx/mpc8560_ads.c
arch/ppc/platforms/85xx/mpc85xx_ads_common.c
arch/ppc/platforms/85xx/mpc85xx_cds_common.c
arch/ppc/platforms/85xx/sbc8560.c
arch/ppc/platforms/85xx/sbc85xx.c
arch/ppc/platforms/85xx/stx_gp3.c
arch/ppc/platforms/chestnut.c
arch/ppc/platforms/chrp_setup.c
arch/ppc/platforms/gemini_setup.c
arch/ppc/platforms/mvme5100.c
arch/ppc/platforms/pmac_cpufreq.c
arch/ppc/platforms/pmac_feature.c
arch/ppc/platforms/pmac_setup.c
arch/ppc/platforms/pmac_time.c
arch/ppc/platforms/powerpmc250.c
arch/ppc/platforms/pplus.c
arch/ppc/platforms/prpmc750.c
arch/ppc/platforms/prpmc800.c
arch/ppc/platforms/radstone_ppc7d.c
arch/ppc/platforms/sandpoint.c
arch/ppc/syslib/mv64x60.c
arch/ppc/syslib/open_pic.c
arch/ppc/syslib/open_pic2.c
arch/ppc/syslib/ppc4xx_setup.c
arch/ppc64/kernel/bpa_iommu.c
arch/ppc64/kernel/kprobes.c
arch/s390/kernel/compat_signal.c
arch/s390/kernel/signal.c
arch/sparc/Kconfig
arch/sparc/defconfig
arch/sparc/kernel/setup.c
arch/sparc/kernel/time.c
arch/sparc/mm/srmmu.c
arch/sparc64/kernel/cpu.c
arch/sparc64/kernel/entry.S
arch/sparc64/kernel/etrap.S
arch/sparc64/kernel/head.S
arch/sparc64/kernel/power.c
arch/sparc64/kernel/ptrace.c
arch/sparc64/kernel/rtrap.S
arch/sparc64/kernel/setup.c
arch/sparc64/kernel/sys32.S
arch/sparc64/kernel/trampoline.S
arch/sparc64/kernel/traps.c
arch/sparc64/kernel/una_asm.S
arch/sparc64/kernel/unaligned.c
arch/sparc64/kernel/us3_cpufreq.c
arch/sparc64/kernel/winfixup.S
arch/sparc64/lib/VISsave.S
arch/sparc64/lib/strncpy_from_user.S
arch/sparc64/lib/user_fixup.c
arch/sparc64/mm/Makefile
arch/sparc64/mm/extable.c [deleted file]
arch/sparc64/mm/fault.c
arch/sparc64/mm/init.c
arch/sparc64/prom/Makefile
arch/sparc64/prom/init.c
arch/sparc64/prom/memory.c [deleted file]
arch/um/Makefile
arch/um/Makefile-i386
arch/um/Makefile-skas
arch/um/Makefile-x86_64
arch/um/drivers/mconsole_user.c
arch/um/drivers/port_kern.c
arch/um/include/common-offsets.h
arch/um/include/os.h
arch/um/include/registers.h
arch/um/include/skas_ptregs.h [new file with mode: 0644]
arch/um/include/sysdep-i386/sc.h [new file with mode: 0644]
arch/um/include/sysdep-i386/sigcontext.h
arch/um/include/sysdep-i386/thread.h [new file with mode: 0644]
arch/um/include/sysdep-x86_64/ptrace.h
arch/um/include/sysdep-x86_64/sc.h [new file with mode: 0644]
arch/um/include/sysdep-x86_64/sigcontext.h
arch/um/include/sysdep-x86_64/thread.h [new file with mode: 0644]
arch/um/include/task.h [new file with mode: 0644]
arch/um/kernel/irq.c
arch/um/kernel/skas/Makefile
arch/um/kernel/skas/util/Makefile [deleted file]
arch/um/kernel/skas/util/mk_ptregs-i386.c [deleted file]
arch/um/kernel/skas/util/mk_ptregs-x86_64.c [deleted file]
arch/um/kernel/sysrq.c
arch/um/kernel/trap_kern.c
arch/um/kernel/um_arch.c
arch/um/os-Linux/elf_aux.c
arch/um/os-Linux/sys-i386/registers.c
arch/um/os-Linux/sys-x86_64/registers.c
arch/um/os-Linux/util/Makefile [deleted file]
arch/um/os-Linux/util/mk_user_constants.c [deleted file]
arch/um/sys-i386/Makefile
arch/um/sys-i386/kernel-offsets.c
arch/um/sys-i386/sysrq.c
arch/um/sys-i386/user-offsets.c
arch/um/sys-i386/util/Makefile [deleted file]
arch/um/sys-i386/util/mk_sc.c [deleted file]
arch/um/sys-i386/util/mk_thread.c [deleted file]
arch/um/sys-x86_64/Makefile
arch/um/sys-x86_64/kernel-offsets.c
arch/um/sys-x86_64/user-offsets.c
arch/um/sys-x86_64/util/Makefile [deleted file]
arch/um/sys-x86_64/util/mk_sc.c [deleted file]
arch/um/sys-x86_64/util/mk_thread.c [deleted file]
arch/um/util/Makefile [deleted file]
arch/um/util/mk_constants.c [deleted file]
arch/um/util/mk_task.c [deleted file]
arch/x86_64/kernel/head.S
arch/x86_64/kernel/kprobes.c
arch/x86_64/kernel/mce.c
arch/x86_64/kernel/setup.c
arch/x86_64/mm/numa.c
drivers/atm/fore200e.c
drivers/char/drm/drm_drv.c
drivers/char/drm/drm_proc.c
drivers/char/drm/drm_stub.c
drivers/char/n_r3964.c
drivers/char/watchdog/mv64x60_wdt.c
drivers/connector/connector.c
drivers/ieee1394/amdtp.c
drivers/ieee1394/csr1212.h
drivers/ieee1394/dv1394.c
drivers/ieee1394/eth1394.c
drivers/ieee1394/eth1394.h
drivers/ieee1394/hosts.c
drivers/ieee1394/hosts.h
drivers/ieee1394/ieee1394_core.c
drivers/ieee1394/nodemgr.c
drivers/ieee1394/ohci1394.c
drivers/ieee1394/raw1394.c
drivers/ieee1394/sbp2.c
drivers/ieee1394/video1394.c
drivers/infiniband/hw/mthca/mthca_main.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/isdn/divert/divert_procfs.c
drivers/isdn/hardware/eicon/diva_didd.c
drivers/isdn/hardware/eicon/divasproc.c
drivers/isdn/hysdn/hysdn_procconf.c
drivers/macintosh/smu.c
drivers/media/video/bttv-cards.c
drivers/media/video/cpia.c
drivers/media/video/rds.h
drivers/media/video/saa6588.c
drivers/mfd/ucb1x00-core.c
drivers/mfd/ucb1x00.h
drivers/mtd/maps/bast-flash.c
drivers/mtd/maps/ixp2000.c
drivers/mtd/maps/ixp4xx.c
drivers/mtd/maps/omap_nor.c
drivers/mtd/maps/sa1100-flash.c
drivers/mtd/nand/s3c2410.c
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/arm/am79c961a.c
drivers/net/bmac.c
drivers/net/bonding/bond_main.c
drivers/net/bonding/bonding.h
drivers/net/cassini.c [new file with mode: 0644]
drivers/net/cassini.h [new file with mode: 0644]
drivers/net/ibm_emac/ibm_emac_core.c
drivers/net/ibmveth.c
drivers/net/irda/vlsi_ir.c
drivers/net/ns83820.c
drivers/net/pcmcia/smc91c92_cs.c
drivers/net/pppoe.c
drivers/net/r8169.c
drivers/net/sk98lin/skge.c
drivers/net/skge.c
drivers/net/starfire.c
drivers/net/sungem.h
drivers/net/tg3.c
drivers/net/tokenring/ibmtr.c
drivers/net/tulip/21142.c
drivers/net/wan/sdlamain.c
drivers/net/wan/syncppp.c
drivers/net/wireless/orinoco.c
drivers/net/wireless/strip.c
drivers/parisc/led.c
drivers/pcmcia/omap_cf.c
drivers/pcmcia/rsrc_nonstatic.c
drivers/pcmcia/ti113x.h
drivers/s390/net/qeth.h
drivers/s390/net/qeth_main.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-9xxx.h
drivers/scsi/Makefile
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/aacraid.h
drivers/scsi/aacraid/comminit.c
drivers/scsi/aacraid/commsup.c
drivers/scsi/aacraid/linit.c
drivers/scsi/aic7xxx/aic7770_osm.c
drivers/scsi/aic7xxx/aic79xx_osm.c
drivers/scsi/aic7xxx/aic79xx_osm_pci.c
drivers/scsi/aic7xxx/aic7xxx_osm.c
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
drivers/scsi/hosts.c
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_hw.h
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/megaraid.c
drivers/scsi/megaraid/Kconfig.megaraid
drivers/scsi/megaraid/Makefile
drivers/scsi/megaraid/megaraid_sas.c [new file with mode: 0644]
drivers/scsi/megaraid/megaraid_sas.h [new file with mode: 0644]
drivers/scsi/qla2xxx/qla_rscn.c
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_transport_sas.c
drivers/scsi/sg.c
drivers/serial/imx.c
drivers/serial/ioc4_serial.c
drivers/serial/s3c2410.c
drivers/serial/sunsu.c
drivers/usb/core/hcd-pci.c
drivers/usb/host/ohci-lh7a404.c
drivers/usb/host/ohci-omap.c
drivers/usb/host/ohci-s3c2410.c
drivers/usb/media/vicam.c
drivers/video/Kconfig
drivers/video/aty/radeon_base.c
drivers/video/aty/radeon_pm.c
drivers/video/aty/radeonfb.h
drivers/video/backlight/corgi_bl.c
drivers/video/cyblafb.c
drivers/video/i810/i810-i2c.c
drivers/video/imxfb.c
drivers/video/intelfb/intelfbdrv.c
drivers/video/p9100.c
drivers/video/pxafb.c
drivers/video/pxafb.h
drivers/video/s3c2410fb.c
fs/9p/vfs_super.c
fs/aio.c
fs/bfs/dir.c
fs/bfs/inode.c
fs/fuse/file.c
fs/hostfs/hostfs_kern.c
fs/namei.c
fs/ntfs/ChangeLog
fs/ntfs/bitmap.c
fs/ntfs/layout.h
fs/ntfs/mft.c
fs/ntfs/unistr.c
fs/read_write.c
include/asm-arm/arch-h720x/system.h
include/asm-arm/arch-imx/imx-regs.h
include/asm-arm/arch-ixp4xx/platform.h
include/asm-arm/arch-rpc/hardware.h
include/asm-arm/arch-versatile/io.h
include/asm-arm/elf.h
include/asm-i386/hw_irq.h
include/asm-ia64/uaccess.h
include/asm-ppc/io.h
include/asm-ppc/mv64x60.h
include/asm-ppc64/uaccess.h
include/asm-s390/sigcontext.h
include/asm-s390/signal.h
include/asm-sparc/btfixup.h
include/asm-sparc/cache.h
include/asm-sparc/cypress.h
include/asm-sparc/delay.h
include/asm-sparc/dma.h
include/asm-sparc/iommu.h
include/asm-sparc/kdebug.h
include/asm-sparc/mbus.h
include/asm-sparc/msi.h
include/asm-sparc/mxcc.h
include/asm-sparc/obio.h
include/asm-sparc/pci.h
include/asm-sparc/pgtable.h
include/asm-sparc/pgtsrmmu.h
include/asm-sparc/processor.h
include/asm-sparc/psr.h
include/asm-sparc/sbi.h
include/asm-sparc/sbus.h
include/asm-sparc/smp.h
include/asm-sparc/smpprim.h
include/asm-sparc/spinlock.h
include/asm-sparc/system.h
include/asm-sparc/traps.h
include/asm-sparc64/head.h
include/asm-sparc64/openprom.h
include/asm-sparc64/oplib.h
include/asm-sparc64/page.h
include/asm-sparc64/pgtable.h
include/asm-sparc64/uaccess.h
include/asm-um/processor-generic.h
include/asm-um/processor-i386.h
include/asm-um/processor-x86_64.h
include/asm-um/uaccess.h
include/asm-x86_64/msr.h
include/asm-x86_64/pgtable.h
include/linux/aio.h
include/linux/atmdev.h
include/linux/bfs_fs.h
include/linux/connector.h
include/linux/if_ether.h
include/linux/inetdevice.h
include/linux/ipv6.h
include/linux/key-ui.h
include/linux/mod_devicetable.h
include/linux/netdevice.h
include/linux/pci_ids.h
include/linux/sched.h
include/linux/skbuff.h
include/linux/tc_ematch/tc_em_meta.h
include/linux/textsearch.h
include/net/dn_nsp.h
include/net/dn_route.h
include/net/inet6_hashtables.h
include/net/inet_hashtables.h
include/net/inet_timewait_sock.h
include/net/ip_vs.h
include/net/sctp/user.h
include/net/sock.h
include/net/xfrm.h
include/rxrpc/call.h
include/rxrpc/message.h
include/scsi/scsi_device.h
kernel/cpuset.c
kernel/exit.c
kernel/signal.c
lib/ts_bm.c
lib/ts_fsm.c
lib/ts_kmp.c
mm/bootmem.c
net/appletalk/ddp.c
net/atm/addr.c
net/atm/addr.h
net/atm/atm_misc.c
net/atm/br2684.c
net/atm/clip.c
net/atm/common.c
net/atm/ioctl.c
net/atm/lec.c
net/atm/resources.c
net/atm/signaling.c
net/atm/svc.c
net/ax25/ax25_in.c
net/core/datagram.c
net/core/dev.c
net/core/netpoll.c
net/core/pktgen.c
net/core/skbuff.c
net/core/sock.c
net/dccp/ipv4.c
net/decnet/af_decnet.c
net/decnet/dn_nsp_out.c
net/econet/af_econet.c
net/ethernet/eth.c
net/ieee80211/ieee80211_module.c
net/ieee80211/ieee80211_tx.c
net/ipv4/arp.c
net/ipv4/devinet.c
net/ipv4/fib_frontend.c
net/ipv4/fib_semantics.c
net/ipv4/fib_trie.c
net/ipv4/icmp.c
net/ipv4/igmp.c
net/ipv4/inet_timewait_sock.c
net/ipv4/ip_gre.c
net/ipv4/ipmr.c
net/ipv4/ipvs/ip_vs_app.c
net/ipv4/netfilter/Kconfig
net/ipv4/netfilter/ip_conntrack_netbios_ns.c
net/ipv4/netfilter/ip_queue.c
net/ipv4/netfilter/ipt_REDIRECT.c
net/ipv4/netfilter/ipt_ULOG.c
net/ipv4/route.c
net/ipv4/tcp_bic.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_output.c
net/ipv6/addrconf.c
net/ipv6/ip6_output.c
net/ipv6/mcast.c
net/ipv6/ndisc.c
net/ipv6/netfilter/ip6_queue.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/irda/irlan/irlan_eth.c
net/key/af_key.c
net/netfilter/nfnetlink.c
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue.c
net/netrom/nr_dev.c
net/packet/af_packet.c
net/rose/af_rose.c
net/rxrpc/call.c
net/rxrpc/connection.c
net/sched/em_meta.c
net/sctp/protocol.c
net/sctp/socket.c
net/socket.c
net/sunrpc/sched.c
net/sysctl_net.c
net/xfrm/xfrm_policy.c
security/keys/Makefile
security/keys/permission.c [new file with mode: 0644]
security/keys/request_key.c
security/keys/request_key_auth.c
security/selinux/hooks.c

index 7f43b040311e526e3e3fdf36f1f3a6f7d98f0f18..237d54c44bc5ee504dc57f8d5f65edc389081e04 100644 (file)
@@ -301,8 +301,84 @@ now, but you can do this to mark internal company procedures or just
 point out some special detail about the sign-off. 
 
 
+12) The canonical patch format
 
-12) More references for submitting patches
+The canonical patch subject line is:
+
+    Subject: [PATCH 001/123] subsystem: summary phrase
+
+The canonical patch message body contains the following:
+
+  - A "from" line specifying the patch author.
+
+  - An empty line.
+
+  - The body of the explanation, which will be copied to the
+    permanent changelog to describe this patch.
+
+  - The "Signed-off-by:" lines, described above, which will
+    also go in the changelog.
+
+  - A marker line containing simply "---".
+
+  - Any additional comments not suitable for the changelog.
+
+  - The actual patch (diff output).
+
+The Subject line format makes it very easy to sort the emails
+alphabetically by subject line - pretty much any email reader will
+support that - since because the sequence number is zero-padded,
+the numerical and alphabetic sort is the same.
+
+The "subsystem" in the email's Subject should identify which
+area or subsystem of the kernel is being patched.
+
+The "summary phrase" in the email's Subject should concisely
+describe the patch which that email contains.  The "summary
+phrase" should not be a filename.  Do not use the same "summary
+phrase" for every patch in a whole patch series.
+
+Bear in mind that the "summary phrase" of your email becomes
+a globally-unique identifier for that patch.  It propagates
+all the way into the git changelog.  The "summary phrase" may
+later be used in developer discussions which refer to the patch.
+People will want to google for the "summary phrase" to read
+discussion regarding that patch.
+
+A couple of example Subjects:
+
+    Subject: [patch 2/5] ext2: improve scalability of bitmap searching
+    Subject: [PATCHv2 001/207] x86: fix eflags tracking
+
+The "from" line must be the very first line in the message body,
+and has the form:
+
+        From: Original Author <author@example.com>
+
+The "from" line specifies who will be credited as the author of the
+patch in the permanent changelog.  If the "from" line is missing,
+then the "From:" line from the email header will be used to determine
+the patch author in the changelog.
+
+The explanation body will be committed to the permanent source
+changelog, so should make sense to a competent reader who has long
+since forgotten the immediate details of the discussion that might
+have led to this patch.
+
+The "---" marker line serves the essential purpose of marking for patch
+handling tools where the changelog message ends.
+
+One good use for the additional comments after the "---" marker is for
+a diffstat, to show what files have changed, and the number of inserted
+and deleted lines per file.  A diffstat is especially useful on bigger
+patches.  Other comments relevant only to the moment or the maintainer,
+not suitable for the permanent changelog, should also go here.
+
+See more details on the proper patch format in the following
+references.
+
+
+13) More references for submitting patches
 
 Andrew Morton, "The perfect patch" (tpp).
   <http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt>
@@ -310,6 +386,14 @@ Andrew Morton, "The perfect patch" (tpp).
 Jeff Garzik, "Linux kernel patch submission format."
   <http://linux.yyz.us/patch-format.html>
 
+Greg KH, "How to piss off a kernel subsystem maintainer"
+  <http://www.kroah.com/log/2005/03/31/>
+
+Kernel Documentation/CodingStyle
+  <http://sosdg.org/~coywolf/lxr/source/Documentation/CodingStyle>
+
+Linus Torvald's mail on the canonical patch format:
+  <http://lkml.org/lkml/2005/4/7/183>
 
 
 -----------------------------------
diff --git a/Documentation/keys-request-key.txt b/Documentation/keys-request-key.txt
new file mode 100644 (file)
index 0000000..5f2b9c5
--- /dev/null
@@ -0,0 +1,161 @@
+                             ===================
+                             KEY REQUEST SERVICE
+                             ===================
+
+The key request service is part of the key retention service (refer to
+Documentation/keys.txt). This document explains more fully how that the
+requesting algorithm works.
+
+The process starts by either the kernel requesting a service by calling
+request_key():
+
+       struct key *request_key(const struct key_type *type,
+                               const char *description,
+                               const char *callout_string);
+
+Or by userspace invoking the request_key system call:
+
+       key_serial_t request_key(const char *type,
+                                const char *description,
+                                const char *callout_info,
+                                key_serial_t dest_keyring);
+
+The main difference between the two access points is that the in-kernel
+interface does not need to link the key to a keyring to prevent it from being
+immediately destroyed. The kernel interface returns a pointer directly to the
+key, and it's up to the caller to destroy the key.
+
+The userspace interface links the key to a keyring associated with the process
+to prevent the key from going away, and returns the serial number of the key to
+the caller.
+
+
+===========
+THE PROCESS
+===========
+
+A request proceeds in the following manner:
+
+ (1) Process A calls request_key() [the userspace syscall calls the kernel
+     interface].
+
+ (2) request_key() searches the process's subscribed keyrings to see if there's
+     a suitable key there. If there is, it returns the key. If there isn't, and
+     callout_info is not set, an error is returned. Otherwise the process
+     proceeds to the next step.
+
+ (3) request_key() sees that A doesn't have the desired key yet, so it creates
+     two things:
+
+     (a) An uninstantiated key U of requested type and description.
+
+     (b) An authorisation key V that refers to key U and notes that process A
+        is the context in which key U should be instantiated and secured, and
+        from which associated key requests may be satisfied.
+
+ (4) request_key() then forks and executes /sbin/request-key with a new session
+     keyring that contains a link to auth key V.
+
+ (5) /sbin/request-key execs an appropriate program to perform the actual
+     instantiation.
+
+ (6) The program may want to access another key from A's context (say a
+     Kerberos TGT key). It just requests the appropriate key, and the keyring
+     search notes that the session keyring has auth key V in its bottom level.
+
+     This will permit it to then search the keyrings of process A with the
+     UID, GID, groups and security info of process A as if it was process A,
+     and come up with key W.
+
+ (7) The program then does what it must to get the data with which to
+     instantiate key U, using key W as a reference (perhaps it contacts a
+     Kerberos server using the TGT) and then instantiates key U.
+
+ (8) Upon instantiating key U, auth key V is automatically revoked so that it
+     may not be used again.
+
+ (9) The program then exits 0 and request_key() deletes key V and returns key
+     U to the caller.
+
+This also extends further. If key W (step 5 above) didn't exist, key W would be
+created uninstantiated, another auth key (X) would be created [as per step 3]
+and another copy of /sbin/request-key spawned [as per step 4]; but the context
+specified by auth key X will still be process A, as it was in auth key V.
+
+This is because process A's keyrings can't simply be attached to
+/sbin/request-key at the appropriate places because (a) execve will discard two
+of them, and (b) it requires the same UID/GID/Groups all the way through.
+
+
+======================
+NEGATIVE INSTANTIATION
+======================
+
+Rather than instantiating a key, it is possible for the possessor of an
+authorisation key to negatively instantiate a key that's under construction.
+This is a short duration placeholder that causes any attempt at re-requesting
+the key whilst it exists to fail with error ENOKEY.
+
+This is provided to prevent excessive repeated spawning of /sbin/request-key
+processes for a key that will never be obtainable.
+
+Should the /sbin/request-key process exit anything other than 0 or die on a
+signal, the key under construction will be automatically negatively
+instantiated for a short amount of time.
+
+
+====================
+THE SEARCH ALGORITHM
+====================
+
+A search of any particular keyring proceeds in the following fashion:
+
+ (1) When the key management code searches for a key (keyring_search_aux) it
+     firstly calls key_permission(SEARCH) on the keyring it's starting with,
+     if this denies permission, it doesn't search further.
+
+ (2) It considers all the non-keyring keys within that keyring and, if any key
+     matches the criteria specified, calls key_permission(SEARCH) on it to see
+     if the key is allowed to be found. If it is, that key is returned; if
+     not, the search continues, and the error code is retained if of higher
+     priority than the one currently set.
+
+ (3) It then considers all the keyring-type keys in the keyring it's currently
+     searching. It calls key_permission(SEARCH) on each keyring, and if this
+     grants permission, it recurses, executing steps (2) and (3) on that
+     keyring.
+
+The process stops immediately a valid key is found with permission granted to
+use it. Any error from a previous match attempt is discarded and the key is
+returned.
+
+When search_process_keyrings() is invoked, it performs the following searches
+until one succeeds:
+
+ (1) If extant, the process's thread keyring is searched.
+
+ (2) If extant, the process's process keyring is searched.
+
+ (3) The process's session keyring is searched.
+
+ (4) If the process has a request_key() authorisation key in its session
+     keyring then:
+
+     (a) If extant, the calling process's thread keyring is searched.
+
+     (b) If extant, the calling process's process keyring is searched.
+
+     (c) The calling process's session keyring is searched.
+
+The moment one succeeds, all pending errors are discarded and the found key is
+returned.
+
+Only if all these fail does the whole thing fail with the highest priority
+error. Note that several errors may have come from LSM.
+
+The error priority is:
+
+       EKEYREVOKED > EKEYEXPIRED > ENOKEY
+
+EACCES/EPERM are only returned on a direct search of a specific keyring where
+the basal keyring does not grant Search permission.
index b22e7c8d059a1666d3c3d4f02e2a01b464b19fab..4afe03a58c5ba912d6977d38a76314fe34d7bf66 100644 (file)
@@ -361,6 +361,8 @@ The main syscalls are:
      /sbin/request-key will be invoked in an attempt to obtain a key. The
      callout_info string will be passed as an argument to the program.
 
+     See also Documentation/keys-request-key.txt.
+
 
 The keyctl syscall functions are:
 
@@ -533,8 +535,8 @@ The keyctl syscall functions are:
 
  (*) Read the payload data from a key:
 
-       key_serial_t keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer,
-                           size_t buflen);
+       long keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer,
+                   size_t buflen);
 
      This function attempts to read the payload data from the specified key
      into the buffer. The process must have read permission on the key to
@@ -555,9 +557,9 @@ The keyctl syscall functions are:
 
  (*) Instantiate a partially constructed key.
 
-       key_serial_t keyctl(KEYCTL_INSTANTIATE, key_serial_t key,
-                           const void *payload, size_t plen,
-                           key_serial_t keyring);
+       long keyctl(KEYCTL_INSTANTIATE, key_serial_t key,
+                   const void *payload, size_t plen,
+                   key_serial_t keyring);
 
      If the kernel calls back to userspace to complete the instantiation of a
      key, userspace should use this call to supply data for the key before the
@@ -576,8 +578,8 @@ The keyctl syscall functions are:
 
  (*) Negatively instantiate a partially constructed key.
 
-       key_serial_t keyctl(KEYCTL_NEGATE, key_serial_t key,
-                           unsigned timeout, key_serial_t keyring);
+       long keyctl(KEYCTL_NEGATE, key_serial_t key,
+                   unsigned timeout, key_serial_t keyring);
 
      If the kernel calls back to userspace to complete the instantiation of a
      key, userspace should use this call mark the key as negative before the
@@ -688,6 +690,8 @@ payload contents" for more information.
     If successful, the key will have been attached to the default keyring for
     implicitly obtained request-key keys, as set by KEYCTL_SET_REQKEY_KEYRING.
 
+    See also Documentation/keys-request-key.txt.
+
 
 (*) When it is no longer required, the key should be released using:
 
index ab65714d95fcec32b6103c384f05bd06ab84c506..b433c8a27e2d16728c69d39ec8ebcbc43a6d84f1 100644 (file)
@@ -355,10 +355,14 @@ ip_dynaddr - BOOLEAN
        Default: 0
 
 icmp_echo_ignore_all - BOOLEAN
+       If set non-zero, then the kernel will ignore all ICMP ECHO
+       requests sent to it.
+       Default: 0
+
 icmp_echo_ignore_broadcasts - BOOLEAN
-       If either is set to true, then the kernel will ignore either all
-       ICMP ECHO requests sent to it or just those to broadcast/multicast
-       addresses, respectively.
+       If set non-zero, then the kernel will ignore all ICMP ECHO and
+       TIMESTAMP requests sent to it via broadcast/multicast.
+       Default: 1
 
 icmp_ratelimit - INTEGER
        Limit the maximal rates for sending ICMP packets whose type matches
index c1bc9a86a99d61a7944886ef6179e6c9813032e8..abf7f7a17ae0eac9f5cd36acfdac298a3dbf8e3e 100644 (file)
@@ -1168,11 +1168,6 @@ L:       linux1394-devel@lists.sourceforge.net
 W:     http://www.linux1394.org/
 S:     Orphan
 
-IEEE 1394 SBP2
-L:     linux1394-devel@lists.sourceforge.net
-W:     http://www.linux1394.org/
-S:     Orphan
-
 IEEE 1394 SUBSYSTEM
 P:     Ben Collins
 M:     bcollins@debian.org
@@ -1207,6 +1202,15 @@ L:       linux1394-devel@lists.sourceforge.net
 W:     http://www.linux1394.org/
 S:     Maintained
 
+IEEE 1394 SBP2
+P:     Ben Collins
+M:     bcollins@debian.org
+P:     Stefan Richter
+M:     stefanr@s5r6.in-berlin.de
+L:     linux1394-devel@lists.sourceforge.net
+W:     http://www.linux1394.org/
+S:     Maintained
+
 IMS TWINTURBO FRAMEBUFFER DRIVER
 P:     Paul Mundt
 M:     lethal@chaoticdreams.org
@@ -1743,8 +1747,11 @@ S:       Maintained
 IPVS
 P:     Wensong Zhang
 M:     wensong@linux-vs.org
+P:     Simon Horman
+M:     horms@verge.net.au
 P:     Julian Anastasov
 M:     ja@ssi.bg
+L:     netdev@vger.kernel.org
 S:     Maintained
 
 NFS CLIENT
index 8cf6becf68dcf3352d0b1ebe8d87c1d1eb5df033..fdb96bc85080700d0e8b551aff06dcf27b5ede7e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 14
-EXTRAVERSION =-rc2
+EXTRAVERSION =-rc3
 NAME=Affluent Albatross
 
 # *DOCUMENTATION*
index 76cc0cb5fc2e429ebe0a98026271bbff7a6225f9..e38671c922bc673016771d1ec94e18edf34b8b9f 100644 (file)
@@ -196,6 +196,7 @@ entUna:
        stq     $26, 208($sp)
        stq     $27, 216($sp)
        stq     $28, 224($sp)
+       mov     $sp, $19
        stq     $gp, 232($sp)
        lda     $8, 0x3fff
        stq     $31, 248($sp)
index 6f509a644bddade182f7b27dade5e971fffb0f13..f9d12319e0fbba45ec9dc97cfd9e31e5581fadea 100644 (file)
@@ -446,16 +446,15 @@ struct unaligned_stat {
 
 
 /* Macro for exception fixup code to access integer registers.  */
-#define una_reg(r)  (regs.regs[(r) >= 16 && (r) <= 18 ? (r)+19 : (r)])
+#define una_reg(r)  (regs->regs[(r) >= 16 && (r) <= 18 ? (r)+19 : (r)])
 
 
 asmlinkage void
 do_entUna(void * va, unsigned long opcode, unsigned long reg,
-         unsigned long a3, unsigned long a4, unsigned long a5,
-         struct allregs regs)
+         struct allregs *regs)
 {
        long error, tmp1, tmp2, tmp3, tmp4;
-       unsigned long pc = regs.pc - 4;
+       unsigned long pc = regs->pc - 4;
        const struct exception_table_entry *fixup;
 
        unaligned[0].count++;
@@ -636,7 +635,7 @@ got_exception:
                printk("Forwarding unaligned exception at %lx (%lx)\n",
                       pc, newpc);
 
-               (&regs)->pc = newpc;
+               regs->pc = newpc;
                return;
        }
 
@@ -650,7 +649,7 @@ got_exception:
               current->comm, current->pid);
 
        printk("pc = [<%016lx>]  ra = [<%016lx>]  ps = %04lx\n",
-              pc, una_reg(26), regs.ps);
+              pc, una_reg(26), regs->ps);
        printk("r0 = %016lx  r1 = %016lx  r2 = %016lx\n",
               una_reg(0), una_reg(1), una_reg(2));
        printk("r3 = %016lx  r4 = %016lx  r5 = %016lx\n",
@@ -670,10 +669,10 @@ got_exception:
               una_reg(22), una_reg(23), una_reg(24));
        printk("r25= %016lx  r27= %016lx  r28= %016lx\n",
               una_reg(25), una_reg(27), una_reg(28));
-       printk("gp = %016lx  sp = %p\n", regs.gp, &regs+1);
+       printk("gp = %016lx  sp = %p\n", regs->gp, regs+1);
 
        dik_show_code((unsigned int *)pc);
-       dik_show_trace((unsigned long *)(&regs+1));
+       dik_show_trace((unsigned long *)(regs+1));
 
        if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
                printk("die_if_kernel recursion detected.\n");
index d7499071755976a0a14b7b0c26eb8db62555e7b9..c02dc8116a18ef5facc08dbf61655c0144cfdaec 100644 (file)
@@ -68,6 +68,7 @@ static void gic_unmask_irq(unsigned int irq)
        writel(mask, gic_dist_base + GIC_DIST_ENABLE_SET + (irq / 32) * 4);
 }
 
+#ifdef CONFIG_SMP
 static void gic_set_cpu(struct irqdesc *desc, unsigned int irq, unsigned int cpu)
 {
        void __iomem *reg = gic_dist_base + GIC_DIST_TARGET + (irq & ~3);
@@ -78,6 +79,7 @@ static void gic_set_cpu(struct irqdesc *desc, unsigned int irq, unsigned int cpu
        val |= 1 << (cpu + shift);
        writel(val, reg);
 }
+#endif
 
 static struct irqchip gic_chip = {
        .ack            = gic_ack_irq,
index a7bd857001522651709ff4fafd57c427ca036ad3..e8053d16829b877bf6f5a8c4269900549bada9f1 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/spinlock.h>
 
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/mach/irq.h>
index 42629ff84f5a8864787c1d862f001e47a3000765..ea569ba482b165bd05292ea3504c3d90bbeab04c 100644 (file)
@@ -305,7 +305,7 @@ long execve(const char *filename, char **argv, char **envp)
                  "Ir" (THREAD_START_SP - sizeof(regs)),
                  "r" (&regs),
                  "Ir" (sizeof(regs))
-               : "r0", "r1", "r2", "r3", "ip", "memory");
+               : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
 
  out:
        return ret;
index e7d22dbcb691e1e4444f94db0ab5da5b45b8731c..f6de76e0a45d388e1974f2015f2e3ba7de6c6094 100644 (file)
@@ -504,7 +504,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
 
                bad_access:
                spin_unlock(&mm->page_table_lock);
-               /* simulate a read access fault */
+               /* simulate a write access fault */
                do_DataAbort(addr, 15 + (1 << 11), regs);
                return -1;
        }
index f83a59761e0276e3732661ce1723c98056e17732..3d88da0c287b93e5f9389881ad7637335c4331fc 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <asm/mach/arch.h>
 
+#include <asm/memory.h>
+
 #include "common.h"
 
 struct meminfo memmap = {
index 41e5849ae8dab7a4bee66186a29cadadcc49be22..f8a742bb2d5b6f57b90f7c3960f66323e59dd413 100644 (file)
 #include <linux/module.h>
 #include <asm/arch/imxfb.h>
 #include <asm/hardware.h>
+#include <asm/arch/imx-regs.h>
 
 #include <asm/mach/map.h>
 
 void imx_gpio_mode(int gpio_mode)
 {
        unsigned int pin = gpio_mode & GPIO_PIN_MASK;
-       unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> 5;
-       unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> 10;
+       unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
+       unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT;
        unsigned int tmp;
 
        /* Pullup enable */
@@ -57,7 +58,7 @@ void imx_gpio_mode(int gpio_mode)
                GPR(port) &= ~(1<<pin);
 
        /* use as gpio? */
-       if( ocr == 3 )
+       if(gpio_mode &  GPIO_GIUS)
                GIUS(port) |= (1<<pin);
        else
                GIUS(port) &= ~(1<<pin);
@@ -72,20 +73,20 @@ void imx_gpio_mode(int gpio_mode)
                tmp |= (ocr << (pin*2));
                OCR1(port) = tmp;
 
-               if( gpio_mode & GPIO_AOUT )
-                       ICONFA1(port) &= ~( 3<<(pin*2));
-               if( gpio_mode & GPIO_BOUT )
-                       ICONFB1(port) &= ~( 3<<(pin*2));
+               ICONFA1(port) &= ~( 3<<(pin*2));
+               ICONFA1(port) |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2);
+               ICONFB1(port) &= ~( 3<<(pin*2));
+               ICONFB1(port) |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << (pin * 2);
        } else {
                tmp = OCR2(port);
                tmp &= ~( 3<<((pin-16)*2));
                tmp |= (ocr << ((pin-16)*2));
                OCR2(port) = tmp;
 
-               if( gpio_mode & GPIO_AOUT )
-                       ICONFA2(port) &= ~( 3<<((pin-16)*2));
-               if( gpio_mode & GPIO_BOUT )
-                       ICONFB2(port) &= ~( 3<<((pin-16)*2));
+               ICONFA2(port) &= ~( 3<<((pin-16)*2));
+               ICONFA2(port) |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << ((pin-16) * 2);
+               ICONFB2(port) &= ~( 3<<((pin-16)*2));
+               ICONFB2(port) |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << ((pin-16) * 2);
        }
 }
 
index e6399b06e4a4742580f74f6f31289ad41c36052d..79236404aec2571b1f26b383b7d0e7a370ad2e19 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/leds.h>
-#include <asm/mach-types.h>
 #include "leds.h"
 
 /*
index 5d25434d332cff721c0c9b43012d3451a800aa81..a7511ddfe364b2123686af22746ce36ba5cc0a24 100644 (file)
@@ -55,7 +55,7 @@ static void __init
 mx1ads_init(void)
 {
 #ifdef CONFIG_LEDS
-       imx_gpio_mode(GPIO_PORTA | GPIO_OUT | GPIO_GPIO | 2);
+       imx_gpio_mode(GPIO_PORTA | GPIO_OUT | 2);
 #endif
        platform_add_devices(devices, ARRAY_SIZE(devices));
 }
index bda7394ec06cf38283575c4fea528630ef038f1a..fdeeef489a73592039c605ed55a2156ac277801f 100644 (file)
@@ -27,7 +27,6 @@ unsigned long iop3xx_pcibios_min_mem = 0;
 /*
  * Default power-off for EP80219
  */
-#include <asm/mach-types.h>
 
 static inline void ep80219_send_to_pic(__u8 c) {
 }
index 0039793b694a20cd63da8930386a5ba3c6cbf9d1..d67ac0e5d4381ef06bba8dca5a3848d9b4d9a4f4 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm/mach-types.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
index 8eddfac7e2b046450d74a6074837b9f73e0fff1b..3c1f0ebbd636e42e8160fddae779bf81d90c9e9c 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm/mach-types.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
index b01042f7de71f5b0a699f869edba99368335e9fe..55992ab586baf87d2418f2f91c865460321b04a0 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/page.h>
 
 #include <asm/mach/map.h>
-#include <asm/mach-types.h>
 
 
 /*
index 1580c7ed2b9d24e5364436c266fa99104a6205b2..bb3e9e5a9aff0e218ec0e9967e680cdecd2160e7 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/page.h>
 
 #include <asm/mach/map.h>
-#include <asm/mach-types.h>
 
 
 /*
index ee8c333e115f6fffa4e08451e8babb8cadfd88a5..129eb49b0670e161d971f4c4db0672c381523c4e 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/page.h>
 
 #include <asm/mach/map.h>
-#include <asm/mach-types.h>
 
 
 /*
index 084afcdfb1eb84ce72ddf0168873b77cdd58616a..2feaf7591f5315ca8fa0f5312ab1bde7b4ad2aa4 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/page.h>
 
 #include <asm/mach/map.h>
-#include <asm/mach-types.h>
 
 
 /*
index 74bd2fd602d45181ed333bb3ee7fb9e9cc6aaf5e..f4d7f1f6ef851253d3466b39d403815dd07209fb 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/setup.h>
 #include <asm/memory.h>
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/tlbflush.h>
@@ -168,7 +167,7 @@ static struct plat_serial8250_port ixp2000_serial_port[] = {
 
 static struct resource ixp2000_uart_resource = {
        .start          = IXP2000_UART_PHYS_BASE,
-       .end            = IXP2000_UART_PHYS_BASE + 0xffff,
+       .end            = IXP2000_UART_PHYS_BASE + 0x1f,
        .flags          = IORESOURCE_MEM,
 };
 
index 0788fb2b5c10e6ae6e2023649930205cc3afb016..522205acb316fc6745d73732481fddf5cd094de7 100644 (file)
@@ -28,7 +28,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/system.h>
-#include <asm/mach-types.h>
 #include <asm/hardware.h>
 
 #include <asm/mach/pci.h>
index 39b06ed806462b69a1afd5ac39c5e49430b1b844..0a41080d2266c27083503f55384bce245cfb8a07 100644 (file)
@@ -123,7 +123,7 @@ static void __init ixdp425_init(void)
        platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
 }
 
-#ifdef CONFIG_ARCH_IXDP465
+#ifdef CONFIG_ARCH_IXDP425
 MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
        /* Maintainer: MontaVista Software, Inc. */
        .phys_ram       = PHYS_OFFSET,
index 2a7fee2a7635109212810c0f5cbc5ca959f364b3..5fd8c9f97f9adab013f423d05f778311853b94e1 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/page.h>
 
 #include <asm/mach/map.h>
-#include <asm/arch/hardware.h>
 
 /*
  * IRQ base register
index c5efcd04fcbc8011c01961ca334a080dcf62005a..c02ef7c0f7ef6cf45b3bfdad6f68468b4f0e8dc9 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/module.h>
-#include <asm/mach-types.h>
 #include <asm/arch/akita.h>
 #include <asm/arch/corgi.h>
 #include <asm/arch/hardware.h>
index a45aaa115a76664bb81438455b06a6ff890886f7..d0660a8c4b704429111daa3bc607e3ac0b582550 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/arch/udc.h>
 #include <asm/arch/pxafb.h>
 #include <asm/arch/mmc.h>
+#include <asm/arch/i2c.h>
 
 #include "generic.h"
 
index f021fd82be52cb7260c91be5c02a8ce0c4d2ef49..5098b50158a332ce81b8bdd36945c5916d9f8cb3 100644 (file)
@@ -40,7 +40,6 @@
 #include <asm/hardware.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/mach-types.h>
 
 #include "devs.h"
 #include "usb-simtec.h"
index 3c8862fde51ad18a362713f821757b1cba4a3903..a30e0451df72230d731978257c23e8570de6f72c 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/leds.h>
-#include <asm/mach-types.h>
 #include <asm/hardware/amba.h>
 #include <asm/hardware/amba_clcd.h>
 #include <asm/hardware/arm_timer.h>
@@ -52,8 +51,9 @@
  *
  * Setup a VA for the Versatile Vectored Interrupt Controller.
  */
-#define VA_VIC_BASE             IO_ADDRESS(VERSATILE_VIC_BASE)
-#define VA_SIC_BASE             IO_ADDRESS(VERSATILE_SIC_BASE)
+#define __io_address(n)                __io(IO_ADDRESS(n))
+#define VA_VIC_BASE            __io_address(VERSATILE_VIC_BASE)
+#define VA_SIC_BASE            __io_address(VERSATILE_SIC_BASE)
 
 static void vic_mask_irq(unsigned int irq)
 {
@@ -214,7 +214,7 @@ void __init versatile_map_io(void)
        iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc));
 }
 
-#define VERSATILE_REFCOUNTER   (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET)
+#define VERSATILE_REFCOUNTER   (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET)
 
 /*
  * This is the Versatile sched_clock implementation.  This has
@@ -231,7 +231,7 @@ unsigned long long sched_clock(void)
 }
 
 
-#define VERSATILE_FLASHCTRL    (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
+#define VERSATILE_FLASHCTRL    (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
 
 static int versatile_flash_init(void)
 {
@@ -309,7 +309,7 @@ static struct platform_device smc91x_device = {
        .resource       = smc91x_resources,
 };
 
-#define VERSATILE_SYSMCI       (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
+#define VERSATILE_SYSMCI       (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
 
 unsigned int mmc_status(struct device *dev)
 {
@@ -343,11 +343,11 @@ static const struct icst307_params versatile_oscvco_params = {
 
 static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco)
 {
-       unsigned long sys_lock = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET;
+       void __iomem *sys_lock = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET;
 #if defined(CONFIG_ARCH_VERSATILE_PB)
-       unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET;
+       void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET;
 #elif defined(CONFIG_MACH_VERSATILE_AB)
-       unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET;
+       void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET;
 #endif
        u32 val;
 
@@ -483,7 +483,7 @@ static struct clcd_panel epson_2_2_in = {
  */
 static struct clcd_panel *versatile_clcd_panel(void)
 {
-       unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
+       void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
        struct clcd_panel *panel = &vga;
        u32 val;
 
@@ -510,7 +510,7 @@ static struct clcd_panel *versatile_clcd_panel(void)
  */
 static void versatile_clcd_disable(struct clcd_fb *fb)
 {
-       unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
+       void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
        u32 val;
 
        val = readl(sys_clcd);
@@ -522,7 +522,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb)
         * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off
         */
        if (fb->panel == &sanyo_2_5_in) {
-               unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL);
+               void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL);
                unsigned long ctrl;
 
                ctrl = readl(versatile_ib2_ctrl);
@@ -537,7 +537,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb)
  */
 static void versatile_clcd_enable(struct clcd_fb *fb)
 {
-       unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
+       void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
        u32 val;
 
        val = readl(sys_clcd);
@@ -571,7 +571,7 @@ static void versatile_clcd_enable(struct clcd_fb *fb)
         * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on
         */
        if (fb->panel == &sanyo_2_5_in) {
-               unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL);
+               void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL);
                unsigned long ctrl;
 
                ctrl = readl(versatile_ib2_ctrl);
@@ -720,7 +720,7 @@ static struct amba_device *amba_devs[] __initdata = {
 };
 
 #ifdef CONFIG_LEDS
-#define VA_LEDS_BASE (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET)
+#define VA_LEDS_BASE (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET)
 
 static void versatile_leds_event(led_event_t ledevt)
 {
@@ -778,11 +778,11 @@ void __init versatile_init(void)
 /*
  * Where is the timer (VA)?
  */
-#define TIMER0_VA_BASE          IO_ADDRESS(VERSATILE_TIMER0_1_BASE)
-#define TIMER1_VA_BASE         (IO_ADDRESS(VERSATILE_TIMER0_1_BASE) + 0x20)
-#define TIMER2_VA_BASE          IO_ADDRESS(VERSATILE_TIMER2_3_BASE)
-#define TIMER3_VA_BASE         (IO_ADDRESS(VERSATILE_TIMER2_3_BASE) + 0x20)
-#define VA_IC_BASE              IO_ADDRESS(VERSATILE_VIC_BASE) 
+#define TIMER0_VA_BASE          __io_address(VERSATILE_TIMER0_1_BASE)
+#define TIMER1_VA_BASE         (__io_address(VERSATILE_TIMER0_1_BASE) + 0x20)
+#define TIMER2_VA_BASE          __io_address(VERSATILE_TIMER2_3_BASE)
+#define TIMER3_VA_BASE         (__io_address(VERSATILE_TIMER2_3_BASE) + 0x20)
+#define VA_IC_BASE              __io_address(VERSATILE_VIC_BASE) 
 
 /*
  * How long is the timer interval?
@@ -877,12 +877,12 @@ static void __init versatile_timer_init(void)
         *      VERSATILE_REFCLK is 32KHz
         *      VERSATILE_TIMCLK is 1MHz
         */
-       val = readl(IO_ADDRESS(VERSATILE_SCTL_BASE));
+       val = readl(__io_address(VERSATILE_SCTL_BASE));
        writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) |
               (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | 
               (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) |
               (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val,
-              IO_ADDRESS(VERSATILE_SCTL_BASE));
+              __io_address(VERSATILE_SCTL_BASE));
 
        /*
         * Initialise to a known state (all timers off)
index d1565e851f0e01f6b6e63f73939455214c817ef0..b80d57d516991b64a08ba47f6fc67d325396389a 100644 (file)
@@ -29,7 +29,6 @@
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/mach/pci.h>
-#include <asm/mach-types.h>
 
 /*
  * these spaces are mapped using the following base registers:
index db5e47dfc303dce4a49b9ca54db0ab1f0e3673af..c54e04c995eedab8884ac688922e7065153d4099 100644 (file)
@@ -370,21 +370,21 @@ config CPU_BIG_ENDIAN
 
 config CPU_ICACHE_DISABLE
        bool "Disable I-Cache"
-       depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020
+       depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_V6
        help
          Say Y here to disable the processor instruction cache. Unless
          you have a reason not to or are unsure, say N.
 
 config CPU_DCACHE_DISABLE
        bool "Disable D-Cache"
-       depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020
+       depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_V6
        help
          Say Y here to disable the processor data cache. Unless
          you have a reason not to or are unsure, say N.
 
 config CPU_DCACHE_WRITETHROUGH
        bool "Force write through D-cache"
-       depends on (CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020) && !CPU_DCACHE_DISABLE
+       depends on (CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_V6) && !CPU_DCACHE_DISABLE
        default y if CPU_ARM925T
        help
          Say Y here to use the data cache in writethrough mode. Unless you
@@ -399,7 +399,7 @@ config CPU_CACHE_ROUND_ROBIN
 
 config CPU_BPREDICT_DISABLE
        bool "Disable branch prediction"
-       depends on CPU_ARM1020
+       depends on CPU_ARM1020 || CPU_V6
        help
          Say Y here to disable branch prediction.  If unsure, say N.
 
index 8f76f3df7b4cf03e949b51f2817e7f0c4af4b44a..dbd346033122140df010997b1c85cb4615b133c1 100644 (file)
  */
        .align  5
 ENTRY(v6_early_abort)
+#ifdef CONFIG_CPU_MPCORE
+       clrex
+#else
+       strex   r0, r1, [sp]                    @ Clear the exclusive monitor
+#endif
        mrc     p15, 0, r1, c5, c0, 0           @ get FSR
        mrc     p15, 0, r0, c6, c0, 0           @ get FAR
 /*
index 85c10a71e7c62ef779ec8810d7a5bb537d7c21d3..72966d90e956b88ed001605c332128efa081ee58 100644 (file)
@@ -18,6 +18,7 @@
 #define HARVARD_CACHE
 #define CACHE_LINE_SIZE                32
 #define D_CACHE_LINE_SIZE      32
+#define BTB_FLUSH_SIZE         8
 
 /*
  *     v6_flush_cache_all()
@@ -98,7 +99,13 @@ ENTRY(v6_coherent_user_range)
        mcr     p15, 0, r0, c7, c5, 1           @ invalidate I line
 #endif
        mcr     p15, 0, r0, c7, c5, 7           @ invalidate BTB entry
-       add     r0, r0, #CACHE_LINE_SIZE
+       add     r0, r0, #BTB_FLUSH_SIZE
+       mcr     p15, 0, r0, c7, c5, 7           @ invalidate BTB entry
+       add     r0, r0, #BTB_FLUSH_SIZE
+       mcr     p15, 0, r0, c7, c5, 7           @ invalidate BTB entry
+       add     r0, r0, #BTB_FLUSH_SIZE
+       mcr     p15, 0, r0, c7, c5, 7           @ invalidate BTB entry
+       add     r0, r0, #BTB_FLUSH_SIZE
        cmp     r0, r1
        blo     1b
 #ifdef HARVARD_CACHE
index b0208c9925764940db06976ec69665b66d7275e0..c9a03981b785895a0d2379706e780847ccef1ed6 100644 (file)
 
 #ifdef CONFIG_CPU_CACHE_VIPT
 
+#define ALIAS_FLUSH_START      0xffff4000
+
+#define TOP_PTE(x)     pte_offset_kernel(top_pmd, x)
+
+static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
+{
+       unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
+
+       set_pte(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL));
+       flush_tlb_kernel_page(to);
+
+       asm(    "mcrr   p15, 0, %1, %0, c14\n"
+       "       mcrr    p15, 0, %1, %0, c5\n"
+           :
+           : "r" (to), "r" (to + PAGE_SIZE - L1_CACHE_BYTES)
+           : "cc");
+}
+
 void flush_cache_mm(struct mm_struct *mm)
 {
        if (cache_is_vivt()) {
@@ -67,24 +85,6 @@ void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsig
        if (cache_is_vipt_aliasing())
                flush_pfn_alias(pfn, user_addr);
 }
-
-#define ALIAS_FLUSH_START      0xffff4000
-
-#define TOP_PTE(x)     pte_offset_kernel(top_pmd, x)
-
-static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
-{
-       unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
-
-       set_pte(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL));
-       flush_tlb_kernel_page(to);
-
-       asm(    "mcrr   p15, 0, %1, %0, c14\n"
-       "       mcrr    p15, 0, %1, %0, c5\n"
-           :
-           : "r" (to), "r" (to + PAGE_SIZE - L1_CACHE_BYTES)
-           : "cc");
-}
 #else
 #define flush_pfn_alias(pfn,vaddr)     do { } while (0)
 #endif
index 6cb20aea7f518b22dbd9b25a6d93cc6ac93fd1ff..02bcc6c1cd1b136284d4a76d1fb067e714544f4a 100644 (file)
@@ -25,7 +25,6 @@
 #include <asm/mach/map.h>
 #include <asm/hardware/clock.h>
 #include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/setup.h>
 
 #include <asm/arch/board.h>
index 409aac2c4b9de75400cf0f34bc50131362bb7125..fd894bb00107bf1c1ad42ec375c691abe224bc44 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/err.h>
 
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 #include <asm/io.h>
 #include <asm/system.h>
 
index 98f1c76f86606f039dad4501651f371f7056f099..14a836d7ac250a4ebee43b3cca8edf1b5e70cba8 100644 (file)
@@ -33,7 +33,6 @@
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 
 #include <asm/arch/mux.h>
 #include <asm/arch/usb.h>
index 838437b2d241bfbcb5bf560f410509cdca049ec2..b66c13c0cc0f8b45742021e35119067b3778d6dc 100644 (file)
 #include <linux/efi.h>
 #include <linux/module.h>
 #include <linux/dmi.h>
+#include <linux/irq.h>
 
 #include <asm/pgtable.h>
 #include <asm/io_apic.h>
 #include <asm/apic.h>
 #include <asm/io.h>
-#include <asm/irq.h>
 #include <asm/mpspec.h>
 
 #ifdef CONFIG_X86_64
index 73aeaf5a9d4e493f7e2be65ac67a285d966e062c..4c1ddf2b57cc37d4196091ee41ea5c5035993023 100644 (file)
@@ -28,6 +28,22 @@ static void __init init_amd(struct cpuinfo_x86 *c)
        int mbytes = num_physpages >> (20-PAGE_SHIFT);
        int r;
 
+#ifdef CONFIG_SMP
+       unsigned long value;
+
+       /* Disable TLB flush filter by setting HWCR.FFDIS on K8
+        * bit 6 of msr C001_0015
+        *
+        * Errata 63 for SH-B3 steppings
+        * Errata 122 for all steppings (F+ have it disabled by default)
+        */
+       if (c->x86 == 15) {
+               rdmsrl(MSR_K7_HWCR, value);
+               value |= 1 << 6;
+               wrmsrl(MSR_K7_HWCR, value);
+       }
+#endif
+
        /*
         *      FIXME: We should handle the K5 here. Set up the write
         *      range and also turn on MSR 83 bits 4 and 31 (write alloc,
index 7e7a202df3c8dc1903874cb1a7b175e1def2bf8c..4c4522b43be5e9a6951e0b4cb7252f2ee67b73e9 100644 (file)
@@ -1,7 +1,7 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <linux/init.h>
-#include <asm/hw_irq.h>
+#include <linux/irq.h>
 #include <asm/numa.h>
 #include "pci.h"
 
index 281ed8ab347ab0a37a50771e86e239d8c9dc825f..cddafe33ff7c522ca007569e0d73faade5465fc7 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/io_apic.h>
-#include <asm/hw_irq.h>
+#include <linux/irq.h>
 #include <linux/acpi.h>
 
 #include "pci.h"
index 6dc726ad71372954b36c02b93949f240ac794ee4..d0a5106fba243f8364d2e8e0d86b844566db7a7c 100644 (file)
@@ -1016,6 +1016,11 @@ ia64_mca_cmc_int_handler(int cmc_irq, void *arg, struct pt_regs *ptregs)
 
                        cmc_polling_enabled = 1;
                        spin_unlock(&cmc_history_lock);
+                       /* If we're being hit with CMC interrupts, we won't
+                        * ever execute the schedule_work() below.  Need to
+                        * disable CMC interrupts on this processor now.
+                        */
+                       ia64_mca_cmc_vector_disable(NULL);
                        schedule_work(&cmc_disable_work);
 
                        /*
index 9362193742aceecf5dd52110767f6cfb502acdd4..d4dd8f15395ecb3495289f6ce8bb91c9da6162d1 100644 (file)
@@ -1,4 +1,4 @@
-OUTPUT_ARCH(powerpc)
+OUTPUT_ARCH(powerpc:common)
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
index ac391d463d78af752e05b3dddff082e1604e6927..78a403b48dba9c861fe54f27ee94cab2c3db09be 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/initrd.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/tty.h>
index d6b2b1965dcb30a179689705a1db8d627ac01abe..27b778ab903b89b40c15ed354d3eb9cda471e887 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/initrd.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/tty.h>
index a38e6f9ef858ae78db73688c3a80b52d217303da..16d953bda22cf13b50f2d43c42a8187d7d4e6e81 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/initrd.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/tty.h>
index 80028df1b445b422ece4a9edfc02186b8aced50e..506949c5dd29d4c069ce518e0e02ef22d0427b1b 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/initrd.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/tty.h>
index b38a851a64ecc2250a4b1dca23377083e703aeb4..79b3f533d0a3a698d2159dbec8f46d39428c2d3b 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/serial.h>
index f761fdf160db5ee353c8cd56518f45ac955102f6..7dc8a68acfd03a99e5c9c5fe18fae9b3b94b5a31 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/serial.h>
index f2748c88665ac5e044565d165fa6c4bf126c7065..8841fd7da6eeb2246349f5a6313b593b8021f880 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/serial.h>
index 18e952d1767cd7a481f38a4c372e8af1b602c1ae..bd3ac0136756bc260c31cec5f0686826d055adcd 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/serial.h>
 #include <linux/module.h>
index 6267b294f7047496eaf854aeec37fb4739d44ee3..9f9039498ae523f3c65f72ff0c53b9c6ba2908e1 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/serial.h>
 #include <linux/module.h>
index 165df94d4aa6d6d248479220e64b8005333aef1c..c76760a781c173089aa065f0d9371c5d24f8af98 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/serial.h>
index 4f6d1ddd6fb8073cc76d7923b3721e77ac80028a..c02f110219f5e7a8d221e40639db5ac3195f9b7b 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/major.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/serial.h>
 #include <linux/module.h>
index c99b365d6110e5534edd483e778301d024eda1f8..20940f4044f477aee7f53fab6edcbeb411eee97b 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/blkdev.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/root_dev.h>
 #include <linux/seq_file.h>
 #include <linux/serial.h>
index 7786818bd9d03709253dbdecc76edd1c472073f6..df6ff98c023ac048d387878ba937371cc0d9a531 100644 (file)
@@ -35,7 +35,6 @@
 #include <asm/time.h>
 #include <asm/dma.h>
 #include <asm/io.h>
-#include <linux/irq.h>
 #include <asm/hw_irq.h>
 #include <asm/machdep.h>
 #include <asm/kgdb.h>
index 57f29ab29bdae072f6f25090f3f4952b401e8e71..66346f0de7ec14178b218146a75d7e716b0c3577 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
-#include <linux/irq.h>
 #include <linux/console.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
index e391e52383c7e1455b7e3da5047522eedcca937b..3a5ff9fb71d6e1cae9e8806cc2f63e3115e545c0 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/major.h>
 #include <linux/initrd.h>
 #include <linux/console.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/bcd.h>
index b292b44b760c4960da0abbb2583cc9441944293d..ce2ce88c80337d0416a9e8d4576e996ed263d26f 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/kdev_t.h>
index c0605244edda159d58b2afc5e66013d0a21a34d6..d4bc5f67ec5358f42aa79c0f68b58ac1e55f7920 100644 (file)
@@ -695,6 +695,13 @@ static int __init pmac_cpufreq_setup(void)
                set_speed_proc = pmu_set_cpu_speed;
                is_pmu_based = 1;
        }
+       /* Else check for TiPb 550 */
+       else if (machine_is_compatible("PowerBook3,3") && cur_freq == 550000) {
+               hi_freq = cur_freq;
+               low_freq = 500000;
+               set_speed_proc = pmu_set_cpu_speed;
+               is_pmu_based = 1;
+       }
        /* Else check for TiPb 400 & 500 */
        else if (machine_is_compatible("PowerBook3,2")) {
                /* We only know about the 400 MHz and the 500Mhz model
index 867336ad5d36b284b12d0d682f9fd28b7867a3ac..dd6d45ae0501cac648d845ea701bb24faa21685c 100644 (file)
@@ -2337,6 +2337,10 @@ static struct pmac_mb_def pmac_mb_defs[] __pmacdata = {
                PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
                PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
        },
+       {       "PowerBook6,7",                 "iBook G4",
+               PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
+               PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
+       },
        {       "PowerBook6,8",                 "PowerBook G4 12\"",
                PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
                PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
index 4c56a4734aec53333b0f328c31c98e765097b99d..d6356f480d906b97f8545ab69684743060e1b67e 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/adb.h>
 #include <linux/cuda.h>
 #include <linux/pmu.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/bitops.h>
index 778ce4fec36836db8d7a3b53ed86960fa863986d..efb819f9490df1a7f90063647475fa35a010c4fe 100644 (file)
@@ -195,7 +195,7 @@ via_calibrate_decr(void)
                ;
        dend = get_dec();
 
-       tb_ticks_per_jiffy = (dstart - dend) / (6 * (HZ/100));
+       tb_ticks_per_jiffy = (dstart - dend) / ((6 * HZ)/100);
        tb_to_us = mulhwu_scale_factor(dstart - dend, 60000);
 
        printk(KERN_INFO "via_calibrate_decr: ticks per jiffy = %u (%u ticks)\n",
index 0abe15159e6ca2cfd804444b8eca5e882593cf5b..e6b520e6e13feaec3e9c073616f57821d1d9a97d 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/ide.h>
index 65705c9117950d097792f06068a0388f88db8f4a..e70aae20d6f9c3a83a5d3ba3d4f771e8e762eb73 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/ioport.h>
 #include <linux/console.h>
 #include <linux/pci.h>
-#include <linux/irq.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
index 24ae1caafc618a4447e91abd2f7a869c0868c5d0..0bb14a5e824caba79a67d8f636ffa4f0dea3e09a 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/ide.h>
 #include <linux/root_dev.h>
index 8b09fa69b35b2addd6d264fcdc8c6f3597691347..de7baefacd3aa43094ee4213a36206f9f72226bc 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/seq_file.h>
 #include <linux/ide.h>
 #include <linux/root_dev.h>
index c30607a972d87121079bd93c5399b1d6b8fc393e..0376c8cff5d1e33bcd22e28d4dac37e4ceeb8921 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
@@ -59,7 +58,6 @@
 #include <asm/mpc10x.h>
 #include <asm/pci-bridge.h>
 #include <asm/mv64x60.h>
-#include <asm/i8259.h>
 
 #include "radstone_ppc7d.h"
 
index 21e31346b12ba6856db725af94f7ac648ab00e5f..5232283c1974a554658998de11cbf02d3a309b3a 100644 (file)
@@ -74,7 +74,6 @@
 #include <linux/initrd.h>
 #include <linux/console.h>
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
index 839f8872826f40480088397ddb9da28f716f1356..4849850a59edd55c872bbb92a13c327842b7ad0e 100644 (file)
@@ -34,7 +34,7 @@ u8 mv64x60_pci_exclude_bridge = 1;
 DEFINE_SPINLOCK(mv64x60_lock);
 
 static phys_addr_t     mv64x60_bridge_pbase;
-static void            *mv64x60_bridge_vbase;
+static void            __iomem *mv64x60_bridge_vbase;
 static u32             mv64x60_bridge_type = MV64x60_TYPE_INVALID;
 static u32             mv64x60_bridge_rev;
 #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
@@ -938,7 +938,7 @@ mv64x60_setup_for_chip(struct mv64x60_handle *bh)
  *
  * Return the virtual address of the bridge's registers.
  */
-void *
+void __iomem *
 mv64x60_get_bridge_vbase(void)
 {
        return mv64x60_bridge_vbase;
index 53da58523e39f3380e303f4f33e0ca20c32db81d..1cf5de21a3fd3a0ffc6b3e26823d7fb236962163 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
-#include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysdev.h>
 #include <linux/errno.h>
index 9a7e8748e2b2460353adc9d3f2974f81aa3e083d..16cff91d9f41899cbbdb9ec525d26c0e889f42ec 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
-#include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/sysdev.h>
 #include <linux/errno.h>
index b843c4fef25e694ba56182ff2ff68e0fe9a0b269..bf83240689dc3b6b84ecde3afce81a6bfe0578b1 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/smp.h>
 #include <linux/threads.h>
 #include <linux/spinlock.h>
-#include <linux/irq.h>
 #include <linux/reboot.h>
 #include <linux/param.h>
 #include <linux/string.h>
index f33a7bccb0d780ed4e66f03b0acf8113c5776cfe..507eb9d0223faef5f97d430051ebbd658f19c5b8 100644 (file)
@@ -99,7 +99,11 @@ get_iost_entry(unsigned long iopt_base, unsigned long io_address, unsigned page_
                break;
 
        default: /* not a known compile time constant */
-               BUILD_BUG_ON(1);
+               {
+                       /* BUILD_BUG_ON() is not usable here */
+                       extern void __get_iost_entry_bad_page_size(void);
+                       __get_iost_entry_bad_page_size();
+               }
                break;
        }
 
index 7e80d49c589a3bf2f5eea3e68f3d3690b1ceeb03..9c6facc24f703240d1dd9fe0ecc3771d2c267dc1 100644 (file)
@@ -59,9 +59,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 
        /* insn must be on a special executable page on ppc64 */
        if (!ret) {
-               up(&kprobe_mutex);
-               p->ainsn.insn = get_insn_slot();
                down(&kprobe_mutex);
+               p->ainsn.insn = get_insn_slot();
+               up(&kprobe_mutex);
                if (!p->ainsn.insn)
                        ret = -ENOMEM;
        }
@@ -90,9 +90,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
-       up(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
        down(&kprobe_mutex);
+       free_insn_slot(p->ainsn.insn);
+       up(&kprobe_mutex);
 }
 
 static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
index 7358cdb8441fbf960a1f1bb5371780f3f5e798c6..4ff6808456ea40798acaacdeb0c4f09481eda3d8 100644 (file)
@@ -143,7 +143,7 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
                        break;
                case __SI_FAULT >> 16:
                        err |= __get_user(tmp, &from->si_addr);
-                       to->si_addr = (void *)(u64) (tmp & PSW32_ADDR_INSN);
+                       to->si_addr = (void __user *)(u64) (tmp & PSW32_ADDR_INSN);
                        break;
                case __SI_POLL >> 16:
                        err |= __get_user(to->si_band, &from->si_band);
@@ -338,7 +338,7 @@ sys32_sigaltstack(const stack_t32 __user *uss, stack_t32 __user *uoss,
                err |= __get_user(kss.ss_flags, &uss->ss_flags);
                if (err)
                        return -EFAULT;
-               kss.ss_sp = (void *) ss_sp;
+               kss.ss_sp = (void __user *) ss_sp;
        }
 
        set_fs (KERNEL_DS);
@@ -461,7 +461,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
                goto badframe;
 
        err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp);
-       st.ss_sp = (void *) A((unsigned long)ss_sp);
+       st.ss_sp = compat_ptr(ss_sp);
        err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size);
        err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags);
        if (err)
index 6a3f5b7473a91b7c1a5ad08238430966f839e9f1..6e0110d71191fe176c24fa655879605a9fdbf3b8 100644 (file)
@@ -376,8 +376,8 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 
        /* Create the ucontext.  */
        err |= __put_user(0, &frame->uc.uc_flags);
-       err |= __put_user(0, &frame->uc.uc_link);
-       err |= __put_user((void *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
+       err |= __put_user(NULL, &frame->uc.uc_link);
+       err |= __put_user((void __user *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
        err |= __put_user(sas_ss_flags(regs->gprs[15]),
                          &frame->uc.uc_stack.ss_flags);
        err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
index aba05394d30a05603685e2bcc62cc9c2b85b4d3b..f7c51b869049b1bcd4bf4d9c740fbcf3bd57d0ec 100644 (file)
@@ -21,66 +21,14 @@ config GENERIC_ISA_DMA
        bool
        default y
 
+config GENERIC_IOMAP
+       bool
+       default y
+
 source "init/Kconfig"
 
 menu "General machine setup"
 
-config VT
-       bool
-       select INPUT
-       default y
-       ---help---
-         If you say Y here, you will get support for terminal devices with
-         display and keyboard devices. These are called "virtual" because you
-         can run several virtual terminals (also called virtual consoles) on
-         one physical terminal. This is rather useful, for example one
-         virtual terminal can collect system messages and warnings, another
-         one can be used for a text-mode user session, and a third could run
-         an X session, all in parallel. Switching between virtual terminals
-         is done with certain key combinations, usually Alt-<function key>.
-
-         The setterm command ("man setterm") can be used to change the
-         properties (such as colors or beeping) of a virtual terminal. The
-         man page console_codes(4) ("man console_codes") contains the special
-         character sequences that can be used to change those properties
-         directly. The fonts used on virtual terminals can be changed with
-         the setfont ("man setfont") command and the key bindings are defined
-         with the loadkeys ("man loadkeys") command.
-
-         You need at least one virtual terminal device in order to make use
-         of your keyboard and monitor. Therefore, only people configuring an
-         embedded system would want to say N here in order to save some
-         memory; the only way to log into such a system is then via a serial
-         or network connection.
-
-         If unsure, say Y, or else you won't be able to do much with your new
-         shiny Linux system :-)
-
-config VT_CONSOLE
-       bool
-       default y
-       ---help---
-         The system console is the device which receives all kernel messages
-         and warnings and which allows logins in single user mode. If you
-         answer Y here, a virtual terminal (the device used to interact with
-         a physical terminal) can be used as system console. This is the most
-         common mode of operations, so you should say Y here unless you want
-         the kernel messages be output only to a serial port (in which case
-         you should say Y to "Console on serial port", below).
-
-         If you do say Y here, by default the currently visible virtual
-         terminal (/dev/tty0) will be used as system console. You can change
-         that with a kernel command line option such as "console=tty3" which
-         would use the third virtual terminal as system console. (Try "man
-         bootparam" or see the documentation of your boot loader (lilo or
-         loadlin) about how to pass options to the kernel at boot time.)
-
-         If unsure, say Y.
-
-config HW_CONSOLE
-       bool
-       default y
-
 config SMP
        bool "Symmetric multi-processing support (does not work on sun4/sun4c)"
        depends on BROKEN
index a69856263009fc63efaa74cde0730994fe689ace..8a3aef1e22f511cb5aba08294fba2665a54d80b5 100644 (file)
@@ -5,6 +5,7 @@ CONFIG_MMU=y
 CONFIG_UID16=y
 CONFIG_HIGHMEM=y
 CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
 
 #
 # Code maturity level options
index 53c192a4982f7210d8bd5587c2f0d99987a86b7b..3509e43055322b69d3bf41641ae6d833b2833a30 100644 (file)
@@ -249,8 +249,6 @@ struct tt_entry *sparc_ttable;
 
 struct pt_regs fake_swapper_regs;
 
-extern void paging_init(void);
-
 void __init setup_arch(char **cmdline_p)
 {
        int i;
index bc015e980341060dc9eb3fa28d6bc9485cb964bd..279a62627c109906d7286f14d96659c7ffa0683a 100644 (file)
@@ -457,7 +457,7 @@ void __init time_init(void)
        sbus_time_init();
 }
 
-extern __inline__ unsigned long do_gettimeoffset(void)
+static inline unsigned long do_gettimeoffset(void)
 {
        return (*master_l10_counter >> 10) & 0x1fffff;
 }
index c89a803cbc20d18e812189fdff5fdd1c067f41d3..c664b962987cdde1ad1a5bd17d288dbd2e907c75 100644 (file)
@@ -260,7 +260,7 @@ static inline pte_t srmmu_pte_modify(pte_t pte, pgprot_t newprot)
 { return __pte((pte_val(pte) & SRMMU_CHG_MASK) | pgprot_val(newprot)); }
 
 /* to find an entry in a top-level page table... */
-extern inline pgd_t *srmmu_pgd_offset(struct mm_struct * mm, unsigned long address)
+static inline pgd_t *srmmu_pgd_offset(struct mm_struct * mm, unsigned long address)
 { return mm->pgd + (address >> SRMMU_PGDIR_SHIFT); }
 
 /* Find an entry in the second-level page table.. */
index 48756958116b56156c774498a8567e75d573f9e7..77ef5df4e5a7c7bb40b8b5f0ff96036083fd9078 100644 (file)
@@ -39,6 +39,8 @@ struct cpu_fp_info linux_sparc_fpu[] = {
   { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"},
   { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"},
   { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"},
+  { 0x3e, 0x19, 0, "UltraSparc IV+ integrated FPU"},
+  { 0x3e, 0x22, 0, "UltraSparc IIIi+ integrated FPU"},
 };
 
 #define NSPARCFPU  (sizeof(linux_sparc_fpu)/sizeof(struct cpu_fp_info))
@@ -53,6 +55,8 @@ struct cpu_iu_info linux_sparc_chips[] = {
   { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"},
   { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"},
   { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"},
+  { 0x3e, 0x19, "TI UltraSparc IV+ (Panther)"},
+  { 0x3e, 0x22, "TI UltraSparc IIIi+ (Serrano)"},
 };
 
 #define NSPARCCHIPS  (sizeof(linux_sparc_chips)/sizeof(struct cpu_iu_info))
index 2879b10729217ca6e5ea5777e76b5f767607ecca..11a848402fb1a14f032fee7a434cdbe574b30467 100644 (file)
@@ -33,7 +33,7 @@
        /* This is trivial with the new code... */
        .globl          do_fpdis
 do_fpdis:
-       sethi           %hi(TSTATE_PEF), %g4                                    ! IEU0
+       sethi           %hi(TSTATE_PEF), %g4
        rdpr            %tstate, %g5
        andcc           %g5, %g4, %g0
        be,pt           %xcc, 1f
@@ -50,18 +50,18 @@ do_fpdis:
        add             %g0, %g0, %g0
        ba,a,pt         %xcc, rtrap_clr_l6
 
-1:     ldub            [%g6 + TI_FPSAVED], %g5                                 ! Load  Group
-       wr              %g0, FPRS_FEF, %fprs                                    ! LSU   Group+4bubbles
-       andcc           %g5, FPRS_FEF, %g0                                      ! IEU1  Group
-       be,a,pt         %icc, 1f                                                ! CTI
-        clr            %g7                                                     ! IEU0
-       ldx             [%g6 + TI_GSR], %g7                                     ! Load  Group
-1:     andcc           %g5, FPRS_DL, %g0                                       ! IEU1
-       bne,pn          %icc, 2f                                                ! CTI
-        fzero          %f0                                                     ! FPA
-       andcc           %g5, FPRS_DU, %g0                                       ! IEU1  Group
-       bne,pn          %icc, 1f                                                ! CTI
-        fzero          %f2                                                     ! FPA
+1:     ldub            [%g6 + TI_FPSAVED], %g5
+       wr              %g0, FPRS_FEF, %fprs
+       andcc           %g5, FPRS_FEF, %g0
+       be,a,pt         %icc, 1f
+        clr            %g7
+       ldx             [%g6 + TI_GSR], %g7
+1:     andcc           %g5, FPRS_DL, %g0
+       bne,pn          %icc, 2f
+        fzero          %f0
+       andcc           %g5, FPRS_DU, %g0
+       bne,pn          %icc, 1f
+        fzero          %f2
        faddd           %f0, %f2, %f4
        fmuld           %f0, %f2, %f6
        faddd           %f0, %f2, %f8
@@ -97,15 +97,17 @@ do_fpdis:
        faddd           %f0, %f2, %f4
        fmuld           %f0, %f2, %f6
        ldxa            [%g3] ASI_DMMU, %g5
-cplus_fptrap_insn_1:
-       sethi           %hi(0), %g2
+       sethi           %hi(sparc64_kern_sec_context), %g2
+       ldx             [%g2 + %lo(sparc64_kern_sec_context)], %g2
        stxa            %g2, [%g3] ASI_DMMU
        membar          #Sync
        add             %g6, TI_FPREGS + 0xc0, %g2
        faddd           %f0, %f2, %f8
        fmuld           %f0, %f2, %f10
-       ldda            [%g1] ASI_BLK_S, %f32   ! grrr, where is ASI_BLK_NUCLEUS 8-(
+       membar          #Sync
+       ldda            [%g1] ASI_BLK_S, %f32
        ldda            [%g2] ASI_BLK_S, %f48
+       membar          #Sync
        faddd           %f0, %f2, %f12
        fmuld           %f0, %f2, %f14
        faddd           %f0, %f2, %f16
@@ -116,7 +118,6 @@ cplus_fptrap_insn_1:
        fmuld           %f0, %f2, %f26
        faddd           %f0, %f2, %f28
        fmuld           %f0, %f2, %f30
-       membar          #Sync
        b,pt            %xcc, fpdis_exit
         nop
 2:     andcc           %g5, FPRS_DU, %g0
@@ -126,15 +127,17 @@ cplus_fptrap_insn_1:
        fzero           %f34
        ldxa            [%g3] ASI_DMMU, %g5
        add             %g6, TI_FPREGS, %g1
-cplus_fptrap_insn_2:
-       sethi           %hi(0), %g2
+       sethi           %hi(sparc64_kern_sec_context), %g2
+       ldx             [%g2 + %lo(sparc64_kern_sec_context)], %g2
        stxa            %g2, [%g3] ASI_DMMU
        membar          #Sync
        add             %g6, TI_FPREGS + 0x40, %g2
        faddd           %f32, %f34, %f36
        fmuld           %f32, %f34, %f38
-       ldda            [%g1] ASI_BLK_S, %f0    ! grrr, where is ASI_BLK_NUCLEUS 8-(
+       membar          #Sync
+       ldda            [%g1] ASI_BLK_S, %f0
        ldda            [%g2] ASI_BLK_S, %f16
+       membar          #Sync
        faddd           %f32, %f34, %f40
        fmuld           %f32, %f34, %f42
        faddd           %f32, %f34, %f44
@@ -147,18 +150,18 @@ cplus_fptrap_insn_2:
        fmuld           %f32, %f34, %f58
        faddd           %f32, %f34, %f60
        fmuld           %f32, %f34, %f62
-       membar          #Sync
        ba,pt           %xcc, fpdis_exit
         nop
 3:     mov             SECONDARY_CONTEXT, %g3
        add             %g6, TI_FPREGS, %g1
        ldxa            [%g3] ASI_DMMU, %g5
-cplus_fptrap_insn_3:
-       sethi           %hi(0), %g2
+       sethi           %hi(sparc64_kern_sec_context), %g2
+       ldx             [%g2 + %lo(sparc64_kern_sec_context)], %g2
        stxa            %g2, [%g3] ASI_DMMU
        membar          #Sync
        mov             0x40, %g2
-       ldda            [%g1] ASI_BLK_S, %f0            ! grrr, where is ASI_BLK_NUCLEUS 8-(
+       membar          #Sync
+       ldda            [%g1] ASI_BLK_S, %f0
        ldda            [%g1 + %g2] ASI_BLK_S, %f16
        add             %g1, 0x80, %g1
        ldda            [%g1] ASI_BLK_S, %f32
@@ -319,8 +322,8 @@ do_fptrap_after_fsr:
        stx             %g3, [%g6 + TI_GSR]
        mov             SECONDARY_CONTEXT, %g3
        ldxa            [%g3] ASI_DMMU, %g5
-cplus_fptrap_insn_4:
-       sethi           %hi(0), %g2
+       sethi           %hi(sparc64_kern_sec_context), %g2
+       ldx             [%g2 + %lo(sparc64_kern_sec_context)], %g2
        stxa            %g2, [%g3] ASI_DMMU
        membar          #Sync
        add             %g6, TI_FPREGS, %g2
@@ -341,33 +344,6 @@ cplus_fptrap_insn_4:
        ba,pt           %xcc, etrap
         wr             %g0, 0, %fprs
 
-cplus_fptrap_1:
-       sethi           %hi(CTX_CHEETAH_PLUS_CTX0), %g2
-
-       .globl          cheetah_plus_patch_fpdis
-cheetah_plus_patch_fpdis:
-       /* We configure the dTLB512_0 for 4MB pages and the
-        * dTLB512_1 for 8K pages when in context zero.
-        */
-       sethi                   %hi(cplus_fptrap_1), %o0
-       lduw                    [%o0 + %lo(cplus_fptrap_1)], %o1
-
-       set                     cplus_fptrap_insn_1, %o2
-       stw                     %o1, [%o2]
-       flush                   %o2
-       set                     cplus_fptrap_insn_2, %o2
-       stw                     %o1, [%o2]
-       flush                   %o2
-       set                     cplus_fptrap_insn_3, %o2
-       stw                     %o1, [%o2]
-       flush                   %o2
-       set                     cplus_fptrap_insn_4, %o2
-       stw                     %o1, [%o2]
-       flush                   %o2
-
-       retl
-        nop
-
        /* The registers for cross calls will be:
         *
         * DATA 0: [low 32-bits]  Address of function to call, jmp to this
index 50d2af1d98aeebff3beb1f4a89f1249778e53fb1..0d8eba21111b75582ba1f52c946a1121ab7a8774 100644 (file)
@@ -68,12 +68,8 @@ etrap_irq:
 
                wrpr    %g3, 0, %otherwin
                wrpr    %g2, 0, %wstate
-cplus_etrap_insn_1:
-               sethi   %hi(0), %g3
-               sllx    %g3, 32, %g3
-cplus_etrap_insn_2:
-               sethi   %hi(0), %g2
-               or      %g3, %g2, %g3
+               sethi   %hi(sparc64_kern_pri_context), %g2
+               ldx     [%g2 + %lo(sparc64_kern_pri_context)], %g3
                stxa    %g3, [%l4] ASI_DMMU
                flush   %l6
                wr      %g0, ASI_AIUS, %asi
@@ -215,12 +211,8 @@ scetrap:   rdpr    %pil, %g2
                mov     PRIMARY_CONTEXT, %l4
                wrpr    %g3, 0, %otherwin
                wrpr    %g2, 0, %wstate
-cplus_etrap_insn_3:
-               sethi   %hi(0), %g3
-               sllx    %g3, 32, %g3
-cplus_etrap_insn_4:
-               sethi   %hi(0), %g2
-               or      %g3, %g2, %g3
+               sethi   %hi(sparc64_kern_pri_context), %g2
+               ldx     [%g2 + %lo(sparc64_kern_pri_context)], %g3
                stxa    %g3, [%l4] ASI_DMMU
                flush   %l6
 
@@ -264,38 +256,3 @@ cplus_etrap_insn_4:
 
 #undef TASK_REGOFF
 #undef ETRAP_PSTATE1
-
-cplus_einsn_1:
-               sethi                   %uhi(CTX_CHEETAH_PLUS_NUC), %g3
-cplus_einsn_2:
-               sethi                   %hi(CTX_CHEETAH_PLUS_CTX0), %g2
-
-               .globl                  cheetah_plus_patch_etrap
-cheetah_plus_patch_etrap:
-               /* We configure the dTLB512_0 for 4MB pages and the
-                * dTLB512_1 for 8K pages when in context zero.
-                */
-               sethi                   %hi(cplus_einsn_1), %o0
-               sethi                   %hi(cplus_etrap_insn_1), %o2
-               lduw                    [%o0 + %lo(cplus_einsn_1)], %o1
-               or                      %o2, %lo(cplus_etrap_insn_1), %o2
-               stw                     %o1, [%o2]
-               flush                   %o2
-               sethi                   %hi(cplus_etrap_insn_3), %o2
-               or                      %o2, %lo(cplus_etrap_insn_3), %o2
-               stw                     %o1, [%o2]
-               flush                   %o2
-
-               sethi                   %hi(cplus_einsn_2), %o0
-               sethi                   %hi(cplus_etrap_insn_2), %o2
-               lduw                    [%o0 + %lo(cplus_einsn_2)], %o1
-               or                      %o2, %lo(cplus_etrap_insn_2), %o2
-               stw                     %o1, [%o2]
-               flush                   %o2
-               sethi                   %hi(cplus_etrap_insn_4), %o2
-               or                      %o2, %lo(cplus_etrap_insn_4), %o2
-               stw                     %o1, [%o2]
-               flush                   %o2
-
-               retl
-                nop
index ecc748fb9ad74b70cb6295dc4fde6fe7bc5376b5..24340496cdd34296ba838adc9fbadd2748c89381 100644 (file)
@@ -325,23 +325,7 @@ cheetah_tlb_fixup:
 1:     sethi   %hi(tlb_type), %g1
        stw     %g2, [%g1 + %lo(tlb_type)]
 
-       BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,1f)
-       ba,pt   %xcc, 2f
-        nop
-
-1:     /* Patch context register writes to support nucleus page
-        * size correctly.
-        */
-       call    cheetah_plus_patch_etrap
-        nop
-       call    cheetah_plus_patch_rtrap
-        nop
-       call    cheetah_plus_patch_fpdis
-        nop
-       call    cheetah_plus_patch_winfixup
-        nop
-
-2:     /* Patch copy/page operations to cheetah optimized versions. */
+       /* Patch copy/page operations to cheetah optimized versions. */
        call    cheetah_patch_copyops
         nop
        call    cheetah_patch_copy_page
@@ -484,20 +468,13 @@ spitfire_vpte_base:
        call    prom_set_trap_table
         sethi  %hi(sparc64_ttable_tl0), %o0
 
-       BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f)
-       ba,pt   %xcc, 2f
-        nop
-
-1:     /* Start using proper page size encodings in ctx register.  */
-       sethi   %uhi(CTX_CHEETAH_PLUS_NUC), %g3
+       /* Start using proper page size encodings in ctx register.  */
+       sethi   %hi(sparc64_kern_pri_context), %g3
+       ldx     [%g3 + %lo(sparc64_kern_pri_context)], %g2
        mov     PRIMARY_CONTEXT, %g1
-       sllx    %g3, 32, %g3
-       sethi   %hi(CTX_CHEETAH_PLUS_CTX0), %g2
-       or      %g3, %g2, %g3
-       stxa    %g3, [%g1] ASI_DMMU
+       stxa    %g2, [%g1] ASI_DMMU
        membar  #Sync
 
-2:
        rdpr    %pstate, %o1
        or      %o1, PSTATE_IE, %o1
        wrpr    %o1, 0, %pstate
@@ -540,8 +517,11 @@ bootup_user_stack_end:
 prom_tba:      .xword  0
 tlb_type:      .word   0       /* Must NOT end up in BSS */
        .section        ".fixup",#alloc,#execinstr
-       .globl  __ret_efault
+
+       .globl  __ret_efault, __retl_efault
 __ret_efault:
        ret
         restore %g0, -EFAULT, %o0
-
+__retl_efault:
+       retl
+        mov    -EFAULT, %o0
index 946cee0257ea2dc34fe25350fc71910b235dfc7c..9e8362ea3104a821aa07317965b62045fc230f33 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <asm/system.h>
 #include <asm/ebus.h>
+#include <asm/isa.h>
 #include <asm/auxio.h>
 
 #include <linux/unistd.h>
@@ -100,46 +101,83 @@ again:
        return 0;
 }
 
-static int __init has_button_interrupt(struct linux_ebus_device *edev)
+static int __init has_button_interrupt(unsigned int irq, int prom_node)
 {
-       if (edev->irqs[0] == PCI_IRQ_NONE)
+       if (irq == PCI_IRQ_NONE)
                return 0;
-       if (!prom_node_has_property(edev->prom_node, "button"))
+       if (!prom_node_has_property(prom_node, "button"))
                return 0;
 
        return 1;
 }
 
-void __init power_init(void)
+static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, int *prom_node_p)
 {
        struct linux_ebus *ebus;
        struct linux_ebus_device *edev;
+
+       for_each_ebus(ebus) {
+               for_each_ebusdev(edev, ebus) {
+                       if (!strcmp(edev->prom_name, "power")) {
+                               *resp = &edev->resource[0];
+                               *irq_p = edev->irqs[0];
+                               *prom_node_p = edev->prom_node;
+                               return 0;
+                       }
+               }
+       }
+       return -ENODEV;
+}
+
+static int __init power_probe_isa(struct resource **resp, unsigned int *irq_p, int *prom_node_p)
+{
+       struct sparc_isa_bridge *isa_bus;
+       struct sparc_isa_device *isa_dev;
+
+       for_each_isa(isa_bus) {
+               for_each_isadev(isa_dev, isa_bus) {
+                       if (!strcmp(isa_dev->prom_name, "power")) {
+                               *resp = &isa_dev->resource;
+                               *irq_p = isa_dev->irq;
+                               *prom_node_p = isa_dev->prom_node;
+                               return 0;
+                       }
+               }
+       }
+       return -ENODEV;
+}
+
+void __init power_init(void)
+{
+       struct resource *res = NULL;
+       unsigned int irq;
+       int prom_node;
        static int invoked;
 
        if (invoked)
                return;
        invoked = 1;
 
-       for_each_ebus(ebus) {
-               for_each_ebusdev(edev, ebus) {
-                       if (!strcmp(edev->prom_name, "power"))
-                               goto found;
-               }
-       }
+       if (!power_probe_ebus(&res, &irq, &prom_node))
+               goto found;
+
+       if (!power_probe_isa(&res, &irq, &prom_node))
+               goto found;
+
        return;
 
 found:
-       power_reg = ioremap(edev->resource[0].start, 0x4);
+       power_reg = ioremap(res->start, 0x4);
        printk("power: Control reg at %p ... ", power_reg);
        poweroff_method = machine_halt;  /* able to use the standard halt */
-       if (has_button_interrupt(edev)) {
+       if (has_button_interrupt(irq, prom_node)) {
                if (kernel_thread(powerd, NULL, CLONE_FS) < 0) {
                        printk("Failed to start power daemon.\n");
                        return;
                }
                printk("powerd running.\n");
 
-               if (request_irq(edev->irqs[0],
+               if (request_irq(irq,
                                power_handler, SA_SHIRQ, "power", NULL) < 0)
                        printk("power: Error, cannot register IRQ handler.\n");
        } else {
index 5efbff90d66862054ce827bb3c327bd636d280bc..774ecbb8a0319061c909c9ad72b39d32b11a2737 100644 (file)
@@ -31,6 +31,7 @@
 #include <asm/visasm.h>
 #include <asm/spitfire.h>
 #include <asm/page.h>
+#include <asm/cpudata.h>
 
 /* Returning from ptrace is a bit tricky because the syscall return
  * low level code assumes any value returned which is negative and
@@ -132,12 +133,16 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
        if ((uaddr ^ (unsigned long) kaddr) & (1UL << 13)) {
                unsigned long start = __pa(kaddr);
                unsigned long end = start + len;
+               unsigned long dcache_line_size;
+
+               dcache_line_size = local_cpu_data().dcache_line_size;
 
                if (tlb_type == spitfire) {
-                       for (; start < end; start += 32)
+                       for (; start < end; start += dcache_line_size)
                                spitfire_put_dcache_tag(start & 0x3fe0, 0x0);
                } else {
-                       for (; start < end; start += 32)
+                       start &= ~(dcache_line_size - 1);
+                       for (; start < end; start += dcache_line_size)
                                __asm__ __volatile__(
                                        "stxa %%g0, [%0] %1\n\t"
                                        "membar #Sync"
@@ -150,8 +155,11 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
        if (write && tlb_type == spitfire) {
                unsigned long start = (unsigned long) kaddr;
                unsigned long end = start + len;
+               unsigned long icache_line_size;
+
+               icache_line_size = local_cpu_data().icache_line_size;
 
-               for (; start < end; start += 32)
+               for (; start < end; start += icache_line_size)
                        flushi(start);
        }
 }
index fafd227735fa1d13b79f8b97e74aa6b3d81f2715..090dcca00d2a1aa8de184c85b7187c79f9c35cd7 100644 (file)
@@ -256,9 +256,8 @@ rt_continue:        ldx                     [%sp + PTREGS_OFF + PT_V9_G1], %g1
                brnz,pn                 %l3, kern_rtt
                 mov                    PRIMARY_CONTEXT, %l7
                ldxa                    [%l7 + %l7] ASI_DMMU, %l0
-cplus_rtrap_insn_1:
-               sethi                   %hi(0), %l1
-               sllx                    %l1, 32, %l1
+               sethi                   %hi(sparc64_kern_pri_nuc_bits), %l1
+               ldx                     [%l1 + %lo(sparc64_kern_pri_nuc_bits)], %l1
                or                      %l0, %l1, %l0
                stxa                    %l0, [%l7] ASI_DMMU
                flush                   %g6
@@ -313,53 +312,36 @@ kern_fpucheck:    ldub                    [%g6 + TI_FPDEPTH], %l5
                wr                      %g1, FPRS_FEF, %fprs
                ldx                     [%o1 + %o5], %g1
                add                     %g6, TI_XFSR, %o1
-               membar                  #StoreLoad | #LoadLoad
                sll                     %o0, 8, %o2
                add                     %g6, TI_FPREGS, %o3
                brz,pn                  %l6, 1f
                 add                    %g6, TI_FPREGS+0x40, %o4
 
+               membar                  #Sync
                ldda                    [%o3 + %o2] ASI_BLK_P, %f0
                ldda                    [%o4 + %o2] ASI_BLK_P, %f16
+               membar                  #Sync
 1:             andcc                   %l2, FPRS_DU, %g0
                be,pn                   %icc, 1f
                 wr                     %g1, 0, %gsr
                add                     %o2, 0x80, %o2
+               membar                  #Sync
                ldda                    [%o3 + %o2] ASI_BLK_P, %f32
                ldda                    [%o4 + %o2] ASI_BLK_P, %f48
-
 1:             membar                  #Sync
                ldx                     [%o1 + %o5], %fsr
 2:             stb                     %l5, [%g6 + TI_FPDEPTH]
                ba,pt                   %xcc, rt_continue
                 nop
 5:             wr                      %g0, FPRS_FEF, %fprs
-               membar                  #StoreLoad | #LoadLoad
                sll                     %o0, 8, %o2
 
                add                     %g6, TI_FPREGS+0x80, %o3
                add                     %g6, TI_FPREGS+0xc0, %o4
+               membar                  #Sync
                ldda                    [%o3 + %o2] ASI_BLK_P, %f32
                ldda                    [%o4 + %o2] ASI_BLK_P, %f48
                membar                  #Sync
                wr                      %g0, FPRS_DU, %fprs
                ba,pt                   %xcc, rt_continue
                 stb                    %l5, [%g6 + TI_FPDEPTH]
-
-cplus_rinsn_1:
-               sethi                   %uhi(CTX_CHEETAH_PLUS_NUC), %l1
-
-               .globl                  cheetah_plus_patch_rtrap
-cheetah_plus_patch_rtrap:
-               /* We configure the dTLB512_0 for 4MB pages and the
-                * dTLB512_1 for 8K pages when in context zero.
-                */
-               sethi                   %hi(cplus_rinsn_1), %o0
-               sethi                   %hi(cplus_rtrap_insn_1), %o2
-               lduw                    [%o0 + %lo(cplus_rinsn_1)], %o1
-               or                      %o2, %lo(cplus_rtrap_insn_1), %o2
-               stw                     %o1, [%o2]
-               flush                   %o2
-
-               retl
-                nop
index 8e8baf2354df6789ef3878f97e0d45765d29e4d3..c1f34237cdf2f2cc1777c7e4842d3b3da6a3610e 100644 (file)
@@ -187,17 +187,13 @@ int prom_callback(long *args)
                }
 
                if ((va >= KERNBASE) && (va < (KERNBASE + (4 * 1024 * 1024)))) {
-                       unsigned long kernel_pctx = 0;
-
-                       if (tlb_type == cheetah_plus)
-                               kernel_pctx |= (CTX_CHEETAH_PLUS_NUC |
-                                               CTX_CHEETAH_PLUS_CTX0);
+                       extern unsigned long sparc64_kern_pri_context;
 
                        /* Spitfire Errata #32 workaround */
                        __asm__ __volatile__("stxa      %0, [%1] %2\n\t"
                                             "flush     %%g6"
                                             : /* No outputs */
-                                            : "r" (kernel_pctx),
+                                            : "r" (sparc64_kern_pri_context),
                                               "r" (PRIMARY_CONTEXT),
                                               "i" (ASI_DMMU));
 
@@ -464,8 +460,6 @@ static void __init boot_flags_init(char *commands)
        }
 }
 
-extern int prom_probe_memory(void);
-extern unsigned long start, end;
 extern void panic_setup(char *, int *);
 
 extern unsigned short root_flags;
@@ -492,12 +486,8 @@ void register_prom_callbacks(void)
                   "' linux-.soft2 to .soft2");
 }
 
-extern void paging_init(void);
-
 void __init setup_arch(char **cmdline_p)
 {
-       int i;
-
        /* Initialize PROM console and command line. */
        *cmdline_p = prom_getbootargs();
        strcpy(saved_command_line, *cmdline_p);
@@ -516,21 +506,6 @@ void __init setup_arch(char **cmdline_p)
        boot_flags_init(*cmdline_p);
 
        idprom_init();
-       (void) prom_probe_memory();
-
-       phys_base = 0xffffffffffffffffUL;
-       for (i = 0; sp_banks[i].num_bytes != 0; i++) {
-               unsigned long top;
-
-               if (sp_banks[i].base_addr < phys_base)
-                       phys_base = sp_banks[i].base_addr;
-               top = sp_banks[i].base_addr +
-                       sp_banks[i].num_bytes;
-       }
-       pfn_base = phys_base >> PAGE_SHIFT;
-
-       kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
-       kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
 
        if (!root_flags)
                root_mountflags &= ~MS_RDONLY;
index 5f9e4fae612efbb2814801386e68484d67de0dd5..9cd272ac3ac10342de0e8ff4f5e0e4c45a860013 100644 (file)
@@ -157,173 +157,199 @@ sys32_socketcall:       /* %o0=call, %o1=args */
        or              %g2, %lo(__socketcall_table_begin), %g2
        jmpl            %g2 + %o0, %g0
         nop
+do_einval:
+       retl
+        mov            -EINVAL, %o0
 
-       /* Each entry is exactly 32 bytes. */
        .align          32
 __socketcall_table_begin:
+
+       /* Each entry is exactly 32 bytes. */
 do_sys_socket: /* sys_socket(int, int, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+1:     ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_socket), %g1
-       ldswa           [%o1 + 0x8] %asi, %o2
+2:     ldswa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(sys_socket), %g0
-        ldswa          [%o1 + 0x4] %asi, %o1
+3:      ldswa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_bind: /* sys_bind(int fd, struct sockaddr *, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+4:     ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_bind), %g1
-       ldswa           [%o1 + 0x8] %asi, %o2
+5:     ldswa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(sys_bind), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+6:      lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_connect: /* sys_connect(int, struct sockaddr *, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+7:     ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_connect), %g1
-       ldswa           [%o1 + 0x8] %asi, %o2
+8:     ldswa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(sys_connect), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+9:      lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_listen: /* sys_listen(int, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+10:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_listen), %g1
        jmpl            %g1 + %lo(sys_listen), %g0
-        ldswa          [%o1 + 0x4] %asi, %o1
+11:     ldswa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
        nop
 do_sys_accept: /* sys_accept(int, struct sockaddr *, int *) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+12:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_accept), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
+13:    lduwa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(sys_accept), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+14:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_getsockname: /* sys_getsockname(int, struct sockaddr *, int *) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+15:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_getsockname), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
+16:    lduwa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(sys_getsockname), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+17:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_getpeername: /* sys_getpeername(int, struct sockaddr *, int *) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+18:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_getpeername), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
+19:    lduwa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(sys_getpeername), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+20:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_socketpair: /* sys_socketpair(int, int, int, int *) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+21:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_socketpair), %g1
-       ldswa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
+22:    ldswa           [%o1 + 0x8] %asi, %o2
+23:    lduwa           [%o1 + 0xc] %asi, %o3
        jmpl            %g1 + %lo(sys_socketpair), %g0
-        ldswa          [%o1 + 0x4] %asi, %o1
+24:     ldswa          [%o1 + 0x4] %asi, %o1
        nop
        nop
 do_sys_send: /* sys_send(int, void *, size_t, unsigned int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+25:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_send), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
+26:    lduwa           [%o1 + 0x8] %asi, %o2
+27:    lduwa           [%o1 + 0xc] %asi, %o3
        jmpl            %g1 + %lo(sys_send), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+28:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
 do_sys_recv: /* sys_recv(int, void *, size_t, unsigned int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+29:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_recv), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
+30:    lduwa           [%o1 + 0x8] %asi, %o2
+31:    lduwa           [%o1 + 0xc] %asi, %o3
        jmpl            %g1 + %lo(sys_recv), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+32:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
 do_sys_sendto: /* sys_sendto(int, u32, compat_size_t, unsigned int, u32, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+33:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_sendto), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
-       lduwa           [%o1 + 0x10] %asi, %o4
-       ldswa           [%o1 + 0x14] %asi, %o5
+34:    lduwa           [%o1 + 0x8] %asi, %o2
+35:    lduwa           [%o1 + 0xc] %asi, %o3
+36:    lduwa           [%o1 + 0x10] %asi, %o4
+37:    ldswa           [%o1 + 0x14] %asi, %o5
        jmpl            %g1 + %lo(sys_sendto), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+38:     lduwa          [%o1 + 0x4] %asi, %o1
 do_sys_recvfrom: /* sys_recvfrom(int, u32, compat_size_t, unsigned int, u32, u32) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+39:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_recvfrom), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
-       lduwa           [%o1 + 0x10] %asi, %o4
-       lduwa           [%o1 + 0x14] %asi, %o5
+40:    lduwa           [%o1 + 0x8] %asi, %o2
+41:    lduwa           [%o1 + 0xc] %asi, %o3
+42:    lduwa           [%o1 + 0x10] %asi, %o4
+43:    lduwa           [%o1 + 0x14] %asi, %o5
        jmpl            %g1 + %lo(sys_recvfrom), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+44:     lduwa          [%o1 + 0x4] %asi, %o1
 do_sys_shutdown: /* sys_shutdown(int, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+45:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(sys_shutdown), %g1
        jmpl            %g1 + %lo(sys_shutdown), %g0
-        ldswa          [%o1 + 0x4] %asi, %o1
+46:     ldswa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
        nop
 do_sys_setsockopt: /* compat_sys_setsockopt(int, int, int, char *, int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+47:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(compat_sys_setsockopt), %g1
-       ldswa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
-       ldswa           [%o1 + 0x10] %asi, %o4
+48:    ldswa           [%o1 + 0x8] %asi, %o2
+49:    lduwa           [%o1 + 0xc] %asi, %o3
+50:    ldswa           [%o1 + 0x10] %asi, %o4
        jmpl            %g1 + %lo(compat_sys_setsockopt), %g0
-        ldswa          [%o1 + 0x4] %asi, %o1
+51:     ldswa          [%o1 + 0x4] %asi, %o1
        nop
 do_sys_getsockopt: /* compat_sys_getsockopt(int, int, int, u32, u32) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+52:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(compat_sys_getsockopt), %g1
-       ldswa           [%o1 + 0x8] %asi, %o2
-       lduwa           [%o1 + 0xc] %asi, %o3
-       lduwa           [%o1 + 0x10] %asi, %o4
+53:    ldswa           [%o1 + 0x8] %asi, %o2
+54:    lduwa           [%o1 + 0xc] %asi, %o3
+55:    lduwa           [%o1 + 0x10] %asi, %o4
        jmpl            %g1 + %lo(compat_sys_getsockopt), %g0
-        ldswa          [%o1 + 0x4] %asi, %o1
+56:     ldswa          [%o1 + 0x4] %asi, %o1
        nop
 do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+57:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(compat_sys_sendmsg), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
+58:    lduwa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(compat_sys_sendmsg), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+59:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
 do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int) */
-       ldswa           [%o1 + 0x0] %asi, %o0
+60:    ldswa           [%o1 + 0x0] %asi, %o0
        sethi           %hi(compat_sys_recvmsg), %g1
-       lduwa           [%o1 + 0x8] %asi, %o2
+61:    lduwa           [%o1 + 0x8] %asi, %o2
        jmpl            %g1 + %lo(compat_sys_recvmsg), %g0
-        lduwa          [%o1 + 0x4] %asi, %o1
+62:     lduwa          [%o1 + 0x4] %asi, %o1
        nop
        nop
        nop
-__socketcall_table_end:
-
-do_einval:
-       retl
-        mov            -EINVAL, %o0
-do_efault:
-       retl
-        mov            -EFAULT, %o0
 
        .section        __ex_table
        .align          4
-       .word           __socketcall_table_begin, 0, __socketcall_table_end, do_efault
+       .word           1b, __retl_efault, 2b, __retl_efault
+       .word           3b, __retl_efault, 4b, __retl_efault
+       .word           5b, __retl_efault, 6b, __retl_efault
+       .word           7b, __retl_efault, 8b, __retl_efault
+       .word           9b, __retl_efault, 10b, __retl_efault
+       .word           11b, __retl_efault, 12b, __retl_efault
+       .word           13b, __retl_efault, 14b, __retl_efault
+       .word           15b, __retl_efault, 16b, __retl_efault
+       .word           17b, __retl_efault, 18b, __retl_efault
+       .word           19b, __retl_efault, 20b, __retl_efault
+       .word           21b, __retl_efault, 22b, __retl_efault
+       .word           23b, __retl_efault, 24b, __retl_efault
+       .word           25b, __retl_efault, 26b, __retl_efault
+       .word           27b, __retl_efault, 28b, __retl_efault
+       .word           29b, __retl_efault, 30b, __retl_efault
+       .word           31b, __retl_efault, 32b, __retl_efault
+       .word           33b, __retl_efault, 34b, __retl_efault
+       .word           35b, __retl_efault, 36b, __retl_efault
+       .word           37b, __retl_efault, 38b, __retl_efault
+       .word           39b, __retl_efault, 40b, __retl_efault
+       .word           41b, __retl_efault, 42b, __retl_efault
+       .word           43b, __retl_efault, 44b, __retl_efault
+       .word           45b, __retl_efault, 46b, __retl_efault
+       .word           47b, __retl_efault, 48b, __retl_efault
+       .word           49b, __retl_efault, 50b, __retl_efault
+       .word           51b, __retl_efault, 52b, __retl_efault
+       .word           53b, __retl_efault, 54b, __retl_efault
+       .word           55b, __retl_efault, 56b, __retl_efault
+       .word           57b, __retl_efault, 58b, __retl_efault
+       .word           59b, __retl_efault, 60b, __retl_efault
+       .word           61b, __retl_efault, 62b, __retl_efault
        .previous
index 89f2fcfcd662e1b6773fca85030dcfe1cb547caf..9478551cb02026b051cc3418ff6ea9d41adf2d80 100644 (file)
@@ -336,20 +336,13 @@ do_unlock:
        call            init_irqwork_curcpu
         nop
 
-       BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f)
-       ba,pt   %xcc, 2f
-        nop
-
-1:     /* Start using proper page size encodings in ctx register.  */
-       sethi   %uhi(CTX_CHEETAH_PLUS_NUC), %g3
+       /* Start using proper page size encodings in ctx register.  */
+       sethi   %hi(sparc64_kern_pri_context), %g3
+       ldx     [%g3 + %lo(sparc64_kern_pri_context)], %g2
        mov     PRIMARY_CONTEXT, %g1
-       sllx    %g3, 32, %g3
-       sethi   %hi(CTX_CHEETAH_PLUS_CTX0), %g2
-       or      %g3, %g2, %g3
-       stxa    %g3, [%g1] ASI_DMMU
+       stxa    %g2, [%g1] ASI_DMMU
        membar  #Sync
 
-2:
        rdpr            %pstate, %o1
        or              %o1, PSTATE_IE, %o1
        wrpr            %o1, 0, %pstate
index f8e7005fede9ab8c5df7a9b6fa73f14216dca017..5570e7bb22bb5a34db2bc7c1fd06feeda2ffdb9f 100644 (file)
@@ -189,19 +189,18 @@ void spitfire_data_access_exception(struct pt_regs *regs, unsigned long sfsr, un
 
        if (regs->tstate & TSTATE_PRIV) {
                /* Test if this comes from uaccess places. */
-               unsigned long fixup;
-               unsigned long g2 = regs->u_regs[UREG_G2];
+               const struct exception_table_entry *entry;
 
-               if ((fixup = search_extables_range(regs->tpc, &g2))) {
-                       /* Ouch, somebody is trying ugly VM hole tricks on us... */
+               entry = search_exception_tables(regs->tpc);
+               if (entry) {
+                       /* Ouch, somebody is trying VM hole tricks on us... */
 #ifdef DEBUG_EXCEPTIONS
                        printk("Exception: PC<%016lx> faddr<UNKNOWN>\n", regs->tpc);
-                       printk("EX_TABLE: insn<%016lx> fixup<%016lx> "
-                              "g2<%016lx>\n", regs->tpc, fixup, g2);
+                       printk("EX_TABLE: insn<%016lx> fixup<%016lx>\n",
+                              regs->tpc, entry->fixup);
 #endif
-                       regs->tpc = fixup;
+                       regs->tpc = entry->fixup;
                        regs->tnpc = regs->tpc + 4;
-                       regs->u_regs[UREG_G2] = g2;
                        return;
                }
                /* Shit... */
@@ -758,26 +757,12 @@ void __init cheetah_ecache_flush_init(void)
        ecache_flush_size = (2 * largest_size);
        ecache_flush_linesize = smallest_linesize;
 
-       /* Discover a physically contiguous chunk of physical
-        * memory in 'sp_banks' of size ecache_flush_size calculated
-        * above.  Store the physical base of this area at
-        * ecache_flush_physbase.
-        */
-       for (node = 0; ; node++) {
-               if (sp_banks[node].num_bytes == 0)
-                       break;
-               if (sp_banks[node].num_bytes >= ecache_flush_size) {
-                       ecache_flush_physbase = sp_banks[node].base_addr;
-                       break;
-               }
-       }
+       ecache_flush_physbase = find_ecache_flush_span(ecache_flush_size);
 
-       /* Note: Zero would be a valid value of ecache_flush_physbase so
-        * don't use that as the success test. :-)
-        */
-       if (sp_banks[node].num_bytes == 0) {
+       if (ecache_flush_physbase == ~0UL) {
                prom_printf("cheetah_ecache_flush_init: Cannot find %d byte "
-                           "contiguous physical memory.\n", ecache_flush_size);
+                           "contiguous physical memory.\n",
+                           ecache_flush_size);
                prom_halt();
        }
 
@@ -1346,16 +1331,12 @@ static int cheetah_fix_ce(unsigned long physaddr)
 /* Return non-zero if PADDR is a valid physical memory address. */
 static int cheetah_check_main_memory(unsigned long paddr)
 {
-       int i;
+       unsigned long vaddr = PAGE_OFFSET + paddr;
 
-       for (i = 0; ; i++) {
-               if (sp_banks[i].num_bytes == 0)
-                       break;
-               if (paddr >= sp_banks[i].base_addr &&
-                   paddr < (sp_banks[i].base_addr + sp_banks[i].num_bytes))
-                       return 1;
-       }
-       return 0;
+       if (vaddr > (unsigned long) high_memory)
+               return 0;
+
+       return kern_addr_valid(vaddr);
 }
 
 void cheetah_cee_handler(struct pt_regs *regs, unsigned long afsr, unsigned long afar)
@@ -1610,10 +1591,10 @@ void cheetah_deferred_handler(struct pt_regs *regs, unsigned long afsr, unsigned
                        /* OK, usermode access. */
                        recoverable = 1;
                } else {
-                       unsigned long g2 = regs->u_regs[UREG_G2];
-                       unsigned long fixup = search_extables_range(regs->tpc, &g2);
+                       const struct exception_table_entry *entry;
 
-                       if (fixup != 0UL) {
+                       entry = search_exception_tables(regs->tpc);
+                       if (entry) {
                                /* OK, kernel access to userspace. */
                                recoverable = 1;
 
@@ -1632,9 +1613,8 @@ void cheetah_deferred_handler(struct pt_regs *regs, unsigned long afsr, unsigned
                                 * recoverable condition.
                                 */
                                if (recoverable) {
-                                       regs->tpc = fixup;
+                                       regs->tpc = entry->fixup;
                                        regs->tnpc = regs->tpc + 4;
-                                       regs->u_regs[UREG_G2] = g2;
                                }
                        }
                }
index da48400bcc95a8b43a7dcef27f63e62998b0489f..1f5b5b708ce7210fd36e0abaa28362dfa8518a0a 100644 (file)
@@ -6,13 +6,6 @@
 
        .text
 
-kernel_unaligned_trap_fault:
-       call    kernel_mna_trap_fault
-        nop
-       retl
-        nop
-       .size   kern_unaligned_trap_fault, .-kern_unaligned_trap_fault
-
        .globl  __do_int_store
 __do_int_store:
        rd      %asi, %o4
@@ -51,24 +44,24 @@ __do_int_store:
 0:
        wr      %o4, 0x0, %asi
        retl
-        nop
+        mov    0, %o0
        .size   __do_int_store, .-__do_int_store
 
        .section        __ex_table
-       .word           4b, kernel_unaligned_trap_fault
-       .word           5b, kernel_unaligned_trap_fault
-       .word           6b, kernel_unaligned_trap_fault
-       .word           7b, kernel_unaligned_trap_fault
-       .word           8b, kernel_unaligned_trap_fault
-       .word           9b, kernel_unaligned_trap_fault
-       .word           10b, kernel_unaligned_trap_fault
-       .word           11b, kernel_unaligned_trap_fault
-       .word           12b, kernel_unaligned_trap_fault
-       .word           13b, kernel_unaligned_trap_fault
-       .word           14b, kernel_unaligned_trap_fault
-       .word           15b, kernel_unaligned_trap_fault
-       .word           16b, kernel_unaligned_trap_fault
-       .word           17b, kernel_unaligned_trap_fault
+       .word           4b, __retl_efault
+       .word           5b, __retl_efault
+       .word           6b, __retl_efault
+       .word           7b, __retl_efault
+       .word           8b, __retl_efault
+       .word           9b, __retl_efault
+       .word           10b, __retl_efault
+       .word           11b, __retl_efault
+       .word           12b, __retl_efault
+       .word           13b, __retl_efault
+       .word           14b, __retl_efault
+       .word           15b, __retl_efault
+       .word           16b, __retl_efault
+       .word           17b, __retl_efault
        .previous
 
        .globl  do_int_load
@@ -133,21 +126,21 @@ do_int_load:
 0:
        wr      %o5, 0x0, %asi
        retl
-        nop
+        mov    0, %o0
        .size   __do_int_load, .-__do_int_load
 
        .section        __ex_table
-       .word           4b, kernel_unaligned_trap_fault
-       .word           5b, kernel_unaligned_trap_fault
-       .word           6b, kernel_unaligned_trap_fault
-       .word           7b, kernel_unaligned_trap_fault
-       .word           8b, kernel_unaligned_trap_fault
-       .word           9b, kernel_unaligned_trap_fault
-       .word           10b, kernel_unaligned_trap_fault
-       .word           11b, kernel_unaligned_trap_fault
-       .word           12b, kernel_unaligned_trap_fault
-       .word           13b, kernel_unaligned_trap_fault
-       .word           14b, kernel_unaligned_trap_fault
-       .word           15b, kernel_unaligned_trap_fault
-       .word           16b, kernel_unaligned_trap_fault
+       .word           4b, __retl_efault
+       .word           5b, __retl_efault
+       .word           6b, __retl_efault
+       .word           7b, __retl_efault
+       .word           8b, __retl_efault
+       .word           9b, __retl_efault
+       .word           10b, __retl_efault
+       .word           11b, __retl_efault
+       .word           12b, __retl_efault
+       .word           13b, __retl_efault
+       .word           14b, __retl_efault
+       .word           15b, __retl_efault
+       .word           16b, __retl_efault
        .previous
index 42718f6a7d3671ea349c3918f2355c11809c272c..70faf630603bc49a34a2cba0bfe4733092aedd36 100644 (file)
@@ -180,14 +180,14 @@ static void __attribute_used__ unaligned_panic(char *str, struct pt_regs *regs)
        die_if_kernel(str, regs);
 }
 
-extern void do_int_load(unsigned long *dest_reg, int size,
-                       unsigned long *saddr, int is_signed, int asi);
+extern int do_int_load(unsigned long *dest_reg, int size,
+                      unsigned long *saddr, int is_signed, int asi);
        
-extern void __do_int_store(unsigned long *dst_addr, int size,
-                          unsigned long src_val, int asi);
+extern int __do_int_store(unsigned long *dst_addr, int size,
+                         unsigned long src_val, int asi);
 
-static inline void do_int_store(int reg_num, int size, unsigned long *dst_addr,
-                               struct pt_regs *regs, int asi, int orig_asi)
+static inline int do_int_store(int reg_num, int size, unsigned long *dst_addr,
+                              struct pt_regs *regs, int asi, int orig_asi)
 {
        unsigned long zero = 0;
        unsigned long *src_val_p = &zero;
@@ -219,7 +219,7 @@ static inline void do_int_store(int reg_num, int size, unsigned long *dst_addr,
                        break;
                };
        }
-       __do_int_store(dst_addr, size, src_val, asi);
+       return __do_int_store(dst_addr, size, src_val, asi);
 }
 
 static inline void advance(struct pt_regs *regs)
@@ -242,14 +242,14 @@ static inline int ok_for_kernel(unsigned int insn)
        return !floating_point_load_or_store_p(insn);
 }
 
-void kernel_mna_trap_fault(void)
+static void kernel_mna_trap_fault(void)
 {
        struct pt_regs *regs = current_thread_info()->kern_una_regs;
        unsigned int insn = current_thread_info()->kern_una_insn;
-       unsigned long g2 = regs->u_regs[UREG_G2];
-       unsigned long fixup = search_extables_range(regs->tpc, &g2);
+       const struct exception_table_entry *entry;
 
-       if (!fixup) {
+       entry = search_exception_tables(regs->tpc);
+       if (!entry) {
                unsigned long address;
 
                address = compute_effective_address(regs, insn,
@@ -270,9 +270,8 @@ void kernel_mna_trap_fault(void)
                die_if_kernel("Oops", regs);
                /* Not reached */
        }
-       regs->tpc = fixup;
+       regs->tpc = entry->fixup;
        regs->tnpc = regs->tpc + 4;
-       regs->u_regs [UREG_G2] = g2;
 
        regs->tstate &= ~TSTATE_ASI;
        regs->tstate |= (ASI_AIUS << 24UL);
@@ -294,8 +293,8 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn, u
 
                kernel_mna_trap_fault();
        } else {
-               unsigned long addr;
-               int orig_asi, asi;
+               unsigned long addr, *reg_addr;
+               int orig_asi, asi, err;
 
                addr = compute_effective_address(regs, insn,
                                                 ((insn >> 25) & 0x1f));
@@ -319,11 +318,12 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn, u
                };
                switch (dir) {
                case load:
-                       do_int_load(fetch_reg_addr(((insn>>25)&0x1f), regs),
-                                   size, (unsigned long *) addr,
-                                   decode_signedness(insn), asi);
-                       if (unlikely(asi != orig_asi)) {
-                               unsigned long val_in = *(unsigned long *) addr;
+                       reg_addr = fetch_reg_addr(((insn>>25)&0x1f), regs);
+                       err = do_int_load(reg_addr, size,
+                                         (unsigned long *) addr,
+                                         decode_signedness(insn), asi);
+                       if (likely(!err) && unlikely(asi != orig_asi)) {
+                               unsigned long val_in = *reg_addr;
                                switch (size) {
                                case 2:
                                        val_in = swab16(val_in);
@@ -339,21 +339,24 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn, u
                                        BUG();
                                        break;
                                };
-                               *(unsigned long *) addr = val_in;
+                               *reg_addr = val_in;
                        }
                        break;
 
                case store:
-                       do_int_store(((insn>>25)&0x1f), size,
-                                    (unsigned long *) addr, regs,
-                                    asi, orig_asi);
+                       err = do_int_store(((insn>>25)&0x1f), size,
+                                          (unsigned long *) addr, regs,
+                                          asi, orig_asi);
                        break;
 
                default:
                        panic("Impossible kernel unaligned trap.");
                        /* Not reached... */
                }
-               advance(regs);
+               if (unlikely(err))
+                       kernel_mna_trap_fault();
+               else
+                       advance(regs);
        }
 }
 
index 9080e7cd4bb0b8506ceea663c6e4e0d5a4f8a87e..0340041f614352a5cd22ddae1a946c8b1cf53e0f 100644 (file)
@@ -208,7 +208,10 @@ static int __init us3_freq_init(void)
        impl  = ((ver >> 32) & 0xffff);
 
        if (manuf == CHEETAH_MANUF &&
-           (impl == CHEETAH_IMPL || impl == CHEETAH_PLUS_IMPL)) {
+           (impl == CHEETAH_IMPL ||
+            impl == CHEETAH_PLUS_IMPL ||
+            impl == JAGUAR_IMPL ||
+            impl == PANTHER_IMPL)) {
                struct cpufreq_driver *driver;
 
                ret = -ENOMEM;
index 99c809a1e5acbbeacebdf561504dd24a2cdfce5a..39160926267b61b7ee816a90c25dbd014b467dfa 100644 (file)
        .text
 
 set_pcontext:
-cplus_winfixup_insn_1:
-       sethi   %hi(0), %l1
+       sethi   %hi(sparc64_kern_pri_context), %l1
+       ldx     [%l1 + %lo(sparc64_kern_pri_context)], %l1
        mov     PRIMARY_CONTEXT, %g1
-       sllx    %l1, 32, %l1
-cplus_winfixup_insn_2:
-       sethi   %hi(0), %g2
-       or      %l1, %g2, %l1
        stxa    %l1, [%g1] ASI_DMMU
        flush   %g6
        retl
         nop
 
-cplus_wfinsn_1:
-       sethi   %uhi(CTX_CHEETAH_PLUS_NUC), %l1
-cplus_wfinsn_2:
-       sethi   %hi(CTX_CHEETAH_PLUS_CTX0), %g2
-
        .align  32
 
        /* Here are the rules, pay attention.
@@ -395,23 +386,3 @@ window_dax_from_user_common:
         add            %sp, PTREGS_OFF, %o0
        ba,pt           %xcc, rtrap
         clr            %l6
-       
-
-       .globl          cheetah_plus_patch_winfixup
-cheetah_plus_patch_winfixup:
-       sethi                   %hi(cplus_wfinsn_1), %o0
-       sethi                   %hi(cplus_winfixup_insn_1), %o2
-       lduw                    [%o0 + %lo(cplus_wfinsn_1)], %o1
-       or                      %o2, %lo(cplus_winfixup_insn_1), %o2
-       stw                     %o1, [%o2]
-       flush                   %o2
-
-       sethi                   %hi(cplus_wfinsn_2), %o0
-       sethi                   %hi(cplus_winfixup_insn_2), %o2
-       lduw                    [%o0 + %lo(cplus_wfinsn_2)], %o1
-       or                      %o2, %lo(cplus_winfixup_insn_2), %o2
-       stw                     %o1, [%o2]
-       flush                   %o2
-
-       retl
-        nop
index 4e18989bd60299e67b693f7e2d9070b52d0cb190..a0ded5c5aa5cb04e8a236dda995d216167fd6dc1 100644 (file)
@@ -59,15 +59,17 @@ vis1:       ldub            [%g6 + TI_FPSAVED], %g3
        be,pn           %icc, 9b
         add            %g6, TI_FPREGS, %g2
        andcc           %o5, FPRS_DL, %g0
-       membar          #StoreStore | #LoadStore
 
        be,pn           %icc, 4f
         add            %g6, TI_FPREGS+0x40, %g3
+       membar          #Sync
        stda            %f0, [%g2 + %g1] ASI_BLK_P
        stda            %f16, [%g3 + %g1] ASI_BLK_P
+       membar          #Sync
        andcc           %o5, FPRS_DU, %g0
        be,pn           %icc, 5f
 4:      add            %g1, 128, %g1
+       membar          #Sync
        stda            %f32, [%g2 + %g1] ASI_BLK_P
 
        stda            %f48, [%g3 + %g1] ASI_BLK_P
@@ -87,7 +89,7 @@ vis1: ldub            [%g6 + TI_FPSAVED], %g3
        sll             %g1, 5, %g1
        add             %g6, TI_FPREGS+0xc0, %g3
        wr              %g0, FPRS_FEF, %fprs
-       membar          #StoreStore | #LoadStore
+       membar          #Sync
        stda            %f32, [%g2 + %g1] ASI_BLK_P
        stda            %f48, [%g3 + %g1] ASI_BLK_P
        membar          #Sync
@@ -128,8 +130,8 @@ VISenterhalf:
        be,pn           %icc, 4f
         add            %g6, TI_FPREGS, %g2
 
-       membar          #StoreStore | #LoadStore
        add             %g6, TI_FPREGS+0x40, %g3
+       membar          #Sync
        stda            %f0, [%g2 + %g1] ASI_BLK_P
        stda            %f16, [%g3 + %g1] ASI_BLK_P
        membar          #Sync
index 09cbbaa0ebf4387427d4422cb69ba51b575056ec..e1264650ca7aa8cb31329227b8129c3c0abed0a0 100644 (file)
@@ -125,15 +125,11 @@ __strncpy_from_user:
         add    %o2, %o3, %o0
        .size   __strncpy_from_user, .-__strncpy_from_user
 
-       .section .fixup,#alloc,#execinstr
-       .align  4
-4:     retl
-        mov    -EFAULT, %o0
-
        .section __ex_table,#alloc
        .align  4
-       .word   60b, 4b
-       .word   61b, 4b
-       .word   62b, 4b
-       .word   63b, 4b
-       .word   64b, 4b
+       .word   60b, __retl_efault
+       .word   61b, __retl_efault
+       .word   62b, __retl_efault
+       .word   63b, __retl_efault
+       .word   64b, __retl_efault
+       .previous
index 0278e34125dbe773b38685bb3433797739b9ecf1..19d1fdb17d0e8b4f5b3ac6ce0a72fe7c11c65a6b 100644 (file)
 
 /* Calculating the exact fault address when using
  * block loads and stores can be very complicated.
+ *
  * Instead of trying to be clever and handling all
  * of the cases, just fix things up simply here.
  */
 
-unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size)
+static unsigned long compute_size(unsigned long start, unsigned long size, unsigned long *offset)
 {
-       char *dst = to;
-       const char __user *src = from;
+       unsigned long fault_addr = current_thread_info()->fault_address;
+       unsigned long end = start + size;
 
-       while (size) {
-               if (__get_user(*dst, src))
-                       break;
-               dst++;
-               src++;
-               size--;
+       if (fault_addr < start || fault_addr >= end) {
+               *offset = 0;
+       } else {
+               *offset = start - fault_addr;
+               size = end - fault_addr;
        }
+       return size;
+}
 
-       if (size)
-               memset(dst, 0, size);
+unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size)
+{
+       unsigned long offset;
+
+       size = compute_size((unsigned long) from, size, &offset);
+       if (likely(size))
+               memset(to + offset, 0, size);
 
        return size;
 }
 
 unsigned long copy_to_user_fixup(void __user *to, const void *from, unsigned long size)
 {
-       char __user *dst = to;
-       const char *src = from;
-
-       while (size) {
-               if (__put_user(*src, dst))
-                       break;
-               dst++;
-               src++;
-               size--;
-       }
+       unsigned long offset;
 
-       return size;
+       return compute_size((unsigned long) to, size, &offset);
 }
 
 unsigned long copy_in_user_fixup(void __user *to, void __user *from, unsigned long size)
 {
-       char __user *dst = to;
-       char __user *src = from;
+       unsigned long fault_addr = current_thread_info()->fault_address;
+       unsigned long start = (unsigned long) to;
+       unsigned long end = start + size;
 
-       while (size) {
-               char tmp;
+       if (fault_addr >= start && fault_addr < end)
+               return end - fault_addr;
 
-               if (__get_user(tmp, src))
-                       break;
-               if (__put_user(tmp, dst))
-                       break;
-               dst++;
-               src++;
-               size--;
-       }
+       start = (unsigned long) from;
+       end = start + size;
+       if (fault_addr >= start && fault_addr < end)
+               return end - fault_addr;
 
        return size;
 }
index cda87333a77b819a2677968c7b5058982d485184..9d0960e69f487a94c0f23b53050267f56f35b1e9 100644 (file)
@@ -5,6 +5,6 @@
 EXTRA_AFLAGS := -ansi
 EXTRA_CFLAGS := -Werror
 
-obj-y    := ultra.o tlb.o fault.o init.o generic.o extable.o
+obj-y    := ultra.o tlb.o fault.o init.o generic.o
 
 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/sparc64/mm/extable.c b/arch/sparc64/mm/extable.c
deleted file mode 100644 (file)
index ec33429..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * linux/arch/sparc64/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-extern const struct exception_table_entry __start___ex_table[];
-extern const struct exception_table_entry __stop___ex_table[];
-
-void sort_extable(struct exception_table_entry *start,
-                 struct exception_table_entry *finish)
-{
-}
-
-/* Caller knows they are in a range if ret->fixup == 0 */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *start,
-              const struct exception_table_entry *last,
-              unsigned long value)
-{
-       const struct exception_table_entry *walk;
-
-       /* Single insn entries are encoded as:
-        *      word 1: insn address
-        *      word 2: fixup code address
-        *
-        * Range entries are encoded as:
-        *      word 1: first insn address
-        *      word 2: 0
-        *      word 3: last insn address + 4 bytes
-        *      word 4: fixup code address
-        *
-        * See asm/uaccess.h for more details.
-        */
-
-       /* 1. Try to find an exact match. */
-       for (walk = start; walk <= last; walk++) {
-               if (walk->fixup == 0) {
-                       /* A range entry, skip both parts. */
-                       walk++;
-                       continue;
-               }
-
-               if (walk->insn == value)
-                       return walk;
-       }
-
-       /* 2. Try to find a range match. */
-       for (walk = start; walk <= (last - 1); walk++) {
-               if (walk->fixup)
-                       continue;
-
-               if (walk[0].insn <= value && walk[1].insn > value)
-                       return walk;
-
-               walk++;
-       }
-
-        return NULL;
-}
-
-/* Special extable search, which handles ranges.  Returns fixup */
-unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
-{
-       const struct exception_table_entry *entry;
-
-       entry = search_exception_tables(addr);
-       if (!entry)
-               return 0;
-
-       /* Inside range?  Fix g2 and return correct fixup */
-       if (!entry->fixup) {
-               *g2 = (addr - entry->insn) / 4;
-               return (entry + 1)->fixup;
-       }
-
-       return entry->fixup;
-}
index db1e3310e907dc2ba2f4c60a237f2c69664964ff..31fbc67719a1f653f643c346615a261173541a98 100644 (file)
@@ -32,8 +32,6 @@
 
 #define ELEMENTS(arr) (sizeof (arr)/sizeof (arr[0]))
 
-extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
-
 /*
  * To debug kernel to catch accesses to certain virtual/physical addresses.
  * Mode = 0 selects physical watchpoints, mode = 1 selects virtual watchpoints.
@@ -71,53 +69,6 @@ void set_brkpt(unsigned long addr, unsigned char mask, int flags, int mode)
                             : "memory");
 }
 
-/* Nice, simple, prom library does all the sweating for us. ;) */
-unsigned long __init prom_probe_memory (void)
-{
-       register struct linux_mlist_p1275 *mlist;
-       register unsigned long bytes, base_paddr, tally;
-       register int i;
-
-       i = 0;
-       mlist = *prom_meminfo()->p1275_available;
-       bytes = tally = mlist->num_bytes;
-       base_paddr = mlist->start_adr;
-  
-       sp_banks[0].base_addr = base_paddr;
-       sp_banks[0].num_bytes = bytes;
-
-       while (mlist->theres_more != (void *) 0) {
-               i++;
-               mlist = mlist->theres_more;
-               bytes = mlist->num_bytes;
-               tally += bytes;
-               if (i >= SPARC_PHYS_BANKS-1) {
-                       printk ("The machine has more banks than "
-                               "this kernel can support\n"
-                               "Increase the SPARC_PHYS_BANKS "
-                               "setting (currently %d)\n",
-                               SPARC_PHYS_BANKS);
-                       i = SPARC_PHYS_BANKS-1;
-                       break;
-               }
-    
-               sp_banks[i].base_addr = mlist->start_adr;
-               sp_banks[i].num_bytes = mlist->num_bytes;
-       }
-
-       i++;
-       sp_banks[i].base_addr = 0xdeadbeefbeefdeadUL;
-       sp_banks[i].num_bytes = 0;
-
-       /* Now mask all bank sizes on a page boundary, it is all we can
-        * use anyways.
-        */
-       for (i = 0; sp_banks[i].num_bytes != 0; i++)
-               sp_banks[i].num_bytes &= PAGE_MASK;
-
-       return tally;
-}
-
 static void __kprobes unhandled_fault(unsigned long address,
                                      struct task_struct *tsk,
                                      struct pt_regs *regs)
@@ -242,7 +193,6 @@ static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn)
 static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
                            unsigned int insn, unsigned long address)
 {
-       unsigned long g2;
        unsigned char asi = ASI_P;
  
        if ((!insn) && (regs->tstate & TSTATE_PRIV))
@@ -273,11 +223,9 @@ static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
                }
        }
                
-       g2 = regs->u_regs[UREG_G2];
-
        /* Is this in ex_table? */
        if (regs->tstate & TSTATE_PRIV) {
-               unsigned long fixup;
+               const struct exception_table_entry *entry;
 
                if (asi == ASI_P && (insn & 0xc0800000) == 0xc0800000) {
                        if (insn & 0x2000)
@@ -288,10 +236,9 @@ static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
        
                /* Look in asi.h: All _S asis have LS bit set */
                if ((asi & 0x1) &&
-                   (fixup = search_extables_range(regs->tpc, &g2))) {
-                       regs->tpc = fixup;
+                   (entry = search_exception_tables(regs->tpc))) {
+                       regs->tpc = entry->fixup;
                        regs->tnpc = regs->tpc + 4;
-                       regs->u_regs[UREG_G2] = g2;
                        return;
                }
        } else {
@@ -461,7 +408,7 @@ good_area:
        }
 
        up_read(&mm->mmap_sem);
-       goto fault_done;
+       return;
 
        /*
         * Something tried to access memory that isn't in our memory map..
@@ -473,8 +420,7 @@ bad_area:
 
 handle_kernel_fault:
        do_kernel_fault(regs, si_code, fault_code, insn, address);
-
-       goto fault_done;
+       return;
 
 /*
  * We ran out of memory, or some other thing happened to us that made
@@ -505,9 +451,4 @@ do_sigbus:
        /* Kernel mode? Handle exceptions or die */
        if (regs->tstate & TSTATE_PRIV)
                goto handle_kernel_fault;
-
-fault_done:
-       /* These values are no longer needed, clear them. */
-       set_thread_fault_code(0);
-       current_thread_info()->fault_address = 0;
 }
index 9f6ca624892d78ccdbd1af9cbefa499f7191ce4e..0d2e967c7200b3eedb3a64879fc2b6703594ec23 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/seq_file.h>
 #include <linux/kprobes.h>
 #include <linux/cache.h>
+#include <linux/sort.h>
 
 #include <asm/head.h>
 #include <asm/system.h>
 
 extern void device_scan(void);
 
-struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
+#define MAX_BANKS      32
+
+static struct linux_prom64_registers pavail[MAX_BANKS] __initdata;
+static struct linux_prom64_registers pavail_rescan[MAX_BANKS] __initdata;
+static int pavail_ents __initdata;
+static int pavail_rescan_ents __initdata;
+
+static int cmp_p64(const void *a, const void *b)
+{
+       const struct linux_prom64_registers *x = a, *y = b;
+
+       if (x->phys_addr > y->phys_addr)
+               return 1;
+       if (x->phys_addr < y->phys_addr)
+               return -1;
+       return 0;
+}
+
+static void __init read_obp_memory(const char *property,
+                                  struct linux_prom64_registers *regs,
+                                  int *num_ents)
+{
+       int node = prom_finddevice("/memory");
+       int prop_size = prom_getproplen(node, property);
+       int ents, ret, i;
+
+       ents = prop_size / sizeof(struct linux_prom64_registers);
+       if (ents > MAX_BANKS) {
+               prom_printf("The machine has more %s property entries than "
+                           "this kernel can support (%d).\n",
+                           property, MAX_BANKS);
+               prom_halt();
+       }
+
+       ret = prom_getproperty(node, property, (char *) regs, prop_size);
+       if (ret == -1) {
+               prom_printf("Couldn't get %s property from /memory.\n");
+               prom_halt();
+       }
+
+       *num_ents = ents;
+
+       /* Sanitize what we got from the firmware, by page aligning
+        * everything.
+        */
+       for (i = 0; i < ents; i++) {
+               unsigned long base, size;
+
+               base = regs[i].phys_addr;
+               size = regs[i].reg_size;
+
+               size &= PAGE_MASK;
+               if (base & ~PAGE_MASK) {
+                       unsigned long new_base = PAGE_ALIGN(base);
+
+                       size -= new_base - base;
+                       if ((long) size < 0L)
+                               size = 0UL;
+                       base = new_base;
+               }
+               regs[i].phys_addr = base;
+               regs[i].reg_size = size;
+       }
+       sort(regs, ents, sizeof(struct  linux_prom64_registers),
+            cmp_p64, NULL);
+}
 
 unsigned long *sparc64_valid_addr_bitmap __read_mostly;
 
@@ -67,6 +133,12 @@ extern unsigned int sparc_ramdisk_size;
 
 struct page *mem_map_zero __read_mostly;
 
+unsigned int sparc64_highest_unlocked_tlb_ent __read_mostly;
+
+unsigned long sparc64_kern_pri_context __read_mostly;
+unsigned long sparc64_kern_pri_nuc_bits __read_mostly;
+unsigned long sparc64_kern_sec_context __read_mostly;
+
 int bigkernel = 0;
 
 /* XXX Tune this... */
@@ -296,6 +368,7 @@ struct linux_prom_translation {
        unsigned long data;
 };
 static struct linux_prom_translation prom_trans[512] __initdata;
+static unsigned int prom_trans_ents __initdata;
 
 extern unsigned long prom_boot_page;
 extern void prom_remap(unsigned long physpage, unsigned long virtpage, int mmu_ihandle);
@@ -309,57 +382,7 @@ unsigned long kern_locked_tte_data;
 unsigned long prom_pmd_phys __read_mostly;
 unsigned int swapper_pgd_zero __read_mostly;
 
-/* Allocate power-of-2 aligned chunks from the end of the
- * kernel image.  Return physical address.
- */
-static inline unsigned long early_alloc_phys(unsigned long size)
-{
-       unsigned long base;
-
-       BUILD_BUG_ON(size & (size - 1));
-
-       kern_size = (kern_size + (size - 1)) & ~(size - 1);
-       base = kern_base + kern_size;
-       kern_size += size;
-
-       return base;
-}
-
-static inline unsigned long load_phys32(unsigned long pa)
-{
-       unsigned long val;
-
-       __asm__ __volatile__("lduwa     [%1] %2, %0"
-                            : "=&r" (val)
-                            : "r" (pa), "i" (ASI_PHYS_USE_EC));
-
-       return val;
-}
-
-static inline unsigned long load_phys64(unsigned long pa)
-{
-       unsigned long val;
-
-       __asm__ __volatile__("ldxa      [%1] %2, %0"
-                            : "=&r" (val)
-                            : "r" (pa), "i" (ASI_PHYS_USE_EC));
-
-       return val;
-}
-
-static inline void store_phys32(unsigned long pa, unsigned long val)
-{
-       __asm__ __volatile__("stwa      %0, [%1] %2"
-                            : /* no outputs */
-                            : "r" (val), "r" (pa), "i" (ASI_PHYS_USE_EC));
-}
-
-static inline void store_phys64(unsigned long pa, unsigned long val)
-{
-       __asm__ __volatile__("stxa      %0, [%1] %2"
-                            : /* no outputs */
-                            : "r" (val), "r" (pa), "i" (ASI_PHYS_USE_EC));
-}
+static pmd_t *prompmd __read_mostly;
 
 #define BASE_PAGE_SIZE 8192
 
@@ -369,34 +392,28 @@ static inline void store_phys64(unsigned long pa, unsigned long val)
  */
 unsigned long prom_virt_to_phys(unsigned long promva, int *error)
 {
-       unsigned long pmd_phys = (prom_pmd_phys +
-                                 ((promva >> 23) & 0x7ff) * sizeof(pmd_t));
-       unsigned long pte_phys;
-       pmd_t pmd_ent;
-       pte_t pte_ent;
+       pmd_t *pmdp = prompmd + ((promva >> 23) & 0x7ff);
+       pte_t *ptep;
        unsigned long base;
 
-       pmd_val(pmd_ent) = load_phys32(pmd_phys);
-       if (pmd_none(pmd_ent)) {
+       if (pmd_none(*pmdp)) {
                if (error)
                        *error = 1;
                return 0;
        }
-
-       pte_phys = (unsigned long)pmd_val(pmd_ent) << 11UL;
-       pte_phys += ((promva >> 13) & 0x3ff) * sizeof(pte_t);
-       pte_val(pte_ent) = load_phys64(pte_phys);
-       if (!pte_present(pte_ent)) {
+       ptep = (pte_t *)__pmd_page(*pmdp) + ((promva >> 13) & 0x3ff);
+       if (!pte_present(*ptep)) {
                if (error)
                        *error = 1;
                return 0;
        }
        if (error) {
                *error = 0;
-               return pte_val(pte_ent);
+               return pte_val(*ptep);
        }
-       base = pte_val(pte_ent) & _PAGE_PADDR;
-       return (base + (promva & (BASE_PAGE_SIZE - 1)));
+       base = pte_val(*ptep) & _PAGE_PADDR;
+
+       return base + (promva & (BASE_PAGE_SIZE - 1));
 }
 
 /* The obp translations are saved based on 8k pagesize, since obp can
@@ -409,25 +426,20 @@ static void __init build_obp_range(unsigned long start, unsigned long end, unsig
        unsigned long vaddr;
 
        for (vaddr = start; vaddr < end; vaddr += BASE_PAGE_SIZE) {
-               unsigned long val, pte_phys, pmd_phys;
-               pmd_t pmd_ent;
-               int i;
-
-               pmd_phys = (prom_pmd_phys +
-                           (((vaddr >> 23) & 0x7ff) * sizeof(pmd_t)));
-               pmd_val(pmd_ent) = load_phys32(pmd_phys);
-               if (pmd_none(pmd_ent)) {
-                       pte_phys = early_alloc_phys(BASE_PAGE_SIZE);
-
-                       for (i = 0; i < BASE_PAGE_SIZE / sizeof(pte_t); i++)
-                               store_phys64(pte_phys+i*sizeof(pte_t),0);
+               unsigned long val;
+               pmd_t *pmd;
+               pte_t *pte;
 
-                       pmd_val(pmd_ent) = pte_phys >> 11UL;
-                       store_phys32(pmd_phys, pmd_val(pmd_ent));
+               pmd = prompmd + ((vaddr >> 23) & 0x7ff);
+               if (pmd_none(*pmd)) {
+                       pte = __alloc_bootmem(BASE_PAGE_SIZE, BASE_PAGE_SIZE,
+                                             PAGE_SIZE);
+                       if (!pte)
+                               prom_halt();
+                       memset(pte, 0, BASE_PAGE_SIZE);
+                       pmd_set(pmd, pte);
                }
-
-               pte_phys = (unsigned long)pmd_val(pmd_ent) << 11UL;
-               pte_phys += (((vaddr >> 13) & 0x3ff) * sizeof(pte_t));
+               pte = (pte_t *) __pmd_page(*pmd) + ((vaddr >> 13) & 0x3ff);
 
                val = data;
 
@@ -435,7 +447,8 @@ static void __init build_obp_range(unsigned long start, unsigned long end, unsig
                if (tlb_type == spitfire)
                        val &= ~0x0003fe0000000000UL;
 
-               store_phys64(pte_phys, val | _PAGE_MODIFIED);
+               set_pte_at(&init_mm, vaddr, pte,
+                          __pte(val | _PAGE_MODIFIED));
 
                data += BASE_PAGE_SIZE;
        }
@@ -448,13 +461,17 @@ static inline int in_obp_range(unsigned long vaddr)
 }
 
 #define OBP_PMD_SIZE 2048
-static void __init build_obp_pgtable(int prom_trans_ents)
+static void __init build_obp_pgtable(void)
 {
        unsigned long i;
 
-       prom_pmd_phys = early_alloc_phys(OBP_PMD_SIZE);
-       for (i = 0; i < OBP_PMD_SIZE; i += 4)
-               store_phys32(prom_pmd_phys + i, 0);
+       prompmd = __alloc_bootmem(OBP_PMD_SIZE, OBP_PMD_SIZE, PAGE_SIZE);
+       if (!prompmd)
+               prom_halt();
+
+       memset(prompmd, 0, OBP_PMD_SIZE);
+
+       prom_pmd_phys = __pa(prompmd);
 
        for (i = 0; i < prom_trans_ents; i++) {
                unsigned long start, end;
@@ -474,7 +491,7 @@ static void __init build_obp_pgtable(int prom_trans_ents)
 /* Read OBP translations property into 'prom_trans[]'.
  * Return the number of entries.
  */
-static int __init read_obp_translations(void)
+static void __init read_obp_translations(void)
 {
        int n, node;
 
@@ -495,8 +512,10 @@ static int __init read_obp_translations(void)
                prom_printf("prom_mappings: Couldn't get property.\n");
                prom_halt();
        }
+
        n = n / sizeof(struct linux_prom_translation);
-       return n;
+
+       prom_trans_ents = n;
 }
 
 static void __init remap_kernel(void)
@@ -516,28 +535,38 @@ static void __init remap_kernel(void)
        prom_dtlb_load(tlb_ent, tte_data, tte_vaddr);
        prom_itlb_load(tlb_ent, tte_data, tte_vaddr);
        if (bigkernel) {
-               prom_dtlb_load(tlb_ent - 1,
+               tlb_ent -= 1;
+               prom_dtlb_load(tlb_ent,
                               tte_data + 0x400000, 
                               tte_vaddr + 0x400000);
-               prom_itlb_load(tlb_ent - 1,
+               prom_itlb_load(tlb_ent,
                               tte_data + 0x400000, 
                               tte_vaddr + 0x400000);
        }
+       sparc64_highest_unlocked_tlb_ent = tlb_ent - 1;
+       if (tlb_type == cheetah_plus) {
+               sparc64_kern_pri_context = (CTX_CHEETAH_PLUS_CTX0 |
+                                           CTX_CHEETAH_PLUS_NUC);
+               sparc64_kern_pri_nuc_bits = CTX_CHEETAH_PLUS_NUC;
+               sparc64_kern_sec_context = CTX_CHEETAH_PLUS_CTX0;
+       }
 }
 
-static void __init inherit_prom_mappings(void)
-{
-       int n;
 
-       n = read_obp_translations();
-       build_obp_pgtable(n);
+static void __init inherit_prom_mappings_pre(void)
+{
+       read_obp_translations();
 
        /* Now fixup OBP's idea about where we really are mapped. */
        prom_printf("Remapping the kernel... ");
        remap_kernel();
 
        prom_printf("done.\n");
+}
 
+static void __init inherit_prom_mappings_post(void)
+{
+       build_obp_pgtable();
        register_prom_callbacks();
 }
 
@@ -722,8 +751,8 @@ void inherit_locked_prom_mappings(int save_p)
                }
        }
        if (tlb_type == spitfire) {
-               int high = SPITFIRE_HIGHEST_LOCKED_TLBENT - bigkernel;
-               for (i = 0; i < high; i++) {
+               int high = sparc64_highest_unlocked_tlb_ent;
+               for (i = 0; i <= high; i++) {
                        unsigned long data;
 
                        /* Spitfire Errata #32 workaround */
@@ -811,9 +840,9 @@ void inherit_locked_prom_mappings(int save_p)
                        }
                }
        } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {
-               int high = CHEETAH_HIGHEST_LOCKED_TLBENT - bigkernel;
+               int high = sparc64_highest_unlocked_tlb_ent;
 
-               for (i = 0; i < high; i++) {
+               for (i = 0; i <= high; i++) {
                        unsigned long data;
 
                        data = cheetah_get_ldtlb_data(i);
@@ -1206,14 +1235,14 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
        int i;
 
 #ifdef CONFIG_DEBUG_BOOTMEM
-       prom_printf("bootmem_init: Scan sp_banks, ");
+       prom_printf("bootmem_init: Scan pavail, ");
 #endif
 
        bytes_avail = 0UL;
-       for (i = 0; sp_banks[i].num_bytes != 0; i++) {
-               end_of_phys_memory = sp_banks[i].base_addr +
-                       sp_banks[i].num_bytes;
-               bytes_avail += sp_banks[i].num_bytes;
+       for (i = 0; i < pavail_ents; i++) {
+               end_of_phys_memory = pavail[i].phys_addr +
+                       pavail[i].reg_size;
+               bytes_avail += pavail[i].reg_size;
                if (cmdline_memory_size) {
                        if (bytes_avail > cmdline_memory_size) {
                                unsigned long slack = bytes_avail - cmdline_memory_size;
@@ -1221,12 +1250,15 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
                                bytes_avail -= slack;
                                end_of_phys_memory -= slack;
 
-                               sp_banks[i].num_bytes -= slack;
-                               if (sp_banks[i].num_bytes == 0) {
-                                       sp_banks[i].base_addr = 0xdeadbeef;
+                               pavail[i].reg_size -= slack;
+                               if ((long)pavail[i].reg_size <= 0L) {
+                                       pavail[i].phys_addr = 0xdeadbeefUL;
+                                       pavail[i].reg_size = 0UL;
+                                       pavail_ents = i;
                                } else {
-                                       sp_banks[i+1].num_bytes = 0;
-                                       sp_banks[i+1].base_addr = 0xdeadbeef;
+                                       pavail[i+1].reg_size = 0Ul;
+                                       pavail[i+1].phys_addr = 0xdeadbeefUL;
+                                       pavail_ents = i + 1;
                                }
                                break;
                        }
@@ -1280,12 +1312,12 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
        /* Now register the available physical memory with the
         * allocator.
         */
-       for (i = 0; sp_banks[i].num_bytes != 0; i++) {
+       for (i = 0; i < pavail_ents; i++) {
 #ifdef CONFIG_DEBUG_BOOTMEM
-               prom_printf("free_bootmem(sp_banks:%d): base[%lx] size[%lx]\n",
-                           i, sp_banks[i].base_addr, sp_banks[i].num_bytes);
+               prom_printf("free_bootmem(pavail:%d): base[%lx] size[%lx]\n",
+                           i, pavail[i].phys_addr, pavail[i].reg_size);
 #endif
-               free_bootmem(sp_banks[i].base_addr, sp_banks[i].num_bytes);
+               free_bootmem(pavail[i].phys_addr, pavail[i].reg_size);
        }
 
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -1334,7 +1366,7 @@ static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend,
        unsigned long alloc_bytes = 0UL;
 
        if ((vstart & ~PAGE_MASK) || (vend & ~PAGE_MASK)) {
-               prom_printf("kernel_map: Unaligned sp_banks[%lx:%lx]\n",
+               prom_printf("kernel_map: Unaligned physmem[%lx:%lx]\n",
                            vstart, vend);
                prom_halt();
        }
@@ -1381,23 +1413,24 @@ static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend,
        return alloc_bytes;
 }
 
-extern struct linux_mlist_p1275 *prom_ptot_ptr;
+static struct linux_prom64_registers pall[MAX_BANKS] __initdata;
+static int pall_ents __initdata;
+
 extern unsigned int kvmap_linear_patch[1];
 
 static void __init kernel_physical_mapping_init(void)
 {
-       struct linux_mlist_p1275 *p = prom_ptot_ptr;
-       unsigned long mem_alloced = 0UL;
+       unsigned long i, mem_alloced = 0UL;
+
+       read_obp_memory("reg", &pall[0], &pall_ents);
 
-       while (p) {
+       for (i = 0; i < pall_ents; i++) {
                unsigned long phys_start, phys_end;
 
-               phys_start = p->start_adr;
-               phys_end = phys_start + p->num_bytes;
+               phys_start = pall[i].phys_addr;
+               phys_end = phys_start + pall[i].reg_size;
                mem_alloced += kernel_map_range(phys_start, phys_end,
                                                PAGE_KERNEL);
-
-               p = p->theres_more;
        }
 
        printk("Allocated %ld bytes for kernel page tables.\n",
@@ -1425,6 +1458,18 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
 }
 #endif
 
+unsigned long __init find_ecache_flush_span(unsigned long size)
+{
+       int i;
+
+       for (i = 0; i < pavail_ents; i++) {
+               if (pavail[i].reg_size >= size)
+                       return pavail[i].phys_addr;
+       }
+
+       return ~0UL;
+}
+
 /* paging_init() sets up the page tables */
 
 extern void cheetah_ecache_flush_init(void);
@@ -1435,7 +1480,19 @@ pgd_t swapper_pg_dir[2048];
 void __init paging_init(void)
 {
        unsigned long end_pfn, pages_avail, shift;
-       unsigned long real_end;
+       unsigned long real_end, i;
+
+       /* Find available physical memory... */
+       read_obp_memory("available", &pavail[0], &pavail_ents);
+
+       phys_base = 0xffffffffffffffffUL;
+       for (i = 0; i < pavail_ents; i++)
+               phys_base = min(phys_base, pavail[i].phys_addr);
+
+       pfn_base = phys_base >> PAGE_SHIFT;
+
+       kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
+       kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
 
        set_bit(0, mmu_context_bmap);
 
@@ -1462,8 +1519,7 @@ void __init paging_init(void)
        
        swapper_pgd_zero = pgd_val(swapper_pg_dir[0]);
        
-       /* Inherit non-locked OBP mappings. */
-       inherit_prom_mappings();
+       inherit_prom_mappings_pre();
        
        /* Ok, we can use our TLB miss and window trap handlers safely.
         * We need to do a quick peek here to see if we are on StarFire
@@ -1474,15 +1530,23 @@ void __init paging_init(void)
                extern void setup_tba(int);
                setup_tba(this_is_starfire);
        }
-
-       inherit_locked_prom_mappings(1);
-
        __flush_tlb_all();
 
+       /* Everything from this point forward, until we are done with
+        * inherit_prom_mappings_post(), must complete successfully
+        * without calling into the firmware.  The firwmare page tables
+        * have not been built, but we are running on the Linux kernel's
+        * trap table.
+        */
+
        /* Setup bootmem... */
        pages_avail = 0;
        last_valid_pfn = end_pfn = bootmem_init(&pages_avail);
 
+       inherit_prom_mappings_post();
+
+       inherit_locked_prom_mappings(1);
+
 #ifdef CONFIG_DEBUG_PAGEALLOC
        kernel_physical_mapping_init();
 #endif
@@ -1507,128 +1571,35 @@ void __init paging_init(void)
        device_scan();
 }
 
-/* Ok, it seems that the prom can allocate some more memory chunks
- * as a side effect of some prom calls we perform during the
- * boot sequence.  My most likely theory is that it is from the
- * prom_set_traptable() call, and OBP is allocating a scratchpad
- * for saving client program register state etc.
- */
-static void __init sort_memlist(struct linux_mlist_p1275 *thislist)
-{
-       int swapi = 0;
-       int i, mitr;
-       unsigned long tmpaddr, tmpsize;
-       unsigned long lowest;
-
-       for (i = 0; thislist[i].theres_more != 0; i++) {
-               lowest = thislist[i].start_adr;
-               for (mitr = i+1; thislist[mitr-1].theres_more != 0; mitr++)
-                       if (thislist[mitr].start_adr < lowest) {
-                               lowest = thislist[mitr].start_adr;
-                               swapi = mitr;
-                       }
-               if (lowest == thislist[i].start_adr)
-                       continue;
-               tmpaddr = thislist[swapi].start_adr;
-               tmpsize = thislist[swapi].num_bytes;
-               for (mitr = swapi; mitr > i; mitr--) {
-                       thislist[mitr].start_adr = thislist[mitr-1].start_adr;
-                       thislist[mitr].num_bytes = thislist[mitr-1].num_bytes;
-               }
-               thislist[i].start_adr = tmpaddr;
-               thislist[i].num_bytes = tmpsize;
-       }
-}
-
-void __init rescan_sp_banks(void)
-{
-       struct linux_prom64_registers memlist[64];
-       struct linux_mlist_p1275 avail[64], *mlist;
-       unsigned long bytes, base_paddr;
-       int num_regs, node = prom_finddevice("/memory");
-       int i;
-
-       num_regs = prom_getproperty(node, "available",
-                                   (char *) memlist, sizeof(memlist));
-       num_regs = (num_regs / sizeof(struct linux_prom64_registers));
-       for (i = 0; i < num_regs; i++) {
-               avail[i].start_adr = memlist[i].phys_addr;
-               avail[i].num_bytes = memlist[i].reg_size;
-               avail[i].theres_more = &avail[i + 1];
-       }
-       avail[i - 1].theres_more = NULL;
-       sort_memlist(avail);
-
-       mlist = &avail[0];
-       i = 0;
-       bytes = mlist->num_bytes;
-       base_paddr = mlist->start_adr;
-  
-       sp_banks[0].base_addr = base_paddr;
-       sp_banks[0].num_bytes = bytes;
-
-       while (mlist->theres_more != NULL){
-               i++;
-               mlist = mlist->theres_more;
-               bytes = mlist->num_bytes;
-               if (i >= SPARC_PHYS_BANKS-1) {
-                       printk ("The machine has more banks than "
-                               "this kernel can support\n"
-                               "Increase the SPARC_PHYS_BANKS "
-                               "setting (currently %d)\n",
-                               SPARC_PHYS_BANKS);
-                       i = SPARC_PHYS_BANKS-1;
-                       break;
-               }
-    
-               sp_banks[i].base_addr = mlist->start_adr;
-               sp_banks[i].num_bytes = mlist->num_bytes;
-       }
-
-       i++;
-       sp_banks[i].base_addr = 0xdeadbeefbeefdeadUL;
-       sp_banks[i].num_bytes = 0;
-
-       for (i = 0; sp_banks[i].num_bytes != 0; i++)
-               sp_banks[i].num_bytes &= PAGE_MASK;
-}
-
 static void __init taint_real_pages(void)
 {
-       struct sparc_phys_banks saved_sp_banks[SPARC_PHYS_BANKS];
        int i;
 
-       for (i = 0; i < SPARC_PHYS_BANKS; i++) {
-               saved_sp_banks[i].base_addr =
-                       sp_banks[i].base_addr;
-               saved_sp_banks[i].num_bytes =
-                       sp_banks[i].num_bytes;
-       }
-
-       rescan_sp_banks();
+       read_obp_memory("available", &pavail_rescan[0], &pavail_rescan_ents);
 
-       /* Find changes discovered in the sp_bank rescan and
+       /* Find changes discovered in the physmem available rescan and
         * reserve the lost portions in the bootmem maps.
         */
-       for (i = 0; saved_sp_banks[i].num_bytes; i++) {
+       for (i = 0; i < pavail_ents; i++) {
                unsigned long old_start, old_end;
 
-               old_start = saved_sp_banks[i].base_addr;
+               old_start = pavail[i].phys_addr;
                old_end = old_start +
-                       saved_sp_banks[i].num_bytes;
+                       pavail[i].reg_size;
                while (old_start < old_end) {
                        int n;
 
-                       for (n = 0; sp_banks[n].num_bytes; n++) {
+                       for (n = 0; pavail_rescan_ents; n++) {
                                unsigned long new_start, new_end;
 
-                               new_start = sp_banks[n].base_addr;
-                               new_end = new_start + sp_banks[n].num_bytes;
+                               new_start = pavail_rescan[n].phys_addr;
+                               new_end = new_start +
+                                       pavail_rescan[n].reg_size;
 
                                if (new_start <= old_start &&
                                    new_end >= (old_start + PAGE_SIZE)) {
-                                       set_bit (old_start >> 22,
-                                                sparc64_valid_addr_bitmap);
+                                       set_bit(old_start >> 22,
+                                               sparc64_valid_addr_bitmap);
                                        goto do_next_page;
                                }
                        }
index c7898a5ee456ba0838afb6fc567551fdde3489b1..3d33ed27bc27b2bb0a98a374c657e99f5e3dc5ad 100644 (file)
@@ -6,5 +6,5 @@
 EXTRA_AFLAGS := -ansi
 EXTRA_CFLAGS := -Werror
 
-lib-y   := bootstr.o devops.o init.o memory.o misc.o \
+lib-y   := bootstr.o devops.o init.o misc.o \
           tree.o console.o printf.o p1275.o cif.o
index 8b4b622d09098aaf439bb40bcd47aea8da8d81fe..f3cc2d8578b200ec8cc140dc4661abfebfea67a8 100644 (file)
@@ -27,7 +27,6 @@ int prom_chosen_node;
  * failure.  It gets passed the pointer to the PROM vector.
  */
 
-extern void prom_meminit(void);
 extern void prom_cif_init(void *, void *);
 
 void __init prom_init(void *cif_handler, void *cif_stack)
@@ -90,8 +89,6 @@ void __init prom_init(void *cif_handler, void *cif_stack)
 
        printk ("PROMLIB: Sun IEEE Boot Prom %s\n", buffer + bufadjust);
 
-       prom_meminit();
-
        /* Initialization successful. */
        return;
 
diff --git a/arch/sparc64/prom/memory.c b/arch/sparc64/prom/memory.c
deleted file mode 100644 (file)
index f4a8143..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/* $Id: memory.c,v 1.5 1999/08/31 06:55:04 davem Exp $
- * memory.c: Prom routine for acquiring various bits of information
- *           about RAM on the machine, both virtual and physical.
- *
- * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
- * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-
-#include <asm/openprom.h>
-#include <asm/oplib.h>
-
-/* This routine, for consistency, returns the ram parameters in the
- * V0 prom memory descriptor format.  I choose this format because I
- * think it was the easiest to work with.  I feel the religious
- * arguments now... ;)  Also, I return the linked lists sorted to
- * prevent paging_init() upset stomach as I have not yet written
- * the pepto-bismol kernel module yet.
- */
-
-struct linux_prom64_registers prom_reg_memlist[64];
-struct linux_prom64_registers prom_reg_tmp[64];
-
-struct linux_mlist_p1275 prom_phys_total[64];
-struct linux_mlist_p1275 prom_prom_taken[64];
-struct linux_mlist_p1275 prom_phys_avail[64];
-
-struct linux_mlist_p1275 *prom_ptot_ptr = prom_phys_total;
-struct linux_mlist_p1275 *prom_ptak_ptr = prom_prom_taken;
-struct linux_mlist_p1275 *prom_pavl_ptr = prom_phys_avail;
-
-struct linux_mem_p1275 prom_memlist;
-
-
-/* Internal Prom library routine to sort a linux_mlist_p1275 memory
- * list.  Used below in initialization.
- */
-static void __init
-prom_sortmemlist(struct linux_mlist_p1275 *thislist)
-{
-       int swapi = 0;
-       int i, mitr;
-       unsigned long tmpaddr, tmpsize;
-       unsigned long lowest;
-
-       for(i=0; thislist[i].theres_more; i++) {
-               lowest = thislist[i].start_adr;
-               for(mitr = i+1; thislist[mitr-1].theres_more; mitr++)
-                       if(thislist[mitr].start_adr < lowest) {
-                               lowest = thislist[mitr].start_adr;
-                               swapi = mitr;
-                       }
-               if(lowest == thislist[i].start_adr) continue;
-               tmpaddr = thislist[swapi].start_adr;
-               tmpsize = thislist[swapi].num_bytes;
-               for(mitr = swapi; mitr > i; mitr--) {
-                       thislist[mitr].start_adr = thislist[mitr-1].start_adr;
-                       thislist[mitr].num_bytes = thislist[mitr-1].num_bytes;
-               }
-               thislist[i].start_adr = tmpaddr;
-               thislist[i].num_bytes = tmpsize;
-       }
-}
-
-/* Initialize the memory lists based upon the prom version. */
-void __init prom_meminit(void)
-{
-       int node = 0;
-       unsigned int iter, num_regs;
-
-       node = prom_finddevice("/memory");
-       num_regs = prom_getproperty(node, "available",
-                                   (char *) prom_reg_memlist,
-                                   sizeof(prom_reg_memlist));
-       num_regs = (num_regs/sizeof(struct linux_prom64_registers));
-       for(iter=0; iter<num_regs; iter++) {
-               prom_phys_avail[iter].start_adr =
-                       prom_reg_memlist[iter].phys_addr;
-               prom_phys_avail[iter].num_bytes =
-                       prom_reg_memlist[iter].reg_size;
-               prom_phys_avail[iter].theres_more =
-                       &prom_phys_avail[iter+1];
-       }
-       prom_phys_avail[iter-1].theres_more = NULL;
-
-       num_regs = prom_getproperty(node, "reg",
-                                   (char *) prom_reg_memlist,
-                                   sizeof(prom_reg_memlist));
-       num_regs = (num_regs/sizeof(struct linux_prom64_registers));
-       for(iter=0; iter<num_regs; iter++) {
-               prom_phys_total[iter].start_adr =
-                       prom_reg_memlist[iter].phys_addr;
-               prom_phys_total[iter].num_bytes =
-                       prom_reg_memlist[iter].reg_size;
-               prom_phys_total[iter].theres_more =
-                       &prom_phys_total[iter+1];
-       }
-       prom_phys_total[iter-1].theres_more = NULL;
-
-       node = prom_finddevice("/virtual-memory");
-       num_regs = prom_getproperty(node, "available",
-                                   (char *) prom_reg_memlist,
-                                   sizeof(prom_reg_memlist));
-       num_regs = (num_regs/sizeof(struct linux_prom64_registers));
-
-       /* Convert available virtual areas to taken virtual
-        * areas.  First sort, then convert.
-        */
-       for(iter=0; iter<num_regs; iter++) {
-               prom_prom_taken[iter].start_adr =
-                       prom_reg_memlist[iter].phys_addr;
-               prom_prom_taken[iter].num_bytes =
-                       prom_reg_memlist[iter].reg_size;
-               prom_prom_taken[iter].theres_more =
-                       &prom_prom_taken[iter+1];
-       }
-       prom_prom_taken[iter-1].theres_more = NULL;
-
-       prom_sortmemlist(prom_prom_taken);
-
-       /* Finally, convert. */
-       for(iter=0; iter<num_regs; iter++) {
-               prom_prom_taken[iter].start_adr =
-                       prom_prom_taken[iter].start_adr +
-                       prom_prom_taken[iter].num_bytes;
-               prom_prom_taken[iter].num_bytes =
-                       prom_prom_taken[iter+1].start_adr -
-                       prom_prom_taken[iter].start_adr;
-       }
-       prom_prom_taken[iter-1].num_bytes =
-               -1UL - prom_prom_taken[iter-1].start_adr;
-
-       /* Sort the other two lists. */
-       prom_sortmemlist(prom_phys_total);
-       prom_sortmemlist(prom_phys_avail);
-
-       /* Link all the lists into the top-level descriptor. */
-       prom_memlist.p1275_totphys=&prom_ptot_ptr;
-       prom_memlist.p1275_prommap=&prom_ptak_ptr;
-       prom_memlist.p1275_available=&prom_pavl_ptr;
-}
-
-/* This returns a pointer to our libraries internal p1275 format
- * memory descriptor.
- */
-struct linux_mem_p1275 *
-prom_meminfo(void)
-{
-       return &prom_memlist;
-}
index 5b5af95721ab16f4cee63ae8ac0c988a91aa45e0..7af37e342e331bf89f0880c2ae0ae4d690f3cbea 100644 (file)
@@ -28,8 +28,6 @@ SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
 ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
        $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
 
-GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
-
 um-modes-$(CONFIG_MODE_TT) += tt
 um-modes-$(CONFIG_MODE_SKAS) += skas
 
@@ -45,9 +43,7 @@ endif
 
 ARCH_INCLUDE   := -I$(ARCH_DIR)/include
 ifneq ($(KBUILD_SRC),)
-ARCH_INCLUDE   += -I$(ARCH_DIR)/include2
 ARCH_INCLUDE   += -I$(srctree)/$(ARCH_DIR)/include
-MRPROPER_DIRS  += $(ARCH_DIR)/include2
 endif
 SYS_DIR                := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 
@@ -87,10 +83,6 @@ CONFIG_KERNEL_HALF_GIGS ?= 0
 
 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
 
-ifeq ($(CONFIG_MODE_SKAS), y)
-$(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h
-endif
-
 .PHONY: linux
 
 all: linux
@@ -111,7 +103,8 @@ else
 $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
 endif
 
-archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
+archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h
+prepare: $(ARCH_DIR)/include/kern_constants.h
 
 LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
 LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
@@ -146,15 +139,13 @@ endef
 #When cleaning we don't include .config, so we don't include
 #TT or skas makefiles and don't clean skas_ptregs.h.
 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
-       $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \
-       $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch
+       $(ARCH_DIR)/include/user_constants.h \
+       $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch
 
 MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
        $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os
 
 archclean:
-       $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util
-       $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util
        @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
                -o -name '*.gcov' \) -type f -print | xargs rm -f
 
@@ -180,9 +171,7 @@ $(ARCH_DIR)/include/sysdep:
        @echo '  SYMLINK $@'
 ifneq ($(KBUILD_SRC),)
        $(Q)mkdir -p $(ARCH_DIR)/include
-       $(Q)mkdir -p $(ARCH_DIR)/include2
-       $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
-       $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep
+       $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
 else
        $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
 endif
@@ -202,8 +191,6 @@ endef
 
 define filechk_gen-asm-offsets
         (set -e; \
-         echo "#ifndef __ASM_OFFSETS_H__"; \
-         echo "#define __ASM_OFFSETS_H__"; \
          echo "/*"; \
          echo " * DO NOT MODIFY."; \
          echo " *"; \
@@ -212,8 +199,7 @@ define filechk_gen-asm-offsets
          echo " */"; \
          echo ""; \
          sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
-         echo ""; \
-         echo "#endif" )
+         echo ""; )
 endef
 
 $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
@@ -222,50 +208,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
 $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
        $(CC) $(USER_CFLAGS) -S -o $@ $<
 
-$(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s
+$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s
        $(call filechk,gen-asm-offsets)
 
-CLEAN_FILES += $(ARCH_DIR)/user-offsets.s  $(ARCH_DIR)/user-offsets.h
+CLEAN_FILES += $(ARCH_DIR)/user-offsets.s
 
 $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \
-                                  $(ARCH_SYMLINKS) \
-                                  $(SYS_DIR)/sc.h \
-                                  include/asm include/linux/version.h \
-                                  include/config/MARKER \
-                                  $(ARCH_DIR)/include/user_constants.h
+                                  archprepare
        $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $<
 
-$(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s
+$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s
        $(call filechk,gen-asm-offsets)
 
-CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s  $(ARCH_DIR)/kernel-offsets.h
-
-$(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task
-       $(call filechk,gen_header)
-
-$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants
-       $(call filechk,gen_header)
-
-$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
-       $(call filechk,gen_header)
-
-$(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs
-       $(call filechk,gen_header)
-
-$(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ;
-
-$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \
-       FORCE ;
-
-$(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ;
-
-$(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$@
-
-$(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$@
-
-$(ARCH_DIR)/os-$(OS)/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$@
+CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s
 
 export SUBARCH USER_CFLAGS OS
index 1ab431a53ac3d0cc3eb336d5d1c07a996e7ab554..2ee8a2858117357f3ae2fdc1412ff42fe633cedc 100644 (file)
@@ -32,25 +32,3 @@ CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH)
 ifneq ($(CONFIG_GPROF),y)
 ARCH_CFLAGS += -DUM_FASTCALL
 endif
-
-SYS_UTIL_DIR   := $(ARCH_DIR)/sys-i386/util
-SYS_HEADERS    := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
-
-prepare: $(SYS_HEADERS)
-
-$(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
-       $(call filechk,gen_header)
-
-$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread 
-       $(call filechk,gen_header)
-
-$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
-
-$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
-
-$(SYS_UTIL_DIR): scripts_basic include/asm FORCE
-       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR)
-
-CLEAN_FILES += $(SYS_HEADERS)
index fd18ec572271b80fd96e446edaebca889b848484..ac35de5316a6a547d4c8293b61387ddbae546476 100644 (file)
@@ -10,5 +10,3 @@ CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
 CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
 LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
 LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
-
-GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h
index 436abbba409bd3e1a9516239022ba3f6ecffabd1..4f118d5cc2ee177c381b3b3d2522071f76025498 100644 (file)
@@ -12,24 +12,3 @@ CHECKFLAGS  += -m64
 
 ELF_ARCH := i386:x86-64
 ELF_FORMAT := elf64-x86-64
-
-SYS_UTIL_DIR := $(ARCH_DIR)/sys-x86_64/util
-SYS_DIR := $(ARCH_DIR)/include/sysdep-x86_64
-
-SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
-
-prepare: $(SYS_HEADERS)
-
-$(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
-       $(call filechk,gen_header)
-
-$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread
-       $(call filechk,gen_header)
-
-$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
-
-$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE
-       $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
-
-CLEAN_FILES += $(SYS_HEADERS)
index 04383f98f4d5ff9258109941ac19cfe387907778..310c1f823f26713eb9a4d6689fd20d504b8e6fb2 100644 (file)
@@ -23,7 +23,7 @@ static struct mconsole_command commands[] = {
        { "reboot", mconsole_reboot, MCONSOLE_PROC },
        { "config", mconsole_config, MCONSOLE_PROC },
        { "remove", mconsole_remove, MCONSOLE_PROC },
-       { "sysrq", mconsole_sysrq, MCONSOLE_PROC },
+       { "sysrq", mconsole_sysrq, MCONSOLE_INTR },
        { "help", mconsole_help, MCONSOLE_INTR },
        { "cad", mconsole_cad, MCONSOLE_INTR },
        { "stop", mconsole_stop, MCONSOLE_PROC },
index c41efd207fcc23b33cf35b09edd94d1c841893c8..189839e4f1d4eae532241945c8bbe70b2d9aa989 100644 (file)
@@ -7,7 +7,6 @@
 #include "linux/sched.h"
 #include "linux/slab.h"
 #include "linux/interrupt.h"
-#include "linux/irq.h"
 #include "linux/spinlock.h"
 #include "linux/errno.h"
 #include "asm/atomic.h"
index 782ac3a3baf98bd82fc16f9c176a64d323d553aa..356390d1f8b945dbedbb3ce11475fdb309b95926 100644 (file)
@@ -1,7 +1,7 @@
 /* for use by sys-$SUBARCH/kernel-offsets.c */
 
-OFFSET(TASK_REGS, task_struct, thread.regs);
-OFFSET(TASK_PID, task_struct, pid);
+OFFSET(HOST_TASK_REGS, task_struct, thread.regs);
+OFFSET(HOST_TASK_PID, task_struct, pid);
 DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
 DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
 DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
index 583329d0a539a012196b2fe0e72e68926865d127..6f766e1faeccd1bd806ddeb09546002c7e898d31 100644 (file)
@@ -157,6 +157,10 @@ extern int os_lock_file(int fd, int excl);
 extern void os_early_checks(void);
 extern int can_do_skas(void);
 
+/* Make sure they are clear when running in TT mode. Required by
+ * SEGV_MAYBE_FIXABLE */
+#define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0)
+
 /* mem.c */
 extern int create_mem_file(unsigned long len);
 
index 0a35e6d0baa047b455a050899f408cddf8632d5c..4892e5fcef07dce7170c70ce85a9f4e3ad867d92 100644 (file)
@@ -15,16 +15,6 @@ extern void save_registers(int pid, union uml_pt_regs *regs);
 extern void restore_registers(int pid, union uml_pt_regs *regs);
 extern void init_registers(int pid);
 extern void get_safe_registers(unsigned long * regs);
+extern void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/skas_ptregs.h b/arch/um/include/skas_ptregs.h
new file mode 100644 (file)
index 0000000..73db19e
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __SKAS_PT_REGS_
+#define __SKAS_PT_REGS_
+
+#include <user_constants.h>
+
+#endif
diff --git a/arch/um/include/sysdep-i386/sc.h b/arch/um/include/sysdep-i386/sc.h
new file mode 100644 (file)
index 0000000..c57d178
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __SYSDEP_I386_SC_H
+#define __SYSDEP_I386_SC_H
+
+#include <user_constants.h>
+
+#define SC_OFFSET(sc, field) \
+       *((unsigned long *) &(((char *) (sc))[HOST_##field]))
+#define SC_FP_OFFSET(sc, field) \
+       *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field]))
+#define SC_FP_OFFSET_PTR(sc, field, type) \
+       ((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field]))
+
+#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
+#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
+#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
+#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
+#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
+#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
+#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
+#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
+#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
+#define SC_EAX(sc) SC_OFFSET(sc, SC_EAX)
+#define SC_EBX(sc) SC_OFFSET(sc, SC_EBX)
+#define SC_ECX(sc) SC_OFFSET(sc, SC_ECX)
+#define SC_EDX(sc) SC_OFFSET(sc, SC_EDX)
+#define SC_EDI(sc) SC_OFFSET(sc, SC_EDI)
+#define SC_ESI(sc) SC_OFFSET(sc, SC_ESI)
+#define SC_EBP(sc) SC_OFFSET(sc, SC_EBP)
+#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
+#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
+#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
+#define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE)
+#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
+#define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW)
+#define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW)
+#define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG)
+#define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF)
+#define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL)
+#define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF)
+#define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL)
+#define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate)
+#define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void)
+
+#endif
index 1fe729265167ad6cfc796cd30957e5ffcff09aa8..23fd2644d7edf596511ebae83b7f6c498f8ed40a 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef __SYS_SIGCONTEXT_I386_H
 #define __SYS_SIGCONTEXT_I386_H
 
+#include "uml-config.h"
 #include <sysdep/sc.h>
 
 #define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
 #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
 
 /* This is Page Fault */
-#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
+#define SEGV_IS_FIXABLE(fi)    ((fi)->trap_no == 14)
+
+/* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */
+#ifdef UML_CONFIG_MODE_SKAS
+#define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo)
+#else
+#define SEGV_MAYBE_FIXABLE(fi) 0
+#endif
 
 extern unsigned long *sc_sigmask(void *sc_ptr);
 extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
diff --git a/arch/um/include/sysdep-i386/thread.h b/arch/um/include/sysdep-i386/thread.h
new file mode 100644 (file)
index 0000000..e2bd6ba
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __UM_THREAD_H
+#define __UM_THREAD_H
+
+#include <kern_constants.h>
+
+#define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS]))
+#ifdef CONFIG_MODE_TT
+#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
+#endif
+
+#endif
index 331aa2d1f3f5469f04c0fa9bbefe0a15934edde0..8f0656766c2171b58a858d889108753f69f2f33d 100644 (file)
@@ -218,10 +218,6 @@ struct syscall_args {
                 case RBP: UPT_RBP(regs) = __upt_val; break; \
                 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
                 case CS: UPT_CS(regs) = __upt_val; break; \
-                case DS: UPT_DS(regs) = __upt_val; break; \
-                case ES: UPT_ES(regs) = __upt_val; break; \
-                case FS: UPT_FS(regs) = __upt_val; break; \
-                case GS: UPT_GS(regs) = __upt_val; break; \
                 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
                 default :  \
                         panic("Bad register in UPT_SET : %d\n", reg);  \
diff --git a/arch/um/include/sysdep-x86_64/sc.h b/arch/um/include/sysdep-x86_64/sc.h
new file mode 100644 (file)
index 0000000..a160d9f
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef __SYSDEP_X86_64_SC_H
+#define __SYSDEP_X86_64_SC_H
+
+/* Copyright (C) 2003 - 2004 PathScale, Inc
+ * Released under the GPL
+ */
+
+#include <user_constants.h>
+
+#define SC_OFFSET(sc, field) \
+        *((unsigned long *) &(((char *) (sc))[HOST_##field]))
+
+#define SC_RBX(sc) SC_OFFSET(sc, SC_RBX)
+#define SC_RCX(sc) SC_OFFSET(sc, SC_RCX)
+#define SC_RDX(sc) SC_OFFSET(sc, SC_RDX)
+#define SC_RSI(sc) SC_OFFSET(sc, SC_RSI)
+#define SC_RDI(sc) SC_OFFSET(sc, SC_RDI)
+#define SC_RBP(sc) SC_OFFSET(sc, SC_RBP)
+#define SC_RAX(sc) SC_OFFSET(sc, SC_RAX)
+#define SC_R8(sc) SC_OFFSET(sc, SC_R8)
+#define SC_R9(sc) SC_OFFSET(sc, SC_R9)
+#define SC_R10(sc) SC_OFFSET(sc, SC_R10)
+#define SC_R11(sc) SC_OFFSET(sc, SC_R11)
+#define SC_R12(sc) SC_OFFSET(sc, SC_R12)
+#define SC_R13(sc) SC_OFFSET(sc, SC_R13)
+#define SC_R14(sc) SC_OFFSET(sc, SC_R14)
+#define SC_R15(sc) SC_OFFSET(sc, SC_R15)
+#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
+#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
+#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
+#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
+#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
+#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
+#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
+#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
+#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
+#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
+#if 0
+#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX)
+#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
+#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
+#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
+#endif
+
+#endif
index 2a78260d15a0d550cf348d4ad9ce7f8f58a12a47..41073235e7ad751efd8701998b9561eaa5cc6a3f 100644 (file)
 #define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0)
 
 /* This is Page Fault */
-#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
+#define SEGV_IS_FIXABLE(fi)    ((fi)->trap_no == 14)
+
+/* No broken SKAS API, which doesn't pass trap_no, here. */
+#define SEGV_MAYBE_FIXABLE(fi) 0
 
 extern unsigned long *sc_sigmask(void *sc_ptr);
 
diff --git a/arch/um/include/sysdep-x86_64/thread.h b/arch/um/include/sysdep-x86_64/thread.h
new file mode 100644 (file)
index 0000000..6a76a7f
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __UM_THREAD_H
+#define __UM_THREAD_H
+
+#include <kern_constants.h>
+
+#ifdef CONFIG_MODE_TT
+#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
+#endif
+
+#endif
diff --git a/arch/um/include/task.h b/arch/um/include/task.h
new file mode 100644 (file)
index 0000000..6375ba7
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __TASK_H
+#define __TASK_H
+
+#include <kern_constants.h>
+
+#define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
+#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID]))
+
+#endif
index dcd814971995ca858c2ce01667800437c65f43b9..bbf94bf2921ed144a6d70990152c1264b8361b33 100644 (file)
@@ -9,7 +9,6 @@
 #include "linux/kernel.h"
 #include "linux/module.h"
 #include "linux/smp.h"
-#include "linux/irq.h"
 #include "linux/kernel_stat.h"
 #include "linux/interrupt.h"
 #include "linux/random.h"
index db36c7c9594070669c4d328f0221f10f10550ac6..8de471b59c1c8188c35887cd18280594c9dc33dc 100644 (file)
@@ -6,8 +6,6 @@
 obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
        syscall.o tlb.o trap_user.o uaccess.o
 
-subdir- := util
-
 USER_OBJS := process.o clone.o
 
 include arch/um/scripts/Makefile.rules
diff --git a/arch/um/kernel/skas/util/Makefile b/arch/um/kernel/skas/util/Makefile
deleted file mode 100644 (file)
index f7b7eba..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-hostprogs-y            := mk_ptregs
-always                 := $(hostprogs-y)
-
-mk_ptregs-objs := mk_ptregs-$(SUBARCH).o
-HOSTCFLAGS_mk_ptregs-$(SUBARCH).o := -I$(objtree)/arch/um
diff --git a/arch/um/kernel/skas/util/mk_ptregs-i386.c b/arch/um/kernel/skas/util/mk_ptregs-i386.c
deleted file mode 100644 (file)
index 1f96e1e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <stdio.h>
-#include <user-offsets.h>
-
-#define SHOW(name) printf("#define %s %d\n", #name, name)
-
-int main(int argc, char **argv)
-{
-       printf("/* Automatically generated by "
-              "arch/um/kernel/skas/util/mk_ptregs */\n");
-       printf("\n");
-       printf("#ifndef __SKAS_PT_REGS_\n");
-       printf("#define __SKAS_PT_REGS_\n");
-       printf("\n");
-       SHOW(HOST_FRAME_SIZE);
-       SHOW(HOST_FP_SIZE);
-       SHOW(HOST_XFP_SIZE);
-
-       SHOW(HOST_IP);
-       SHOW(HOST_SP);
-       SHOW(HOST_EFLAGS);
-       SHOW(HOST_EAX);
-       SHOW(HOST_EBX);
-       SHOW(HOST_ECX);
-       SHOW(HOST_EDX);
-       SHOW(HOST_ESI);
-       SHOW(HOST_EDI);
-       SHOW(HOST_EBP);
-       SHOW(HOST_CS);
-       SHOW(HOST_SS);
-       SHOW(HOST_DS);
-       SHOW(HOST_FS);
-       SHOW(HOST_ES);
-       SHOW(HOST_GS);
-
-       printf("\n");
-       printf("#endif\n");
-       return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c
deleted file mode 100644 (file)
index 5fccbfe..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2003 PathScale, Inc.
- *
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <user-offsets.h>
-
-#define SHOW(name) \
-       printf("#define %s (%d / sizeof(unsigned long))\n", #name, name)
-
-int main(int argc, char **argv)
-{
-       printf("/* Automatically generated by "
-              "arch/um/kernel/skas/util/mk_ptregs */\n");
-       printf("\n");
-       printf("#ifndef __SKAS_PT_REGS_\n");
-       printf("#define __SKAS_PT_REGS_\n");
-       SHOW(HOST_FRAME_SIZE);
-       SHOW(HOST_RBX);
-       SHOW(HOST_RCX);
-       SHOW(HOST_RDI);
-       SHOW(HOST_RSI);
-       SHOW(HOST_RDX);
-       SHOW(HOST_RBP);
-       SHOW(HOST_RAX);
-       SHOW(HOST_R8);
-       SHOW(HOST_R9);
-       SHOW(HOST_R10);
-       SHOW(HOST_R11);
-       SHOW(HOST_R12);
-       SHOW(HOST_R13);
-       SHOW(HOST_R14);
-       SHOW(HOST_R15);
-       SHOW(HOST_ORIG_RAX);
-       SHOW(HOST_CS);
-       SHOW(HOST_SS);
-       SHOW(HOST_EFLAGS);
-#if 0
-       SHOW(HOST_FS);
-       SHOW(HOST_GS);
-       SHOW(HOST_DS);
-       SHOW(HOST_ES);
-#endif
-
-       SHOW(HOST_IP);
-       SHOW(HOST_SP);
-       printf("#define HOST_FP_SIZE 0\n");
-       printf("#define HOST_XFP_SIZE 0\n");
-       printf("\n");
-       printf("\n");
-       printf("#endif\n");
-       return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index f80850091e798c1eab0ad3f820cdf21350cf22b3..b331e970002ffe29c4d8db3d97c0d42a0084e525 100644 (file)
@@ -62,13 +62,7 @@ void show_stack(struct task_struct *task, unsigned long *esp)
 
        if (esp == NULL) {
                if (task != current && task != NULL) {
-                       /* XXX: Isn't this bogus? I.e. isn't this the
-                        * *userspace* stack of this task? If not so, use this
-                        * even when task == current (as in i386).
-                        */
                        esp = (unsigned long *) KSTK_ESP(task);
-                       /* Which one? No actual difference - just coding style.*/
-                       //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs);
                } else {
                        esp = (unsigned long *) &esp;
                }
@@ -84,5 +78,5 @@ void show_stack(struct task_struct *task, unsigned long *esp)
        }
 
        printk("Call Trace: \n");
-       show_trace(current, esp);
+       show_trace(task, esp);
 }
index d297429ac3605613511356fd355bf596b683c2f5..95c8f8733bafb516e67d044d6d78a87779a46c98 100644 (file)
@@ -26,6 +26,9 @@
 #include "mconsole_kern.h"
 #include "mem.h"
 #include "mem_kern.h"
+#ifdef CONFIG_MODE_SKAS
+#include "skas.h"
+#endif
 
 /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
 int handle_page_fault(unsigned long address, unsigned long ip, 
@@ -134,7 +137,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
        else if(current->mm == NULL)
                panic("Segfault with no mm");
 
-       if (SEGV_IS_FIXABLE(&fi))
+       if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi))
                err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
        else {
                err = -EFAULT;
index f0a275947d34b18dea67b432c1543c054738d35f..93dc782dc1cc8f5d790b2151694c4caf757238d0 100644 (file)
@@ -334,6 +334,8 @@ int linux_main(int argc, char **argv)
                add_arg(DEFAULT_COMMAND_LINE);
 
        os_early_checks();
+       if (force_tt)
+               clear_can_do_skas();
        mode_tt = force_tt ? 1 : !can_do_skas();
 #ifndef CONFIG_MODE_TT
        if (mode_tt) {
index ab33cb3c74ec26e5ba282067cb701a741cfab5ca..5a99dd3fbed0477bb7443eba1324e70f0dc4bcf4 100644 (file)
@@ -12,7 +12,7 @@
 #include "init.h"
 #include "elf_user.h"
 #include "mem_user.h"
-#include <kernel-offsets.h>
+#include <kern_constants.h>
 
 /* Use the one from the kernel - the host may miss it, if having old headers. */
 #if UM_ELF_CLASS == UM_ELFCLASS32
index 3125d320722c9c529c1c566f2854d20439192e1b..aee4812333c6ebebb6b821ebb92ac28820fcaf34 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <setjmp.h>
 #include "sysdep/ptrace_user.h"
 #include "sysdep/ptrace.h"
 #include "uml-config.h"
@@ -126,13 +127,11 @@ void get_safe_registers(unsigned long *regs)
        memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
 }
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
+{
+       struct __jmp_buf_tag *jmpbuf = buffer;
+
+       UPT_SET(uml_regs, EIP, jmpbuf->__jmpbuf[JB_PC]);
+       UPT_SET(uml_regs, UESP, jmpbuf->__jmpbuf[JB_SP]);
+       UPT_SET(uml_regs, EBP, jmpbuf->__jmpbuf[JB_BP]);
+}
index 44438d15c3d699c5492d903a2e87df3765efe550..4b638dfb52b07b73cbf7cb450513417510c5bb8e 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <setjmp.h>
 #include "ptrace_user.h"
 #include "uml-config.h"
 #include "skas_ptregs.h"
@@ -74,13 +75,11 @@ void get_safe_registers(unsigned long *regs)
        memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
 }
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
+{
+       struct __jmp_buf_tag *jmpbuf = buffer;
+
+       UPT_SET(uml_regs, RIP, jmpbuf->__jmpbuf[JB_PC]);
+       UPT_SET(uml_regs, RSP, jmpbuf->__jmpbuf[JB_RSP]);
+       UPT_SET(uml_regs, RBP, jmpbuf->__jmpbuf[JB_RBP]);
+}
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile
deleted file mode 100644 (file)
index 9778aed..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-hostprogs-y            := mk_user_constants
-always                 := $(hostprogs-y)
-
-HOSTCFLAGS_mk_user_constants.o := -I$(objtree)/arch/um
diff --git a/arch/um/os-Linux/util/mk_user_constants.c b/arch/um/os-Linux/util/mk_user_constants.c
deleted file mode 100644 (file)
index 4838f30..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <stdio.h>
-#include <user-offsets.h>
-
-int main(int argc, char **argv)
-{
-  printf("/*\n");
-  printf(" * Generated by mk_user_constants\n");
-  printf(" */\n");
-  printf("\n");
-  printf("#ifndef __UM_USER_CONSTANTS_H\n");
-  printf("#define __UM_USER_CONSTANTS_H\n");
-  printf("\n");
-  /* I'd like to use FRAME_SIZE from ptrace.h here, but that's wrong on
-   * x86_64 (216 vs 168 bytes).  user_regs_struct is the correct size on
-   * both x86_64 and i386.
-   */
-  printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE);
-
-  printf("\n");
-  printf("#endif\n");
-
-  return(0);
-}
index 4ca2a229da4997adebe0bc5f0425727bdda0e790..6dfeb70f6957727bf8a5a5c17fb8852599375ae2 100644 (file)
@@ -18,6 +18,4 @@ module.c-dir = kernel
 
 $(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS))
 
-subdir- := util
-
 include arch/um/scripts/Makefile.unmap
index a1070af2bcd823a1d2c580afbfb1c156b14242f5..35db850575066e5a34125f674d0257e98a24f8ee 100644 (file)
@@ -18,9 +18,9 @@
 
 void foo(void)
 {
-       OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
+       OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
 #ifdef CONFIG_MODE_TT
-       OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
+       OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
 #endif
 #include <common-offsets.h>
 }
index e3706d15c4f51bfefe364ee37c45c5fe99375c12..d5244f07053990392d695705013bc86993cad76c 100644 (file)
@@ -88,9 +88,7 @@ void show_trace(struct task_struct* task, unsigned long * stack)
                task = current;
 
        if (task != current) {
-               //ebp = (unsigned long) KSTK_EBP(task);
-               /* Which one? No actual difference - just coding style.*/
-               ebp = (unsigned long) PT_REGS_EBP(&task->thread.regs);
+               ebp = (unsigned long) KSTK_EBP(task);
        } else {
                asm ("movl %%ebp, %0" : "=r" (ebp) : );
        }
@@ -99,15 +97,6 @@ void show_trace(struct task_struct* task, unsigned long * stack)
                ((unsigned long)stack & (~(THREAD_SIZE - 1)));
        print_context_stack(context, stack, ebp);
 
-       /*while (((long) stack & (THREAD_SIZE-1)) != 0) {
-               addr = *stack;
-               if (__kernel_text_address(addr)) {
-                       printk("%08lx:  [<%08lx>]", (unsigned long) stack, addr);
-                       print_symbol(" %s", addr);
-                       printk("\n");
-               }
-               stack++;
-       }*/
        printk("\n");
 }
 
index 3ceaabceb3d71f301afea622ba4f796532727e70..26b68675053d49c9d20c9ad1cc5a8a2b769f1ccd 100644 (file)
@@ -7,47 +7,48 @@
 #define DEFINE(sym, val) \
         asm volatile("\n->" #sym " %0 " #val : : "i" (val))
 
+#define DEFINE_LONGS(sym, val) \
+        asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
+
 #define OFFSET(sym, str, mem) \
        DEFINE(sym, offsetof(struct str, mem));
 
 void foo(void)
 {
-       OFFSET(SC_IP, sigcontext, eip);
-       OFFSET(SC_SP, sigcontext, esp);
-       OFFSET(SC_FS, sigcontext, fs);
-       OFFSET(SC_GS, sigcontext, gs);
-       OFFSET(SC_DS, sigcontext, ds);
-       OFFSET(SC_ES, sigcontext, es);
-       OFFSET(SC_SS, sigcontext, ss);
-       OFFSET(SC_CS, sigcontext, cs);
-       OFFSET(SC_EFLAGS, sigcontext, eflags);
-       OFFSET(SC_EAX, sigcontext, eax);
-       OFFSET(SC_EBX, sigcontext, ebx);
-       OFFSET(SC_ECX, sigcontext, ecx);
-       OFFSET(SC_EDX, sigcontext, edx);
-       OFFSET(SC_EDI, sigcontext, edi);
-       OFFSET(SC_ESI, sigcontext, esi);
-       OFFSET(SC_EBP, sigcontext, ebp);
-       OFFSET(SC_TRAPNO, sigcontext, trapno);
-       OFFSET(SC_ERR, sigcontext, err);
-       OFFSET(SC_CR2, sigcontext, cr2);
-       OFFSET(SC_FPSTATE, sigcontext, fpstate);
-       OFFSET(SC_SIGMASK, sigcontext, oldmask);
-       OFFSET(SC_FP_CW, _fpstate, cw);
-       OFFSET(SC_FP_SW, _fpstate, sw);
-       OFFSET(SC_FP_TAG, _fpstate, tag);
-       OFFSET(SC_FP_IPOFF, _fpstate, ipoff);
-       OFFSET(SC_FP_CSSEL, _fpstate, cssel);
-       OFFSET(SC_FP_DATAOFF, _fpstate, dataoff);
-       OFFSET(SC_FP_DATASEL, _fpstate, datasel);
-       OFFSET(SC_FP_ST, _fpstate, _st);
-       OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env);
+       OFFSET(HOST_SC_IP, sigcontext, eip);
+       OFFSET(HOST_SC_SP, sigcontext, esp);
+       OFFSET(HOST_SC_FS, sigcontext, fs);
+       OFFSET(HOST_SC_GS, sigcontext, gs);
+       OFFSET(HOST_SC_DS, sigcontext, ds);
+       OFFSET(HOST_SC_ES, sigcontext, es);
+       OFFSET(HOST_SC_SS, sigcontext, ss);
+       OFFSET(HOST_SC_CS, sigcontext, cs);
+       OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
+       OFFSET(HOST_SC_EAX, sigcontext, eax);
+       OFFSET(HOST_SC_EBX, sigcontext, ebx);
+       OFFSET(HOST_SC_ECX, sigcontext, ecx);
+       OFFSET(HOST_SC_EDX, sigcontext, edx);
+       OFFSET(HOST_SC_EDI, sigcontext, edi);
+       OFFSET(HOST_SC_ESI, sigcontext, esi);
+       OFFSET(HOST_SC_EBP, sigcontext, ebp);
+       OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
+       OFFSET(HOST_SC_ERR, sigcontext, err);
+       OFFSET(HOST_SC_CR2, sigcontext, cr2);
+       OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate);
+       OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
+       OFFSET(HOST_SC_FP_CW, _fpstate, cw);
+       OFFSET(HOST_SC_FP_SW, _fpstate, sw);
+       OFFSET(HOST_SC_FP_TAG, _fpstate, tag);
+       OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff);
+       OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel);
+       OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff);
+       OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel);
+       OFFSET(HOST_SC_FP_ST, _fpstate, _st);
+       OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
 
        DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
-       DEFINE(HOST_FP_SIZE,
-               sizeof(struct user_i387_struct) / sizeof(unsigned long));
-       DEFINE(HOST_XFP_SIZE,
-              sizeof(struct user_fxsr_struct) / sizeof(unsigned long));
+       DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct));
+       DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct));
 
        DEFINE(HOST_IP, EIP);
        DEFINE(HOST_SP, UESP);
@@ -65,5 +66,5 @@ void foo(void)
        DEFINE(HOST_FS, FS);
        DEFINE(HOST_ES, ES);
        DEFINE(HOST_GS, GS);
-       DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct));
+       DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
 }
diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile
deleted file mode 100644 (file)
index bf61afd..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-hostprogs-y    := mk_sc mk_thread
-always         := $(hostprogs-y)
-
-HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um
-HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um
diff --git a/arch/um/sys-i386/util/mk_sc.c b/arch/um/sys-i386/util/mk_sc.c
deleted file mode 100644 (file)
index 04c0d73..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdio.h>
-#include <user-offsets.h>
-
-#define SC_OFFSET(name, field) \
-  printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
-        name)
-
-#define SC_FP_OFFSET(name, field) \
-  printf("#define " #name \
-        "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
-        name)
-
-#define SC_FP_OFFSET_PTR(name, field, type) \
-  printf("#define " #name \
-        "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
-        name)
-
-int main(int argc, char **argv)
-{
-  SC_OFFSET(SC_IP, eip);
-  SC_OFFSET(SC_SP, esp);
-  SC_OFFSET(SC_FS, fs);
-  SC_OFFSET(SC_GS, gs);
-  SC_OFFSET(SC_DS, ds);
-  SC_OFFSET(SC_ES, es);
-  SC_OFFSET(SC_SS, ss);
-  SC_OFFSET(SC_CS, cs);
-  SC_OFFSET(SC_EFLAGS, eflags);
-  SC_OFFSET(SC_EAX, eax);
-  SC_OFFSET(SC_EBX, ebx);
-  SC_OFFSET(SC_ECX, ecx);
-  SC_OFFSET(SC_EDX, edx);
-  SC_OFFSET(SC_EDI, edi);
-  SC_OFFSET(SC_ESI, esi);
-  SC_OFFSET(SC_EBP, ebp);
-  SC_OFFSET(SC_TRAPNO, trapno);
-  SC_OFFSET(SC_ERR, err);
-  SC_OFFSET(SC_CR2, cr2);
-  SC_OFFSET(SC_FPSTATE, fpstate);
-  SC_OFFSET(SC_SIGMASK, oldmask);
-  SC_FP_OFFSET(SC_FP_CW, cw);
-  SC_FP_OFFSET(SC_FP_SW, sw);
-  SC_FP_OFFSET(SC_FP_TAG, tag);
-  SC_FP_OFFSET(SC_FP_IPOFF, ipoff);
-  SC_FP_OFFSET(SC_FP_CSSEL, cssel);
-  SC_FP_OFFSET(SC_FP_DATAOFF, dataoff);
-  SC_FP_OFFSET(SC_FP_DATASEL, datasel);
-  SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate");
-  SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void");
-  return(0);
-}
diff --git a/arch/um/sys-i386/util/mk_thread.c b/arch/um/sys-i386/util/mk_thread.c
deleted file mode 100644 (file)
index 7470d0d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <stdio.h>
-#include <kernel-offsets.h>
-
-int main(int argc, char **argv)
-{
-  printf("/*\n");
-  printf(" * Generated by mk_thread\n");
-  printf(" */\n");
-  printf("\n");
-  printf("#ifndef __UM_THREAD_H\n");
-  printf("#define __UM_THREAD_H\n");
-  printf("\n");
-  printf("#define TASK_DEBUGREGS(task) ((unsigned long *) "
-        "&(((char *) (task))[%d]))\n", TASK_DEBUGREGS);
-#ifdef TASK_EXTERN_PID
-  printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n",
-        TASK_EXTERN_PID);
-#endif
-  printf("\n");
-  printf("#endif\n");
-  return(0);
-}
index f0ab574d1e95b6bc64a583e3ac1e6ac42ede4f03..06c3633457a2b28a9a6ad8b69dc523bb60d3ced9 100644 (file)
@@ -29,6 +29,4 @@ module.c-dir = kernel
 
 $(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS))
 
-subdir- := util
-
 include arch/um/scripts/Makefile.unmap
index 998541eade41e0cd80f16cfc0a9de8835dd8467e..bfcb104b846ee8731d3a73f1df5e09a56fcb4fb5 100644 (file)
@@ -19,7 +19,7 @@
 void foo(void)
 {
 #ifdef CONFIG_MODE_TT
-       OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
+       OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
 #endif
 #include <common-offsets.h>
 }
index 513d17ceafd4de4cad8a5f722837347eb038af53..5a585bfbb8c2148101f1195be7b70cdf6f054e5b 100644 (file)
@@ -16,71 +16,76 @@ typedef __u32 u32;
 #define DEFINE(sym, val) \
         asm volatile("\n->" #sym " %0 " #val : : "i" (val))
 
+#define DEFINE_LONGS(sym, val) \
+        asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
+
 #define OFFSET(sym, str, mem) \
        DEFINE(sym, offsetof(struct str, mem));
 
 void foo(void)
 {
-       OFFSET(SC_RBX, sigcontext, rbx);
-       OFFSET(SC_RCX, sigcontext, rcx);
-       OFFSET(SC_RDX, sigcontext, rdx);
-       OFFSET(SC_RSI, sigcontext, rsi);
-       OFFSET(SC_RDI, sigcontext, rdi);
-       OFFSET(SC_RBP, sigcontext, rbp);
-       OFFSET(SC_RAX, sigcontext, rax);
-       OFFSET(SC_R8, sigcontext, r8);
-       OFFSET(SC_R9, sigcontext, r9);
-       OFFSET(SC_R10, sigcontext, r10);
-       OFFSET(SC_R11, sigcontext, r11);
-       OFFSET(SC_R12, sigcontext, r12);
-       OFFSET(SC_R13, sigcontext, r13);
-       OFFSET(SC_R14, sigcontext, r14);
-       OFFSET(SC_R15, sigcontext, r15);
-       OFFSET(SC_IP, sigcontext, rip);
-       OFFSET(SC_SP, sigcontext, rsp);
-       OFFSET(SC_CR2, sigcontext, cr2);
-       OFFSET(SC_ERR, sigcontext, err);
-       OFFSET(SC_TRAPNO, sigcontext, trapno);
-       OFFSET(SC_CS, sigcontext, cs);
-       OFFSET(SC_FS, sigcontext, fs);
-       OFFSET(SC_GS, sigcontext, gs);
-       OFFSET(SC_EFLAGS, sigcontext, eflags);
-       OFFSET(SC_SIGMASK, sigcontext, oldmask);
+       OFFSET(HOST_SC_RBX, sigcontext, rbx);
+       OFFSET(HOST_SC_RCX, sigcontext, rcx);
+       OFFSET(HOST_SC_RDX, sigcontext, rdx);
+       OFFSET(HOST_SC_RSI, sigcontext, rsi);
+       OFFSET(HOST_SC_RDI, sigcontext, rdi);
+       OFFSET(HOST_SC_RBP, sigcontext, rbp);
+       OFFSET(HOST_SC_RAX, sigcontext, rax);
+       OFFSET(HOST_SC_R8, sigcontext, r8);
+       OFFSET(HOST_SC_R9, sigcontext, r9);
+       OFFSET(HOST_SC_R10, sigcontext, r10);
+       OFFSET(HOST_SC_R11, sigcontext, r11);
+       OFFSET(HOST_SC_R12, sigcontext, r12);
+       OFFSET(HOST_SC_R13, sigcontext, r13);
+       OFFSET(HOST_SC_R14, sigcontext, r14);
+       OFFSET(HOST_SC_R15, sigcontext, r15);
+       OFFSET(HOST_SC_IP, sigcontext, rip);
+       OFFSET(HOST_SC_SP, sigcontext, rsp);
+       OFFSET(HOST_SC_CR2, sigcontext, cr2);
+       OFFSET(HOST_SC_ERR, sigcontext, err);
+       OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
+       OFFSET(HOST_SC_CS, sigcontext, cs);
+       OFFSET(HOST_SC_FS, sigcontext, fs);
+       OFFSET(HOST_SC_GS, sigcontext, gs);
+       OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
+       OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
 #if 0
-       OFFSET(SC_ORIG_RAX, sigcontext, orig_rax);
-       OFFSET(SC_DS, sigcontext, ds);
-       OFFSET(SC_ES, sigcontext, es);
-       OFFSET(SC_SS, sigcontext, ss);
+       OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax);
+       OFFSET(HOST_SC_DS, sigcontext, ds);
+       OFFSET(HOST_SC_ES, sigcontext, es);
+       OFFSET(HOST_SC_SS, sigcontext, ss);
 #endif
 
-       DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
-       DEFINE(HOST_RBX, RBX);
-       DEFINE(HOST_RCX, RCX);
-       DEFINE(HOST_RDI, RDI);
-       DEFINE(HOST_RSI, RSI);
-       DEFINE(HOST_RDX, RDX);
-       DEFINE(HOST_RBP, RBP);
-       DEFINE(HOST_RAX, RAX);
-       DEFINE(HOST_R8, R8);
-       DEFINE(HOST_R9, R9);
-       DEFINE(HOST_R10, R10);
-       DEFINE(HOST_R11, R11);
-       DEFINE(HOST_R12, R12);
-       DEFINE(HOST_R13, R13);
-       DEFINE(HOST_R14, R14);
-       DEFINE(HOST_R15, R15);
-       DEFINE(HOST_ORIG_RAX, ORIG_RAX);
-       DEFINE(HOST_CS, CS);
-       DEFINE(HOST_SS, SS);
-       DEFINE(HOST_EFLAGS, EFLAGS);
+       DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE);
+       DEFINE(HOST_FP_SIZE, 0);
+       DEFINE(HOST_XFP_SIZE, 0);
+       DEFINE_LONGS(HOST_RBX, RBX);
+       DEFINE_LONGS(HOST_RCX, RCX);
+       DEFINE_LONGS(HOST_RDI, RDI);
+       DEFINE_LONGS(HOST_RSI, RSI);
+       DEFINE_LONGS(HOST_RDX, RDX);
+       DEFINE_LONGS(HOST_RBP, RBP);
+       DEFINE_LONGS(HOST_RAX, RAX);
+       DEFINE_LONGS(HOST_R8, R8);
+       DEFINE_LONGS(HOST_R9, R9);
+       DEFINE_LONGS(HOST_R10, R10);
+       DEFINE_LONGS(HOST_R11, R11);
+       DEFINE_LONGS(HOST_R12, R12);
+       DEFINE_LONGS(HOST_R13, R13);
+       DEFINE_LONGS(HOST_R14, R14);
+       DEFINE_LONGS(HOST_R15, R15);
+       DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
+       DEFINE_LONGS(HOST_CS, CS);
+       DEFINE_LONGS(HOST_SS, SS);
+       DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
 #if 0
-       DEFINE(HOST_FS, FS);
-       DEFINE(HOST_GS, GS);
-       DEFINE(HOST_DS, DS);
-       DEFINE(HOST_ES, ES);
+       DEFINE_LONGS(HOST_FS, FS);
+       DEFINE_LONGS(HOST_GS, GS);
+       DEFINE_LONGS(HOST_DS, DS);
+       DEFINE_LONGS(HOST_ES, ES);
 #endif
 
-       DEFINE(HOST_IP, RIP);
-       DEFINE(HOST_SP, RSP);
-       DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct));
+       DEFINE_LONGS(HOST_IP, RIP);
+       DEFINE_LONGS(HOST_SP, RSP);
+       DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
 }
diff --git a/arch/um/sys-x86_64/util/Makefile b/arch/um/sys-x86_64/util/Makefile
deleted file mode 100644 (file)
index 75b052c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2003 - 2004 Pathscale, Inc
-# Released under the GPL
-
-hostprogs-y    := mk_sc mk_thread
-always         := $(hostprogs-y)
-
-HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um
-HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um
diff --git a/arch/um/sys-x86_64/util/mk_sc.c b/arch/um/sys-x86_64/util/mk_sc.c
deleted file mode 100644 (file)
index 7619bc3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 2003 - 2004 PathScale, Inc
- * Released under the GPL
- */
-
-#include <stdio.h>
-#include <user-offsets.h>
-
-#define SC_OFFSET(name) \
-  printf("#define " #name \
-        "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
-        name)
-
-int main(int argc, char **argv)
-{
-  SC_OFFSET(SC_RBX);
-  SC_OFFSET(SC_RCX);
-  SC_OFFSET(SC_RDX);
-  SC_OFFSET(SC_RSI);
-  SC_OFFSET(SC_RDI);
-  SC_OFFSET(SC_RBP);
-  SC_OFFSET(SC_RAX);
-  SC_OFFSET(SC_R8);
-  SC_OFFSET(SC_R9);
-  SC_OFFSET(SC_R10);
-  SC_OFFSET(SC_R11);
-  SC_OFFSET(SC_R12);
-  SC_OFFSET(SC_R13);
-  SC_OFFSET(SC_R14);
-  SC_OFFSET(SC_R15);
-  SC_OFFSET(SC_IP);
-  SC_OFFSET(SC_SP);
-  SC_OFFSET(SC_CR2);
-  SC_OFFSET(SC_ERR);
-  SC_OFFSET(SC_TRAPNO);
-  SC_OFFSET(SC_CS);
-  SC_OFFSET(SC_FS);
-  SC_OFFSET(SC_GS);
-  SC_OFFSET(SC_EFLAGS);
-  SC_OFFSET(SC_SIGMASK);
-#if 0
-  SC_OFFSET(SC_ORIG_RAX);
-  SC_OFFSET(SC_DS);
-  SC_OFFSET(SC_ES);
-  SC_OFFSET(SC_SS);
-#endif
-  return(0);
-}
diff --git a/arch/um/sys-x86_64/util/mk_thread.c b/arch/um/sys-x86_64/util/mk_thread.c
deleted file mode 100644 (file)
index 1551739..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>
-#include <kernel-offsets.h>
-
-int main(int argc, char **argv)
-{
-  printf("/*\n");
-  printf(" * Generated by mk_thread\n");
-  printf(" */\n");
-  printf("\n");
-  printf("#ifndef __UM_THREAD_H\n");
-  printf("#define __UM_THREAD_H\n");
-  printf("\n");
-#ifdef TASK_EXTERN_PID
-  printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n",
-        TASK_EXTERN_PID);
-#endif
-  printf("\n");
-  printf("#endif\n");
-  return(0);
-}
diff --git a/arch/um/util/Makefile b/arch/um/util/Makefile
deleted file mode 100644 (file)
index 4c7551c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-hostprogs-y            := mk_task mk_constants
-always                 := $(hostprogs-y)
-
-HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um
-HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um
diff --git a/arch/um/util/mk_constants.c b/arch/um/util/mk_constants.c
deleted file mode 100644 (file)
index ab217be..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-#include <kernel-offsets.h>
-
-#define SHOW_INT(sym) printf("#define %s %d\n", #sym, sym)
-#define SHOW_STR(sym) printf("#define %s %s\n", #sym, sym)
-
-int main(int argc, char **argv)
-{
-  printf("/*\n");
-  printf(" * Generated by mk_constants\n");
-  printf(" */\n");
-  printf("\n");
-  printf("#ifndef __UM_CONSTANTS_H\n");
-  printf("#define __UM_CONSTANTS_H\n");
-  printf("\n");
-
-  SHOW_INT(UM_KERN_PAGE_SIZE);
-
-  SHOW_STR(UM_KERN_EMERG);
-  SHOW_STR(UM_KERN_ALERT);
-  SHOW_STR(UM_KERN_CRIT);
-  SHOW_STR(UM_KERN_ERR);
-  SHOW_STR(UM_KERN_WARNING);
-  SHOW_STR(UM_KERN_NOTICE);
-  SHOW_STR(UM_KERN_INFO);
-  SHOW_STR(UM_KERN_DEBUG);
-
-  SHOW_INT(UM_NSEC_PER_SEC);
-  printf("\n");
-  printf("#endif\n");
-  return(0);
-}
diff --git a/arch/um/util/mk_task.c b/arch/um/util/mk_task.c
deleted file mode 100644 (file)
index 36c9606..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stdio.h>
-#include <kernel-offsets.h>
-
-void print_ptr(char *name, char *type, int offset)
-{
-  printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type,
-        offset);
-}
-
-void print(char *name, char *type, int offset)
-{
-  printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
-        offset);
-}
-
-int main(int argc, char **argv)
-{
-  printf("/*\n");
-  printf(" * Generated by mk_task\n");
-  printf(" */\n");
-  printf("\n");
-  printf("#ifndef __TASK_H\n");
-  printf("#define __TASK_H\n");
-  printf("\n");
-  print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS);
-  print("TASK_PID", "int", TASK_PID);
-  printf("\n");
-  printf("#endif\n");
-  return(0);
-}
index 4592bf21fcafa32e34d580a113255e6f61d1b754..b92e5f45ed46743ab03fbd7e2dbb4c44da5057ab 100644 (file)
@@ -270,26 +270,26 @@ ENTRY(level3_kernel_pgt)
 .org 0x4000
 ENTRY(level2_ident_pgt)
        /* 40MB for bootup.     */
-       .quad   0x0000000000000183
-       .quad   0x0000000000200183
-       .quad   0x0000000000400183
-       .quad   0x0000000000600183
-       .quad   0x0000000000800183
-       .quad   0x0000000000A00183
-       .quad   0x0000000000C00183
-       .quad   0x0000000000E00183
-       .quad   0x0000000001000183
-       .quad   0x0000000001200183
-       .quad   0x0000000001400183
-       .quad   0x0000000001600183
-       .quad   0x0000000001800183
-       .quad   0x0000000001A00183
-       .quad   0x0000000001C00183
-       .quad   0x0000000001E00183
-       .quad   0x0000000002000183
-       .quad   0x0000000002200183
-       .quad   0x0000000002400183
-       .quad   0x0000000002600183
+       .quad   0x0000000000000083
+       .quad   0x0000000000200083
+       .quad   0x0000000000400083
+       .quad   0x0000000000600083
+       .quad   0x0000000000800083
+       .quad   0x0000000000A00083
+       .quad   0x0000000000C00083
+       .quad   0x0000000000E00083
+       .quad   0x0000000001000083
+       .quad   0x0000000001200083
+       .quad   0x0000000001400083
+       .quad   0x0000000001600083
+       .quad   0x0000000001800083
+       .quad   0x0000000001A00083
+       .quad   0x0000000001C00083
+       .quad   0x0000000001E00083
+       .quad   0x0000000002000083
+       .quad   0x0000000002200083
+       .quad   0x0000000002400083
+       .quad   0x0000000002600083
        /* Temporary mappings for the super early allocator in arch/x86_64/mm/init.c */
        .globl temp_boot_pmds
 temp_boot_pmds:
index df08c43276a07fffee23a7dd7edf28feb92b2de7..76a28b007be95fcb17344fe48c7a1b93935a6bc0 100644 (file)
@@ -77,9 +77,9 @@ static inline int is_IF_modifier(kprobe_opcode_t *insn)
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
        /* insn: must be on special executable page on x86_64. */
-       up(&kprobe_mutex);
-       p->ainsn.insn = get_insn_slot();
        down(&kprobe_mutex);
+       p->ainsn.insn = get_insn_slot();
+       up(&kprobe_mutex);
        if (!p->ainsn.insn) {
                return -ENOMEM;
        }
@@ -231,9 +231,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
 
 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
-       up(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn);
        down(&kprobe_mutex);
+       free_insn_slot(p->ainsn.insn);
+       up(&kprobe_mutex);
 }
 
 static inline void save_previous_kprobe(void)
index 08203b07f4bd6d6c5aa26ddc9cedda58a29fda7f..69541db5ff2c46ae58d199ab3ed695fbf7165572 100644 (file)
@@ -54,9 +54,12 @@ void mce_log(struct mce *mce)
 {
        unsigned next, entry;
        mce->finished = 0;
-       smp_wmb();
+       wmb();
        for (;;) {
                entry = rcu_dereference(mcelog.next);
+               /* The rmb forces the compiler to reload next in each
+                   iteration */
+               rmb();
                for (;;) {
                        /* When the buffer fills up discard new entries. Assume
                           that the earlier errors are the more interesting. */
@@ -69,6 +72,7 @@ void mce_log(struct mce *mce)
                                entry++;
                                continue;
                        }
+                       break;
                }
                smp_rmb();
                next = entry + 1;
@@ -76,9 +80,9 @@ void mce_log(struct mce *mce)
                        break;
        }
        memcpy(mcelog.entry + entry, mce, sizeof(struct mce));
-       smp_wmb();
+       wmb();
        mcelog.entry[entry].finished = 1;
-       smp_wmb();
+       wmb();
 
        if (!test_and_set_bit(0, &console_logged))
                notify_user = 1;
index 238f73e1a834cc9b2fcb57b175416d091e6968f6..cb28df14ff6fea87991daba07241b86835db30ee 100644 (file)
@@ -831,8 +831,6 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
 #endif
 }
 
-#define HWCR 0xc0010015
-
 static int __init init_amd(struct cpuinfo_x86 *c)
 {
        int r;
@@ -841,14 +839,18 @@ static int __init init_amd(struct cpuinfo_x86 *c)
 #ifdef CONFIG_SMP
        unsigned long value;
 
-       // Disable TLB flush filter by setting HWCR.FFDIS:
-       // bit 6 of msr C001_0015
-       //
-       // Errata 63 for SH-B3 steppings
-       // Errata 122 for all(?) steppings
-       rdmsrl(HWCR, value);
-       value |= 1 << 6;
-       wrmsrl(HWCR, value);
+       /*
+        * Disable TLB flush filter by setting HWCR.FFDIS on K8
+        * bit 6 of msr C001_0015
+        *
+        * Errata 63 for SH-B3 steppings
+        * Errata 122 for all steppings (F+ have it disabled by default)
+        */
+       if (c->x86 == 15) {
+               rdmsrl(MSR_K8_HWCR, value);
+               value |= 1 << 6;
+               wrmsrl(MSR_K8_HWCR, value);
+       }
 #endif
 
        /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
@@ -965,13 +967,12 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
 static void srat_detect_node(void)
 {
 #ifdef CONFIG_NUMA
-       unsigned apicid, node;
+       unsigned node;
        int cpu = smp_processor_id();
 
        /* Don't do the funky fallback heuristics the AMD version employs
           for now. */
-       apicid = phys_proc_id[cpu];
-       node = apicid_to_node[apicid];
+       node = apicid_to_node[hard_smp_processor_id()];
        if (node == NUMA_NO_NODE)
                node = 0;
        cpu_to_node[cpu] = node;
index 80a49d9bd8a77941a89794b32eba75e0cc2490aa..2148038210017df1dbdbf4b286079cb4d3ce6a12 100644 (file)
@@ -167,18 +167,16 @@ void __init numa_init_array(void)
           mapping. To avoid this fill in the mapping for all possible
           CPUs, as the number of CPUs is not known yet. 
           We round robin the existing nodes. */
-       rr = 0;
+       rr = first_node(node_online_map);
        for (i = 0; i < NR_CPUS; i++) {
                if (cpu_to_node[i] != NUMA_NO_NODE)
                        continue;
+               cpu_to_node[i] = rr;
                rr = next_node(rr, node_online_map);
                if (rr == MAX_NUMNODES)
                        rr = first_node(node_online_map);
-               cpu_to_node[i] = rr;
-               rr++; 
        }
 
-       set_bit(0, &node_to_cpumask[cpu_to_node(0)]);
 }
 
 #ifdef CONFIG_NUMA_EMU
@@ -266,9 +264,7 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
 
 __cpuinit void numa_add_cpu(int cpu)
 {
-       /* BP is initialized elsewhere */
-       if (cpu) 
-               set_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
+       set_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
 } 
 
 unsigned long __init numa_free_all_bootmem(void) 
index 2bf723a7b6e62c12918b865cac2cf6c970d81736..6f1a83c9d9e0c63b71c1d2e1fb98c7b114a30d13 100644 (file)
@@ -178,14 +178,12 @@ fore200e_irq_itoa(int irq)
 
 
 static void*
-fore200e_kmalloc(int size, int flags)
+fore200e_kmalloc(int size, unsigned int __nocast flags)
 {
-    void* chunk = kmalloc(size, flags);
+    void *chunk = kzalloc(size, flags);
 
-    if (chunk)
-       memset(chunk, 0x00, size);
-    else
-       printk(FORE200E "kmalloc() failed, requested size = %d, flags = 0x%x\n", size, flags);
+    if (!chunk)
+       printk(FORE200E "kmalloc() failed, requested size = %d, flags = 0x%x\n",                        size, flags);
     
     return chunk;
 }
index 6ba48f346fcf2407d400e1d7217f10b2d72e0c7a..041bb47b5c39fb4f0c71e6562a2be159b4394bb5 100644 (file)
@@ -376,7 +376,7 @@ static int __init drm_core_init(void)
                goto err_p2;
        }
 
-       drm_proc_root = create_proc_entry("dri", S_IFDIR, NULL);
+       drm_proc_root = proc_mkdir("dri", NULL);
        if (!drm_proc_root) {
                DRM_ERROR("Cannot create /proc/dri\n");
                ret = -1;
index 32d2bb99462c67d7b9ef4416abd3147445afc36e..977961002488171d10897735c993d010040b5364 100644 (file)
@@ -95,7 +95,7 @@ int drm_proc_init(drm_device_t *dev, int minor,
        char                  name[64];
 
        sprintf(name, "%d", minor);
-       *dev_root = create_proc_entry(name, S_IFDIR, root);
+       *dev_root = proc_mkdir(name, root);
        if (!*dev_root) {
                DRM_ERROR("Cannot create /proc/dri/%s\n", name);
                return -1;
index 95a976c96eb8303c9df9cc249c8c3d9e99cc999c..70458cb061c614e9f830cbd2d958d390a43c791a 100644 (file)
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(cards_limit, "Maximum number of graphics cards");
 MODULE_PARM_DESC(debug, "Enable debug output");
 
 module_param_named(cards_limit, drm_cards_limit, int, 0444);
-module_param_named(debug, drm_debug, int, 0666);
+module_param_named(debug, drm_debug, int, 0600);
 
 drm_head_t **drm_heads;
 struct drm_sysfs_class *drm_class;
index 2291a87e8ada6ce17070bfc38ceb41f512290568..97d6dc24b8003fabc28213e7c5090b966d481cd2 100644 (file)
@@ -229,8 +229,8 @@ static int __init r3964_init(void)
        TRACE_L("line discipline %d registered", N_R3964);
        TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, 
                tty_ldisc_N_R3964.num);
-       TRACE_L("open=%x", (int)tty_ldisc_N_R3964.open);
-       TRACE_L("tty_ldisc_N_R3964 = %x", (int)&tty_ldisc_N_R3964);
+       TRACE_L("open=%p", tty_ldisc_N_R3964.open);
+       TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
      }
    else
      {
@@ -267,8 +267,8 @@ static void add_tx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH
    
    spin_unlock_irqrestore(&pInfo->lock, flags);
 
-   TRACE_Q("add_tx_queue %x, length %d, tx_first = %x", 
-          (int)pHeader, pHeader->length, (int)pInfo->tx_first );
+   TRACE_Q("add_tx_queue %p, length %d, tx_first = %p", 
+          pHeader, pHeader->length, pInfo->tx_first );
 }
 
 static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
@@ -285,10 +285,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
       return;
 
 #ifdef DEBUG_QUEUE
-   printk("r3964: remove_from_tx_queue: %x, length %d - ",
-          (int)pHeader, (int)pHeader->length );
+   printk("r3964: remove_from_tx_queue: %p, length %u - ",
+          pHeader, pHeader->length );
    for(pDump=pHeader;pDump;pDump=pDump->next)
-        printk("%x ", (int)pDump);
+        printk("%p ", pDump);
    printk("\n");
 #endif
 
@@ -319,10 +319,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
    spin_unlock_irqrestore(&pInfo->lock, flags);
 
    kfree(pHeader);
-   TRACE_M("remove_from_tx_queue - kfree %x",(int)pHeader);
+   TRACE_M("remove_from_tx_queue - kfree %p",pHeader);
 
-   TRACE_Q("remove_from_tx_queue: tx_first = %x, tx_last = %x",
-          (int)pInfo->tx_first, (int)pInfo->tx_last );
+   TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
+          pInfo->tx_first, pInfo->tx_last );
 }
 
 static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader)
@@ -346,9 +346,9 @@ static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH
    
    spin_unlock_irqrestore(&pInfo->lock, flags);
 
-   TRACE_Q("add_rx_queue: %x, length = %d, rx_first = %x, count = %d",
-          (int)pHeader, pHeader->length,
-          (int)pInfo->rx_first, pInfo->blocks_in_rx_queue);
+   TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
+          pHeader, pHeader->length,
+          pInfo->rx_first, pInfo->blocks_in_rx_queue);
 }
 
 static void remove_from_rx_queue(struct r3964_info *pInfo,
@@ -360,10 +360,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo,
    if(pHeader==NULL)
       return;
 
-   TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d",
-          (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue );
-   TRACE_Q("remove_from_rx_queue: %x, length %d",
-          (int)pHeader, (int)pHeader->length );
+   TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
+          pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
+   TRACE_Q("remove_from_rx_queue: %p, length %u",
+          pHeader, pHeader->length );
 
    spin_lock_irqsave(&pInfo->lock, flags);
 
@@ -401,10 +401,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo,
    spin_unlock_irqrestore(&pInfo->lock, flags);
 
    kfree(pHeader);
-   TRACE_M("remove_from_rx_queue - kfree %x",(int)pHeader);
+   TRACE_M("remove_from_rx_queue - kfree %p",pHeader);
 
-   TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d",
-          (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue );
+   TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
+          pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
 }
 
 static void put_char(struct r3964_info *pInfo, unsigned char ch)
@@ -506,8 +506,8 @@ static void transmit_block(struct r3964_info *pInfo)
    if(tty->driver->write_room)
       room=tty->driver->write_room(tty);
 
-   TRACE_PS("transmit_block %x, room %d, length %d", 
-          (int)pBlock, room, pBlock->length);
+   TRACE_PS("transmit_block %p, room %d, length %d", 
+          pBlock, room, pBlock->length);
    
    while(pInfo->tx_position < pBlock->length)
    {
@@ -588,7 +588,7 @@ static void on_receive_block(struct r3964_info *pInfo)
 
    /* prepare struct r3964_block_header: */
    pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL);
-   TRACE_M("on_receive_block - kmalloc %x",(int)pBlock);
+   TRACE_M("on_receive_block - kmalloc %p",pBlock);
 
    if(pBlock==NULL)
       return;
@@ -868,11 +868,11 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
                if(pMsg)
                {
                   kfree(pMsg);
-                  TRACE_M("enable_signals - msg kfree %x",(int)pMsg);
+                  TRACE_M("enable_signals - msg kfree %p",pMsg);
                }
             }
             kfree(pClient);
-            TRACE_M("enable_signals - kfree %x",(int)pClient);
+            TRACE_M("enable_signals - kfree %p",pClient);
             return 0;
          }
       }
@@ -890,7 +890,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
       {
          /* add client to client list */
          pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL);
-         TRACE_M("enable_signals - kmalloc %x",(int)pClient);
+         TRACE_M("enable_signals - kmalloc %p",pClient);
          if(pClient==NULL)
             return -ENOMEM;
 
@@ -954,7 +954,7 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
 queue_the_message:
 
       pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL);
-      TRACE_M("add_msg - kmalloc %x",(int)pMsg);
+      TRACE_M("add_msg - kmalloc %p",pMsg);
       if(pMsg==NULL) {
          return;
       }
@@ -1067,11 +1067,11 @@ static int r3964_open(struct tty_struct *tty)
    struct r3964_info *pInfo;
    
    TRACE_L("open");
-   TRACE_L("tty=%x, PID=%d, disc_data=%x", 
-          (int)tty, current->pid, (int)tty->disc_data);
+   TRACE_L("tty=%p, PID=%d, disc_data=%p", 
+          tty, current->pid, tty->disc_data);
    
    pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); 
-   TRACE_M("r3964_open - info kmalloc %x",(int)pInfo);
+   TRACE_M("r3964_open - info kmalloc %p",pInfo);
 
    if(!pInfo)
    {
@@ -1080,26 +1080,26 @@ static int r3964_open(struct tty_struct *tty)
    }
 
    pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
-   TRACE_M("r3964_open - rx_buf kmalloc %x",(int)pInfo->rx_buf);
+   TRACE_M("r3964_open - rx_buf kmalloc %p",pInfo->rx_buf);
 
    if(!pInfo->rx_buf)
    {
       printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
       kfree(pInfo);
-      TRACE_M("r3964_open - info kfree %x",(int)pInfo);
+      TRACE_M("r3964_open - info kfree %p",pInfo);
       return -ENOMEM;
    }
    
    pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
-   TRACE_M("r3964_open - tx_buf kmalloc %x",(int)pInfo->tx_buf);
+   TRACE_M("r3964_open - tx_buf kmalloc %p",pInfo->tx_buf);
 
    if(!pInfo->tx_buf)
    {
       printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
       kfree(pInfo->rx_buf);
-      TRACE_M("r3964_open - rx_buf kfree %x",(int)pInfo->rx_buf);
+      TRACE_M("r3964_open - rx_buf kfree %p",pInfo->rx_buf);
       kfree(pInfo);
-      TRACE_M("r3964_open - info kfree %x",(int)pInfo);
+      TRACE_M("r3964_open - info kfree %p",pInfo);
       return -ENOMEM;
    }
 
@@ -1154,11 +1154,11 @@ static void r3964_close(struct tty_struct *tty)
           if(pMsg)
           {
              kfree(pMsg);
-             TRACE_M("r3964_close - msg kfree %x",(int)pMsg);
+             TRACE_M("r3964_close - msg kfree %p",pMsg);
           }
        }
        kfree(pClient);
-       TRACE_M("r3964_close - client kfree %x",(int)pClient);
+       TRACE_M("r3964_close - client kfree %p",pClient);
        pClient=pNext;
     }
     /* Remove jobs from tx_queue: */
@@ -1177,11 +1177,11 @@ static void r3964_close(struct tty_struct *tty)
     /* Free buffers: */
     wake_up_interruptible(&pInfo->read_wait);
     kfree(pInfo->rx_buf);
-    TRACE_M("r3964_close - rx_buf kfree %x",(int)pInfo->rx_buf);
+    TRACE_M("r3964_close - rx_buf kfree %p",pInfo->rx_buf);
     kfree(pInfo->tx_buf);
-    TRACE_M("r3964_close - tx_buf kfree %x",(int)pInfo->tx_buf);
+    TRACE_M("r3964_close - tx_buf kfree %p",pInfo->tx_buf);
     kfree(pInfo);
-    TRACE_M("r3964_close - info kfree %x",(int)pInfo);
+    TRACE_M("r3964_close - info kfree %p",pInfo);
 }
 
 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
@@ -1234,7 +1234,7 @@ repeat:
       count = sizeof(struct r3964_client_message);
 
       kfree(pMsg);
-      TRACE_M("r3964_read - msg kfree %x",(int)pMsg);
+      TRACE_M("r3964_read - msg kfree %p",pMsg);
 
       if (copy_to_user(buf,&theMsg, count))
        return -EFAULT;
@@ -1279,7 +1279,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
  * Allocate a buffer for the data and copy it from the buffer with header prepended
  */
    new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL);
-   TRACE_M("r3964_write - kmalloc %x",(int)new_data);
+   TRACE_M("r3964_write - kmalloc %p",new_data);
    if (new_data == NULL) {
       if (pInfo->flags & R3964_DEBUG)
       {
index 1436aea3b28f798d0d55142bda96605b8078ca79..6d3ff0836c440b90b61697e2bc2c4559f45b085b 100644 (file)
@@ -87,6 +87,8 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file)
        mv64x60_wdt_service();
        mv64x60_wdt_handler_enable();
 
+       nonseekable_open(inode, file);
+
        return 0;
 }
 
@@ -103,12 +105,9 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-static ssize_t mv64x60_wdt_write(struct file *file, const char *data,
+static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data,
                                 size_t len, loff_t * ppos)
 {
-       if (*ppos != file->f_pos)
-               return -ESPIPE;
-
        if (len)
                mv64x60_wdt_service();
 
@@ -119,6 +118,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
                             unsigned int cmd, unsigned long arg)
 {
        int timeout;
+       void __user *argp = (void __user *)arg;
        static struct watchdog_info info = {
                .options = WDIOF_KEEPALIVEPING,
                .firmware_version = 0,
@@ -127,13 +127,13 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
 
        switch (cmd) {
        case WDIOC_GETSUPPORT:
-               if (copy_to_user((void *)arg, &info, sizeof(info)))
+               if (copy_to_user(argp, &info, sizeof(info)))
                        return -EFAULT;
                break;
 
        case WDIOC_GETSTATUS:
        case WDIOC_GETBOOTSTATUS:
-               if (put_user(wdt_status, (int *)arg))
+               if (put_user(wdt_status, (int __user *)argp))
                        return -EFAULT;
                wdt_status &= ~WDIOF_KEEPALIVEPING;
                break;
@@ -154,7 +154,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
 
        case WDIOC_GETTIMEOUT:
                timeout = mv64x60_wdt_timeout * HZ;
-               if (put_user(timeout, (int *)arg))
+               if (put_user(timeout, (int __user *)argp))
                        return -EFAULT;
                break;
 
index bb0b3a8de14bde88adf870f4bea29e5c6e90f6bd..1422285d537c59e20df6d1fe8273c3b1e5afc960 100644 (file)
@@ -69,7 +69,8 @@ int cn_already_initialized = 0;
  * a new message.
  *
  */
-int cn_netlink_send(struct cn_msg *msg, u32 __group, int gfp_mask)
+int cn_netlink_send(struct cn_msg *msg, u32 __group,
+                   unsigned int __nocast gfp_mask)
 {
        struct cn_callback_entry *__cbq;
        unsigned int size;
index 84ae027b021a19920dede6881f2260ddefb48978..e8e28569a6684feb2c0ae4e5d41447479c5480bc 100644 (file)
@@ -1297,4 +1297,3 @@ static void __exit amdtp_exit_module (void)
 
 module_init(amdtp_init_module);
 module_exit(amdtp_exit_module);
-MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16);
index e6734263a1d3c6c16375d52fba8c7455a48ac392..28c5f4b726e2e375867ac256c746bd7c0cb40773 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
-#include <linux/sched.h>
 #include <linux/vmalloc.h>
 #include <asm/pgalloc.h>
 
index 4538b0235ca34ebd3aca87428443153b080b4255..e34730c7a8748ab77e06242a1d9efe8bb177bae2 100644 (file)
@@ -2660,4 +2660,3 @@ static int __init dv1394_init_module(void)
 
 module_init(dv1394_init_module);
 module_exit(dv1394_exit_module);
-MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16);
index cd53c174ced171119eabe814919ff570b310006b..4802bbbb6dc9817c9b4f49b08bcad65268f8f84a 100644 (file)
@@ -89,7 +89,7 @@
 #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
 
 static char version[] __devinitdata =
-       "$Rev: 1264 $ Ben Collins <bcollins@debian.org>";
+       "$Rev: 1312 $ Ben Collins <bcollins@debian.org>";
 
 struct fragment_info {
        struct list_head list;
@@ -221,9 +221,7 @@ static int ether1394_open (struct net_device *dev)
        if (priv->bc_state == ETHER1394_BC_ERROR) {
                /* we'll try again */
                priv->iso = hpsb_iso_recv_init(priv->host,
-                                              ETHER1394_GASP_BUFFERS * 2 *
-                                              (1 << (priv->host->csr.max_rec +
-                                                     1)),
+                                              ETHER1394_ISO_BUF_SIZE,
                                               ETHER1394_GASP_BUFFERS,
                                               priv->broadcast_channel,
                                               HPSB_ISO_DMA_PACKET_PER_BUFFER,
@@ -635,8 +633,8 @@ static void ether1394_add_host (struct hpsb_host *host)
         * be checked when the eth device is opened. */
        priv->broadcast_channel = host->csr.broadcast_channel & 0x3f;
 
-       priv->iso = hpsb_iso_recv_init(host, (ETHER1394_GASP_BUFFERS * 2 *
-                                             (1 << (host->csr.max_rec + 1))),
+       priv->iso = hpsb_iso_recv_init(host,
+                                      ETHER1394_ISO_BUF_SIZE,
                                       ETHER1394_GASP_BUFFERS,
                                       priv->broadcast_channel,
                                       HPSB_ISO_DMA_PACKET_PER_BUFFER,
@@ -1770,7 +1768,7 @@ fail:
 static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
        strcpy (info->driver, driver_name);
-       strcpy (info->version, "$Rev: 1264 $");
+       strcpy (info->version, "$Rev: 1312 $");
        /* FIXME XXX provide sane businfo */
        strcpy (info->bus_info, "ieee1394");
 }
index ed8f1c4b7fd80ee38ca331d0a2df32e12bea101d..a77213cfc4837b8dd302e1b502ac36073c664d9b 100644 (file)
 
 #define ETHER1394_GASP_BUFFERS 16
 
+/* rawiso buffer size - due to a limitation in rawiso, we must limit each
+ * GASP buffer to be less than PAGE_SIZE. */
+#define ETHER1394_ISO_BUF_SIZE ETHER1394_GASP_BUFFERS *                        \
+                                  min((unsigned int)PAGE_SIZE,                 \
+                                      2 * (1U << (priv->host->csr.max_rec + 1)))
+
 /* Node set == 64 */
 #define NODE_SET                       (ALL_NODES + 1)
 
index c502c6e9c440bea39cd64c2d0225ffa96b3929b2..aeeaeb670d035c769a6f47d0f39099681f689293 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/timer.h>
+#include <linux/jiffies.h>
 
 #include "csr1212.h"
 #include "ieee1394.h"
@@ -217,7 +218,7 @@ int hpsb_update_config_rom_image(struct hpsb_host *host)
 
        /* IEEE 1394a-2000 prohibits using the same generation number
         * twice in a 60 second period. */
-       if (jiffies - host->csr.gen_timestamp[next_gen] < 60 * HZ)
+       if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ))
                /* Wait 60 seconds from the last time this generation number was
                 * used. */
                reset_delay = (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies;
index 739e76840d5106716be264d4f025c9a1b351b496..38f42112dff0f8b48782e038b10db69bb1241a84 100644 (file)
@@ -135,17 +135,17 @@ enum isoctl_cmd {
 
 enum reset_types {
         /* 166 microsecond reset -- only type of reset available on
-           non-1394a capable IEEE 1394 controllers */
+           non-1394a capable controllers */
         LONG_RESET,
 
         /* Short (arbitrated) reset -- only available on 1394a capable
-           IEEE 1394 capable controllers */
+           controllers */
         SHORT_RESET,
 
-       /* Variants, that set force_root before issueing the bus reset */
+       /* Variants that set force_root before issueing the bus reset */
        LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
 
-       /* Variants, that clear force_root before issueing the bus reset */
+       /* Variants that clear force_root before issueing the bus reset */
        LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
 };
 
index d633770fac8ee3b99a3a77c84356db02be2bf7c6..32a1e016c85e76d2ec80b02dc055621c959b74c2 100644 (file)
@@ -70,7 +70,7 @@ const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S32
 struct class *hpsb_protocol_class;
 
 #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
-static void dump_packet(const char *text, quadlet_t *data, int size)
+static void dump_packet(const char *text, quadlet_t *data, int size, int speed)
 {
        int i;
 
@@ -78,12 +78,15 @@ static void dump_packet(const char *text, quadlet_t *data, int size)
        size = (size > 4 ? 4 : size);
 
        printk(KERN_DEBUG "ieee1394: %s", text);
+       if (speed > -1 && speed < 6)
+               printk(" at %s", hpsb_speedto_str[speed]);
+       printk(":");
        for (i = 0; i < size; i++)
                printk(" %08x", data[i]);
        printk("\n");
 }
 #else
-#define dump_packet(x,y,z)
+#define dump_packet(a,b,c,d)
 #endif
 
 static void abort_requests(struct hpsb_host *host);
@@ -544,8 +547,7 @@ int hpsb_send_packet(struct hpsb_packet *packet)
                 if (packet->data_size)
                        memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
 
-                dump_packet("send packet local:", packet->header,
-                            packet->header_size);
+                dump_packet("send packet local", packet->header, packet->header_size, -1);
 
                 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
                 hpsb_packet_received(host, data, size, 0);
@@ -561,21 +563,7 @@ int hpsb_send_packet(struct hpsb_packet *packet)
                                        + NODEID_TO_NODE(packet->node_id)];
         }
 
-#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
-        switch (packet->speed_code) {
-        case 2:
-                dump_packet("send packet 400:", packet->header,
-                            packet->header_size);
-                break;
-        case 1:
-                dump_packet("send packet 200:", packet->header,
-                            packet->header_size);
-                break;
-        default:
-                dump_packet("send packet 100:", packet->header,
-                            packet->header_size);
-        }
-#endif
+        dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
 
         return host->driver->transmit_packet(host, packet);
 }
@@ -636,7 +624,7 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
 
        if (packet == NULL) {
                 HPSB_DEBUG("unsolicited response packet received - no tlabel match");
-                dump_packet("contents:", data, 16);
+                dump_packet("contents", data, 16, -1);
                spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
                 return;
         }
@@ -677,7 +665,7 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
         if (!tcode_match) {
                spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
                 HPSB_INFO("unsolicited response packet received - tcode mismatch");
-                dump_packet("contents:", data, 16);
+                dump_packet("contents", data, 16, -1);
                 return;
         }
 
@@ -914,7 +902,7 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
                 return;
         }
 
-        dump_packet("received packet:", data, size);
+        dump_packet("received packet", data, size, -1);
 
         tcode = (data[0] >> 4) & 0xf;
 
index b23322523ef57b1cf147e4368239487e55ef15bc..347ece6b583c19cdf67e521dcb5ae3ebf2c1ecdd 100644 (file)
@@ -64,10 +64,10 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
        struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci;
        int i, ret = 0;
 
-       for (i = 0; i < 3; i++) {
+       for (i = 1; ; i++) {
                ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
                                buffer, length);
-               if (!ret)
+               if (!ret || i == 3)
                        break;
 
                if (msleep_interruptible(334))
@@ -1438,9 +1438,13 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
        if (host->busmgr_id == 0xffff && host->node_count > 1)
        {
                u16 root_node = host->node_count - 1;
-               struct node_entry *ne = find_entry_by_nodeid(host, root_node | LOCAL_BUS);
 
-               if (ne && ne->busopt.cmc)
+               /* get cycle master capability flag from root node */
+               if (host->is_cycmst ||
+                   (!hpsb_read(host, LOCAL_BUS | root_node, get_hpsb_generation(host),
+                               (CSR_REGISTER_BASE + CSR_CONFIG_ROM + 2 * sizeof(quadlet_t)),
+                               &bc, sizeof(quadlet_t)) &&
+                    be32_to_cpu(bc) & 1 << CSR_CMC_SHIFT))
                        hpsb_send_phy_config(host, root_node, -1);
                else {
                        HPSB_DEBUG("The root node is not cycle master capable; "
@@ -1557,24 +1561,19 @@ static int nodemgr_host_thread(void *__hi)
                        }
                }
 
-               if (!nodemgr_check_irm_capability(host, reset_cycles)) {
+               if (!nodemgr_check_irm_capability(host, reset_cycles) ||
+                   !nodemgr_do_irm_duties(host, reset_cycles)) {
                        reset_cycles++;
                        up(&nodemgr_serialize);
                        continue;
                }
+               reset_cycles = 0;
 
                /* Scan our nodes to get the bus options and create node
                 * entries. This does not do the sysfs stuff, since that
                 * would trigger hotplug callbacks and such, which is a
                 * bad idea at this point. */
                nodemgr_node_scan(hi, generation);
-               if (!nodemgr_do_irm_duties(host, reset_cycles)) {
-                       reset_cycles++;
-                       up(&nodemgr_serialize);
-                       continue;
-               }
-
-               reset_cycles = 0;
 
                /* This actually does the full probe, with sysfs
                 * registration. */
index 27018c8efc242ee0a660c5be9d8449597e551c42..6a6acbd80af4fb8c7b6ea0373b5075d39fa4d207 100644 (file)
@@ -162,7 +162,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
 printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
 
 static char version[] __devinitdata =
-       "$Rev: 1299 $ Ben Collins <bcollins@debian.org>";
+       "$Rev: 1313 $ Ben Collins <bcollins@debian.org>";
 
 /* Module Parameters */
 static int phys_dma = 1;
@@ -1084,7 +1084,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
                        initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
 
                        if (printk_ratelimit())
-                               PRINT(KERN_ERR, "IR legacy activated");
+                               DBGMSG("IR legacy activated");
                }
 
                 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
index b4fa14793fe5f1a421965c8ae550ef72f7ec926f..5fe4f2ba0979713682bf6ed48adf86bc826eecbd 100644 (file)
@@ -2958,4 +2958,3 @@ static void __exit cleanup_raw1394(void)
 module_init(init_raw1394);
 module_exit(cleanup_raw1394);
 MODULE_LICENSE("GPL");
-MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16);
index de88218ef7cce8c8eb4912aedb4bdffbd64f7561..12cec7c4a34295acc8e25607c7b383aedd973521 100644 (file)
@@ -97,16 +97,18 @@ static char version[] __devinitdata =
  */
 static int max_speed = IEEE1394_SPEED_MAX;
 module_param(max_speed, int, 0644);
-MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb default, 1 = 200mb, 0 = 100mb)");
+MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb, 1 = 200mb, 0 = 100mb)");
 
 /*
  * Set serialize_io to 1 if you'd like only one scsi command sent
  * down to us at a time (debugging). This might be necessary for very
  * badly behaved sbp2 devices.
+ *
+ * TODO: Make this configurable per device.
  */
-static int serialize_io;
+static int serialize_io = 1;
 module_param(serialize_io, int, 0444);
-MODULE_PARM_DESC(serialize_io, "Serialize all I/O coming down from the scsi drivers (default = 0)");
+MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default = 1, faster = 0)");
 
 /*
  * Bump up max_sectors if you'd like to support very large sized
@@ -596,6 +598,14 @@ static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_i
        spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
 }
 
+/*
+ * Is scsi_id valid? Is the 1394 node still present?
+ */
+static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_id)
+{
+       return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo;
+}
+
 \f
 
 /*********************************************
@@ -631,11 +641,23 @@ static int sbp2_remove(struct device *dev)
 {
        struct unit_directory *ud;
        struct scsi_id_instance_data *scsi_id;
+       struct scsi_device *sdev;
 
        SBP2_DEBUG("sbp2_remove");
 
        ud = container_of(dev, struct unit_directory, device);
        scsi_id = ud->device.driver_data;
+       if (!scsi_id)
+               return 0;
+
+       /* Trigger shutdown functions in scsi's highlevel. */
+       if (scsi_id->scsi_host)
+               scsi_unblock_requests(scsi_id->scsi_host);
+       sdev = scsi_id->sdev;
+       if (sdev) {
+               scsi_id->sdev = NULL;
+               scsi_remove_device(sdev);
+       }
 
        sbp2_logout_device(scsi_id);
        sbp2_remove_device(scsi_id);
@@ -2473,37 +2495,26 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
        struct scsi_id_instance_data *scsi_id =
                (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
        struct sbp2scsi_host_info *hi;
+       int result = DID_NO_CONNECT << 16;
 
        SBP2_DEBUG("sbp2scsi_queuecommand");
 
-       /*
-        * If scsi_id is null, it means there is no device in this slot,
-        * so we should return selection timeout.
-        */
-       if (!scsi_id) {
-               SCpnt->result = DID_NO_CONNECT << 16;
-               done (SCpnt);
-               return 0;
-       }
+       if (!sbp2util_node_is_available(scsi_id))
+               goto done;
 
        hi = scsi_id->hi;
 
        if (!hi) {
                SBP2_ERR("sbp2scsi_host_info is NULL - this is bad!");
-               SCpnt->result = DID_NO_CONNECT << 16;
-               done (SCpnt);
-               return(0);
+               goto done;
        }
 
        /*
         * Until we handle multiple luns, just return selection time-out
         * to any IO directed at non-zero LUNs
         */
-       if (SCpnt->device->lun) {
-               SCpnt->result = DID_NO_CONNECT << 16;
-               done (SCpnt);
-               return(0);
-       }
+       if (SCpnt->device->lun)
+               goto done;
 
        /*
         * Check for request sense command, and handle it here
@@ -2514,7 +2525,7 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
                memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen);
                memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
                sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_GOOD, SCpnt, done);
-               return(0);
+               return 0;
        }
 
        /*
@@ -2522,9 +2533,8 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
         */
        if (!hpsb_node_entry_valid(scsi_id->ne)) {
                SBP2_ERR("Bus reset in progress - rejecting command");
-               SCpnt->result = DID_BUS_BUSY << 16;
-               done (SCpnt);
-               return(0);
+               result = DID_BUS_BUSY << 16;
+               goto done;
        }
 
        /*
@@ -2535,8 +2545,12 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
                sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT,
                                          SCpnt, done);
        }
+       return 0;
 
-       return(0);
+done:
+       SCpnt->result = result;
+       done(SCpnt);
+       return 0;
 }
 
 /*
@@ -2683,14 +2697,27 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
 }
 
 
-static int sbp2scsi_slave_configure (struct scsi_device *sdev)
+static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
 {
-       blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
+       ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev;
+       return 0;
+}
+
 
+static int sbp2scsi_slave_configure(struct scsi_device *sdev)
+{
+       blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
        return 0;
 }
 
 
+static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
+{
+       ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL;
+       return;
+}
+
+
 /*
  * Called by scsi stack when something has really gone wrong.  Usually
  * called when a command has timed-out for some reason.
@@ -2705,7 +2732,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
        SBP2_ERR("aborting sbp2 command");
        scsi_print_command(SCpnt);
 
-       if (scsi_id) {
+       if (sbp2util_node_is_available(scsi_id)) {
 
                /*
                 * Right now, just return any matching command structures
@@ -2742,31 +2769,24 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
 /*
  * Called by scsi stack when something has really gone wrong.
  */
-static int __sbp2scsi_reset(struct scsi_cmnd *SCpnt)
+static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
 {
        struct scsi_id_instance_data *scsi_id =
                (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
+       unsigned long flags;
 
        SBP2_ERR("reset requested");
 
-       if (scsi_id) {
+       spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
+
+       if (sbp2util_node_is_available(scsi_id)) {
                SBP2_ERR("Generating sbp2 fetch agent reset");
                sbp2_agent_reset(scsi_id, 0);
        }
 
-       return(SUCCESS);
-}
-
-static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
-{
-       unsigned long flags;
-       int rc;
-
-       spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
-       rc = __sbp2scsi_reset(SCpnt);
        spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags);
 
-       return rc;
+       return SUCCESS;
 }
 
 static const char *sbp2scsi_info (struct Scsi_Host *host)
@@ -2817,7 +2837,9 @@ static struct scsi_host_template scsi_driver_template = {
        .eh_device_reset_handler =      sbp2scsi_reset,
        .eh_bus_reset_handler =         sbp2scsi_reset,
        .eh_host_reset_handler =        sbp2scsi_reset,
+       .slave_alloc =                  sbp2scsi_slave_alloc,
        .slave_configure =              sbp2scsi_slave_configure,
+       .slave_destroy =                sbp2scsi_slave_destroy,
        .this_id =                      -1,
        .sg_tablesize =                 SG_ALL,
        .use_clustering =               ENABLE_CLUSTERING,
@@ -2837,7 +2859,8 @@ static int sbp2_module_init(void)
 
        /* Module load debug option to force one command at a time (serializing I/O) */
        if (serialize_io) {
-               SBP2_ERR("Driver forced to serialize I/O (serialize_io = 1)");
+               SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)");
+               SBP2_INFO("Try serialize_io=0 for better performance");
                scsi_driver_template.can_queue = 1;
                scsi_driver_template.cmd_per_lun = 1;
        }
index 9d6facf2f78f5751f3da65890ea94cf3f5419143..11be9c9c82a8743cf65faca95c2b23738feaae51 100644 (file)
@@ -1571,4 +1571,3 @@ static int __init video1394_init_module (void)
 
 module_init(video1394_init_module);
 module_exit(video1394_exit_module);
-MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16);
index ffbcd40418d5fd82f8d246e0585fb7bd5ede17c7..23a3f56c78995ee8a21078544da3ab9b1bbda22a 100644 (file)
@@ -503,6 +503,25 @@ err_free_aux:
        return err;
 }
 
+static void mthca_free_icms(struct mthca_dev *mdev)
+{
+       u8 status;
+
+       mthca_free_icm_table(mdev, mdev->mcg_table.table);
+       if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
+               mthca_free_icm_table(mdev, mdev->srq_table.table);
+       mthca_free_icm_table(mdev, mdev->cq_table.table);
+       mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
+       mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
+       mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
+       mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
+       mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
+       mthca_unmap_eq_icm(mdev);
+
+       mthca_UNMAP_ICM_AUX(mdev, &status);
+       mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
+}
+
 static int __devinit mthca_init_arbel(struct mthca_dev *mdev)
 {
        struct mthca_dev_lim        dev_lim;
@@ -580,18 +599,7 @@ static int __devinit mthca_init_arbel(struct mthca_dev *mdev)
        return 0;
 
 err_free_icm:
-       if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
-               mthca_free_icm_table(mdev, mdev->srq_table.table);
-       mthca_free_icm_table(mdev, mdev->cq_table.table);
-       mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
-       mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
-       mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
-       mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
-       mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
-       mthca_unmap_eq_icm(mdev);
-
-       mthca_UNMAP_ICM_AUX(mdev, &status);
-       mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
+       mthca_free_icms(mdev);
 
 err_stop_fw:
        mthca_UNMAP_FA(mdev, &status);
@@ -611,18 +619,7 @@ static void mthca_close_hca(struct mthca_dev *mdev)
        mthca_CLOSE_HCA(mdev, 0, &status);
 
        if (mthca_is_memfree(mdev)) {
-               if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
-                       mthca_free_icm_table(mdev, mdev->srq_table.table);
-               mthca_free_icm_table(mdev, mdev->cq_table.table);
-               mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
-               mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
-               mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
-               mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
-               mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
-               mthca_unmap_eq_icm(mdev);
-
-               mthca_UNMAP_ICM_AUX(mdev, &status);
-               mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
+               mthca_free_icms(mdev);
 
                mthca_UNMAP_FA(mdev, &status);
                mthca_free_icm(mdev, mdev->fw.arbel.fw_icm);
index 704f48e0b6a738dc7a9c2e3ae41751dafc1c205a..6c5bf07489f4a47bb4dab5ee527ad09c9e50c87c 100644 (file)
@@ -474,7 +474,7 @@ err:
        spin_unlock(&priv->lock);
 }
 
-static void path_lookup(struct sk_buff *skb, struct net_device *dev)
+static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(skb->dev);
 
@@ -569,7 +569,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (skb->dst && skb->dst->neighbour) {
                if (unlikely(!*to_ipoib_neigh(skb->dst->neighbour))) {
-                       path_lookup(skb, dev);
+                       ipoib_path_lookup(skb, dev);
                        goto out;
                }
 
index e1f0d87de0eb1f072f4c38c2954c673ec509462c..0b0ea26023e59994e5c9b3836317d082d5fd33b0 100644 (file)
@@ -287,12 +287,12 @@ divert_dev_init(void)
        init_waitqueue_head(&rd_queue);
 
 #ifdef CONFIG_PROC_FS
-       isdn_proc_entry = create_proc_entry("isdn", S_IFDIR | S_IRUGO | S_IXUGO, proc_net);
+       isdn_proc_entry = proc_mkdir("net/isdn", NULL);
        if (!isdn_proc_entry)
                return (-1);
        isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry);
        if (!isdn_divert_entry) {
-               remove_proc_entry("isdn", proc_net);
+               remove_proc_entry("net/isdn", NULL);
                return (-1);
        }
        isdn_divert_entry->proc_fops = &isdn_fops; 
@@ -312,7 +312,7 @@ divert_dev_deinit(void)
 
 #ifdef CONFIG_PROC_FS
        remove_proc_entry("divert", isdn_proc_entry);
-       remove_proc_entry("isdn", proc_net);
+       remove_proc_entry("net/isdn", NULL);
 #endif /* CONFIG_PROC_FS */
 
        return (0);
index 7fdf8ae5be52e8e4d25f565821461f7fdb36ad9e..27204f4b111a7c724407abd3adfa07ab99efacb0 100644 (file)
@@ -30,8 +30,6 @@ static char *DRIVERNAME =
 static char *DRIVERLNAME = "divadidd";
 char *DRIVERRELEASE_DIDD = "2.0";
 
-static char *main_proc_dir = "eicon";
-
 MODULE_DESCRIPTION("DIDD table driver for diva drivers");
 MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
 MODULE_SUPPORTED_DEVICE("Eicon diva drivers");
@@ -89,7 +87,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof,
 
 static int DIVA_INIT_FUNCTION create_proc(void)
 {
-       proc_net_eicon = create_proc_entry(main_proc_dir, S_IFDIR, proc_net);
+       proc_net_eicon = proc_mkdir("net/eicon", NULL);
 
        if (proc_net_eicon) {
                if ((proc_didd =
@@ -105,7 +103,7 @@ static int DIVA_INIT_FUNCTION create_proc(void)
 static void DIVA_EXIT_FUNCTION remove_proc(void)
 {
        remove_proc_entry(DRIVERLNAME, proc_net_eicon);
-       remove_proc_entry(main_proc_dir, proc_net);
+       remove_proc_entry("net/eicon", NULL);
 }
 
 static int DIVA_INIT_FUNCTION divadidd_init(void)
index b6435589d459494b57608579984f3ef19973b77a..c12efa6f842917340b870f58276ad0ffa5d6b23a 100644 (file)
@@ -381,7 +381,7 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a)
        char tmp[16];
 
        sprintf(tmp, "%s%d", adapter_dir_name, a->controller);
-       if (!(de = create_proc_entry(tmp, S_IFDIR, proc_net_eicon)))
+       if (!(de = proc_mkdir(tmp, proc_net_eicon)))
                return (0);
        a->proc_adapter_dir = (void *) de;
 
index 5da507e532fc5ef9bbac164516f89d8f081e4d8e..639582f61f41e416e98dbb493a70a9a3d1f7df15 100644 (file)
@@ -394,7 +394,7 @@ hysdn_procconf_init(void)
        hysdn_card *card;
        uchar conf_name[20];
 
-       hysdn_proc_entry = create_proc_entry(PROC_SUBDIR_NAME, S_IFDIR | S_IRUGO | S_IXUGO, proc_net);
+       hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
        if (!hysdn_proc_entry) {
                printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n");
                return (-1);
index a85ac18dd21d13971738fbb45a93415384ed194f..9b38674fbf7558d689aab1e88e284df3e692f504 100644 (file)
@@ -153,8 +153,10 @@ static irqreturn_t smu_db_intr(int irq, void *arg, struct pt_regs *regs)
        spin_lock_irqsave(&smu->lock, flags);
 
        gpio = pmac_do_feature_call(PMAC_FTR_READ_GPIO, NULL, smu->doorbell);
-       if ((gpio & 7) != 7)
+       if ((gpio & 7) != 7) {
+               spin_unlock_irqrestore(&smu->lock, flags);
                return IRQ_HANDLED;
+       }
 
        cmd = smu->cmd_cur;
        smu->cmd_cur = NULL;
index 190977a1e5494598b753d3a34ea5c2a60ad989b6..6c332800d6abf511fd3333b00359a15a3895b253 100644 (file)
@@ -2398,7 +2398,7 @@ struct tvcard bttv_tvcards[] = {
        .svhs           = 2,
        .muxsel         = { 2, 3 },
        .gpiomask       = 0x00e00007,
-       .audiomux       = { 0x00400005, 0, 0, 0, 0, 0 },
+       .audiomux       = { 0x00400005, 0, 0x00000001, 0, 0x00c00007, 0 },
        .no_msp34xx     = 1,
        .no_tda9875     = 1,
        .no_tda7432     = 1,
index 8c08b7f1ad233389cb4377bdf04c154f1f7ed6f2..b7ec9bf45085ea6e31ba526938654eb24a32f647 100644 (file)
@@ -1397,7 +1397,7 @@ static void destroy_proc_cpia_cam(struct cam_data *cam)
 
 static void proc_cpia_create(void)
 {
-       cpia_proc_root = create_proc_entry("cpia", S_IFDIR, NULL);
+       cpia_proc_root = proc_mkdir("cpia", NULL);
 
        if (cpia_proc_root)
                cpia_proc_root->owner = THIS_MODULE;
index 30337d0f1a87daa0e16d6ffaabf54a5daf4dfcbe..0d30eb744e61abae812fb8098007308e65bc5c89 100644 (file)
@@ -31,7 +31,7 @@
 struct rds_command {
        unsigned int  block_count;
        int           result;
-       unsigned char *buffer;
+       unsigned char __user *buffer;
        struct file   *instance;
        poll_table    *event_list;
 };
index 1a657a70ff43c53158a50ce2140e90c55429889d..72b70eb5da1d70e5f586dabfea18e1effad28a74 100644 (file)
@@ -157,7 +157,7 @@ static struct i2c_client client_template;
 
 /* ---------------------------------------------------------------------- */
 
-static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf)
+static int block_to_user_buf(struct saa6588 *s, unsigned char __user *user_buf)
 {
        int i;
 
@@ -191,7 +191,7 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a)
 {
        unsigned long flags;
 
-       unsigned char *buf_ptr = a->buffer;     /* This is a user space buffer! */
+       unsigned char __user *buf_ptr = a->buffer;
        unsigned int i;
        unsigned int rd_blocks;
 
index 10f6ce1bc0abc0272cd320d52847cd77c6eb4255..612564ac6f7b45056c944987064270b12208f86e 100644 (file)
@@ -642,8 +642,6 @@ static void __exit ucb1x00_exit(void)
 module_init(ucb1x00_init);
 module_exit(ucb1x00_exit);
 
-EXPORT_SYMBOL(ucb1x00_class);
-
 EXPORT_SYMBOL(ucb1x00_io_set_dir);
 EXPORT_SYMBOL(ucb1x00_io_write);
 EXPORT_SYMBOL(ucb1x00_io_read);
index 6b632644f59a1b1a7c6eb297f24e90389c3567a9..9c9a647d8b7b696fb114786c1b08716727659a54 100644 (file)
@@ -106,8 +106,6 @@ struct ucb1x00_irq {
        void (*fn)(int, void *);
 };
 
-extern struct class ucb1x00_class;
-
 struct ucb1x00 {
        spinlock_t              lock;
        struct mcp              *mcp;
index 0c45464e3f7b8636f6d816b280a150e930dea6de..0ba0ff7d43b9593489659f6ffb933e73d9d33c4f 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/mach/flash.h>
 
 #include <asm/arch/map.h>
index 3e94b616743d0cec3cc123fb8952b2aedf4f236b..a9f86c7fbd52e7319c8825196070e54da6e20a0e 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <asm/io.h>
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 #include <asm/mach/flash.h>
 
 #include <linux/reboot.h>
index 5afe660aa2c4f9f8eb96a10a2762f385e5548f4e..3fcc3288407437792479c456574ac09c50ee716e 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/ioport.h>
 #include <linux/device.h>
 #include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/mach/flash.h>
 
 #include <linux/reboot.h>
@@ -254,6 +253,6 @@ module_init(ixp4xx_flash_init);
 module_exit(ixp4xx_flash_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems")
+MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems");
 MODULE_AUTHOR("Deepak Saxena");
 
index 8cc71409a3285c62e68206b5ee92a83d05527c86..b17bca657daf53599d8e8328ee1110b08cb50e95 100644 (file)
@@ -42,7 +42,6 @@
 
 #include <asm/io.h>
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 #include <asm/mach/flash.h>
 #include <asm/arch/tc.h>
 
index 52385705da09fe32d13590c7628aa2372e303e65..8dcaa357b4bb13bbaba9e543f1b45dc49ce880b3 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/concat.h>
 
-#include <asm/mach-types.h>
 #include <asm/io.h>
 #include <asm/sizes.h>
 #include <asm/mach/flash.h>
index 891e3a1b91106fa761ccbf032c4d4f0854655601..b47ebcb31e0fdf5a1116c0e2a99d387dbc2941f9 100644 (file)
@@ -58,7 +58,6 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/hardware/clock.h>
 
 #include <asm/arch/regs-nand.h>
index 96f14ab1c1f52f805e64c62959fadc84d1b1e412..c748b0e1641921b195d5df144ae0addba10eb3b3 100644 (file)
@@ -548,6 +548,14 @@ config SUNGEM
          Support for the Sun GEM chip, aka Sun GigabitEthernet/P 2.0.  See also
          <http://www.sun.com/products-n-solutions/hardware/docs/pdf/806-3985-10.pdf>.
 
+config CASSINI
+       tristate "Sun Cassini support"
+       depends on NET_ETHERNET && PCI
+       select CRC32
+       help
+         Support for the Sun Cassini chip, aka Sun GigaSwift Ethernet. See also
+         <http://www.sun.com/products-n-solutions/hardware/docs/pdf/817-4341-10.pdf>
+
 config NET_VENDOR_3COM
        bool "3COM cards"
        depends on NET_ETHERNET && (ISA || EISA || MCA || PCI)
@@ -1647,7 +1655,7 @@ config LAN_SAA9730
 
 config NET_POCKET
        bool "Pocket and portable adapters"
-       depends on NET_ETHERNET && ISA
+       depends on NET_ETHERNET && PARPORT
        ---help---
          Cute little network (Ethernet) devices which attach to the parallel
          port ("pocket adapters"), commonly used with laptops. If you have
@@ -1671,7 +1679,7 @@ config NET_POCKET
 
 config ATP
        tristate "AT-LAN-TEC/RealTek pocket adapter support"
-       depends on NET_POCKET && ISA && X86
+       depends on NET_POCKET && PARPORT && X86
        select CRC32
        ---help---
          This is a network (Ethernet) device which attaches to your parallel
@@ -1686,7 +1694,7 @@ config ATP
 
 config DE600
        tristate "D-Link DE600 pocket adapter support"
-       depends on NET_POCKET && ISA
+       depends on NET_POCKET && PARPORT
        ---help---
          This is a network (Ethernet) device which attaches to your parallel
          port. Read <file:Documentation/networking/DLINK.txt> as well as the
@@ -1701,7 +1709,7 @@ config DE600
 
 config DE620
        tristate "D-Link DE620 pocket adapter support"
-       depends on NET_POCKET && ISA
+       depends on NET_POCKET && PARPORT
        ---help---
          This is a network (Ethernet) device which attaches to your parallel
          port. Read <file:Documentation/networking/DLINK.txt> as well as the
index 8645c843cf4d0216c8e8e4a53b202d7a576c2b07..8aeec9f2495b5e712879b7735e95bf141ce49e05 100644 (file)
@@ -28,6 +28,7 @@ obj-$(CONFIG_SUNQE) += sunqe.o
 obj-$(CONFIG_SUNBMAC) += sunbmac.o
 obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
 obj-$(CONFIG_SUNGEM) += sungem.o sungem_phy.o
+obj-$(CONFIG_CASSINI) += cassini.o
 
 obj-$(CONFIG_MACE) += mace.o
 obj-$(CONFIG_BMAC) += bmac.o
index 9b659e3c8d674280bc283dd99f7a872c7b2b7d0d..c56d86d371a9c6d15eac175a7770c80f96d26b60 100644 (file)
  */
 #include <linux/kernel.h>
 #include <linux/types.h>
-#include <linux/fcntl.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
-#include <linux/in.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
-#include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
@@ -33,7 +30,6 @@
 #include <asm/system.h>
 #include <asm/irq.h>
 #include <asm/io.h>
-#include <asm/dma.h>
 
 #define TX_BUFFERS 15
 #define RX_BUFFERS 25
@@ -85,7 +81,7 @@ static inline unsigned short read_ireg(u_long base_addr, u_int reg)
        u_short v;
        __asm__(
        "str%?h %1, [%2]        @ NAT_RAP\n\t"
-       "str%?h %0, [%2, #8]    @ NET_IDP\n\t"
+       "ldr%?h %0, [%2, #8]    @ NET_IDP\n\t"
        : "=r" (v)
        : "r" (reg), "r" (ISAIO_BASE + 0x0464));
        return v;
@@ -288,7 +284,7 @@ static void am79c961_timer(unsigned long data)
        else if (!lnkstat && carrier)
                netif_carrier_off(dev);
 
-       mod_timer(&priv->timer, jiffies + 5*HZ);
+       mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500));
 }
 
 /*
@@ -709,13 +705,9 @@ static int __init am79c961_init(void)
                goto release;
 
        am79c961_banner();
-       printk(KERN_INFO "%s: ether address ", dev->name);
 
-       /* Retrive and print the ethernet address. */
-       for (i = 0; i < 6; i++) {
+       for (i = 0; i < 6; i++)
                dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff;
-               printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
-       }
 
        spin_lock_init(&priv->chip_lock);
        init_timer(&priv->timer);
@@ -736,8 +728,14 @@ static int __init am79c961_init(void)
 #endif
 
        ret = register_netdev(dev);
-       if (ret == 0)
+       if (ret == 0) {
+               printk(KERN_INFO "%s: ether address ", dev->name);
+
+               for (i = 0; i < 6; i++)
+                       printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
+
                return 0;
+       }
 
 release:
        release_region(dev->base_addr, 0x18);
index 8dc657fc8afb37f18623efb160e58b216a615520..60dba4a1ca5ce8d57081088c22d16eeb7a2ee8f6 100644 (file)
@@ -218,7 +218,7 @@ void bmwrite(struct net_device *dev, unsigned long reg_offset, unsigned data )
 
 
 static inline
-volatile unsigned short bmread(struct net_device *dev, unsigned long reg_offset )
+unsigned short bmread(struct net_device *dev, unsigned long reg_offset )
 {
        return in_le16((void __iomem *)dev->base_addr + reg_offset);
 }
index 6d00c3de1a836a8ec703bab4480646a8c6e7aed1..f0a5b772a386b3659ab2ba6f76bc64f4f6765f57 100644 (file)
  *       * Added xmit_hash_policy_layer34()
  *     - Modified by Jay Vosburgh <fubar@us.ibm.com> to also support mode 4.
  *       Set version to 2.6.3.
+ * 2005/09/26 - Jay Vosburgh <fubar@us.ibm.com>
+ *     - Removed backwards compatibility for old ifenslaves.  Version 2.6.4.
  */
 
 //#define BONDING_DEBUG 1
@@ -595,14 +597,7 @@ static int arp_ip_count    = 0;
 static int bond_mode   = BOND_MODE_ROUNDROBIN;
 static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2;
 static int lacp_fast   = 0;
-static int app_abi_ver = 0;
-static int orig_app_abi_ver = -1; /* This is used to save the first ABI version
-                                  * we receive from the application. Once set,
-                                  * it won't be changed, and the module will
-                                  * refuse to enslave/release interfaces if the
-                                  * command comes from an application using
-                                  * another ABI version.
-                                  */
+
 struct bond_parm_tbl {
        char *modename;
        int mode;
@@ -1294,12 +1289,13 @@ static void bond_mc_list_destroy(struct bonding *bond)
 /*
  * Copy all the Multicast addresses from src to the bonding device dst
  */
-static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond, int gpf_flag)
+static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond,
+                            unsigned int __nocast gfp_flag)
 {
        struct dev_mc_list *dmi, *new_dmi;
 
        for (dmi = mc_list; dmi; dmi = dmi->next) {
-               new_dmi = kmalloc(sizeof(struct dev_mc_list), gpf_flag);
+               new_dmi = kmalloc(sizeof(struct dev_mc_list), gfp_flag);
 
                if (!new_dmi) {
                        /* FIXME: Potential memory leak !!! */
@@ -1702,51 +1698,29 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
                }
        }
 
-       if (app_abi_ver >= 1) {
-               /* The application is using an ABI, which requires the
-                * slave interface to be closed.
-                */
-               if ((slave_dev->flags & IFF_UP)) {
-                       printk(KERN_ERR DRV_NAME
-                              ": Error: %s is up\n",
-                              slave_dev->name);
-                       res = -EPERM;
-                       goto err_undo_flags;
-               }
-
-               if (slave_dev->set_mac_address == NULL) {
-                       printk(KERN_ERR DRV_NAME
-                              ": Error: The slave device you specified does "
-                              "not support setting the MAC address.\n");
-                       printk(KERN_ERR
-                              "Your kernel likely does not support slave "
-                              "devices.\n");
+       /*
+        * Old ifenslave binaries are no longer supported.  These can
+        * be identified with moderate accurary by the state of the slave:
+        * the current ifenslave will set the interface down prior to
+        * enslaving it; the old ifenslave will not.
+        */
+       if ((slave_dev->flags & IFF_UP)) {
+               printk(KERN_ERR DRV_NAME ": %s is up. "
+                      "This may be due to an out of date ifenslave.\n",
+                      slave_dev->name);
+               res = -EPERM;
+               goto err_undo_flags;
+       }
 
-                       res = -EOPNOTSUPP;
-                       goto err_undo_flags;
-               }
-       } else {
-               /* The application is not using an ABI, which requires the
-                * slave interface to be open.
-                */
-               if (!(slave_dev->flags & IFF_UP)) {
-                       printk(KERN_ERR DRV_NAME
-                              ": Error: %s is not running\n",
-                              slave_dev->name);
-                       res = -EINVAL;
-                       goto err_undo_flags;
-               }
+       if (slave_dev->set_mac_address == NULL) {
+               printk(KERN_ERR DRV_NAME
+                      ": Error: The slave device you specified does "
+                      "not support setting the MAC address.\n");
+               printk(KERN_ERR
+                      "Your kernel likely does not support slave devices.\n");
 
-               if ((bond->params.mode == BOND_MODE_8023AD) ||
-                   (bond->params.mode == BOND_MODE_TLB)    ||
-                   (bond->params.mode == BOND_MODE_ALB)) {
-                       printk(KERN_ERR DRV_NAME
-                              ": Error: to use %s mode, you must upgrade "
-                              "ifenslave.\n",
-                              bond_mode_name(bond->params.mode));
-                       res = -EOPNOTSUPP;
-                       goto err_undo_flags;
-               }
+               res = -EOPNOTSUPP;
+               goto err_undo_flags;
        }
 
        new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
@@ -1762,41 +1736,36 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
         */
        new_slave->original_flags = slave_dev->flags;
 
-       if (app_abi_ver >= 1) {
-               /* save slave's original ("permanent") mac address for
-                * modes that needs it, and for restoring it upon release,
-                * and then set it to the master's address
-                */
-               memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN);
+       /*
+        * Save slave's original ("permanent") mac address for modes
+        * that need it, and for restoring it upon release, and then
+        * set it to the master's address
+        */
+       memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN);
 
-               /* set slave to master's mac address
-                * The application already set the master's
-                * mac address to that of the first slave
-                */
-               memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len);
-               addr.sa_family = slave_dev->type;
-               res = dev_set_mac_address(slave_dev, &addr);
-               if (res) {
-                       dprintk("Error %d calling set_mac_address\n", res);
-                       goto err_free;
-               }
+       /*
+        * Set slave to master's mac address.  The application already
+        * set the master's mac address to that of the first slave
+        */
+       memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len);
+       addr.sa_family = slave_dev->type;
+       res = dev_set_mac_address(slave_dev, &addr);
+       if (res) {
+               dprintk("Error %d calling set_mac_address\n", res);
+               goto err_free;
+       }
 
-               /* open the slave since the application closed it */
-               res = dev_open(slave_dev);
-               if (res) {
-                       dprintk("Openning slave %s failed\n", slave_dev->name);
-                       goto err_restore_mac;
-               }
+       /* open the slave since the application closed it */
+       res = dev_open(slave_dev);
+       if (res) {
+               dprintk("Openning slave %s failed\n", slave_dev->name);
+               goto err_restore_mac;
        }
 
        res = netdev_set_master(slave_dev, bond_dev);
        if (res) {
                dprintk("Error %d calling netdev_set_master\n", res);
-               if (app_abi_ver < 1) {
-                       goto err_free;
-               } else {
-                       goto err_close;
-               }
+               goto err_close;
        }
 
        new_slave->dev = slave_dev;
@@ -1997,39 +1966,6 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
 
        write_unlock_bh(&bond->lock);
 
-       if (app_abi_ver < 1) {
-               /*
-                * !!! This is to support old versions of ifenslave.
-                * We can remove this in 2.5 because our ifenslave takes
-                * care of this for us.
-                * We check to see if the master has a mac address yet.
-                * If not, we'll give it the mac address of our slave device.
-                */
-               int ndx = 0;
-
-               for (ndx = 0; ndx < bond_dev->addr_len; ndx++) {
-                       dprintk("Checking ndx=%d of bond_dev->dev_addr\n",
-                               ndx);
-                       if (bond_dev->dev_addr[ndx] != 0) {
-                               dprintk("Found non-zero byte at ndx=%d\n",
-                                       ndx);
-                               break;
-                       }
-               }
-
-               if (ndx == bond_dev->addr_len) {
-                       /*
-                        * We got all the way through the address and it was
-                        * all 0's.
-                        */
-                       dprintk("%s doesn't have a MAC address yet.  \n",
-                               bond_dev->name);
-                       dprintk("Going to give assign it from %s.\n",
-                               slave_dev->name);
-                       bond_sethwaddr(bond_dev, slave_dev);
-               }
-       }
-
        printk(KERN_INFO DRV_NAME
               ": %s: enslaving %s as a%s interface with a%s link.\n",
               bond_dev->name, slave_dev->name,
@@ -2227,12 +2163,10 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de
        /* close slave before restoring its mac address */
        dev_close(slave_dev);
 
-       if (app_abi_ver >= 1) {
-               /* restore original ("permanent") mac address */
-               memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
-               addr.sa_family = slave_dev->type;
-               dev_set_mac_address(slave_dev, &addr);
-       }
+       /* restore original ("permanent") mac address */
+       memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
+       addr.sa_family = slave_dev->type;
+       dev_set_mac_address(slave_dev, &addr);
 
        /* restore the original state of the
         * IFF_NOARP flag that might have been
@@ -2320,12 +2254,10 @@ static int bond_release_all(struct net_device *bond_dev)
                /* close slave before restoring its mac address */
                dev_close(slave_dev);
 
-               if (app_abi_ver >= 1) {
-                       /* restore original ("permanent") mac address*/
-                       memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
-                       addr.sa_family = slave_dev->type;
-                       dev_set_mac_address(slave_dev, &addr);
-               }
+               /* restore original ("permanent") mac address*/
+               memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
+               addr.sa_family = slave_dev->type;
+               dev_set_mac_address(slave_dev, &addr);
 
                /* restore the original state of the IFF_NOARP flag that might have
                 * been set by bond_set_slave_inactive_flags()
@@ -2423,57 +2355,6 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
        return res;
 }
 
-static int bond_ethtool_ioctl(struct net_device *bond_dev, struct ifreq *ifr)
-{
-       struct ethtool_drvinfo info;
-       void __user *addr = ifr->ifr_data;
-       uint32_t cmd;
-
-       if (get_user(cmd, (uint32_t __user *)addr)) {
-               return -EFAULT;
-       }
-
-       switch (cmd) {
-       case ETHTOOL_GDRVINFO:
-               if (copy_from_user(&info, addr, sizeof(info))) {
-                       return -EFAULT;
-               }
-
-               if (strcmp(info.driver, "ifenslave") == 0) {
-                       int new_abi_ver;
-                       char *endptr;
-
-                       new_abi_ver = simple_strtoul(info.fw_version,
-                                                    &endptr, 0);
-                       if (*endptr) {
-                               printk(KERN_ERR DRV_NAME
-                                      ": Error: got invalid ABI "
-                                      "version from application\n");
-
-                               return -EINVAL;
-                       }
-
-                       if (orig_app_abi_ver == -1) {
-                               orig_app_abi_ver  = new_abi_ver;
-                       }
-
-                       app_abi_ver = new_abi_ver;
-               }
-
-               strncpy(info.driver,  DRV_NAME, 32);
-               strncpy(info.version, DRV_VERSION, 32);
-               snprintf(info.fw_version, 32, "%d", BOND_ABI_VERSION);
-
-               if (copy_to_user(addr, &info, sizeof(info))) {
-                       return -EFAULT;
-               }
-
-               return 0;
-       default:
-               return -EOPNOTSUPP;
-       }
-}
-
 static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
 {
        struct bonding *bond = bond_dev->priv;
@@ -2776,7 +2657,7 @@ static u32 bond_glean_dev_ip(struct net_device *dev)
                return 0;
 
        rcu_read_lock();
-       idev = __in_dev_get(dev);
+       idev = __in_dev_get_rcu(dev);
        if (!idev)
                goto out;
 
@@ -3442,16 +3323,11 @@ static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave
        seq_printf(seq, "Link Failure Count: %d\n",
                   slave->link_failure_count);
 
-       if (app_abi_ver >= 1) {
-               seq_printf(seq,
-                          "Permanent HW addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
-                          slave->perm_hwaddr[0],
-                          slave->perm_hwaddr[1],
-                          slave->perm_hwaddr[2],
-                          slave->perm_hwaddr[3],
-                          slave->perm_hwaddr[4],
-                          slave->perm_hwaddr[5]);
-       }
+       seq_printf(seq,
+                  "Permanent HW addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
+                  slave->perm_hwaddr[0], slave->perm_hwaddr[1],
+                  slave->perm_hwaddr[2], slave->perm_hwaddr[3],
+                  slave->perm_hwaddr[4], slave->perm_hwaddr[5]);
 
        if (bond->params.mode == BOND_MODE_8023AD) {
                const struct aggregator *agg
@@ -4010,15 +3886,12 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
        struct ifslave k_sinfo;
        struct ifslave __user *u_sinfo = NULL;
        struct mii_ioctl_data *mii = NULL;
-       int prev_abi_ver = orig_app_abi_ver;
        int res = 0;
 
        dprintk("bond_ioctl: master=%s, cmd=%d\n",
                bond_dev->name, cmd);
 
        switch (cmd) {
-       case SIOCETHTOOL:
-               return bond_ethtool_ioctl(bond_dev, ifr);
        case SIOCGMIIPHY:
                mii = if_mii(ifr);
                if (!mii) {
@@ -4090,21 +3963,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
                return -EPERM;
        }
 
-       if (orig_app_abi_ver == -1) {
-               /* no orig_app_abi_ver was provided yet, so we'll use the
-                * current one from now on, even if it's 0
-                */
-               orig_app_abi_ver = app_abi_ver;
-
-       } else if (orig_app_abi_ver != app_abi_ver) {
-               printk(KERN_ERR DRV_NAME
-                      ": Error: already using ifenslave ABI version %d; to "
-                      "upgrade ifenslave to version %d, you must first "
-                      "reload bonding.\n",
-                      orig_app_abi_ver, app_abi_ver);
-               return -EINVAL;
-       }
-
        slave_dev = dev_get_by_name(ifr->ifr_slave);
 
        dprintk("slave_dev=%p: \n", slave_dev);
@@ -4137,14 +3995,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
                dev_put(slave_dev);
        }
 
-       if (res < 0) {
-               /* The ioctl failed, so there's no point in changing the
-                * orig_app_abi_ver. We'll restore it's value just in case
-                * we've changed it earlier in this function.
-                */
-               orig_app_abi_ver = prev_abi_ver;
-       }
-
        return res;
 }
 
@@ -4578,9 +4428,18 @@ static inline void bond_set_mode_ops(struct bonding *bond, int mode)
        }
 }
 
+static void bond_ethtool_get_drvinfo(struct net_device *bond_dev,
+                                   struct ethtool_drvinfo *drvinfo)
+{
+       strncpy(drvinfo->driver, DRV_NAME, 32);
+       strncpy(drvinfo->version, DRV_VERSION, 32);
+       snprintf(drvinfo->fw_version, 32, "%d", BOND_ABI_VERSION);
+}
+
 static struct ethtool_ops bond_ethtool_ops = {
        .get_tx_csum            = ethtool_op_get_tx_csum,
        .get_sg                 = ethtool_op_get_sg,
+       .get_drvinfo            = bond_ethtool_get_drvinfo,
 };
 
 /*
index 3881969808627cebcb7ed6a25f6b9b3557b6a1ec..bbf9da8af624d7d5df7a4c4ccc3d2ff151402248 100644 (file)
@@ -40,8 +40,8 @@
 #include "bond_3ad.h"
 #include "bond_alb.h"
 
-#define DRV_VERSION    "2.6.3"
-#define DRV_RELDATE    "June 8, 2005"
+#define DRV_VERSION    "2.6.4"
+#define DRV_RELDATE    "September 26, 2005"
 #define DRV_NAME       "bonding"
 #define DRV_DESCRIPTION        "Ethernet Channel Bonding Driver"
 
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
new file mode 100644 (file)
index 0000000..2e61742
--- /dev/null
@@ -0,0 +1,5237 @@
+/* cassini.c: Sun Microsystems Cassini(+) ethernet driver.
+ *
+ * Copyright (C) 2004 Sun Microsystems Inc.
+ * Copyright (C) 2003 Adrian Sun (asun@darksunrising.com)
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * This driver uses the sungem driver (c) David Miller
+ * (davem@redhat.com) as its basis.
+ *
+ * The cassini chip has a number of features that distinguish it from
+ * the gem chip:
+ *  4 transmit descriptor rings that are used for either QoS (VLAN) or
+ *      load balancing (non-VLAN mode)
+ *  batching of multiple packets
+ *  multiple CPU dispatching
+ *  page-based RX descriptor engine with separate completion rings
+ *  Gigabit support (GMII and PCS interface)
+ *  MIF link up/down detection works
+ *
+ * RX is handled by page sized buffers that are attached as fragments to
+ * the skb. here's what's done:
+ *  -- driver allocates pages at a time and keeps reference counts
+ *     on them.
+ *  -- the upper protocol layers assume that the header is in the skb
+ *     itself. as a result, cassini will copy a small amount (64 bytes)
+ *     to make them happy.
+ *  -- driver appends the rest of the data pages as frags to skbuffs
+ *     and increments the reference count
+ *  -- on page reclamation, the driver swaps the page with a spare page.
+ *     if that page is still in use, it frees its reference to that page,
+ *     and allocates a new page for use. otherwise, it just recycles the
+ *     the page. 
+ *
+ * NOTE: cassini can parse the header. however, it's not worth it
+ *       as long as the network stack requires a header copy.
+ *
+ * TX has 4 queues. currently these queues are used in a round-robin
+ * fashion for load balancing. They can also be used for QoS. for that
+ * to work, however, QoS information needs to be exposed down to the driver
+ * level so that subqueues get targetted to particular transmit rings.
+ * alternatively, the queues can be configured via use of the all-purpose
+ * ioctl.
+ *
+ * RX DATA: the rx completion ring has all the info, but the rx desc
+ * ring has all of the data. RX can conceivably come in under multiple
+ * interrupts, but the INT# assignment needs to be set up properly by
+ * the BIOS and conveyed to the driver. PCI BIOSes don't know how to do
+ * that. also, the two descriptor rings are designed to distinguish between
+ * encrypted and non-encrypted packets, but we use them for buffering 
+ * instead.
+ *
+ * by default, the selective clear mask is set up to process rx packets.  
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/compiler.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/mm.h>
+#include <linux/highmem.h>
+#include <linux/list.h>
+#include <linux/dma-mapping.h>
+
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/ethtool.h>
+#include <linux/crc32.h>
+#include <linux/random.h>
+#include <linux/mii.h>
+#include <linux/ip.h>
+#include <linux/tcp.h>
+
+#include <net/checksum.h>
+
+#include <asm/atomic.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/byteorder.h>
+#include <asm/uaccess.h>
+
+#define cas_page_map(x)      kmap_atomic((x), KM_SKB_DATA_SOFTIRQ)
+#define cas_page_unmap(x)    kunmap_atomic((x), KM_SKB_DATA_SOFTIRQ)
+#define CAS_NCPUS            num_online_cpus()
+
+#if defined(CONFIG_CASSINI_NAPI) && defined(HAVE_NETDEV_POLL)
+#define USE_NAPI
+#define cas_skb_release(x)  netif_receive_skb(x)
+#else
+#define cas_skb_release(x)  netif_rx(x)
+#endif
+
+/* select which firmware to use */
+#define USE_HP_WORKAROUND     
+#define HP_WORKAROUND_DEFAULT /* select which firmware to use as default */
+#define CAS_HP_ALT_FIRMWARE   cas_prog_null /* alternate firmware */
+
+#include "cassini.h"
+
+#define USE_TX_COMPWB      /* use completion writeback registers */
+#define USE_CSMA_CD_PROTO  /* standard CSMA/CD */
+#define USE_RX_BLANK       /* hw interrupt mitigation */
+#undef USE_ENTROPY_DEV     /* don't test for entropy device */
+
+/* NOTE: these aren't useable unless PCI interrupts can be assigned.
+ * also, we need to make cp->lock finer-grained.
+ */
+#undef  USE_PCI_INTB
+#undef  USE_PCI_INTC
+#undef  USE_PCI_INTD
+#undef  USE_QOS
+
+#undef  USE_VPD_DEBUG       /* debug vpd information if defined */
+
+/* rx processing options */
+#define USE_PAGE_ORDER      /* specify to allocate large rx pages */
+#define RX_DONT_BATCH  0    /* if 1, don't batch flows */
+#define RX_COPY_ALWAYS 0    /* if 0, use frags */
+#define RX_COPY_MIN    64   /* copy a little to make upper layers happy */
+#undef  RX_COUNT_BUFFERS    /* define to calculate RX buffer stats */
+
+#define DRV_MODULE_NAME                "cassini"
+#define PFX DRV_MODULE_NAME    ": "
+#define DRV_MODULE_VERSION     "1.4"
+#define DRV_MODULE_RELDATE     "1 July 2004"
+
+#define CAS_DEF_MSG_ENABLE       \
+       (NETIF_MSG_DRV          | \
+        NETIF_MSG_PROBE        | \
+        NETIF_MSG_LINK         | \
+        NETIF_MSG_TIMER        | \
+        NETIF_MSG_IFDOWN       | \
+        NETIF_MSG_IFUP         | \
+        NETIF_MSG_RX_ERR       | \
+        NETIF_MSG_TX_ERR)
+
+/* length of time before we decide the hardware is borked,
+ * and dev->tx_timeout() should be called to fix the problem
+ */
+#define CAS_TX_TIMEOUT                 (HZ)
+#define CAS_LINK_TIMEOUT                (22*HZ/10)
+#define CAS_LINK_FAST_TIMEOUT           (1)
+
+/* timeout values for state changing. these specify the number
+ * of 10us delays to be used before giving up.
+ */
+#define STOP_TRIES_PHY 1000
+#define STOP_TRIES     5000
+
+/* specify a minimum frame size to deal with some fifo issues 
+ * max mtu == 2 * page size - ethernet header - 64 - swivel =
+ *            2 * page_size - 0x50
+ */
+#define CAS_MIN_FRAME                  97
+#define CAS_1000MB_MIN_FRAME            255
+#define CAS_MIN_MTU                     60
+#define CAS_MAX_MTU                     min(((cp->page_size << 1) - 0x50), 9000)
+
+#if 1
+/*
+ * Eliminate these and use separate atomic counters for each, to
+ * avoid a race condition.
+ */
+#else
+#define CAS_RESET_MTU                   1
+#define CAS_RESET_ALL                   2
+#define CAS_RESET_SPARE                 3
+#endif
+
+static char version[] __devinitdata =
+       DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
+
+MODULE_AUTHOR("Adrian Sun (asun@darksunrising.com)");
+MODULE_DESCRIPTION("Sun Cassini(+) ethernet driver");
+MODULE_LICENSE("GPL");
+MODULE_PARM(cassini_debug, "i");
+MODULE_PARM_DESC(cassini_debug, "Cassini bitmapped debugging message enable value");
+MODULE_PARM(link_mode, "i");
+MODULE_PARM_DESC(link_mode, "default link mode");
+
+/*
+ * Work around for a PCS bug in which the link goes down due to the chip
+ * being confused and never showing a link status of "up."
+ */
+#define DEFAULT_LINKDOWN_TIMEOUT 5
+/* 
+ * Value in seconds, for user input.
+ */
+static int linkdown_timeout = DEFAULT_LINKDOWN_TIMEOUT;
+MODULE_PARM(linkdown_timeout, "i");
+MODULE_PARM_DESC(linkdown_timeout,
+"min reset interval in sec. for PCS linkdown issue; disabled if not positive");
+
+/*
+ * value in 'ticks' (units used by jiffies). Set when we init the
+ * module because 'HZ' in actually a function call on some flavors of
+ * Linux.  This will default to DEFAULT_LINKDOWN_TIMEOUT * HZ.
+ */
+static int link_transition_timeout;
+
+
+static int cassini_debug = -1; /* -1 == use CAS_DEF_MSG_ENABLE as value */
+static int link_mode;
+
+static u16 link_modes[] __devinitdata = {
+       BMCR_ANENABLE,                   /* 0 : autoneg */
+       0,                               /* 1 : 10bt half duplex */
+       BMCR_SPEED100,                   /* 2 : 100bt half duplex */
+       BMCR_FULLDPLX,                   /* 3 : 10bt full duplex */
+       BMCR_SPEED100|BMCR_FULLDPLX,     /* 4 : 100bt full duplex */
+       CAS_BMCR_SPEED1000|BMCR_FULLDPLX /* 5 : 1000bt full duplex */
+};
+
+static struct pci_device_id cas_pci_tbl[] __devinitdata = {
+       { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_CASSINI,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+       { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SATURN,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+       { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, cas_pci_tbl);
+
+static void cas_set_link_modes(struct cas *cp);
+
+static inline void cas_lock_tx(struct cas *cp)
+{
+       int i;
+
+       for (i = 0; i < N_TX_RINGS; i++)  
+               spin_lock(&cp->tx_lock[i]);
+}
+
+static inline void cas_lock_all(struct cas *cp)
+{
+       spin_lock_irq(&cp->lock);
+       cas_lock_tx(cp);
+}
+
+/* WTZ: QA was finding deadlock problems with the previous
+ * versions after long test runs with multiple cards per machine.
+ * See if replacing cas_lock_all with safer versions helps. The
+ * symptoms QA is reporting match those we'd expect if interrupts
+ * aren't being properly restored, and we fixed a previous deadlock
+ * with similar symptoms by using save/restore versions in other
+ * places.
+ */
+#define cas_lock_all_save(cp, flags) \
+do { \
+       struct cas *xxxcp = (cp); \
+       spin_lock_irqsave(&xxxcp->lock, flags); \
+       cas_lock_tx(xxxcp); \
+} while (0)
+
+static inline void cas_unlock_tx(struct cas *cp)
+{
+       int i;
+
+       for (i = N_TX_RINGS; i > 0; i--)  
+               spin_unlock(&cp->tx_lock[i - 1]);  
+}
+
+static inline void cas_unlock_all(struct cas *cp)
+{
+       cas_unlock_tx(cp);
+       spin_unlock_irq(&cp->lock);
+}
+
+#define cas_unlock_all_restore(cp, flags) \
+do { \
+       struct cas *xxxcp = (cp); \
+       cas_unlock_tx(xxxcp); \
+       spin_unlock_irqrestore(&xxxcp->lock, flags); \
+} while (0)
+
+static void cas_disable_irq(struct cas *cp, const int ring)
+{
+       /* Make sure we won't get any more interrupts */
+       if (ring == 0) {
+               writel(0xFFFFFFFF, cp->regs + REG_INTR_MASK);
+               return;
+       }
+
+       /* disable completion interrupts and selectively mask */
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               switch (ring) {
+#if defined (USE_PCI_INTB) || defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
+#ifdef USE_PCI_INTB
+               case 1:
+#endif
+#ifdef USE_PCI_INTC
+               case 2:
+#endif
+#ifdef USE_PCI_INTD
+               case 3:
+#endif
+                       writel(INTRN_MASK_CLEAR_ALL | INTRN_MASK_RX_EN, 
+                              cp->regs + REG_PLUS_INTRN_MASK(ring));
+                       break;
+#endif
+               default:
+                       writel(INTRN_MASK_CLEAR_ALL, cp->regs +
+                              REG_PLUS_INTRN_MASK(ring));
+                       break;
+               }
+       }
+}
+
+static inline void cas_mask_intr(struct cas *cp)
+{
+       int i;
+
+       for (i = 0; i < N_RX_COMP_RINGS; i++)
+               cas_disable_irq(cp, i);
+}
+
+static void cas_enable_irq(struct cas *cp, const int ring)
+{
+       if (ring == 0) { /* all but TX_DONE */
+               writel(INTR_TX_DONE, cp->regs + REG_INTR_MASK);
+               return;
+       }
+
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               switch (ring) {
+#if defined (USE_PCI_INTB) || defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
+#ifdef USE_PCI_INTB
+               case 1:
+#endif
+#ifdef USE_PCI_INTC
+               case 2:
+#endif
+#ifdef USE_PCI_INTD
+               case 3:
+#endif
+                       writel(INTRN_MASK_RX_EN, cp->regs +
+                              REG_PLUS_INTRN_MASK(ring));
+                       break;
+#endif
+               default:
+                       break;
+               }
+       }
+}
+
+static inline void cas_unmask_intr(struct cas *cp)
+{
+       int i;
+
+       for (i = 0; i < N_RX_COMP_RINGS; i++)
+               cas_enable_irq(cp, i);
+}
+
+static inline void cas_entropy_gather(struct cas *cp)
+{
+#ifdef USE_ENTROPY_DEV
+       if ((cp->cas_flags & CAS_FLAG_ENTROPY_DEV) == 0)
+               return;
+
+       batch_entropy_store(readl(cp->regs + REG_ENTROPY_IV),
+                           readl(cp->regs + REG_ENTROPY_IV),
+                           sizeof(uint64_t)*8);
+#endif
+}
+
+static inline void cas_entropy_reset(struct cas *cp)
+{
+#ifdef USE_ENTROPY_DEV
+       if ((cp->cas_flags & CAS_FLAG_ENTROPY_DEV) == 0)
+               return;
+
+       writel(BIM_LOCAL_DEV_PAD | BIM_LOCAL_DEV_PROM | BIM_LOCAL_DEV_EXT, 
+              cp->regs + REG_BIM_LOCAL_DEV_EN);
+       writeb(ENTROPY_RESET_STC_MODE, cp->regs + REG_ENTROPY_RESET);
+       writeb(0x55, cp->regs + REG_ENTROPY_RAND_REG);
+
+       /* if we read back 0x0, we don't have an entropy device */
+       if (readb(cp->regs + REG_ENTROPY_RAND_REG) == 0)
+               cp->cas_flags &= ~CAS_FLAG_ENTROPY_DEV;
+#endif
+}
+
+/* access to the phy. the following assumes that we've initialized the MIF to 
+ * be in frame rather than bit-bang mode
+ */
+static u16 cas_phy_read(struct cas *cp, int reg)
+{
+       u32 cmd;
+       int limit = STOP_TRIES_PHY;
+
+       cmd = MIF_FRAME_ST | MIF_FRAME_OP_READ;
+       cmd |= CAS_BASE(MIF_FRAME_PHY_ADDR, cp->phy_addr);
+       cmd |= CAS_BASE(MIF_FRAME_REG_ADDR, reg);
+       cmd |= MIF_FRAME_TURN_AROUND_MSB;
+       writel(cmd, cp->regs + REG_MIF_FRAME);
+       
+       /* poll for completion */
+       while (limit-- > 0) {
+               udelay(10);
+               cmd = readl(cp->regs + REG_MIF_FRAME);
+               if (cmd & MIF_FRAME_TURN_AROUND_LSB)
+                       return (cmd & MIF_FRAME_DATA_MASK);
+       }
+       return 0xFFFF; /* -1 */
+}
+
+static int cas_phy_write(struct cas *cp, int reg, u16 val)
+{
+       int limit = STOP_TRIES_PHY;
+       u32 cmd;
+
+       cmd = MIF_FRAME_ST | MIF_FRAME_OP_WRITE;
+       cmd |= CAS_BASE(MIF_FRAME_PHY_ADDR, cp->phy_addr);
+       cmd |= CAS_BASE(MIF_FRAME_REG_ADDR, reg);
+       cmd |= MIF_FRAME_TURN_AROUND_MSB;
+       cmd |= val & MIF_FRAME_DATA_MASK;
+       writel(cmd, cp->regs + REG_MIF_FRAME);
+       
+       /* poll for completion */
+       while (limit-- > 0) {
+               udelay(10);
+               cmd = readl(cp->regs + REG_MIF_FRAME);
+               if (cmd & MIF_FRAME_TURN_AROUND_LSB)
+                       return 0;
+       }
+       return -1;
+}
+
+static void cas_phy_powerup(struct cas *cp)
+{
+       u16 ctl = cas_phy_read(cp, MII_BMCR);   
+
+       if ((ctl & BMCR_PDOWN) == 0)
+               return;
+       ctl &= ~BMCR_PDOWN;
+       cas_phy_write(cp, MII_BMCR, ctl);
+}
+
+static void cas_phy_powerdown(struct cas *cp)
+{
+       u16 ctl = cas_phy_read(cp, MII_BMCR);   
+
+       if (ctl & BMCR_PDOWN)
+               return;
+       ctl |= BMCR_PDOWN;
+       cas_phy_write(cp, MII_BMCR, ctl);
+}
+
+/* cp->lock held. note: the last put_page will free the buffer */
+static int cas_page_free(struct cas *cp, cas_page_t *page)
+{
+       pci_unmap_page(cp->pdev, page->dma_addr, cp->page_size, 
+                      PCI_DMA_FROMDEVICE);
+       __free_pages(page->buffer, cp->page_order);
+       kfree(page);
+       return 0;
+}
+
+#ifdef RX_COUNT_BUFFERS
+#define RX_USED_ADD(x, y)       ((x)->used += (y))
+#define RX_USED_SET(x, y)       ((x)->used  = (y))
+#else
+#define RX_USED_ADD(x, y) 
+#define RX_USED_SET(x, y)
+#endif
+
+/* local page allocation routines for the receive buffers. jumbo pages
+ * require at least 8K contiguous and 8K aligned buffers.
+ */
+static cas_page_t *cas_page_alloc(struct cas *cp, const int flags)
+{
+       cas_page_t *page;
+
+       page = kmalloc(sizeof(cas_page_t), flags);
+       if (!page)
+               return NULL;
+
+       INIT_LIST_HEAD(&page->list);
+       RX_USED_SET(page, 0);
+       page->buffer = alloc_pages(flags, cp->page_order);
+       if (!page->buffer)
+               goto page_err;
+       page->dma_addr = pci_map_page(cp->pdev, page->buffer, 0,
+                                     cp->page_size, PCI_DMA_FROMDEVICE);
+       return page;
+
+page_err:
+       kfree(page);
+       return NULL;
+}
+
+/* initialize spare pool of rx buffers, but allocate during the open */
+static void cas_spare_init(struct cas *cp)
+{
+       spin_lock(&cp->rx_inuse_lock);
+       INIT_LIST_HEAD(&cp->rx_inuse_list);
+       spin_unlock(&cp->rx_inuse_lock);
+
+       spin_lock(&cp->rx_spare_lock);
+       INIT_LIST_HEAD(&cp->rx_spare_list);
+       cp->rx_spares_needed = RX_SPARE_COUNT;
+       spin_unlock(&cp->rx_spare_lock);
+}
+
+/* used on close. free all the spare buffers. */
+static void cas_spare_free(struct cas *cp)
+{
+       struct list_head list, *elem, *tmp;
+
+       /* free spare buffers */
+       INIT_LIST_HEAD(&list);
+       spin_lock(&cp->rx_spare_lock);
+       list_splice(&cp->rx_spare_list, &list);
+       INIT_LIST_HEAD(&cp->rx_spare_list);
+       spin_unlock(&cp->rx_spare_lock);
+       list_for_each_safe(elem, tmp, &list) {
+               cas_page_free(cp, list_entry(elem, cas_page_t, list));
+       }
+
+       INIT_LIST_HEAD(&list);
+#if 1
+       /*
+        * Looks like Adrian had protected this with a different
+        * lock than used everywhere else to manipulate this list.
+        */
+       spin_lock(&cp->rx_inuse_lock);
+       list_splice(&cp->rx_inuse_list, &list);
+       INIT_LIST_HEAD(&cp->rx_inuse_list);
+       spin_unlock(&cp->rx_inuse_lock);
+#else
+       spin_lock(&cp->rx_spare_lock);
+       list_splice(&cp->rx_inuse_list, &list);
+       INIT_LIST_HEAD(&cp->rx_inuse_list);
+       spin_unlock(&cp->rx_spare_lock);
+#endif
+       list_for_each_safe(elem, tmp, &list) {
+               cas_page_free(cp, list_entry(elem, cas_page_t, list));
+       }
+}
+
+/* replenish spares if needed */
+static void cas_spare_recover(struct cas *cp, const int flags)
+{
+       struct list_head list, *elem, *tmp;
+       int needed, i;
+
+       /* check inuse list. if we don't need any more free buffers,
+        * just free it
+        */
+
+       /* make a local copy of the list */
+       INIT_LIST_HEAD(&list);
+       spin_lock(&cp->rx_inuse_lock);
+       list_splice(&cp->rx_inuse_list, &list);
+       INIT_LIST_HEAD(&cp->rx_inuse_list);
+       spin_unlock(&cp->rx_inuse_lock);
+       
+       list_for_each_safe(elem, tmp, &list) {
+               cas_page_t *page = list_entry(elem, cas_page_t, list);
+
+               if (page_count(page->buffer) > 1) 
+                       continue;
+
+               list_del(elem);
+               spin_lock(&cp->rx_spare_lock);
+               if (cp->rx_spares_needed > 0) {
+                       list_add(elem, &cp->rx_spare_list);
+                       cp->rx_spares_needed--;
+                       spin_unlock(&cp->rx_spare_lock);
+               } else {
+                       spin_unlock(&cp->rx_spare_lock);
+                       cas_page_free(cp, page);
+               }
+       }
+
+       /* put any inuse buffers back on the list */
+       if (!list_empty(&list)) {
+               spin_lock(&cp->rx_inuse_lock);
+               list_splice(&list, &cp->rx_inuse_list);
+               spin_unlock(&cp->rx_inuse_lock);
+       }
+       
+       spin_lock(&cp->rx_spare_lock);
+       needed = cp->rx_spares_needed;
+       spin_unlock(&cp->rx_spare_lock);
+       if (!needed)
+               return;
+
+       /* we still need spares, so try to allocate some */
+       INIT_LIST_HEAD(&list);
+       i = 0;
+       while (i < needed) {
+               cas_page_t *spare = cas_page_alloc(cp, flags);
+               if (!spare) 
+                       break;
+               list_add(&spare->list, &list);
+               i++;
+       }
+
+       spin_lock(&cp->rx_spare_lock);
+       list_splice(&list, &cp->rx_spare_list);
+       cp->rx_spares_needed -= i;
+       spin_unlock(&cp->rx_spare_lock);
+}
+
+/* pull a page from the list. */
+static cas_page_t *cas_page_dequeue(struct cas *cp)
+{
+       struct list_head *entry;
+       int recover;
+
+       spin_lock(&cp->rx_spare_lock);
+       if (list_empty(&cp->rx_spare_list)) {
+               /* try to do a quick recovery */
+               spin_unlock(&cp->rx_spare_lock);
+               cas_spare_recover(cp, GFP_ATOMIC);
+               spin_lock(&cp->rx_spare_lock);
+               if (list_empty(&cp->rx_spare_list)) {
+                       if (netif_msg_rx_err(cp))
+                               printk(KERN_ERR "%s: no spare buffers "
+                                      "available.\n", cp->dev->name);
+                       spin_unlock(&cp->rx_spare_lock);
+                       return NULL;
+               }
+       }
+
+       entry = cp->rx_spare_list.next;
+       list_del(entry);
+       recover = ++cp->rx_spares_needed;
+       spin_unlock(&cp->rx_spare_lock);
+
+       /* trigger the timer to do the recovery */
+       if ((recover & (RX_SPARE_RECOVER_VAL - 1)) == 0) {
+#if 1
+               atomic_inc(&cp->reset_task_pending);
+               atomic_inc(&cp->reset_task_pending_spare);
+               schedule_work(&cp->reset_task);
+#else
+               atomic_set(&cp->reset_task_pending, CAS_RESET_SPARE);
+               schedule_work(&cp->reset_task);
+#endif
+       }
+       return list_entry(entry, cas_page_t, list);
+}
+
+
+static void cas_mif_poll(struct cas *cp, const int enable)
+{
+       u32 cfg;
+       
+       cfg  = readl(cp->regs + REG_MIF_CFG); 
+       cfg &= (MIF_CFG_MDIO_0 | MIF_CFG_MDIO_1);
+
+       if (cp->phy_type & CAS_PHY_MII_MDIO1)
+               cfg |= MIF_CFG_PHY_SELECT; 
+
+       /* poll and interrupt on link status change. */
+       if (enable) {
+               cfg |= MIF_CFG_POLL_EN;
+               cfg |= CAS_BASE(MIF_CFG_POLL_REG, MII_BMSR);
+               cfg |= CAS_BASE(MIF_CFG_POLL_PHY, cp->phy_addr);
+       }
+       writel((enable) ? ~(BMSR_LSTATUS | BMSR_ANEGCOMPLETE) : 0xFFFF, 
+              cp->regs + REG_MIF_MASK); 
+       writel(cfg, cp->regs + REG_MIF_CFG);
+}
+
+/* Must be invoked under cp->lock */
+static void cas_begin_auto_negotiation(struct cas *cp, struct ethtool_cmd *ep)
+{
+       u16 ctl;
+#if 1
+       int lcntl;
+       int changed = 0;
+       int oldstate = cp->lstate;
+       int link_was_not_down = !(oldstate == link_down);
+#endif
+       /* Setup link parameters */
+       if (!ep)
+               goto start_aneg;
+       lcntl = cp->link_cntl;
+       if (ep->autoneg == AUTONEG_ENABLE)
+               cp->link_cntl = BMCR_ANENABLE;
+       else {
+               cp->link_cntl = 0;
+               if (ep->speed == SPEED_100)
+                       cp->link_cntl |= BMCR_SPEED100;
+               else if (ep->speed == SPEED_1000)
+                       cp->link_cntl |= CAS_BMCR_SPEED1000;
+               if (ep->duplex == DUPLEX_FULL)
+                       cp->link_cntl |= BMCR_FULLDPLX;
+       }
+#if 1
+       changed = (lcntl != cp->link_cntl);
+#endif
+start_aneg:
+       if (cp->lstate == link_up) {
+               printk(KERN_INFO "%s: PCS link down.\n",
+                      cp->dev->name);
+       } else {
+               if (changed) {
+                       printk(KERN_INFO "%s: link configuration changed\n",
+                              cp->dev->name);
+               }
+       }
+       cp->lstate = link_down;
+       cp->link_transition = LINK_TRANSITION_LINK_DOWN;
+       if (!cp->hw_running)
+               return;
+#if 1
+       /*
+        * WTZ: If the old state was link_up, we turn off the carrier
+        * to replicate everything we do elsewhere on a link-down
+        * event when we were already in a link-up state..  
+        */
+       if (oldstate == link_up)
+               netif_carrier_off(cp->dev);
+       if (changed  && link_was_not_down) {
+               /*
+                * WTZ: This branch will simply schedule a full reset after
+                * we explicitly changed link modes in an ioctl. See if this
+                * fixes the link-problems we were having for forced mode. 
+                */
+               atomic_inc(&cp->reset_task_pending);
+               atomic_inc(&cp->reset_task_pending_all);
+               schedule_work(&cp->reset_task);
+               cp->timer_ticks = 0;
+               mod_timer(&cp->link_timer, jiffies + CAS_LINK_TIMEOUT);
+               return;
+       }
+#endif
+       if (cp->phy_type & CAS_PHY_SERDES) {
+               u32 val = readl(cp->regs + REG_PCS_MII_CTRL);
+
+               if (cp->link_cntl & BMCR_ANENABLE) {
+                       val |= (PCS_MII_RESTART_AUTONEG | PCS_MII_AUTONEG_EN);
+                       cp->lstate = link_aneg;
+               } else {
+                       if (cp->link_cntl & BMCR_FULLDPLX)
+                               val |= PCS_MII_CTRL_DUPLEX;
+                       val &= ~PCS_MII_AUTONEG_EN;
+                       cp->lstate = link_force_ok;
+               }
+               cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
+               writel(val, cp->regs + REG_PCS_MII_CTRL);
+
+       } else {
+               cas_mif_poll(cp, 0);
+               ctl = cas_phy_read(cp, MII_BMCR);
+               ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | 
+                        CAS_BMCR_SPEED1000 | BMCR_ANENABLE);
+               ctl |= cp->link_cntl;
+               if (ctl & BMCR_ANENABLE) {
+                       ctl |= BMCR_ANRESTART;
+                       cp->lstate = link_aneg;
+               } else {
+                       cp->lstate = link_force_ok;
+               }
+               cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
+               cas_phy_write(cp, MII_BMCR, ctl);
+               cas_mif_poll(cp, 1);
+       }
+
+       cp->timer_ticks = 0;
+       mod_timer(&cp->link_timer, jiffies + CAS_LINK_TIMEOUT);
+}
+
+/* Must be invoked under cp->lock. */
+static int cas_reset_mii_phy(struct cas *cp)
+{
+       int limit = STOP_TRIES_PHY;
+       u16 val;
+       
+       cas_phy_write(cp, MII_BMCR, BMCR_RESET);
+       udelay(100);
+       while (limit--) {
+               val = cas_phy_read(cp, MII_BMCR);
+               if ((val & BMCR_RESET) == 0)
+                       break;
+               udelay(10);
+       }
+       return (limit <= 0);
+}
+
+static void cas_saturn_firmware_load(struct cas *cp)
+{
+       cas_saturn_patch_t *patch = cas_saturn_patch;
+
+       cas_phy_powerdown(cp);
+
+       /* expanded memory access mode */
+       cas_phy_write(cp, DP83065_MII_MEM, 0x0);
+
+       /* pointer configuration for new firmware */
+       cas_phy_write(cp, DP83065_MII_REGE, 0x8ff9);
+       cas_phy_write(cp, DP83065_MII_REGD, 0xbd);
+       cas_phy_write(cp, DP83065_MII_REGE, 0x8ffa);
+       cas_phy_write(cp, DP83065_MII_REGD, 0x82);
+       cas_phy_write(cp, DP83065_MII_REGE, 0x8ffb);
+       cas_phy_write(cp, DP83065_MII_REGD, 0x0);
+       cas_phy_write(cp, DP83065_MII_REGE, 0x8ffc);
+       cas_phy_write(cp, DP83065_MII_REGD, 0x39);
+
+       /* download new firmware */
+       cas_phy_write(cp, DP83065_MII_MEM, 0x1);
+       cas_phy_write(cp, DP83065_MII_REGE, patch->addr);
+       while (patch->addr) {
+               cas_phy_write(cp, DP83065_MII_REGD, patch->val);
+               patch++;
+       }
+
+       /* enable firmware */
+       cas_phy_write(cp, DP83065_MII_REGE, 0x8ff8);
+       cas_phy_write(cp, DP83065_MII_REGD, 0x1);
+}
+
+
+/* phy initialization */
+static void cas_phy_init(struct cas *cp)
+{
+       u16 val;
+
+       /* if we're in MII/GMII mode, set up phy */
+       if (CAS_PHY_MII(cp->phy_type)) {
+               writel(PCS_DATAPATH_MODE_MII,
+                      cp->regs + REG_PCS_DATAPATH_MODE);
+
+               cas_mif_poll(cp, 0);
+               cas_reset_mii_phy(cp); /* take out of isolate mode */
+
+               if (PHY_LUCENT_B0 == cp->phy_id) {
+                       /* workaround link up/down issue with lucent */
+                       cas_phy_write(cp, LUCENT_MII_REG, 0x8000);
+                       cas_phy_write(cp, MII_BMCR, 0x00f1);
+                       cas_phy_write(cp, LUCENT_MII_REG, 0x0);
+
+               } else if (PHY_BROADCOM_B0 == (cp->phy_id & 0xFFFFFFFC)) {
+                       /* workarounds for broadcom phy */
+                       cas_phy_write(cp, BROADCOM_MII_REG8, 0x0C20);
+                       cas_phy_write(cp, BROADCOM_MII_REG7, 0x0012);
+                       cas_phy_write(cp, BROADCOM_MII_REG5, 0x1804);
+                       cas_phy_write(cp, BROADCOM_MII_REG7, 0x0013);
+                       cas_phy_write(cp, BROADCOM_MII_REG5, 0x1204);
+                       cas_phy_write(cp, BROADCOM_MII_REG7, 0x8006);
+                       cas_phy_write(cp, BROADCOM_MII_REG5, 0x0132);
+                       cas_phy_write(cp, BROADCOM_MII_REG7, 0x8006);
+                       cas_phy_write(cp, BROADCOM_MII_REG5, 0x0232);
+                       cas_phy_write(cp, BROADCOM_MII_REG7, 0x201F);
+                       cas_phy_write(cp, BROADCOM_MII_REG5, 0x0A20);
+
+               } else if (PHY_BROADCOM_5411 == cp->phy_id) {
+                       val = cas_phy_read(cp, BROADCOM_MII_REG4);
+                       val = cas_phy_read(cp, BROADCOM_MII_REG4);
+                       if (val & 0x0080) {
+                               /* link workaround */
+                               cas_phy_write(cp, BROADCOM_MII_REG4, 
+                                             val & ~0x0080);
+                       }
+                       
+               } else if (cp->cas_flags & CAS_FLAG_SATURN) {
+                       writel((cp->phy_type & CAS_PHY_MII_MDIO0) ? 
+                              SATURN_PCFG_FSI : 0x0, 
+                              cp->regs + REG_SATURN_PCFG);
+
+                       /* load firmware to address 10Mbps auto-negotiation
+                        * issue. NOTE: this will need to be changed if the 
+                        * default firmware gets fixed.
+                        */
+                       if (PHY_NS_DP83065 == cp->phy_id) {
+                               cas_saturn_firmware_load(cp);
+                       }
+                       cas_phy_powerup(cp);
+               }
+
+               /* advertise capabilities */
+               val = cas_phy_read(cp, MII_BMCR);
+               val &= ~BMCR_ANENABLE;
+               cas_phy_write(cp, MII_BMCR, val);
+               udelay(10);
+
+               cas_phy_write(cp, MII_ADVERTISE,
+                             cas_phy_read(cp, MII_ADVERTISE) |
+                             (ADVERTISE_10HALF | ADVERTISE_10FULL |
+                              ADVERTISE_100HALF | ADVERTISE_100FULL |
+                              CAS_ADVERTISE_PAUSE | 
+                              CAS_ADVERTISE_ASYM_PAUSE));
+               
+               if (cp->cas_flags & CAS_FLAG_1000MB_CAP) {
+                       /* make sure that we don't advertise half
+                        * duplex to avoid a chip issue
+                        */
+                       val  = cas_phy_read(cp, CAS_MII_1000_CTRL);
+                       val &= ~CAS_ADVERTISE_1000HALF;
+                       val |= CAS_ADVERTISE_1000FULL;
+                       cas_phy_write(cp, CAS_MII_1000_CTRL, val);
+               }
+
+       } else {
+               /* reset pcs for serdes */
+               u32 val;
+               int limit;
+
+               writel(PCS_DATAPATH_MODE_SERDES,
+                      cp->regs + REG_PCS_DATAPATH_MODE);
+
+               /* enable serdes pins on saturn */
+               if (cp->cas_flags & CAS_FLAG_SATURN)
+                       writel(0, cp->regs + REG_SATURN_PCFG);
+
+               /* Reset PCS unit. */
+               val = readl(cp->regs + REG_PCS_MII_CTRL);
+               val |= PCS_MII_RESET;
+               writel(val, cp->regs + REG_PCS_MII_CTRL);
+
+               limit = STOP_TRIES;
+               while (limit-- > 0) {
+                       udelay(10);
+                       if ((readl(cp->regs + REG_PCS_MII_CTRL) & 
+                            PCS_MII_RESET) == 0)
+                               break;
+               }
+               if (limit <= 0)
+                       printk(KERN_WARNING "%s: PCS reset bit would not "
+                              "clear [%08x].\n", cp->dev->name,
+                              readl(cp->regs + REG_PCS_STATE_MACHINE));
+
+               /* Make sure PCS is disabled while changing advertisement
+                * configuration.
+                */
+               writel(0x0, cp->regs + REG_PCS_CFG);
+
+               /* Advertise all capabilities except half-duplex. */
+               val  = readl(cp->regs + REG_PCS_MII_ADVERT);
+               val &= ~PCS_MII_ADVERT_HD;
+               val |= (PCS_MII_ADVERT_FD | PCS_MII_ADVERT_SYM_PAUSE | 
+                       PCS_MII_ADVERT_ASYM_PAUSE);
+               writel(val, cp->regs + REG_PCS_MII_ADVERT);
+
+               /* enable PCS */
+               writel(PCS_CFG_EN, cp->regs + REG_PCS_CFG);
+
+               /* pcs workaround: enable sync detect */
+               writel(PCS_SERDES_CTRL_SYNCD_EN,
+                      cp->regs + REG_PCS_SERDES_CTRL);
+       }
+}
+
+
+static int cas_pcs_link_check(struct cas *cp)
+{
+       u32 stat, state_machine;
+       int retval = 0;
+
+       /* The link status bit latches on zero, so you must
+        * read it twice in such a case to see a transition
+        * to the link being up.
+        */
+       stat = readl(cp->regs + REG_PCS_MII_STATUS);
+       if ((stat & PCS_MII_STATUS_LINK_STATUS) == 0)
+               stat = readl(cp->regs + REG_PCS_MII_STATUS);
+
+       /* The remote-fault indication is only valid
+        * when autoneg has completed.
+        */
+       if ((stat & (PCS_MII_STATUS_AUTONEG_COMP |
+                    PCS_MII_STATUS_REMOTE_FAULT)) ==
+           (PCS_MII_STATUS_AUTONEG_COMP | PCS_MII_STATUS_REMOTE_FAULT)) {
+               if (netif_msg_link(cp))
+                       printk(KERN_INFO "%s: PCS RemoteFault\n", 
+                              cp->dev->name);
+       }
+
+       /* work around link detection issue by querying the PCS state
+        * machine directly.
+        */
+       state_machine = readl(cp->regs + REG_PCS_STATE_MACHINE);
+       if ((state_machine & PCS_SM_LINK_STATE_MASK) != SM_LINK_STATE_UP) {
+               stat &= ~PCS_MII_STATUS_LINK_STATUS;
+       } else if (state_machine & PCS_SM_WORD_SYNC_STATE_MASK) {
+               stat |= PCS_MII_STATUS_LINK_STATUS;
+       }
+
+       if (stat & PCS_MII_STATUS_LINK_STATUS) {
+               if (cp->lstate != link_up) {
+                       if (cp->opened) {
+                               cp->lstate = link_up;
+                               cp->link_transition = LINK_TRANSITION_LINK_UP;
+                               
+                               cas_set_link_modes(cp);
+                               netif_carrier_on(cp->dev);
+                       }
+               }
+       } else if (cp->lstate == link_up) {
+               cp->lstate = link_down;
+               if (link_transition_timeout != 0 &&
+                   cp->link_transition != LINK_TRANSITION_REQUESTED_RESET &&
+                   !cp->link_transition_jiffies_valid) {
+                       /*
+                        * force a reset, as a workaround for the 
+                        * link-failure problem. May want to move this to a 
+                        * point a bit earlier in the sequence. If we had
+                        * generated a reset a short time ago, we'll wait for
+                        * the link timer to check the status until a
+                        * timer expires (link_transistion_jiffies_valid is
+                        * true when the timer is running.)  Instead of using
+                        * a system timer, we just do a check whenever the
+                        * link timer is running - this clears the flag after
+                        * a suitable delay.
+                        */
+                       retval = 1;
+                       cp->link_transition = LINK_TRANSITION_REQUESTED_RESET;
+                       cp->link_transition_jiffies = jiffies;
+                       cp->link_transition_jiffies_valid = 1;
+               } else {
+                       cp->link_transition = LINK_TRANSITION_ON_FAILURE;
+               }
+               netif_carrier_off(cp->dev);
+               if (cp->opened && netif_msg_link(cp)) {
+                       printk(KERN_INFO "%s: PCS link down.\n",
+                              cp->dev->name);
+               }
+
+               /* Cassini only: if you force a mode, there can be
+                * sync problems on link down. to fix that, the following
+                * things need to be checked:
+                * 1) read serialink state register
+                * 2) read pcs status register to verify link down.
+                * 3) if link down and serial link == 0x03, then you need
+                *    to global reset the chip.
+                */
+               if ((cp->cas_flags & CAS_FLAG_REG_PLUS) == 0) {
+                       /* should check to see if we're in a forced mode */
+                       stat = readl(cp->regs + REG_PCS_SERDES_STATE);
+                       if (stat == 0x03)
+                               return 1;
+               }
+       } else if (cp->lstate == link_down) {
+               if (link_transition_timeout != 0 &&
+                   cp->link_transition != LINK_TRANSITION_REQUESTED_RESET &&
+                   !cp->link_transition_jiffies_valid) {
+                       /* force a reset, as a workaround for the
+                        * link-failure problem.  May want to move
+                        * this to a point a bit earlier in the
+                        * sequence.
+                        */
+                       retval = 1;
+                       cp->link_transition = LINK_TRANSITION_REQUESTED_RESET;
+                       cp->link_transition_jiffies = jiffies;
+                       cp->link_transition_jiffies_valid = 1;
+               } else {
+                       cp->link_transition = LINK_TRANSITION_STILL_FAILED;
+               }
+       }
+
+       return retval;
+}
+
+static int cas_pcs_interrupt(struct net_device *dev, 
+                            struct cas *cp, u32 status)
+{
+       u32 stat = readl(cp->regs + REG_PCS_INTR_STATUS);
+
+       if ((stat & PCS_INTR_STATUS_LINK_CHANGE) == 0) 
+               return 0;
+       return cas_pcs_link_check(cp);
+}
+
+static int cas_txmac_interrupt(struct net_device *dev, 
+                              struct cas *cp, u32 status)
+{
+       u32 txmac_stat = readl(cp->regs + REG_MAC_TX_STATUS);
+
+       if (!txmac_stat)
+               return 0;
+
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: txmac interrupt, txmac_stat: 0x%x\n",
+                       cp->dev->name, txmac_stat);
+
+       /* Defer timer expiration is quite normal,
+        * don't even log the event.
+        */
+       if ((txmac_stat & MAC_TX_DEFER_TIMER) &&
+           !(txmac_stat & ~MAC_TX_DEFER_TIMER))
+               return 0;
+
+       spin_lock(&cp->stat_lock[0]);
+       if (txmac_stat & MAC_TX_UNDERRUN) {
+               printk(KERN_ERR "%s: TX MAC xmit underrun.\n",
+                      dev->name);
+               cp->net_stats[0].tx_fifo_errors++;
+       }
+
+       if (txmac_stat & MAC_TX_MAX_PACKET_ERR) {
+               printk(KERN_ERR "%s: TX MAC max packet size error.\n",
+                      dev->name);
+               cp->net_stats[0].tx_errors++;
+       }
+
+       /* The rest are all cases of one of the 16-bit TX
+        * counters expiring.
+        */
+       if (txmac_stat & MAC_TX_COLL_NORMAL)
+               cp->net_stats[0].collisions += 0x10000;
+
+       if (txmac_stat & MAC_TX_COLL_EXCESS) {
+               cp->net_stats[0].tx_aborted_errors += 0x10000;
+               cp->net_stats[0].collisions += 0x10000;
+       }
+
+       if (txmac_stat & MAC_TX_COLL_LATE) {
+               cp->net_stats[0].tx_aborted_errors += 0x10000;
+               cp->net_stats[0].collisions += 0x10000;
+       }
+       spin_unlock(&cp->stat_lock[0]);
+
+       /* We do not keep track of MAC_TX_COLL_FIRST and
+        * MAC_TX_PEAK_ATTEMPTS events.
+        */
+       return 0;
+}
+
+static void cas_load_firmware(struct cas *cp, cas_hp_inst_t *firmware) 
+{
+       cas_hp_inst_t *inst;
+       u32 val;
+       int i;
+
+       i = 0;
+       while ((inst = firmware) && inst->note) {
+               writel(i, cp->regs + REG_HP_INSTR_RAM_ADDR);
+
+               val = CAS_BASE(HP_INSTR_RAM_HI_VAL, inst->val);
+               val |= CAS_BASE(HP_INSTR_RAM_HI_MASK, inst->mask);
+               writel(val, cp->regs + REG_HP_INSTR_RAM_DATA_HI);
+
+               val = CAS_BASE(HP_INSTR_RAM_MID_OUTARG, inst->outarg >> 10);
+               val |= CAS_BASE(HP_INSTR_RAM_MID_OUTOP, inst->outop);
+               val |= CAS_BASE(HP_INSTR_RAM_MID_FNEXT, inst->fnext);
+               val |= CAS_BASE(HP_INSTR_RAM_MID_FOFF, inst->foff);
+               val |= CAS_BASE(HP_INSTR_RAM_MID_SNEXT, inst->snext);
+               val |= CAS_BASE(HP_INSTR_RAM_MID_SOFF, inst->soff);
+               val |= CAS_BASE(HP_INSTR_RAM_MID_OP, inst->op);
+               writel(val, cp->regs + REG_HP_INSTR_RAM_DATA_MID);
+
+               val = CAS_BASE(HP_INSTR_RAM_LOW_OUTMASK, inst->outmask);
+               val |= CAS_BASE(HP_INSTR_RAM_LOW_OUTSHIFT, inst->outshift);
+               val |= CAS_BASE(HP_INSTR_RAM_LOW_OUTEN, inst->outenab);
+               val |= CAS_BASE(HP_INSTR_RAM_LOW_OUTARG, inst->outarg);
+               writel(val, cp->regs + REG_HP_INSTR_RAM_DATA_LOW);
+               ++firmware;
+               ++i;
+       }
+}
+
+static void cas_init_rx_dma(struct cas *cp)
+{
+       u64 desc_dma = cp->block_dvma; 
+       u32 val;
+       int i, size;
+
+       /* rx free descriptors */
+       val = CAS_BASE(RX_CFG_SWIVEL, RX_SWIVEL_OFF_VAL); 
+       val |= CAS_BASE(RX_CFG_DESC_RING, RX_DESC_RINGN_INDEX(0));
+       val |= CAS_BASE(RX_CFG_COMP_RING, RX_COMP_RINGN_INDEX(0));
+       if ((N_RX_DESC_RINGS > 1) &&
+           (cp->cas_flags & CAS_FLAG_REG_PLUS))  /* do desc 2 */
+               val |= CAS_BASE(RX_CFG_DESC_RING1, RX_DESC_RINGN_INDEX(1));
+       writel(val, cp->regs + REG_RX_CFG);
+
+       val = (unsigned long) cp->init_rxds[0] - 
+               (unsigned long) cp->init_block;
+       writel((desc_dma + val) >> 32, cp->regs + REG_RX_DB_HI);
+       writel((desc_dma + val) & 0xffffffff, cp->regs + REG_RX_DB_LOW);
+       writel(RX_DESC_RINGN_SIZE(0) - 4, cp->regs + REG_RX_KICK);
+
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               /* rx desc 2 is for IPSEC packets. however, 
+                * we don't it that for that purpose.
+                */
+               val = (unsigned long) cp->init_rxds[1] - 
+                       (unsigned long) cp->init_block;
+               writel((desc_dma + val) >> 32, cp->regs + REG_PLUS_RX_DB1_HI);
+               writel((desc_dma + val) & 0xffffffff, cp->regs + 
+                      REG_PLUS_RX_DB1_LOW);
+               writel(RX_DESC_RINGN_SIZE(1) - 4, cp->regs + 
+                      REG_PLUS_RX_KICK1);
+       }
+       
+       /* rx completion registers */
+       val = (unsigned long) cp->init_rxcs[0] - 
+               (unsigned long) cp->init_block;
+       writel((desc_dma + val) >> 32, cp->regs + REG_RX_CB_HI);
+       writel((desc_dma + val) & 0xffffffff, cp->regs + REG_RX_CB_LOW);
+
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               /* rx comp 2-4 */
+               for (i = 1; i < MAX_RX_COMP_RINGS; i++) {
+                       val = (unsigned long) cp->init_rxcs[i] - 
+                               (unsigned long) cp->init_block;
+                       writel((desc_dma + val) >> 32, cp->regs + 
+                              REG_PLUS_RX_CBN_HI(i));
+                       writel((desc_dma + val) & 0xffffffff, cp->regs + 
+                              REG_PLUS_RX_CBN_LOW(i));
+               }
+       }
+
+       /* read selective clear regs to prevent spurious interrupts
+        * on reset because complete == kick.
+        * selective clear set up to prevent interrupts on resets
+        */
+       readl(cp->regs + REG_INTR_STATUS_ALIAS);
+       writel(INTR_RX_DONE | INTR_RX_BUF_UNAVAIL, cp->regs + REG_ALIAS_CLEAR);
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               for (i = 1; i < N_RX_COMP_RINGS; i++)
+                       readl(cp->regs + REG_PLUS_INTRN_STATUS_ALIAS(i));
+
+               /* 2 is different from 3 and 4 */
+               if (N_RX_COMP_RINGS > 1)
+                       writel(INTR_RX_DONE_ALT | INTR_RX_BUF_UNAVAIL_1, 
+                              cp->regs + REG_PLUS_ALIASN_CLEAR(1));
+
+               for (i = 2; i < N_RX_COMP_RINGS; i++) 
+                       writel(INTR_RX_DONE_ALT, 
+                              cp->regs + REG_PLUS_ALIASN_CLEAR(i));
+       }
+
+       /* set up pause thresholds */
+       val  = CAS_BASE(RX_PAUSE_THRESH_OFF,
+                       cp->rx_pause_off / RX_PAUSE_THRESH_QUANTUM);
+       val |= CAS_BASE(RX_PAUSE_THRESH_ON, 
+                       cp->rx_pause_on / RX_PAUSE_THRESH_QUANTUM);
+       writel(val, cp->regs + REG_RX_PAUSE_THRESH);
+       
+       /* zero out dma reassembly buffers */
+       for (i = 0; i < 64; i++) {
+               writel(i, cp->regs + REG_RX_TABLE_ADDR);
+               writel(0x0, cp->regs + REG_RX_TABLE_DATA_LOW);
+               writel(0x0, cp->regs + REG_RX_TABLE_DATA_MID);
+               writel(0x0, cp->regs + REG_RX_TABLE_DATA_HI);
+       }
+
+       /* make sure address register is 0 for normal operation */
+       writel(0x0, cp->regs + REG_RX_CTRL_FIFO_ADDR);
+       writel(0x0, cp->regs + REG_RX_IPP_FIFO_ADDR);
+
+       /* interrupt mitigation */
+#ifdef USE_RX_BLANK
+       val = CAS_BASE(RX_BLANK_INTR_TIME, RX_BLANK_INTR_TIME_VAL);
+       val |= CAS_BASE(RX_BLANK_INTR_PKT, RX_BLANK_INTR_PKT_VAL);
+       writel(val, cp->regs + REG_RX_BLANK);
+#else
+       writel(0x0, cp->regs + REG_RX_BLANK);
+#endif
+
+       /* interrupt generation as a function of low water marks for
+        * free desc and completion entries. these are used to trigger
+        * housekeeping for rx descs. we don't use the free interrupt
+        * as it's not very useful
+        */
+       /* val = CAS_BASE(RX_AE_THRESH_FREE, RX_AE_FREEN_VAL(0)); */
+       val = CAS_BASE(RX_AE_THRESH_COMP, RX_AE_COMP_VAL);
+       writel(val, cp->regs + REG_RX_AE_THRESH);
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               val = CAS_BASE(RX_AE1_THRESH_FREE, RX_AE_FREEN_VAL(1));
+               writel(val, cp->regs + REG_PLUS_RX_AE1_THRESH);
+       }
+
+       /* Random early detect registers. useful for congestion avoidance.
+        * this should be tunable.
+        */
+       writel(0x0, cp->regs + REG_RX_RED);
+       
+       /* receive page sizes. default == 2K (0x800) */
+       val = 0;
+       if (cp->page_size == 0x1000)
+               val = 0x1;
+       else if (cp->page_size == 0x2000)
+               val = 0x2;
+       else if (cp->page_size == 0x4000)
+               val = 0x3;
+       
+       /* round mtu + offset. constrain to page size. */
+       size = cp->dev->mtu + 64;
+       if (size > cp->page_size)
+               size = cp->page_size;
+
+       if (size <= 0x400)
+               i = 0x0;
+       else if (size <= 0x800)
+               i = 0x1;
+       else if (size <= 0x1000)
+               i = 0x2;
+       else
+               i = 0x3;
+
+       cp->mtu_stride = 1 << (i + 10);
+       val  = CAS_BASE(RX_PAGE_SIZE, val);
+       val |= CAS_BASE(RX_PAGE_SIZE_MTU_STRIDE, i); 
+       val |= CAS_BASE(RX_PAGE_SIZE_MTU_COUNT, cp->page_size >> (i + 10));
+       val |= CAS_BASE(RX_PAGE_SIZE_MTU_OFF, 0x1);
+       writel(val, cp->regs + REG_RX_PAGE_SIZE);
+       
+       /* enable the header parser if desired */
+       if (CAS_HP_FIRMWARE == cas_prog_null)
+               return;
+
+       val = CAS_BASE(HP_CFG_NUM_CPU, CAS_NCPUS > 63 ? 0 : CAS_NCPUS);
+       val |= HP_CFG_PARSE_EN | HP_CFG_SYN_INC_MASK;
+       val |= CAS_BASE(HP_CFG_TCP_THRESH, HP_TCP_THRESH_VAL);
+       writel(val, cp->regs + REG_HP_CFG);
+}
+
+static inline void cas_rxc_init(struct cas_rx_comp *rxc)
+{
+       memset(rxc, 0, sizeof(*rxc));
+       rxc->word4 = cpu_to_le64(RX_COMP4_ZERO); 
+}
+
+/* NOTE: we use the ENC RX DESC ring for spares. the rx_page[0,1]
+ * flipping is protected by the fact that the chip will not
+ * hand back the same page index while it's being processed.
+ */
+static inline cas_page_t *cas_page_spare(struct cas *cp, const int index)
+{
+       cas_page_t *page = cp->rx_pages[1][index];
+       cas_page_t *new;
+
+       if (page_count(page->buffer) == 1)
+               return page;
+
+       new = cas_page_dequeue(cp);
+       if (new) {
+               spin_lock(&cp->rx_inuse_lock);
+               list_add(&page->list, &cp->rx_inuse_list);
+               spin_unlock(&cp->rx_inuse_lock);
+       }
+       return new;
+}
+                                  
+/* this needs to be changed if we actually use the ENC RX DESC ring */
+static cas_page_t *cas_page_swap(struct cas *cp, const int ring, 
+                                const int index)
+{
+       cas_page_t **page0 = cp->rx_pages[0];
+       cas_page_t **page1 = cp->rx_pages[1];
+
+       /* swap if buffer is in use */
+       if (page_count(page0[index]->buffer) > 1) {
+               cas_page_t *new = cas_page_spare(cp, index);
+               if (new) {
+                       page1[index] = page0[index];
+                       page0[index] = new;
+               }
+       } 
+       RX_USED_SET(page0[index], 0);
+       return page0[index];
+}
+
+static void cas_clean_rxds(struct cas *cp)
+{
+       /* only clean ring 0 as ring 1 is used for spare buffers */
+        struct cas_rx_desc *rxd = cp->init_rxds[0];
+       int i, size;
+
+       /* release all rx flows */
+       for (i = 0; i < N_RX_FLOWS; i++) {
+               struct sk_buff *skb;
+               while ((skb = __skb_dequeue(&cp->rx_flows[i]))) {
+                       cas_skb_release(skb);
+               }
+       }
+
+       /* initialize descriptors */
+       size = RX_DESC_RINGN_SIZE(0);
+       for (i = 0; i < size; i++) {
+               cas_page_t *page = cas_page_swap(cp, 0, i);
+               rxd[i].buffer = cpu_to_le64(page->dma_addr);
+               rxd[i].index  = cpu_to_le64(CAS_BASE(RX_INDEX_NUM, i) | 
+                                           CAS_BASE(RX_INDEX_RING, 0));
+       }
+
+       cp->rx_old[0]  = RX_DESC_RINGN_SIZE(0) - 4; 
+       cp->rx_last[0] = 0;
+       cp->cas_flags &= ~CAS_FLAG_RXD_POST(0);
+}
+
+static void cas_clean_rxcs(struct cas *cp)
+{
+       int i, j;
+
+       /* take ownership of rx comp descriptors */
+       memset(cp->rx_cur, 0, sizeof(*cp->rx_cur)*N_RX_COMP_RINGS);
+       memset(cp->rx_new, 0, sizeof(*cp->rx_new)*N_RX_COMP_RINGS);
+       for (i = 0; i < N_RX_COMP_RINGS; i++) {
+               struct cas_rx_comp *rxc = cp->init_rxcs[i];
+               for (j = 0; j < RX_COMP_RINGN_SIZE(i); j++) {
+                       cas_rxc_init(rxc + j);
+               }
+       }
+}
+
+#if 0
+/* When we get a RX fifo overflow, the RX unit is probably hung
+ * so we do the following.
+ *
+ * If any part of the reset goes wrong, we return 1 and that causes the
+ * whole chip to be reset.
+ */
+static int cas_rxmac_reset(struct cas *cp)
+{
+       struct net_device *dev = cp->dev;
+       int limit;
+       u32 val;
+
+       /* First, reset MAC RX. */
+       writel(cp->mac_rx_cfg & ~MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
+       for (limit = 0; limit < STOP_TRIES; limit++) {
+               if (!(readl(cp->regs + REG_MAC_RX_CFG) & MAC_RX_CFG_EN))
+                       break;
+               udelay(10);
+       }
+       if (limit == STOP_TRIES) {
+               printk(KERN_ERR "%s: RX MAC will not disable, resetting whole "
+                      "chip.\n", dev->name);
+               return 1;
+       }
+
+       /* Second, disable RX DMA. */
+       writel(0, cp->regs + REG_RX_CFG);
+       for (limit = 0; limit < STOP_TRIES; limit++) {
+               if (!(readl(cp->regs + REG_RX_CFG) & RX_CFG_DMA_EN))
+                       break;
+               udelay(10);
+       }
+       if (limit == STOP_TRIES) {
+               printk(KERN_ERR "%s: RX DMA will not disable, resetting whole "
+                      "chip.\n", dev->name);
+               return 1;
+       }
+
+       mdelay(5);
+
+       /* Execute RX reset command. */
+       writel(SW_RESET_RX, cp->regs + REG_SW_RESET);
+       for (limit = 0; limit < STOP_TRIES; limit++) {
+               if (!(readl(cp->regs + REG_SW_RESET) & SW_RESET_RX))
+                       break;
+               udelay(10);
+       }
+       if (limit == STOP_TRIES) {
+               printk(KERN_ERR "%s: RX reset command will not execute, "
+                      "resetting whole chip.\n", dev->name);
+               return 1;
+       }
+
+       /* reset driver rx state */
+       cas_clean_rxds(cp);
+       cas_clean_rxcs(cp);
+
+       /* Now, reprogram the rest of RX unit. */
+       cas_init_rx_dma(cp);
+
+       /* re-enable */
+       val = readl(cp->regs + REG_RX_CFG);
+       writel(val | RX_CFG_DMA_EN, cp->regs + REG_RX_CFG);
+       writel(MAC_RX_FRAME_RECV, cp->regs + REG_MAC_RX_MASK);
+       val = readl(cp->regs + REG_MAC_RX_CFG);
+       writel(val | MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
+       return 0;
+}
+#endif
+
+static int cas_rxmac_interrupt(struct net_device *dev, struct cas *cp,
+                              u32 status)
+{
+       u32 stat = readl(cp->regs + REG_MAC_RX_STATUS);
+
+       if (!stat)
+               return 0;
+
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: rxmac interrupt, stat: 0x%x\n",
+                       cp->dev->name, stat);
+
+       /* these are all rollovers */
+       spin_lock(&cp->stat_lock[0]);
+       if (stat & MAC_RX_ALIGN_ERR) 
+               cp->net_stats[0].rx_frame_errors += 0x10000;
+
+       if (stat & MAC_RX_CRC_ERR)
+               cp->net_stats[0].rx_crc_errors += 0x10000;
+
+       if (stat & MAC_RX_LEN_ERR)
+               cp->net_stats[0].rx_length_errors += 0x10000;
+
+       if (stat & MAC_RX_OVERFLOW) {
+               cp->net_stats[0].rx_over_errors++;
+               cp->net_stats[0].rx_fifo_errors++;
+       }
+
+       /* We do not track MAC_RX_FRAME_COUNT and MAC_RX_VIOL_ERR
+        * events.
+        */
+       spin_unlock(&cp->stat_lock[0]);
+       return 0;
+}
+
+static int cas_mac_interrupt(struct net_device *dev, struct cas *cp,
+                            u32 status)
+{
+       u32 stat = readl(cp->regs + REG_MAC_CTRL_STATUS);
+
+       if (!stat)
+               return 0;
+
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: mac interrupt, stat: 0x%x\n",
+                       cp->dev->name, stat);
+
+       /* This interrupt is just for pause frame and pause
+        * tracking.  It is useful for diagnostics and debug
+        * but probably by default we will mask these events.
+        */
+       if (stat & MAC_CTRL_PAUSE_STATE)
+               cp->pause_entered++;
+
+       if (stat & MAC_CTRL_PAUSE_RECEIVED)
+               cp->pause_last_time_recvd = (stat >> 16);
+
+       return 0;
+}
+
+       
+/* Must be invoked under cp->lock. */
+static inline int cas_mdio_link_not_up(struct cas *cp)
+{
+       u16 val;
+       
+       switch (cp->lstate) {
+       case link_force_ret:
+               if (netif_msg_link(cp))
+                       printk(KERN_INFO "%s: Autoneg failed again, keeping"
+                               " forced mode\n", cp->dev->name);
+               cas_phy_write(cp, MII_BMCR, cp->link_fcntl);
+               cp->timer_ticks = 5;
+               cp->lstate = link_force_ok;
+               cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
+               break;
+               
+       case link_aneg:
+               val = cas_phy_read(cp, MII_BMCR);
+
+               /* Try forced modes. we try things in the following order:
+                * 1000 full -> 100 full/half -> 10 half
+                */
+               val &= ~(BMCR_ANRESTART | BMCR_ANENABLE);
+               val |= BMCR_FULLDPLX;
+               val |= (cp->cas_flags & CAS_FLAG_1000MB_CAP) ? 
+                       CAS_BMCR_SPEED1000 : BMCR_SPEED100;
+               cas_phy_write(cp, MII_BMCR, val);
+               cp->timer_ticks = 5;
+               cp->lstate = link_force_try;
+               cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
+               break;
+
+       case link_force_try:
+               /* Downgrade from 1000 to 100 to 10 Mbps if necessary. */
+               val = cas_phy_read(cp, MII_BMCR);
+               cp->timer_ticks = 5;
+               if (val & CAS_BMCR_SPEED1000) { /* gigabit */
+                       val &= ~CAS_BMCR_SPEED1000;
+                       val |= (BMCR_SPEED100 | BMCR_FULLDPLX);
+                       cas_phy_write(cp, MII_BMCR, val);
+                       break;
+               }
+
+               if (val & BMCR_SPEED100) {
+                       if (val & BMCR_FULLDPLX) /* fd failed */
+                               val &= ~BMCR_FULLDPLX;
+                       else { /* 100Mbps failed */
+                               val &= ~BMCR_SPEED100;
+                       }
+                       cas_phy_write(cp, MII_BMCR, val);
+                       break;
+               }
+       default:
+               break;
+       }
+       return 0;
+}
+
+
+/* must be invoked with cp->lock held */
+static int cas_mii_link_check(struct cas *cp, const u16 bmsr)
+{
+       int restart;
+
+       if (bmsr & BMSR_LSTATUS) {
+               /* Ok, here we got a link. If we had it due to a forced
+                * fallback, and we were configured for autoneg, we 
+                * retry a short autoneg pass. If you know your hub is
+                * broken, use ethtool ;)
+                */
+               if ((cp->lstate == link_force_try) && 
+                   (cp->link_cntl & BMCR_ANENABLE)) {
+                       cp->lstate = link_force_ret;
+                       cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
+                       cas_mif_poll(cp, 0);
+                       cp->link_fcntl = cas_phy_read(cp, MII_BMCR);
+                       cp->timer_ticks = 5;
+                       if (cp->opened && netif_msg_link(cp))
+                               printk(KERN_INFO "%s: Got link after fallback, retrying"
+                                      " autoneg once...\n", cp->dev->name);
+                       cas_phy_write(cp, MII_BMCR,
+                                     cp->link_fcntl | BMCR_ANENABLE |
+                                     BMCR_ANRESTART);
+                       cas_mif_poll(cp, 1);
+
+               } else if (cp->lstate != link_up) {
+                       cp->lstate = link_up;
+                       cp->link_transition = LINK_TRANSITION_LINK_UP;
+
+                       if (cp->opened) {
+                               cas_set_link_modes(cp);
+                               netif_carrier_on(cp->dev);
+                       }
+               }
+               return 0;
+       }
+
+       /* link not up. if the link was previously up, we restart the
+        * whole process
+        */
+       restart = 0;
+       if (cp->lstate == link_up) {
+               cp->lstate = link_down;
+               cp->link_transition = LINK_TRANSITION_LINK_DOWN;
+
+               netif_carrier_off(cp->dev);
+               if (cp->opened && netif_msg_link(cp))
+                       printk(KERN_INFO "%s: Link down\n",
+                              cp->dev->name);
+               restart = 1;
+               
+       } else if (++cp->timer_ticks > 10)
+               cas_mdio_link_not_up(cp);
+               
+       return restart;
+}
+
+static int cas_mif_interrupt(struct net_device *dev, struct cas *cp,
+                            u32 status)
+{
+       u32 stat = readl(cp->regs + REG_MIF_STATUS);
+       u16 bmsr;
+
+       /* check for a link change */
+       if (CAS_VAL(MIF_STATUS_POLL_STATUS, stat) == 0)
+               return 0;
+
+       bmsr = CAS_VAL(MIF_STATUS_POLL_DATA, stat);
+       return cas_mii_link_check(cp, bmsr);
+}
+
+static int cas_pci_interrupt(struct net_device *dev, struct cas *cp,
+                            u32 status)
+{
+       u32 stat = readl(cp->regs + REG_PCI_ERR_STATUS);
+
+       if (!stat)
+               return 0;
+
+       printk(KERN_ERR "%s: PCI error [%04x:%04x] ", dev->name, stat,
+              readl(cp->regs + REG_BIM_DIAG));
+
+       /* cassini+ has this reserved */
+       if ((stat & PCI_ERR_BADACK) &&
+           ((cp->cas_flags & CAS_FLAG_REG_PLUS) == 0))
+               printk("<No ACK64# during ABS64 cycle> ");
+
+       if (stat & PCI_ERR_DTRTO)
+               printk("<Delayed transaction timeout> ");
+       if (stat & PCI_ERR_OTHER)
+               printk("<other> ");
+       if (stat & PCI_ERR_BIM_DMA_WRITE)
+               printk("<BIM DMA 0 write req> ");
+       if (stat & PCI_ERR_BIM_DMA_READ)
+               printk("<BIM DMA 0 read req> ");
+       printk("\n");
+
+       if (stat & PCI_ERR_OTHER) {
+               u16 cfg;
+
+               /* Interrogate PCI config space for the
+                * true cause.
+                */
+               pci_read_config_word(cp->pdev, PCI_STATUS, &cfg);
+               printk(KERN_ERR "%s: Read PCI cfg space status [%04x]\n",
+                      dev->name, cfg);
+               if (cfg & PCI_STATUS_PARITY)
+                       printk(KERN_ERR "%s: PCI parity error detected.\n",
+                              dev->name);
+               if (cfg & PCI_STATUS_SIG_TARGET_ABORT)
+                       printk(KERN_ERR "%s: PCI target abort.\n",
+                              dev->name);
+               if (cfg & PCI_STATUS_REC_TARGET_ABORT)
+                       printk(KERN_ERR "%s: PCI master acks target abort.\n",
+                              dev->name);
+               if (cfg & PCI_STATUS_REC_MASTER_ABORT)
+                       printk(KERN_ERR "%s: PCI master abort.\n", dev->name);
+               if (cfg & PCI_STATUS_SIG_SYSTEM_ERROR)
+                       printk(KERN_ERR "%s: PCI system error SERR#.\n",
+                              dev->name);
+               if (cfg & PCI_STATUS_DETECTED_PARITY)
+                       printk(KERN_ERR "%s: PCI parity error.\n",
+                              dev->name);
+
+               /* Write the error bits back to clear them. */
+               cfg &= (PCI_STATUS_PARITY |
+                       PCI_STATUS_SIG_TARGET_ABORT |
+                       PCI_STATUS_REC_TARGET_ABORT |
+                       PCI_STATUS_REC_MASTER_ABORT |
+                       PCI_STATUS_SIG_SYSTEM_ERROR |
+                       PCI_STATUS_DETECTED_PARITY);
+               pci_write_config_word(cp->pdev, PCI_STATUS, cfg);
+       }
+
+       /* For all PCI errors, we should reset the chip. */
+       return 1;
+}
+
+/* All non-normal interrupt conditions get serviced here.
+ * Returns non-zero if we should just exit the interrupt
+ * handler right now (ie. if we reset the card which invalidates
+ * all of the other original irq status bits).
+ */
+static int cas_abnormal_irq(struct net_device *dev, struct cas *cp,
+                           u32 status)
+{
+       if (status & INTR_RX_TAG_ERROR) {
+               /* corrupt RX tag framing */
+               if (netif_msg_rx_err(cp))
+                       printk(KERN_DEBUG "%s: corrupt rx tag framing\n",
+                               cp->dev->name);
+               spin_lock(&cp->stat_lock[0]);
+               cp->net_stats[0].rx_errors++;
+               spin_unlock(&cp->stat_lock[0]);
+               goto do_reset;
+       }
+
+       if (status & INTR_RX_LEN_MISMATCH) {
+               /* length mismatch. */
+               if (netif_msg_rx_err(cp))
+                       printk(KERN_DEBUG "%s: length mismatch for rx frame\n",
+                               cp->dev->name);
+               spin_lock(&cp->stat_lock[0]);
+               cp->net_stats[0].rx_errors++;
+               spin_unlock(&cp->stat_lock[0]);
+               goto do_reset;
+       }
+
+       if (status & INTR_PCS_STATUS) {
+               if (cas_pcs_interrupt(dev, cp, status))
+                       goto do_reset;
+       }
+
+       if (status & INTR_TX_MAC_STATUS) {
+               if (cas_txmac_interrupt(dev, cp, status))
+                       goto do_reset;
+       }
+
+       if (status & INTR_RX_MAC_STATUS) {
+               if (cas_rxmac_interrupt(dev, cp, status))
+                       goto do_reset;
+       }
+
+       if (status & INTR_MAC_CTRL_STATUS) {
+               if (cas_mac_interrupt(dev, cp, status))
+                       goto do_reset;
+       }
+
+       if (status & INTR_MIF_STATUS) {
+               if (cas_mif_interrupt(dev, cp, status))
+                       goto do_reset;
+       }
+
+       if (status & INTR_PCI_ERROR_STATUS) {
+               if (cas_pci_interrupt(dev, cp, status))
+                       goto do_reset;
+       }
+       return 0;
+
+do_reset:
+#if 1
+       atomic_inc(&cp->reset_task_pending);
+       atomic_inc(&cp->reset_task_pending_all);
+       printk(KERN_ERR "%s:reset called in cas_abnormal_irq [0x%x]\n",
+              dev->name, status);
+       schedule_work(&cp->reset_task);
+#else
+       atomic_set(&cp->reset_task_pending, CAS_RESET_ALL);
+       printk(KERN_ERR "reset called in cas_abnormal_irq\n");
+       schedule_work(&cp->reset_task);
+#endif
+       return 1;
+}
+
+/* NOTE: CAS_TABORT returns 1 or 2 so that it can be used when
+ *       determining whether to do a netif_stop/wakeup
+ */
+#define CAS_TABORT(x)      (((x)->cas_flags & CAS_FLAG_TARGET_ABORT) ? 2 : 1)
+#define CAS_ROUND_PAGE(x)  (((x) + PAGE_SIZE - 1) & PAGE_MASK)
+static inline int cas_calc_tabort(struct cas *cp, const unsigned long addr,
+                                 const int len)
+{
+       unsigned long off = addr + len;
+
+       if (CAS_TABORT(cp) == 1)
+               return 0;
+       if ((CAS_ROUND_PAGE(off) - off) > TX_TARGET_ABORT_LEN)
+               return 0;
+       return TX_TARGET_ABORT_LEN;
+}
+
+static inline void cas_tx_ringN(struct cas *cp, int ring, int limit)
+{
+       struct cas_tx_desc *txds;
+       struct sk_buff **skbs;
+       struct net_device *dev = cp->dev;
+       int entry, count;
+
+       spin_lock(&cp->tx_lock[ring]);
+       txds = cp->init_txds[ring];
+       skbs = cp->tx_skbs[ring];
+       entry = cp->tx_old[ring];
+
+       count = TX_BUFF_COUNT(ring, entry, limit);
+       while (entry != limit) {
+               struct sk_buff *skb = skbs[entry];
+               dma_addr_t daddr;
+               u32 dlen;
+               int frag;
+
+               if (!skb) {
+                       /* this should never occur */
+                       entry = TX_DESC_NEXT(ring, entry);
+                       continue;
+               }
+
+               /* however, we might get only a partial skb release. */
+               count -= skb_shinfo(skb)->nr_frags +
+                       + cp->tx_tiny_use[ring][entry].nbufs + 1;
+               if (count < 0)
+                       break;
+
+               if (netif_msg_tx_done(cp))
+                       printk(KERN_DEBUG "%s: tx[%d] done, slot %d\n",
+                              cp->dev->name, ring, entry);
+
+               skbs[entry] = NULL;
+               cp->tx_tiny_use[ring][entry].nbufs = 0;
+               
+               for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) {
+                       struct cas_tx_desc *txd = txds + entry;
+
+                       daddr = le64_to_cpu(txd->buffer);
+                       dlen = CAS_VAL(TX_DESC_BUFLEN,
+                                      le64_to_cpu(txd->control));
+                       pci_unmap_page(cp->pdev, daddr, dlen,
+                                      PCI_DMA_TODEVICE);
+                       entry = TX_DESC_NEXT(ring, entry);
+
+                       /* tiny buffer may follow */
+                       if (cp->tx_tiny_use[ring][entry].used) {
+                               cp->tx_tiny_use[ring][entry].used = 0;
+                               entry = TX_DESC_NEXT(ring, entry);
+                       } 
+               }
+
+               spin_lock(&cp->stat_lock[ring]);
+               cp->net_stats[ring].tx_packets++;
+               cp->net_stats[ring].tx_bytes += skb->len;
+               spin_unlock(&cp->stat_lock[ring]);
+               dev_kfree_skb_irq(skb);
+       }
+       cp->tx_old[ring] = entry;
+
+       /* this is wrong for multiple tx rings. the net device needs
+        * multiple queues for this to do the right thing.  we wait
+        * for 2*packets to be available when using tiny buffers
+        */
+       if (netif_queue_stopped(dev) &&
+           (TX_BUFFS_AVAIL(cp, ring) > CAS_TABORT(cp)*(MAX_SKB_FRAGS + 1)))
+               netif_wake_queue(dev);
+       spin_unlock(&cp->tx_lock[ring]);
+}
+
+static void cas_tx(struct net_device *dev, struct cas *cp,
+                  u32 status)
+{
+        int limit, ring;
+#ifdef USE_TX_COMPWB
+       u64 compwb = le64_to_cpu(cp->init_block->tx_compwb);
+#endif
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: tx interrupt, status: 0x%x, %lx\n",
+                       cp->dev->name, status, compwb);
+       /* process all the rings */
+       for (ring = 0; ring < N_TX_RINGS; ring++) {
+#ifdef USE_TX_COMPWB
+               /* use the completion writeback registers */
+               limit = (CAS_VAL(TX_COMPWB_MSB, compwb) << 8) |
+                       CAS_VAL(TX_COMPWB_LSB, compwb);
+               compwb = TX_COMPWB_NEXT(compwb);
+#else
+               limit = readl(cp->regs + REG_TX_COMPN(ring));
+#endif
+               if (cp->tx_old[ring] != limit) 
+                       cas_tx_ringN(cp, ring, limit);
+       }
+}
+
+
+static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc, 
+                             int entry, const u64 *words, 
+                             struct sk_buff **skbref)
+{
+       int dlen, hlen, len, i, alloclen;
+       int off, swivel = RX_SWIVEL_OFF_VAL;
+       struct cas_page *page;
+       struct sk_buff *skb;
+       void *addr, *crcaddr;
+       char *p; 
+
+       hlen = CAS_VAL(RX_COMP2_HDR_SIZE, words[1]);
+       dlen = CAS_VAL(RX_COMP1_DATA_SIZE, words[0]);
+       len  = hlen + dlen;
+
+       if (RX_COPY_ALWAYS || (words[2] & RX_COMP3_SMALL_PKT)) 
+               alloclen = len;
+       else 
+               alloclen = max(hlen, RX_COPY_MIN);
+
+       skb = dev_alloc_skb(alloclen + swivel + cp->crc_size);
+       if (skb == NULL) 
+               return -1;
+
+       *skbref = skb;
+       skb->dev = cp->dev;
+       skb_reserve(skb, swivel);
+
+       p = skb->data;
+       addr = crcaddr = NULL;
+       if (hlen) { /* always copy header pages */
+               i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
+               page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
+               off = CAS_VAL(RX_COMP2_HDR_OFF, words[1]) * 0x100 + 
+                       swivel;
+
+               i = hlen;
+               if (!dlen) /* attach FCS */
+                       i += cp->crc_size;
+               pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr + off, i,
+                                   PCI_DMA_FROMDEVICE);
+               addr = cas_page_map(page->buffer);
+               memcpy(p, addr + off, i);
+               pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
+                                   PCI_DMA_FROMDEVICE);
+               cas_page_unmap(addr);
+               RX_USED_ADD(page, 0x100);
+               p += hlen;
+               swivel = 0;
+       } 
+
+
+       if (alloclen < (hlen + dlen)) {
+               skb_frag_t *frag = skb_shinfo(skb)->frags;
+
+               /* normal or jumbo packets. we use frags */
+               i = CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
+               page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
+               off = CAS_VAL(RX_COMP1_DATA_OFF, words[0]) + swivel;
+
+               hlen = min(cp->page_size - off, dlen);
+               if (hlen < 0) {
+                       if (netif_msg_rx_err(cp)) {
+                               printk(KERN_DEBUG "%s: rx page overflow: "
+                                      "%d\n", cp->dev->name, hlen);
+                       }
+                       dev_kfree_skb_irq(skb);
+                       return -1;
+               }
+               i = hlen;
+               if (i == dlen)  /* attach FCS */
+                       i += cp->crc_size;
+               pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr + off, i,
+                                   PCI_DMA_FROMDEVICE);
+
+               /* make sure we always copy a header */
+               swivel = 0;
+               if (p == (char *) skb->data) { /* not split */
+                       addr = cas_page_map(page->buffer);
+                       memcpy(p, addr + off, RX_COPY_MIN);
+                       pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
+                                       PCI_DMA_FROMDEVICE);
+                       cas_page_unmap(addr);
+                       off += RX_COPY_MIN;
+                       swivel = RX_COPY_MIN;
+                       RX_USED_ADD(page, cp->mtu_stride);
+               } else {
+                       RX_USED_ADD(page, hlen);
+               }
+               skb_put(skb, alloclen);
+
+               skb_shinfo(skb)->nr_frags++;
+               skb->data_len += hlen - swivel;
+               skb->len      += hlen - swivel;
+
+               get_page(page->buffer);
+               frag->page = page->buffer;
+               frag->page_offset = off;
+               frag->size = hlen - swivel;
+               
+               /* any more data? */
+               if ((words[0] & RX_COMP1_SPLIT_PKT) && ((dlen -= hlen) > 0)) {
+                       hlen = dlen;
+                       off = 0;
+
+                       i = CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
+                       page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
+                       pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr, 
+                                           hlen + cp->crc_size, 
+                                           PCI_DMA_FROMDEVICE);
+                       pci_dma_sync_single_for_device(cp->pdev, page->dma_addr,
+                                           hlen + cp->crc_size,
+                                           PCI_DMA_FROMDEVICE);
+
+                       skb_shinfo(skb)->nr_frags++;
+                       skb->data_len += hlen;
+                       skb->len      += hlen; 
+                       frag++;
+
+                       get_page(page->buffer);
+                       frag->page = page->buffer;
+                       frag->page_offset = 0;
+                       frag->size = hlen;
+                       RX_USED_ADD(page, hlen + cp->crc_size);
+               }
+
+               if (cp->crc_size) {
+                       addr = cas_page_map(page->buffer);
+                       crcaddr  = addr + off + hlen;
+               }
+
+       } else {
+               /* copying packet */
+               if (!dlen)
+                       goto end_copy_pkt;
+
+               i = CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
+               page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
+               off = CAS_VAL(RX_COMP1_DATA_OFF, words[0]) + swivel;
+               hlen = min(cp->page_size - off, dlen);
+               if (hlen < 0) {
+                       if (netif_msg_rx_err(cp)) {
+                               printk(KERN_DEBUG "%s: rx page overflow: "
+                                      "%d\n", cp->dev->name, hlen);
+                       }
+                       dev_kfree_skb_irq(skb);
+                       return -1;
+               }
+               i = hlen;
+               if (i == dlen) /* attach FCS */
+                       i += cp->crc_size;
+               pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr + off, i,
+                                   PCI_DMA_FROMDEVICE);
+               addr = cas_page_map(page->buffer);
+               memcpy(p, addr + off, i);
+               pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
+                                   PCI_DMA_FROMDEVICE);
+               cas_page_unmap(addr);
+               if (p == (char *) skb->data) /* not split */
+                       RX_USED_ADD(page, cp->mtu_stride);
+               else
+                       RX_USED_ADD(page, i);
+       
+               /* any more data? */
+               if ((words[0] & RX_COMP1_SPLIT_PKT) && ((dlen -= hlen) > 0)) {
+                       p += hlen;
+                       i = CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
+                       page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
+                       pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr, 
+                                           dlen + cp->crc_size, 
+                                           PCI_DMA_FROMDEVICE);
+                       addr = cas_page_map(page->buffer);
+                       memcpy(p, addr, dlen + cp->crc_size);
+                       pci_dma_sync_single_for_device(cp->pdev, page->dma_addr,
+                                           dlen + cp->crc_size,
+                                           PCI_DMA_FROMDEVICE);
+                       cas_page_unmap(addr);
+                       RX_USED_ADD(page, dlen + cp->crc_size); 
+               }
+end_copy_pkt:
+               if (cp->crc_size) {
+                       addr    = NULL;
+                       crcaddr = skb->data + alloclen;
+               }
+               skb_put(skb, alloclen);
+       }
+
+       i = CAS_VAL(RX_COMP4_TCP_CSUM, words[3]);
+       if (cp->crc_size) {
+               /* checksum includes FCS. strip it out. */
+               i = csum_fold(csum_partial(crcaddr, cp->crc_size, i));
+               if (addr)
+                       cas_page_unmap(addr);
+       }
+       skb->csum = ntohs(i ^ 0xffff);
+       skb->ip_summed = CHECKSUM_HW;
+       skb->protocol = eth_type_trans(skb, cp->dev);
+       return len;
+}
+
+
+/* we can handle up to 64 rx flows at a time. we do the same thing
+ * as nonreassm except that we batch up the buffers. 
+ * NOTE: we currently just treat each flow as a bunch of packets that
+ *       we pass up. a better way would be to coalesce the packets
+ *       into a jumbo packet. to do that, we need to do the following:
+ *       1) the first packet will have a clean split between header and
+ *          data. save both.
+ *       2) each time the next flow packet comes in, extend the
+ *          data length and merge the checksums.
+ *       3) on flow release, fix up the header.
+ *       4) make sure the higher layer doesn't care.
+ * because packets get coalesced, we shouldn't run into fragment count 
+ * issues.
+ */
+static inline void cas_rx_flow_pkt(struct cas *cp, const u64 *words,
+                                  struct sk_buff *skb)
+{
+       int flowid = CAS_VAL(RX_COMP3_FLOWID, words[2]) & (N_RX_FLOWS - 1);
+       struct sk_buff_head *flow = &cp->rx_flows[flowid];
+       
+       /* this is protected at a higher layer, so no need to 
+        * do any additional locking here. stick the buffer
+        * at the end.
+        */
+       __skb_insert(skb, flow->prev, (struct sk_buff *) flow, flow);
+       if (words[0] & RX_COMP1_RELEASE_FLOW) {
+               while ((skb = __skb_dequeue(flow))) {
+                       cas_skb_release(skb);
+               }
+       }
+}
+
+/* put rx descriptor back on ring. if a buffer is in use by a higher
+ * layer, this will need to put in a replacement.
+ */
+static void cas_post_page(struct cas *cp, const int ring, const int index)
+{
+       cas_page_t *new;
+       int entry;
+
+       entry = cp->rx_old[ring];
+
+       new = cas_page_swap(cp, ring, index);
+       cp->init_rxds[ring][entry].buffer = cpu_to_le64(new->dma_addr);
+       cp->init_rxds[ring][entry].index  =
+               cpu_to_le64(CAS_BASE(RX_INDEX_NUM, index) | 
+                           CAS_BASE(RX_INDEX_RING, ring));
+
+       entry = RX_DESC_ENTRY(ring, entry + 1);
+       cp->rx_old[ring] = entry;
+       
+       if (entry % 4)
+               return;
+
+       if (ring == 0)
+               writel(entry, cp->regs + REG_RX_KICK);
+       else if ((N_RX_DESC_RINGS > 1) &&
+                (cp->cas_flags & CAS_FLAG_REG_PLUS)) 
+               writel(entry, cp->regs + REG_PLUS_RX_KICK1);
+}
+
+
+/* only when things are bad */
+static int cas_post_rxds_ringN(struct cas *cp, int ring, int num)
+{
+       unsigned int entry, last, count, released;
+       int cluster;
+       cas_page_t **page = cp->rx_pages[ring];
+
+       entry = cp->rx_old[ring];
+
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: rxd[%d] interrupt, done: %d\n",
+                      cp->dev->name, ring, entry);
+
+       cluster = -1;
+       count = entry & 0x3; 
+       last = RX_DESC_ENTRY(ring, num ? entry + num - 4: entry - 4);
+       released = 0;
+       while (entry != last) {
+               /* make a new buffer if it's still in use */
+               if (page_count(page[entry]->buffer) > 1) {
+                       cas_page_t *new = cas_page_dequeue(cp);
+                       if (!new) {
+                               /* let the timer know that we need to 
+                                * do this again
+                                */
+                               cp->cas_flags |= CAS_FLAG_RXD_POST(ring);
+                               if (!timer_pending(&cp->link_timer))
+                                       mod_timer(&cp->link_timer, jiffies + 
+                                                 CAS_LINK_FAST_TIMEOUT);
+                               cp->rx_old[ring]  = entry;
+                               cp->rx_last[ring] = num ? num - released : 0;
+                               return -ENOMEM;
+                       }
+                       spin_lock(&cp->rx_inuse_lock);
+                       list_add(&page[entry]->list, &cp->rx_inuse_list);
+                       spin_unlock(&cp->rx_inuse_lock);
+                       cp->init_rxds[ring][entry].buffer = 
+                               cpu_to_le64(new->dma_addr);
+                       page[entry] = new;
+                       
+               }
+
+               if (++count == 4) {
+                       cluster = entry;
+                       count = 0;
+               }
+               released++;
+               entry = RX_DESC_ENTRY(ring, entry + 1);
+       }
+       cp->rx_old[ring] = entry;
+
+       if (cluster < 0) 
+               return 0;
+
+       if (ring == 0)
+               writel(cluster, cp->regs + REG_RX_KICK);
+       else if ((N_RX_DESC_RINGS > 1) &&
+                (cp->cas_flags & CAS_FLAG_REG_PLUS)) 
+               writel(cluster, cp->regs + REG_PLUS_RX_KICK1);
+       return 0;
+}
+
+
+/* process a completion ring. packets are set up in three basic ways:
+ * small packets: should be copied header + data in single buffer.
+ * large packets: header and data in a single buffer.
+ * split packets: header in a separate buffer from data. 
+ *                data may be in multiple pages. data may be > 256
+ *                bytes but in a single page. 
+ *
+ * NOTE: RX page posting is done in this routine as well. while there's
+ *       the capability of using multiple RX completion rings, it isn't
+ *       really worthwhile due to the fact that the page posting will
+ *       force serialization on the single descriptor ring. 
+ */
+static int cas_rx_ringN(struct cas *cp, int ring, int budget)
+{
+       struct cas_rx_comp *rxcs = cp->init_rxcs[ring];
+       int entry, drops;
+       int npackets = 0;
+
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: rx[%d] interrupt, done: %d/%d\n",
+                      cp->dev->name, ring,
+                      readl(cp->regs + REG_RX_COMP_HEAD), 
+                      cp->rx_new[ring]);
+
+       entry = cp->rx_new[ring];
+       drops = 0;
+       while (1) {
+               struct cas_rx_comp *rxc = rxcs + entry;
+               struct sk_buff *skb;
+               int type, len;
+               u64 words[4];
+               int i, dring;
+
+               words[0] = le64_to_cpu(rxc->word1);
+               words[1] = le64_to_cpu(rxc->word2);
+               words[2] = le64_to_cpu(rxc->word3);
+               words[3] = le64_to_cpu(rxc->word4);
+
+               /* don't touch if still owned by hw */
+               type = CAS_VAL(RX_COMP1_TYPE, words[0]);
+               if (type == 0)
+                       break;
+
+               /* hw hasn't cleared the zero bit yet */
+               if (words[3] & RX_COMP4_ZERO) {
+                       break;
+               }
+
+               /* get info on the packet */
+               if (words[3] & (RX_COMP4_LEN_MISMATCH | RX_COMP4_BAD)) {
+                       spin_lock(&cp->stat_lock[ring]);
+                       cp->net_stats[ring].rx_errors++;
+                       if (words[3] & RX_COMP4_LEN_MISMATCH)
+                               cp->net_stats[ring].rx_length_errors++;
+                       if (words[3] & RX_COMP4_BAD)
+                               cp->net_stats[ring].rx_crc_errors++;
+                       spin_unlock(&cp->stat_lock[ring]);
+
+                       /* We'll just return it to Cassini. */
+               drop_it:
+                       spin_lock(&cp->stat_lock[ring]);
+                       ++cp->net_stats[ring].rx_dropped;
+                       spin_unlock(&cp->stat_lock[ring]);
+                       goto next;
+               }
+
+               len = cas_rx_process_pkt(cp, rxc, entry, words, &skb);
+               if (len < 0) {
+                       ++drops;
+                       goto drop_it;
+               }
+
+               /* see if it's a flow re-assembly or not. the driver
+                * itself handles release back up.
+                */
+               if (RX_DONT_BATCH || (type == 0x2)) {
+                       /* non-reassm: these always get released */
+                       cas_skb_release(skb); 
+               } else {
+                       cas_rx_flow_pkt(cp, words, skb);
+               }
+
+               spin_lock(&cp->stat_lock[ring]);
+               cp->net_stats[ring].rx_packets++;
+               cp->net_stats[ring].rx_bytes += len;
+               spin_unlock(&cp->stat_lock[ring]);
+               cp->dev->last_rx = jiffies;
+
+       next:
+               npackets++;
+
+               /* should it be released? */
+               if (words[0] & RX_COMP1_RELEASE_HDR) {
+                       i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
+                       dring = CAS_VAL(RX_INDEX_RING, i);
+                       i = CAS_VAL(RX_INDEX_NUM, i);
+                       cas_post_page(cp, dring, i);
+               }
+               
+               if (words[0] & RX_COMP1_RELEASE_DATA) {
+                       i = CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
+                       dring = CAS_VAL(RX_INDEX_RING, i);
+                       i = CAS_VAL(RX_INDEX_NUM, i);
+                       cas_post_page(cp, dring, i);
+               }
+
+               if (words[0] & RX_COMP1_RELEASE_NEXT) {
+                       i = CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
+                       dring = CAS_VAL(RX_INDEX_RING, i);
+                       i = CAS_VAL(RX_INDEX_NUM, i);
+                       cas_post_page(cp, dring, i);
+               }
+
+               /* skip to the next entry */
+               entry = RX_COMP_ENTRY(ring, entry + 1 + 
+                                     CAS_VAL(RX_COMP1_SKIP, words[0]));
+#ifdef USE_NAPI
+               if (budget && (npackets >= budget))
+                       break;
+#endif
+       }
+       cp->rx_new[ring] = entry;
+
+       if (drops)
+               printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
+                      cp->dev->name);
+       return npackets;
+}
+
+
+/* put completion entries back on the ring */
+static void cas_post_rxcs_ringN(struct net_device *dev,
+                               struct cas *cp, int ring)
+{
+       struct cas_rx_comp *rxc = cp->init_rxcs[ring];
+       int last, entry;
+
+       last = cp->rx_cur[ring];
+       entry = cp->rx_new[ring]; 
+       if (netif_msg_intr(cp))
+               printk(KERN_DEBUG "%s: rxc[%d] interrupt, done: %d/%d\n",
+                      dev->name, ring, readl(cp->regs + REG_RX_COMP_HEAD),
+                      entry);
+       
+       /* zero and re-mark descriptors */
+       while (last != entry) {
+               cas_rxc_init(rxc + last);
+               last = RX_COMP_ENTRY(ring, last + 1);
+       }
+       cp->rx_cur[ring] = last;
+
+       if (ring == 0)
+               writel(last, cp->regs + REG_RX_COMP_TAIL);
+       else if (cp->cas_flags & CAS_FLAG_REG_PLUS) 
+               writel(last, cp->regs + REG_PLUS_RX_COMPN_TAIL(ring));
+}
+
+
+
+/* cassini can use all four PCI interrupts for the completion ring. 
+ * rings 3 and 4 are identical
+ */
+#if defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
+static inline void cas_handle_irqN(struct net_device *dev, 
+                                  struct cas *cp, const u32 status,
+                                  const int ring)
+{
+       if (status & (INTR_RX_COMP_FULL_ALT | INTR_RX_COMP_AF_ALT)) 
+               cas_post_rxcs_ringN(dev, cp, ring);
+}
+
+static irqreturn_t cas_interruptN(int irq, void *dev_id, struct pt_regs *regs)
+{
+       struct net_device *dev = dev_id;
+       struct cas *cp = netdev_priv(dev);
+       unsigned long flags;
+       int ring;
+       u32 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(ring));
+
+       /* check for shared irq */
+       if (status == 0)
+               return IRQ_NONE;
+
+       ring = (irq == cp->pci_irq_INTC) ? 2 : 3;
+       spin_lock_irqsave(&cp->lock, flags);
+       if (status & INTR_RX_DONE_ALT) { /* handle rx separately */
+#ifdef USE_NAPI
+               cas_mask_intr(cp);
+               netif_rx_schedule(dev);
+#else
+               cas_rx_ringN(cp, ring, 0);
+#endif
+               status &= ~INTR_RX_DONE_ALT;
+       }
+
+       if (status)
+               cas_handle_irqN(dev, cp, status, ring);
+       spin_unlock_irqrestore(&cp->lock, flags);
+       return IRQ_HANDLED;
+}
+#endif
+
+#ifdef USE_PCI_INTB
+/* everything but rx packets */
+static inline void cas_handle_irq1(struct cas *cp, const u32 status)
+{
+       if (status & INTR_RX_BUF_UNAVAIL_1) {
+               /* Frame arrived, no free RX buffers available. 
+                * NOTE: we can get this on a link transition. */
+               cas_post_rxds_ringN(cp, 1, 0);
+               spin_lock(&cp->stat_lock[1]);
+               cp->net_stats[1].rx_dropped++;
+               spin_unlock(&cp->stat_lock[1]);
+       }
+
+       if (status & INTR_RX_BUF_AE_1) 
+               cas_post_rxds_ringN(cp, 1, RX_DESC_RINGN_SIZE(1) - 
+                                   RX_AE_FREEN_VAL(1));
+
+       if (status & (INTR_RX_COMP_AF | INTR_RX_COMP_FULL))
+               cas_post_rxcs_ringN(cp, 1);
+}
+
+/* ring 2 handles a few more events than 3 and 4 */
+static irqreturn_t cas_interrupt1(int irq, void *dev_id, struct pt_regs *regs)
+{
+       struct net_device *dev = dev_id;
+       struct cas *cp = netdev_priv(dev);
+       unsigned long flags;
+       u32 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(1));
+
+       /* check for shared interrupt */
+       if (status == 0)
+               return IRQ_NONE;
+
+       spin_lock_irqsave(&cp->lock, flags);
+       if (status & INTR_RX_DONE_ALT) { /* handle rx separately */
+#ifdef USE_NAPI
+               cas_mask_intr(cp);
+               netif_rx_schedule(dev);
+#else
+               cas_rx_ringN(cp, 1, 0);
+#endif
+               status &= ~INTR_RX_DONE_ALT;
+       }
+       if (status)
+               cas_handle_irq1(cp, status);
+       spin_unlock_irqrestore(&cp->lock, flags);
+       return IRQ_HANDLED;
+}
+#endif
+
+static inline void cas_handle_irq(struct net_device *dev,
+                                 struct cas *cp, const u32 status)
+{
+       /* housekeeping interrupts */
+       if (status & INTR_ERROR_MASK)
+               cas_abnormal_irq(dev, cp, status);
+
+       if (status & INTR_RX_BUF_UNAVAIL) {
+               /* Frame arrived, no free RX buffers available. 
+                * NOTE: we can get this on a link transition.
+                */
+               cas_post_rxds_ringN(cp, 0, 0);
+               spin_lock(&cp->stat_lock[0]);
+               cp->net_stats[0].rx_dropped++;
+               spin_unlock(&cp->stat_lock[0]);
+       } else if (status & INTR_RX_BUF_AE) {
+               cas_post_rxds_ringN(cp, 0, RX_DESC_RINGN_SIZE(0) -
+                                   RX_AE_FREEN_VAL(0));
+       }
+
+       if (status & (INTR_RX_COMP_AF | INTR_RX_COMP_FULL))
+               cas_post_rxcs_ringN(dev, cp, 0);
+}
+
+static irqreturn_t cas_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+       struct net_device *dev = dev_id;
+       struct cas *cp = netdev_priv(dev);
+       unsigned long flags;
+       u32 status = readl(cp->regs + REG_INTR_STATUS);
+
+       if (status == 0)
+               return IRQ_NONE;
+
+       spin_lock_irqsave(&cp->lock, flags);
+       if (status & (INTR_TX_ALL | INTR_TX_INTME)) {
+               cas_tx(dev, cp, status);
+               status &= ~(INTR_TX_ALL | INTR_TX_INTME);
+       }
+
+       if (status & INTR_RX_DONE) {
+#ifdef USE_NAPI
+               cas_mask_intr(cp);
+               netif_rx_schedule(dev);
+#else
+               cas_rx_ringN(cp, 0, 0);
+#endif
+               status &= ~INTR_RX_DONE;
+       }
+
+       if (status)
+               cas_handle_irq(dev, cp, status);
+       spin_unlock_irqrestore(&cp->lock, flags);
+       return IRQ_HANDLED;
+}
+
+
+#ifdef USE_NAPI
+static int cas_poll(struct net_device *dev, int *budget)
+{
+       struct cas *cp = netdev_priv(dev);
+       int i, enable_intr, todo, credits;
+       u32 status = readl(cp->regs + REG_INTR_STATUS);
+       unsigned long flags;
+
+       spin_lock_irqsave(&cp->lock, flags);
+       cas_tx(dev, cp, status);
+       spin_unlock_irqrestore(&cp->lock, flags);
+
+       /* NAPI rx packets. we spread the credits across all of the
+        * rxc rings
+        */
+       todo = min(*budget, dev->quota);
+
+       /* to make sure we're fair with the work we loop through each
+        * ring N_RX_COMP_RING times with a request of 
+        * todo / N_RX_COMP_RINGS
+        */
+       enable_intr = 1;
+       credits = 0;
+       for (i = 0; i < N_RX_COMP_RINGS; i++) {
+               int j;
+               for (j = 0; j < N_RX_COMP_RINGS; j++) {
+                       credits += cas_rx_ringN(cp, j, todo / N_RX_COMP_RINGS);
+                       if (credits >= todo) {
+                               enable_intr = 0;
+                               goto rx_comp;
+                       }
+               }
+       }
+
+rx_comp:
+       *budget    -= credits;
+       dev->quota -= credits;
+
+       /* final rx completion */
+       spin_lock_irqsave(&cp->lock, flags);
+       if (status)
+               cas_handle_irq(dev, cp, status);
+
+#ifdef USE_PCI_INTB
+       if (N_RX_COMP_RINGS > 1) {
+               status = readl(cp->regs + REG_PLUS_INTRN_STATUS(1));
+               if (status)
+                       cas_handle_irq1(dev, cp, status);
+       }
+#endif
+
+#ifdef USE_PCI_INTC
+       if (N_RX_COMP_RINGS > 2) {
+               status = readl(cp->regs + REG_PLUS_INTRN_STATUS(2));
+               if (status)
+                       cas_handle_irqN(dev, cp, status, 2);
+       }
+#endif
+
+#ifdef USE_PCI_INTD
+       if (N_RX_COMP_RINGS > 3) {
+               status = readl(cp->regs + REG_PLUS_INTRN_STATUS(3));
+               if (status)
+                       cas_handle_irqN(dev, cp, status, 3);
+       }
+#endif
+       spin_unlock_irqrestore(&cp->lock, flags);
+       if (enable_intr) {
+               netif_rx_complete(dev);
+               cas_unmask_intr(cp);
+               return 0;
+       }
+       return 1;
+}
+#endif
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void cas_netpoll(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+
+       cas_disable_irq(cp, 0);
+       cas_interrupt(cp->pdev->irq, dev, NULL);
+       cas_enable_irq(cp, 0);
+
+#ifdef USE_PCI_INTB
+       if (N_RX_COMP_RINGS > 1) {
+               /* cas_interrupt1(); */
+       }
+#endif
+#ifdef USE_PCI_INTC
+       if (N_RX_COMP_RINGS > 2) {
+               /* cas_interruptN(); */
+       }
+#endif
+#ifdef USE_PCI_INTD
+       if (N_RX_COMP_RINGS > 3) {
+               /* cas_interruptN(); */
+       }
+#endif
+}
+#endif
+
+static void cas_tx_timeout(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+
+       printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
+       if (!cp->hw_running) {
+               printk("%s: hrm.. hw not running!\n", dev->name);
+               return;
+       }
+
+       printk(KERN_ERR "%s: MIF_STATE[%08x]\n",
+              dev->name, readl(cp->regs + REG_MIF_STATE_MACHINE));
+
+       printk(KERN_ERR "%s: MAC_STATE[%08x]\n",
+              dev->name, readl(cp->regs + REG_MAC_STATE_MACHINE));
+
+       printk(KERN_ERR "%s: TX_STATE[%08x:%08x:%08x] "
+              "FIFO[%08x:%08x:%08x] SM1[%08x] SM2[%08x]\n",
+              dev->name,
+              readl(cp->regs + REG_TX_CFG),
+              readl(cp->regs + REG_MAC_TX_STATUS),
+              readl(cp->regs + REG_MAC_TX_CFG),
+              readl(cp->regs + REG_TX_FIFO_PKT_CNT),
+              readl(cp->regs + REG_TX_FIFO_WRITE_PTR),
+              readl(cp->regs + REG_TX_FIFO_READ_PTR),
+              readl(cp->regs + REG_TX_SM_1),
+              readl(cp->regs + REG_TX_SM_2));
+
+       printk(KERN_ERR "%s: RX_STATE[%08x:%08x:%08x]\n",
+              dev->name,
+              readl(cp->regs + REG_RX_CFG),
+              readl(cp->regs + REG_MAC_RX_STATUS),
+              readl(cp->regs + REG_MAC_RX_CFG));
+
+       printk(KERN_ERR "%s: HP_STATE[%08x:%08x:%08x:%08x]\n",
+              dev->name,
+              readl(cp->regs + REG_HP_STATE_MACHINE),
+              readl(cp->regs + REG_HP_STATUS0),
+              readl(cp->regs + REG_HP_STATUS1),
+              readl(cp->regs + REG_HP_STATUS2));
+
+#if 1
+       atomic_inc(&cp->reset_task_pending);
+       atomic_inc(&cp->reset_task_pending_all);
+       schedule_work(&cp->reset_task);
+#else
+       atomic_set(&cp->reset_task_pending, CAS_RESET_ALL);
+       schedule_work(&cp->reset_task);
+#endif
+}
+
+static inline int cas_intme(int ring, int entry)
+{
+       /* Algorithm: IRQ every 1/2 of descriptors. */
+       if (!(entry & ((TX_DESC_RINGN_SIZE(ring) >> 1) - 1)))
+               return 1;
+       return 0;
+}
+
+
+static void cas_write_txd(struct cas *cp, int ring, int entry,
+                         dma_addr_t mapping, int len, u64 ctrl, int last)
+{
+       struct cas_tx_desc *txd = cp->init_txds[ring] + entry;
+
+       ctrl |= CAS_BASE(TX_DESC_BUFLEN, len);
+       if (cas_intme(ring, entry))
+               ctrl |= TX_DESC_INTME;
+       if (last)
+               ctrl |= TX_DESC_EOF;
+       txd->control = cpu_to_le64(ctrl);
+       txd->buffer = cpu_to_le64(mapping);
+}
+
+static inline void *tx_tiny_buf(struct cas *cp, const int ring, 
+                               const int entry)
+{
+       return cp->tx_tiny_bufs[ring] + TX_TINY_BUF_LEN*entry;
+}
+
+static inline dma_addr_t tx_tiny_map(struct cas *cp, const int ring, 
+                                    const int entry, const int tentry)
+{
+       cp->tx_tiny_use[ring][tentry].nbufs++;
+       cp->tx_tiny_use[ring][entry].used = 1;
+       return cp->tx_tiny_dvma[ring] + TX_TINY_BUF_LEN*entry;
+}
+
+static inline int cas_xmit_tx_ringN(struct cas *cp, int ring, 
+                                   struct sk_buff *skb)
+{
+       struct net_device *dev = cp->dev;
+       int entry, nr_frags, frag, tabort, tentry;
+       dma_addr_t mapping;
+       unsigned long flags;
+       u64 ctrl;
+       u32 len;
+
+       spin_lock_irqsave(&cp->tx_lock[ring], flags);
+
+       /* This is a hard error, log it. */
+       if (TX_BUFFS_AVAIL(cp, ring) <= 
+           CAS_TABORT(cp)*(skb_shinfo(skb)->nr_frags + 1)) {
+               netif_stop_queue(dev);
+               spin_unlock_irqrestore(&cp->tx_lock[ring], flags);
+               printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
+                      "queue awake!\n", dev->name);
+               return 1;
+       }
+
+       ctrl = 0;
+       if (skb->ip_summed == CHECKSUM_HW) {
+               u64 csum_start_off, csum_stuff_off;
+
+               csum_start_off = (u64) (skb->h.raw - skb->data);
+               csum_stuff_off = (u64) ((skb->h.raw + skb->csum) - skb->data);
+
+               ctrl =  TX_DESC_CSUM_EN | 
+                       CAS_BASE(TX_DESC_CSUM_START, csum_start_off) |
+                       CAS_BASE(TX_DESC_CSUM_STUFF, csum_stuff_off);
+       }
+
+       entry = cp->tx_new[ring];
+       cp->tx_skbs[ring][entry] = skb;
+
+       nr_frags = skb_shinfo(skb)->nr_frags;
+       len = skb_headlen(skb);
+       mapping = pci_map_page(cp->pdev, virt_to_page(skb->data),
+                              offset_in_page(skb->data), len,
+                              PCI_DMA_TODEVICE);
+
+       tentry = entry;
+       tabort = cas_calc_tabort(cp, (unsigned long) skb->data, len);
+       if (unlikely(tabort)) {
+               /* NOTE: len is always >  tabort */
+               cas_write_txd(cp, ring, entry, mapping, len - tabort, 
+                             ctrl | TX_DESC_SOF, 0);
+               entry = TX_DESC_NEXT(ring, entry);
+
+               memcpy(tx_tiny_buf(cp, ring, entry), skb->data + 
+                      len - tabort, tabort);
+               mapping = tx_tiny_map(cp, ring, entry, tentry);
+               cas_write_txd(cp, ring, entry, mapping, tabort, ctrl,
+                             (nr_frags == 0));
+       } else {
+               cas_write_txd(cp, ring, entry, mapping, len, ctrl | 
+                             TX_DESC_SOF, (nr_frags == 0));
+       }
+       entry = TX_DESC_NEXT(ring, entry);
+
+       for (frag = 0; frag < nr_frags; frag++) {
+               skb_frag_t *fragp = &skb_shinfo(skb)->frags[frag];
+
+               len = fragp->size;
+               mapping = pci_map_page(cp->pdev, fragp->page,
+                                      fragp->page_offset, len,
+                                      PCI_DMA_TODEVICE);
+
+               tabort = cas_calc_tabort(cp, fragp->page_offset, len);
+               if (unlikely(tabort)) {
+                       void *addr;
+
+                       /* NOTE: len is always > tabort */
+                       cas_write_txd(cp, ring, entry, mapping, len - tabort,
+                                     ctrl, 0);
+                       entry = TX_DESC_NEXT(ring, entry);
+                       
+                       addr = cas_page_map(fragp->page);
+                       memcpy(tx_tiny_buf(cp, ring, entry),
+                              addr + fragp->page_offset + len - tabort, 
+                              tabort);
+                       cas_page_unmap(addr);
+                       mapping = tx_tiny_map(cp, ring, entry, tentry);
+                       len     = tabort;
+               }
+
+               cas_write_txd(cp, ring, entry, mapping, len, ctrl,
+                             (frag + 1 == nr_frags));
+               entry = TX_DESC_NEXT(ring, entry);
+       }
+
+       cp->tx_new[ring] = entry;
+       if (TX_BUFFS_AVAIL(cp, ring) <= CAS_TABORT(cp)*(MAX_SKB_FRAGS + 1))
+               netif_stop_queue(dev);
+
+       if (netif_msg_tx_queued(cp))
+               printk(KERN_DEBUG "%s: tx[%d] queued, slot %d, skblen %d, "
+                      "avail %d\n",
+                      dev->name, ring, entry, skb->len, 
+                      TX_BUFFS_AVAIL(cp, ring));
+       writel(entry, cp->regs + REG_TX_KICKN(ring));
+       spin_unlock_irqrestore(&cp->tx_lock[ring], flags);
+       return 0;
+} 
+
+static int cas_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+
+       /* this is only used as a load-balancing hint, so it doesn't
+        * need to be SMP safe
+        */
+       static int ring; 
+
+       skb = skb_padto(skb, cp->min_frame_size);
+       if (!skb)
+               return 0;
+
+       /* XXX: we need some higher-level QoS hooks to steer packets to
+        *      individual queues.
+        */
+       if (cas_xmit_tx_ringN(cp, ring++ & N_TX_RINGS_MASK, skb))
+               return 1;
+       dev->trans_start = jiffies;
+       return 0;
+}
+
+static void cas_init_tx_dma(struct cas *cp)
+{
+       u64 desc_dma = cp->block_dvma;
+       unsigned long off;
+       u32 val;
+       int i;
+
+       /* set up tx completion writeback registers. must be 8-byte aligned */
+#ifdef USE_TX_COMPWB
+       off = offsetof(struct cas_init_block, tx_compwb);
+       writel((desc_dma + off) >> 32, cp->regs + REG_TX_COMPWB_DB_HI);
+       writel((desc_dma + off) & 0xffffffff, cp->regs + REG_TX_COMPWB_DB_LOW);
+#endif
+
+       /* enable completion writebacks, enable paced mode,
+        * disable read pipe, and disable pre-interrupt compwbs
+        */
+       val =   TX_CFG_COMPWB_Q1 | TX_CFG_COMPWB_Q2 | 
+               TX_CFG_COMPWB_Q3 | TX_CFG_COMPWB_Q4 |
+               TX_CFG_DMA_RDPIPE_DIS | TX_CFG_PACED_MODE | 
+               TX_CFG_INTR_COMPWB_DIS;
+
+       /* write out tx ring info and tx desc bases */
+       for (i = 0; i < MAX_TX_RINGS; i++) {
+               off = (unsigned long) cp->init_txds[i] - 
+                       (unsigned long) cp->init_block;
+
+               val |= CAS_TX_RINGN_BASE(i);
+               writel((desc_dma + off) >> 32, cp->regs + REG_TX_DBN_HI(i));
+               writel((desc_dma + off) & 0xffffffff, cp->regs +
+                      REG_TX_DBN_LOW(i));
+               /* don't zero out the kick register here as the system
+                * will wedge
+                */
+       }
+       writel(val, cp->regs + REG_TX_CFG);
+
+       /* program max burst sizes. these numbers should be different
+        * if doing QoS.
+        */
+#ifdef USE_QOS
+       writel(0x800, cp->regs + REG_TX_MAXBURST_0);
+       writel(0x1600, cp->regs + REG_TX_MAXBURST_1);
+       writel(0x2400, cp->regs + REG_TX_MAXBURST_2);
+       writel(0x4800, cp->regs + REG_TX_MAXBURST_3);
+#else
+       writel(0x800, cp->regs + REG_TX_MAXBURST_0);
+       writel(0x800, cp->regs + REG_TX_MAXBURST_1);
+       writel(0x800, cp->regs + REG_TX_MAXBURST_2);
+       writel(0x800, cp->regs + REG_TX_MAXBURST_3);
+#endif
+}
+
+/* Must be invoked under cp->lock. */
+static inline void cas_init_dma(struct cas *cp)
+{
+       cas_init_tx_dma(cp);
+       cas_init_rx_dma(cp);
+}
+
+/* Must be invoked under cp->lock. */
+static u32 cas_setup_multicast(struct cas *cp)
+{
+       u32 rxcfg = 0;
+       int i;
+       
+       if (cp->dev->flags & IFF_PROMISC) {
+               rxcfg |= MAC_RX_CFG_PROMISC_EN;
+
+       } else if (cp->dev->flags & IFF_ALLMULTI) {
+               for (i=0; i < 16; i++)
+                       writel(0xFFFF, cp->regs + REG_MAC_HASH_TABLEN(i));
+               rxcfg |= MAC_RX_CFG_HASH_FILTER_EN;
+
+       } else {
+               u16 hash_table[16];
+               u32 crc;
+               struct dev_mc_list *dmi = cp->dev->mc_list;
+               int i;
+
+               /* use the alternate mac address registers for the
+                * first 15 multicast addresses
+                */
+               for (i = 1; i <= CAS_MC_EXACT_MATCH_SIZE; i++) {
+                       if (!dmi) {
+                               writel(0x0, cp->regs + REG_MAC_ADDRN(i*3 + 0));
+                               writel(0x0, cp->regs + REG_MAC_ADDRN(i*3 + 1));
+                               writel(0x0, cp->regs + REG_MAC_ADDRN(i*3 + 2));
+                               continue;
+                       }
+                       writel((dmi->dmi_addr[4] << 8) | dmi->dmi_addr[5], 
+                              cp->regs + REG_MAC_ADDRN(i*3 + 0));
+                       writel((dmi->dmi_addr[2] << 8) | dmi->dmi_addr[3], 
+                              cp->regs + REG_MAC_ADDRN(i*3 + 1));
+                       writel((dmi->dmi_addr[0] << 8) | dmi->dmi_addr[1], 
+                              cp->regs + REG_MAC_ADDRN(i*3 + 2));
+                       dmi = dmi->next;
+               }
+
+               /* use hw hash table for the next series of 
+                * multicast addresses
+                */
+               memset(hash_table, 0, sizeof(hash_table));
+               while (dmi) {
+                       crc = ether_crc_le(ETH_ALEN, dmi->dmi_addr);
+                       crc >>= 24;
+                       hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
+                       dmi = dmi->next;
+               }
+               for (i=0; i < 16; i++)
+                       writel(hash_table[i], cp->regs + 
+                              REG_MAC_HASH_TABLEN(i));
+               rxcfg |= MAC_RX_CFG_HASH_FILTER_EN;
+       }
+
+       return rxcfg;
+}
+
+/* must be invoked under cp->stat_lock[N_TX_RINGS] */
+static void cas_clear_mac_err(struct cas *cp)
+{
+       writel(0, cp->regs + REG_MAC_COLL_NORMAL);
+       writel(0, cp->regs + REG_MAC_COLL_FIRST);
+       writel(0, cp->regs + REG_MAC_COLL_EXCESS);
+       writel(0, cp->regs + REG_MAC_COLL_LATE);
+       writel(0, cp->regs + REG_MAC_TIMER_DEFER);
+       writel(0, cp->regs + REG_MAC_ATTEMPTS_PEAK);
+       writel(0, cp->regs + REG_MAC_RECV_FRAME);
+       writel(0, cp->regs + REG_MAC_LEN_ERR);
+       writel(0, cp->regs + REG_MAC_ALIGN_ERR);
+       writel(0, cp->regs + REG_MAC_FCS_ERR);
+       writel(0, cp->regs + REG_MAC_RX_CODE_ERR);
+}
+
+
+static void cas_mac_reset(struct cas *cp)
+{
+       int i;
+
+       /* do both TX and RX reset */
+       writel(0x1, cp->regs + REG_MAC_TX_RESET);
+       writel(0x1, cp->regs + REG_MAC_RX_RESET);
+
+       /* wait for TX */
+       i = STOP_TRIES;
+       while (i-- > 0) {
+               if (readl(cp->regs + REG_MAC_TX_RESET) == 0)
+                       break;
+               udelay(10);
+       }
+
+       /* wait for RX */
+       i = STOP_TRIES;
+       while (i-- > 0) {
+               if (readl(cp->regs + REG_MAC_RX_RESET) == 0)
+                       break;
+               udelay(10);
+       }
+
+       if (readl(cp->regs + REG_MAC_TX_RESET) |
+           readl(cp->regs + REG_MAC_RX_RESET))
+               printk(KERN_ERR "%s: mac tx[%d]/rx[%d] reset failed [%08x]\n",
+                      cp->dev->name, readl(cp->regs + REG_MAC_TX_RESET),
+                      readl(cp->regs + REG_MAC_RX_RESET),
+                      readl(cp->regs + REG_MAC_STATE_MACHINE));
+}
+
+
+/* Must be invoked under cp->lock. */
+static void cas_init_mac(struct cas *cp)
+{
+       unsigned char *e = &cp->dev->dev_addr[0];
+       int i;
+#ifdef CONFIG_CASSINI_MULTICAST_REG_WRITE
+       u32 rxcfg;
+#endif
+       cas_mac_reset(cp);
+
+       /* setup core arbitration weight register */
+       writel(CAWR_RR_DIS, cp->regs + REG_CAWR);
+
+       /* XXX Use pci_dma_burst_advice() */
+#if !defined(CONFIG_SPARC64) && !defined(CONFIG_ALPHA)
+       /* set the infinite burst register for chips that don't have
+        * pci issues.
+        */
+       if ((cp->cas_flags & CAS_FLAG_TARGET_ABORT) == 0)
+               writel(INF_BURST_EN, cp->regs + REG_INF_BURST);
+#endif
+
+       writel(0x1BF0, cp->regs + REG_MAC_SEND_PAUSE);
+
+       writel(0x00, cp->regs + REG_MAC_IPG0);
+       writel(0x08, cp->regs + REG_MAC_IPG1);
+       writel(0x04, cp->regs + REG_MAC_IPG2);
+       
+       /* change later for 802.3z */
+       writel(0x40, cp->regs + REG_MAC_SLOT_TIME); 
+
+       /* min frame + FCS */
+       writel(ETH_ZLEN + 4, cp->regs + REG_MAC_FRAMESIZE_MIN);
+
+       /* Ethernet payload + header + FCS + optional VLAN tag. NOTE: we
+        * specify the maximum frame size to prevent RX tag errors on 
+        * oversized frames.
+        */
+       writel(CAS_BASE(MAC_FRAMESIZE_MAX_BURST, 0x2000) |
+              CAS_BASE(MAC_FRAMESIZE_MAX_FRAME, 
+                       (CAS_MAX_MTU + ETH_HLEN + 4 + 4)), 
+              cp->regs + REG_MAC_FRAMESIZE_MAX);
+
+       /* NOTE: crc_size is used as a surrogate for half-duplex. 
+        * workaround saturn half-duplex issue by increasing preamble
+        * size to 65 bytes.
+        */
+       if ((cp->cas_flags & CAS_FLAG_SATURN) && cp->crc_size)
+               writel(0x41, cp->regs + REG_MAC_PA_SIZE);
+       else
+               writel(0x07, cp->regs + REG_MAC_PA_SIZE);
+       writel(0x04, cp->regs + REG_MAC_JAM_SIZE);
+       writel(0x10, cp->regs + REG_MAC_ATTEMPT_LIMIT);
+       writel(0x8808, cp->regs + REG_MAC_CTRL_TYPE);
+
+       writel((e[5] | (e[4] << 8)) & 0x3ff, cp->regs + REG_MAC_RANDOM_SEED);
+
+       writel(0, cp->regs + REG_MAC_ADDR_FILTER0);
+       writel(0, cp->regs + REG_MAC_ADDR_FILTER1);
+       writel(0, cp->regs + REG_MAC_ADDR_FILTER2);
+       writel(0, cp->regs + REG_MAC_ADDR_FILTER2_1_MASK);
+       writel(0, cp->regs + REG_MAC_ADDR_FILTER0_MASK);
+
+       /* setup mac address in perfect filter array */
+       for (i = 0; i < 45; i++)
+               writel(0x0, cp->regs + REG_MAC_ADDRN(i));
+
+       writel((e[4] << 8) | e[5], cp->regs + REG_MAC_ADDRN(0));
+       writel((e[2] << 8) | e[3], cp->regs + REG_MAC_ADDRN(1));
+       writel((e[0] << 8) | e[1], cp->regs + REG_MAC_ADDRN(2));
+
+       writel(0x0001, cp->regs + REG_MAC_ADDRN(42));
+       writel(0xc200, cp->regs + REG_MAC_ADDRN(43));
+       writel(0x0180, cp->regs + REG_MAC_ADDRN(44));
+
+#ifndef CONFIG_CASSINI_MULTICAST_REG_WRITE
+       cp->mac_rx_cfg = cas_setup_multicast(cp);
+#else
+       /* WTZ: Do what Adrian did in cas_set_multicast. Doing
+        * a writel does not seem to be necessary because Cassini
+        * seems to preserve the configuration when we do the reset.
+        * If the chip is in trouble, though, it is not clear if we
+        * can really count on this behavior. cas_set_multicast uses
+        * spin_lock_irqsave, but we are called only in cas_init_hw and
+        * cas_init_hw is protected by cas_lock_all, which calls
+        * spin_lock_irq (so it doesn't need to save the flags, and
+        * we should be OK for the writel, as that is the only 
+        * difference).
+        */
+       cp->mac_rx_cfg = rxcfg = cas_setup_multicast(cp);
+       writel(rxcfg, cp->regs + REG_MAC_RX_CFG);
+#endif
+       spin_lock(&cp->stat_lock[N_TX_RINGS]);
+       cas_clear_mac_err(cp);
+       spin_unlock(&cp->stat_lock[N_TX_RINGS]);
+
+       /* Setup MAC interrupts.  We want to get all of the interesting
+        * counter expiration events, but we do not want to hear about
+        * normal rx/tx as the DMA engine tells us that.
+        */
+       writel(MAC_TX_FRAME_XMIT, cp->regs + REG_MAC_TX_MASK);
+       writel(MAC_RX_FRAME_RECV, cp->regs + REG_MAC_RX_MASK);
+
+       /* Don't enable even the PAUSE interrupts for now, we
+        * make no use of those events other than to record them.
+        */
+       writel(0xffffffff, cp->regs + REG_MAC_CTRL_MASK);
+}
+
+/* Must be invoked under cp->lock. */
+static void cas_init_pause_thresholds(struct cas *cp)
+{
+       /* Calculate pause thresholds.  Setting the OFF threshold to the
+        * full RX fifo size effectively disables PAUSE generation
+        */
+       if (cp->rx_fifo_size <= (2 * 1024)) {
+               cp->rx_pause_off = cp->rx_pause_on = cp->rx_fifo_size;
+       } else {
+               int max_frame = (cp->dev->mtu + ETH_HLEN + 4 + 4 + 64) & ~63;
+               if (max_frame * 3 > cp->rx_fifo_size) {
+                       cp->rx_pause_off = 7104;
+                       cp->rx_pause_on  = 960;
+               } else {
+                       int off = (cp->rx_fifo_size - (max_frame * 2));
+                       int on = off - max_frame;
+                       cp->rx_pause_off = off;
+                       cp->rx_pause_on = on;
+               }
+       }
+}
+
+static int cas_vpd_match(const void __iomem *p, const char *str)
+{
+       int len = strlen(str) + 1;
+       int i;
+       
+       for (i = 0; i < len; i++) {
+               if (readb(p + i) != str[i])
+                       return 0;
+       }
+       return 1;
+}
+
+
+/* get the mac address by reading the vpd information in the rom.
+ * also get the phy type and determine if there's an entropy generator.
+ * NOTE: this is a bit convoluted for the following reasons:
+ *  1) vpd info has order-dependent mac addresses for multinic cards
+ *  2) the only way to determine the nic order is to use the slot
+ *     number.
+ *  3) fiber cards don't have bridges, so their slot numbers don't
+ *     mean anything.
+ *  4) we don't actually know we have a fiber card until after 
+ *     the mac addresses are parsed.
+ */
+static int cas_get_vpd_info(struct cas *cp, unsigned char *dev_addr,
+                           const int offset)
+{
+       void __iomem *p = cp->regs + REG_EXPANSION_ROM_RUN_START;
+       void __iomem *base, *kstart;
+       int i, len;
+       int found = 0;
+#define VPD_FOUND_MAC        0x01
+#define VPD_FOUND_PHY        0x02
+
+       int phy_type = CAS_PHY_MII_MDIO0; /* default phy type */
+       int mac_off  = 0;
+
+       /* give us access to the PROM */
+       writel(BIM_LOCAL_DEV_PROM | BIM_LOCAL_DEV_PAD,
+              cp->regs + REG_BIM_LOCAL_DEV_EN);
+
+       /* check for an expansion rom */
+       if (readb(p) != 0x55 || readb(p + 1) != 0xaa)
+               goto use_random_mac_addr;
+
+       /* search for beginning of vpd */
+       base = NULL;
+       for (i = 2; i < EXPANSION_ROM_SIZE; i++) {
+               /* check for PCIR */
+               if ((readb(p + i + 0) == 0x50) &&
+                   (readb(p + i + 1) == 0x43) &&
+                   (readb(p + i + 2) == 0x49) &&
+                   (readb(p + i + 3) == 0x52)) {
+                       base = p + (readb(p + i + 8) | 
+                                   (readb(p + i + 9) << 8));
+                       break;
+               }               
+       }
+
+       if (!base || (readb(base) != 0x82))
+               goto use_random_mac_addr;
+       
+       i = (readb(base + 1) | (readb(base + 2) << 8)) + 3;
+       while (i < EXPANSION_ROM_SIZE) {
+               if (readb(base + i) != 0x90) /* no vpd found */
+                       goto use_random_mac_addr;
+
+               /* found a vpd field */
+               len = readb(base + i + 1) | (readb(base + i + 2) << 8);
+
+               /* extract keywords */
+               kstart = base + i + 3;
+               p = kstart;
+               while ((p - kstart) < len) {
+                       int klen = readb(p + 2);
+                       int j;
+                       char type;
+
+                       p += 3;
+                       
+                       /* look for the following things:
+                        * -- correct length == 29
+                        * 3 (type) + 2 (size) + 
+                        * 18 (strlen("local-mac-address") + 1) + 
+                        * 6 (mac addr) 
+                        * -- VPD Instance 'I'
+                        * -- VPD Type Bytes 'B'
+                        * -- VPD data length == 6
+                        * -- property string == local-mac-address
+                        * 
+                        * -- correct length == 24
+                        * 3 (type) + 2 (size) + 
+                        * 12 (strlen("entropy-dev") + 1) + 
+                        * 7 (strlen("vms110") + 1)
+                        * -- VPD Instance 'I'
+                        * -- VPD Type String 'B'
+                        * -- VPD data length == 7
+                        * -- property string == entropy-dev
+                        *
+                        * -- correct length == 18
+                        * 3 (type) + 2 (size) + 
+                        * 9 (strlen("phy-type") + 1) + 
+                        * 4 (strlen("pcs") + 1)
+                        * -- VPD Instance 'I'
+                        * -- VPD Type String 'S'
+                        * -- VPD data length == 4
+                        * -- property string == phy-type
+                        * 
+                        * -- correct length == 23
+                        * 3 (type) + 2 (size) + 
+                        * 14 (strlen("phy-interface") + 1) + 
+                        * 4 (strlen("pcs") + 1)
+                        * -- VPD Instance 'I'
+                        * -- VPD Type String 'S'
+                        * -- VPD data length == 4
+                        * -- property string == phy-interface
+                        */
+                       if (readb(p) != 'I')
+                               goto next;
+
+                       /* finally, check string and length */
+                       type = readb(p + 3);
+                       if (type == 'B') {
+                               if ((klen == 29) && readb(p + 4) == 6 &&
+                                   cas_vpd_match(p + 5, 
+                                                 "local-mac-address")) {
+                                       if (mac_off++ > offset) 
+                                               goto next;
+
+                                       /* set mac address */
+                                       for (j = 0; j < 6; j++) 
+                                               dev_addr[j] = 
+                                                       readb(p + 23 + j);
+                                       goto found_mac;
+                               }
+                       }
+
+                       if (type != 'S')
+                               goto next;
+
+#ifdef USE_ENTROPY_DEV
+                       if ((klen == 24) && 
+                           cas_vpd_match(p + 5, "entropy-dev") &&
+                           cas_vpd_match(p + 17, "vms110")) {
+                               cp->cas_flags |= CAS_FLAG_ENTROPY_DEV;
+                               goto next;
+                       }
+#endif
+
+                       if (found & VPD_FOUND_PHY)
+                               goto next;
+
+                       if ((klen == 18) && readb(p + 4) == 4 &&
+                           cas_vpd_match(p + 5, "phy-type")) {
+                               if (cas_vpd_match(p + 14, "pcs")) {
+                                       phy_type = CAS_PHY_SERDES;
+                                       goto found_phy;
+                               }
+                       }
+                       
+                       if ((klen == 23) && readb(p + 4) == 4 &&
+                           cas_vpd_match(p + 5, "phy-interface")) {
+                               if (cas_vpd_match(p + 19, "pcs")) {
+                                       phy_type = CAS_PHY_SERDES;
+                                       goto found_phy;
+                               }
+                       }
+found_mac:
+                       found |= VPD_FOUND_MAC;
+                       goto next;
+
+found_phy:
+                       found |= VPD_FOUND_PHY;
+
+next:
+                       p += klen;
+               }
+               i += len + 3;
+       }
+
+use_random_mac_addr:
+       if (found & VPD_FOUND_MAC)
+               goto done;
+
+       /* Sun MAC prefix then 3 random bytes. */
+       printk(PFX "MAC address not found in ROM VPD\n");
+       dev_addr[0] = 0x08;
+       dev_addr[1] = 0x00;
+       dev_addr[2] = 0x20;
+       get_random_bytes(dev_addr + 3, 3);
+
+done:
+       writel(0, cp->regs + REG_BIM_LOCAL_DEV_EN);
+       return phy_type;
+}
+
+/* check pci invariants */
+static void cas_check_pci_invariants(struct cas *cp)
+{
+       struct pci_dev *pdev = cp->pdev;
+       u8 rev;
+
+       cp->cas_flags = 0;
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
+       if ((pdev->vendor == PCI_VENDOR_ID_SUN) &&
+           (pdev->device == PCI_DEVICE_ID_SUN_CASSINI)) {
+               if (rev >= CAS_ID_REVPLUS)
+                       cp->cas_flags |= CAS_FLAG_REG_PLUS;
+               if (rev < CAS_ID_REVPLUS02u)
+                       cp->cas_flags |= CAS_FLAG_TARGET_ABORT;
+
+               /* Original Cassini supports HW CSUM, but it's not
+                * enabled by default as it can trigger TX hangs.
+                */
+               if (rev < CAS_ID_REV2)
+                       cp->cas_flags |= CAS_FLAG_NO_HW_CSUM;
+       } else {
+               /* Only sun has original cassini chips.  */
+               cp->cas_flags |= CAS_FLAG_REG_PLUS;
+
+               /* We use a flag because the same phy might be externally
+                * connected.
+                */
+               if ((pdev->vendor == PCI_VENDOR_ID_NS) &&
+                   (pdev->device == PCI_DEVICE_ID_NS_SATURN))
+                       cp->cas_flags |= CAS_FLAG_SATURN;
+       }
+}
+
+
+static int cas_check_invariants(struct cas *cp)
+{
+       struct pci_dev *pdev = cp->pdev;
+       u32 cfg;
+       int i;
+
+       /* get page size for rx buffers. */
+       cp->page_order = 0; 
+#ifdef USE_PAGE_ORDER
+       if (PAGE_SHIFT < CAS_JUMBO_PAGE_SHIFT) {
+               /* see if we can allocate larger pages */
+               struct page *page = alloc_pages(GFP_ATOMIC, 
+                                               CAS_JUMBO_PAGE_SHIFT - 
+                                               PAGE_SHIFT);
+               if (page) {
+                       __free_pages(page, CAS_JUMBO_PAGE_SHIFT - PAGE_SHIFT);
+                       cp->page_order = CAS_JUMBO_PAGE_SHIFT - PAGE_SHIFT;
+               } else {
+                       printk(PFX "MTU limited to %d bytes\n", CAS_MAX_MTU);
+               }
+       }
+#endif
+       cp->page_size = (PAGE_SIZE << cp->page_order);
+
+       /* Fetch the FIFO configurations. */
+       cp->tx_fifo_size = readl(cp->regs + REG_TX_FIFO_SIZE) * 64;
+       cp->rx_fifo_size = RX_FIFO_SIZE;
+
+       /* finish phy determination. MDIO1 takes precedence over MDIO0 if 
+        * they're both connected.
+        */
+       cp->phy_type = cas_get_vpd_info(cp, cp->dev->dev_addr, 
+                                       PCI_SLOT(pdev->devfn));
+       if (cp->phy_type & CAS_PHY_SERDES) {
+               cp->cas_flags |= CAS_FLAG_1000MB_CAP;
+               return 0; /* no more checking needed */
+       } 
+
+       /* MII */
+       cfg = readl(cp->regs + REG_MIF_CFG);
+       if (cfg & MIF_CFG_MDIO_1) {
+               cp->phy_type = CAS_PHY_MII_MDIO1;
+       } else if (cfg & MIF_CFG_MDIO_0) {
+               cp->phy_type = CAS_PHY_MII_MDIO0;
+       }
+
+       cas_mif_poll(cp, 0);
+       writel(PCS_DATAPATH_MODE_MII, cp->regs + REG_PCS_DATAPATH_MODE);
+
+       for (i = 0; i < 32; i++) {
+               u32 phy_id;
+               int j;
+
+               for (j = 0; j < 3; j++) {
+                       cp->phy_addr = i;
+                       phy_id = cas_phy_read(cp, MII_PHYSID1) << 16;
+                       phy_id |= cas_phy_read(cp, MII_PHYSID2);
+                       if (phy_id && (phy_id != 0xFFFFFFFF)) {
+                               cp->phy_id = phy_id;
+                               goto done;
+                       }
+               }
+       }
+       printk(KERN_ERR PFX "MII phy did not respond [%08x]\n",
+              readl(cp->regs + REG_MIF_STATE_MACHINE));
+       return -1;
+
+done:
+       /* see if we can do gigabit */
+       cfg = cas_phy_read(cp, MII_BMSR);
+       if ((cfg & CAS_BMSR_1000_EXTEND) && 
+           cas_phy_read(cp, CAS_MII_1000_EXTEND))
+               cp->cas_flags |= CAS_FLAG_1000MB_CAP;
+       return 0;
+}
+
+/* Must be invoked under cp->lock. */
+static inline void cas_start_dma(struct cas *cp)
+{
+       int i;
+       u32 val;
+       int txfailed = 0;
+       
+       /* enable dma */
+       val = readl(cp->regs + REG_TX_CFG) | TX_CFG_DMA_EN;
+       writel(val, cp->regs + REG_TX_CFG);
+       val = readl(cp->regs + REG_RX_CFG) | RX_CFG_DMA_EN;
+       writel(val, cp->regs + REG_RX_CFG);
+
+       /* enable the mac */
+       val = readl(cp->regs + REG_MAC_TX_CFG) | MAC_TX_CFG_EN;
+       writel(val, cp->regs + REG_MAC_TX_CFG);
+       val = readl(cp->regs + REG_MAC_RX_CFG) | MAC_RX_CFG_EN;
+       writel(val, cp->regs + REG_MAC_RX_CFG);
+
+       i = STOP_TRIES;
+       while (i-- > 0) {
+               val = readl(cp->regs + REG_MAC_TX_CFG);
+               if ((val & MAC_TX_CFG_EN))
+                       break;
+               udelay(10);
+       }
+       if (i < 0) txfailed = 1;
+       i = STOP_TRIES;
+       while (i-- > 0) {
+               val = readl(cp->regs + REG_MAC_RX_CFG);
+               if ((val & MAC_RX_CFG_EN)) {
+                       if (txfailed) {
+                         printk(KERN_ERR 
+                                "%s: enabling mac failed [tx:%08x:%08x].\n", 
+                                cp->dev->name,
+                                readl(cp->regs + REG_MIF_STATE_MACHINE),
+                                readl(cp->regs + REG_MAC_STATE_MACHINE));
+                       }
+                       goto enable_rx_done;
+               }
+               udelay(10);
+       }
+       printk(KERN_ERR "%s: enabling mac failed [%s:%08x:%08x].\n", 
+              cp->dev->name,
+              (txfailed? "tx,rx":"rx"),
+              readl(cp->regs + REG_MIF_STATE_MACHINE),
+              readl(cp->regs + REG_MAC_STATE_MACHINE));
+
+enable_rx_done:
+       cas_unmask_intr(cp); /* enable interrupts */
+       writel(RX_DESC_RINGN_SIZE(0) - 4, cp->regs + REG_RX_KICK);
+       writel(0, cp->regs + REG_RX_COMP_TAIL);
+
+       if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
+               if (N_RX_DESC_RINGS > 1) 
+                       writel(RX_DESC_RINGN_SIZE(1) - 4, 
+                              cp->regs + REG_PLUS_RX_KICK1);
+
+               for (i = 1; i < N_RX_COMP_RINGS; i++) 
+                       writel(0, cp->regs + REG_PLUS_RX_COMPN_TAIL(i));
+       }
+}
+
+/* Must be invoked under cp->lock. */
+static void cas_read_pcs_link_mode(struct cas *cp, int *fd, int *spd,
+                                  int *pause)
+{
+       u32 val = readl(cp->regs + REG_PCS_MII_LPA);
+       *fd     = (val & PCS_MII_LPA_FD) ? 1 : 0;
+       *pause  = (val & PCS_MII_LPA_SYM_PAUSE) ? 0x01 : 0x00;
+       if (val & PCS_MII_LPA_ASYM_PAUSE)
+               *pause |= 0x10;
+       *spd = 1000;
+}
+
+/* Must be invoked under cp->lock. */
+static void cas_read_mii_link_mode(struct cas *cp, int *fd, int *spd,
+                                  int *pause)
+{
+       u32 val;
+
+       *fd = 0;
+       *spd = 10;
+       *pause = 0;
+       
+       /* use GMII registers */
+       val = cas_phy_read(cp, MII_LPA);
+       if (val & CAS_LPA_PAUSE)
+               *pause = 0x01;
+
+       if (val & CAS_LPA_ASYM_PAUSE)
+               *pause |= 0x10;
+
+       if (val & LPA_DUPLEX)
+               *fd = 1;
+       if (val & LPA_100)
+               *spd = 100;
+
+       if (cp->cas_flags & CAS_FLAG_1000MB_CAP) {
+               val = cas_phy_read(cp, CAS_MII_1000_STATUS);
+               if (val & (CAS_LPA_1000FULL | CAS_LPA_1000HALF))
+                       *spd = 1000;
+               if (val & CAS_LPA_1000FULL)
+                       *fd = 1;
+       }
+}
+
+/* A link-up condition has occurred, initialize and enable the
+ * rest of the chip.
+ *
+ * Must be invoked under cp->lock.
+ */
+static void cas_set_link_modes(struct cas *cp)
+{
+       u32 val;
+       int full_duplex, speed, pause;
+
+       full_duplex = 0;
+       speed = 10;
+       pause = 0;
+
+       if (CAS_PHY_MII(cp->phy_type)) {
+               cas_mif_poll(cp, 0);
+               val = cas_phy_read(cp, MII_BMCR);
+               if (val & BMCR_ANENABLE) {
+                       cas_read_mii_link_mode(cp, &full_duplex, &speed, 
+                                              &pause);
+               } else {
+                       if (val & BMCR_FULLDPLX)
+                               full_duplex = 1;
+
+                       if (val & BMCR_SPEED100)
+                               speed = 100;
+                       else if (val & CAS_BMCR_SPEED1000)
+                               speed = (cp->cas_flags & CAS_FLAG_1000MB_CAP) ?
+                                       1000 : 100;
+               }
+               cas_mif_poll(cp, 1);
+
+       } else {
+               val = readl(cp->regs + REG_PCS_MII_CTRL);
+               cas_read_pcs_link_mode(cp, &full_duplex, &speed, &pause);
+               if ((val & PCS_MII_AUTONEG_EN) == 0) {
+                       if (val & PCS_MII_CTRL_DUPLEX)
+                               full_duplex = 1;
+               }
+       }
+
+       if (netif_msg_link(cp))
+               printk(KERN_INFO "%s: Link up at %d Mbps, %s-duplex.\n",
+                      cp->dev->name, speed, (full_duplex ? "full" : "half"));
+
+       val = MAC_XIF_TX_MII_OUTPUT_EN | MAC_XIF_LINK_LED;
+       if (CAS_PHY_MII(cp->phy_type)) {
+               val |= MAC_XIF_MII_BUFFER_OUTPUT_EN;
+               if (!full_duplex)
+                       val |= MAC_XIF_DISABLE_ECHO;
+       }
+       if (full_duplex) 
+               val |= MAC_XIF_FDPLX_LED;
+       if (speed == 1000)
+               val |= MAC_XIF_GMII_MODE;
+       writel(val, cp->regs + REG_MAC_XIF_CFG);
+
+       /* deal with carrier and collision detect. */
+       val = MAC_TX_CFG_IPG_EN;
+       if (full_duplex) {
+               val |= MAC_TX_CFG_IGNORE_CARRIER;
+               val |= MAC_TX_CFG_IGNORE_COLL;
+       } else {
+#ifndef USE_CSMA_CD_PROTO
+               val |= MAC_TX_CFG_NEVER_GIVE_UP_EN;
+               val |= MAC_TX_CFG_NEVER_GIVE_UP_LIM;
+#endif
+       }
+       /* val now set up for REG_MAC_TX_CFG */
+
+       /* If gigabit and half-duplex, enable carrier extension
+        * mode.  increase slot time to 512 bytes as well. 
+        * else, disable it and make sure slot time is 64 bytes.
+        * also activate checksum bug workaround
+        */
+       if ((speed == 1000) && !full_duplex) {
+               writel(val | MAC_TX_CFG_CARRIER_EXTEND, 
+                      cp->regs + REG_MAC_TX_CFG);
+
+               val = readl(cp->regs + REG_MAC_RX_CFG);
+               val &= ~MAC_RX_CFG_STRIP_FCS; /* checksum workaround */
+               writel(val | MAC_RX_CFG_CARRIER_EXTEND, 
+                      cp->regs + REG_MAC_RX_CFG);
+
+               writel(0x200, cp->regs + REG_MAC_SLOT_TIME);
+
+               cp->crc_size = 4;
+               /* minimum size gigabit frame at half duplex */
+               cp->min_frame_size = CAS_1000MB_MIN_FRAME;
+
+       } else {
+               writel(val, cp->regs + REG_MAC_TX_CFG);
+
+               /* checksum bug workaround. don't strip FCS when in 
+                * half-duplex mode
+                */
+               val = readl(cp->regs + REG_MAC_RX_CFG);
+               if (full_duplex) {
+                       val |= MAC_RX_CFG_STRIP_FCS;
+                       cp->crc_size = 0;
+                       cp->min_frame_size = CAS_MIN_MTU;
+               } else {
+                       val &= ~MAC_RX_CFG_STRIP_FCS;
+                       cp->crc_size = 4;
+                       cp->min_frame_size = CAS_MIN_FRAME;
+               }
+               writel(val & ~MAC_RX_CFG_CARRIER_EXTEND, 
+                      cp->regs + REG_MAC_RX_CFG);
+               writel(0x40, cp->regs + REG_MAC_SLOT_TIME);
+       }
+
+       if (netif_msg_link(cp)) {
+               if (pause & 0x01) {
+                       printk(KERN_INFO "%s: Pause is enabled "
+                              "(rxfifo: %d off: %d on: %d)\n",
+                              cp->dev->name,
+                              cp->rx_fifo_size,
+                              cp->rx_pause_off,
+                              cp->rx_pause_on);
+               } else if (pause & 0x10) {
+                       printk(KERN_INFO "%s: TX pause enabled\n",
+                              cp->dev->name);
+               } else {
+                       printk(KERN_INFO "%s: Pause is disabled\n",
+                              cp->dev->name);
+               }
+       }
+
+       val = readl(cp->regs + REG_MAC_CTRL_CFG);
+       val &= ~(MAC_CTRL_CFG_SEND_PAUSE_EN | MAC_CTRL_CFG_RECV_PAUSE_EN);
+       if (pause) { /* symmetric or asymmetric pause */
+               val |= MAC_CTRL_CFG_SEND_PAUSE_EN;
+               if (pause & 0x01) { /* symmetric pause */
+                       val |= MAC_CTRL_CFG_RECV_PAUSE_EN;
+               } 
+       }
+       writel(val, cp->regs + REG_MAC_CTRL_CFG);
+       cas_start_dma(cp);
+}
+
+/* Must be invoked under cp->lock. */
+static void cas_init_hw(struct cas *cp, int restart_link)
+{
+       if (restart_link)
+               cas_phy_init(cp);
+
+       cas_init_pause_thresholds(cp);
+       cas_init_mac(cp);
+       cas_init_dma(cp);
+
+       if (restart_link) {
+               /* Default aneg parameters */
+               cp->timer_ticks = 0;
+               cas_begin_auto_negotiation(cp, NULL);
+       } else if (cp->lstate == link_up) {
+               cas_set_link_modes(cp);
+               netif_carrier_on(cp->dev);
+       }
+}
+
+/* Must be invoked under cp->lock. on earlier cassini boards,
+ * SOFT_0 is tied to PCI reset. we use this to force a pci reset,
+ * let it settle out, and then restore pci state.
+ */
+static void cas_hard_reset(struct cas *cp)
+{
+       writel(BIM_LOCAL_DEV_SOFT_0, cp->regs + REG_BIM_LOCAL_DEV_EN); 
+       udelay(20);
+       pci_restore_state(cp->pdev);
+}
+
+
+static void cas_global_reset(struct cas *cp, int blkflag)
+{
+       int limit;
+
+       /* issue a global reset. don't use RSTOUT. */
+       if (blkflag && !CAS_PHY_MII(cp->phy_type)) {
+               /* For PCS, when the blkflag is set, we should set the
+                * SW_REST_BLOCK_PCS_SLINK bit to prevent the results of
+                * the last autonegotiation from being cleared.  We'll
+                * need some special handling if the chip is set into a
+                * loopback mode.
+                */
+               writel((SW_RESET_TX | SW_RESET_RX | SW_RESET_BLOCK_PCS_SLINK), 
+                      cp->regs + REG_SW_RESET);
+       } else {
+               writel(SW_RESET_TX | SW_RESET_RX, cp->regs + REG_SW_RESET);
+       }
+
+       /* need to wait at least 3ms before polling register */
+       mdelay(3);
+
+       limit = STOP_TRIES;
+       while (limit-- > 0) {
+               u32 val = readl(cp->regs + REG_SW_RESET);
+               if ((val & (SW_RESET_TX | SW_RESET_RX)) == 0)
+                       goto done;
+               udelay(10);
+       }
+       printk(KERN_ERR "%s: sw reset failed.\n", cp->dev->name);
+
+done:
+       /* enable various BIM interrupts */
+       writel(BIM_CFG_DPAR_INTR_ENABLE | BIM_CFG_RMA_INTR_ENABLE | 
+              BIM_CFG_RTA_INTR_ENABLE, cp->regs + REG_BIM_CFG);
+
+       /* clear out pci error status mask for handled errors.
+        * we don't deal with DMA counter overflows as they happen
+        * all the time.
+        */
+       writel(0xFFFFFFFFU & ~(PCI_ERR_BADACK | PCI_ERR_DTRTO | 
+                              PCI_ERR_OTHER | PCI_ERR_BIM_DMA_WRITE | 
+                              PCI_ERR_BIM_DMA_READ), cp->regs + 
+              REG_PCI_ERR_STATUS_MASK);
+
+       /* set up for MII by default to address mac rx reset timeout
+        * issue
+        */
+       writel(PCS_DATAPATH_MODE_MII, cp->regs + REG_PCS_DATAPATH_MODE);
+}
+
+static void cas_reset(struct cas *cp, int blkflag)
+{
+       u32 val;
+
+       cas_mask_intr(cp);
+       cas_global_reset(cp, blkflag);
+       cas_mac_reset(cp);
+       cas_entropy_reset(cp);
+
+       /* disable dma engines. */
+       val = readl(cp->regs + REG_TX_CFG);
+       val &= ~TX_CFG_DMA_EN;
+       writel(val, cp->regs + REG_TX_CFG);
+
+       val = readl(cp->regs + REG_RX_CFG);
+       val &= ~RX_CFG_DMA_EN;
+       writel(val, cp->regs + REG_RX_CFG);
+
+       /* program header parser */
+       if ((cp->cas_flags & CAS_FLAG_TARGET_ABORT) ||
+           (CAS_HP_ALT_FIRMWARE == cas_prog_null)) {
+               cas_load_firmware(cp, CAS_HP_FIRMWARE);
+       } else {
+               cas_load_firmware(cp, CAS_HP_ALT_FIRMWARE);
+       }
+
+       /* clear out error registers */
+       spin_lock(&cp->stat_lock[N_TX_RINGS]);
+       cas_clear_mac_err(cp);
+       spin_unlock(&cp->stat_lock[N_TX_RINGS]);
+}
+
+/* Shut down the chip, must be called with pm_sem held.  */
+static void cas_shutdown(struct cas *cp)
+{
+       unsigned long flags;
+
+       /* Make us not-running to avoid timers respawning */
+       cp->hw_running = 0;
+
+       del_timer_sync(&cp->link_timer);
+
+       /* Stop the reset task */
+#if 0
+       while (atomic_read(&cp->reset_task_pending_mtu) ||
+              atomic_read(&cp->reset_task_pending_spare) ||
+              atomic_read(&cp->reset_task_pending_all))
+               schedule();
+
+#else
+       while (atomic_read(&cp->reset_task_pending))
+               schedule();
+#endif 
+       /* Actually stop the chip */
+       cas_lock_all_save(cp, flags);
+       cas_reset(cp, 0);
+       if (cp->cas_flags & CAS_FLAG_SATURN)
+               cas_phy_powerdown(cp);
+       cas_unlock_all_restore(cp, flags);
+}
+
+static int cas_change_mtu(struct net_device *dev, int new_mtu)
+{
+       struct cas *cp = netdev_priv(dev);
+
+       if (new_mtu < CAS_MIN_MTU || new_mtu > CAS_MAX_MTU)
+               return -EINVAL;
+
+       dev->mtu = new_mtu;
+       if (!netif_running(dev) || !netif_device_present(dev))
+               return 0;
+
+       /* let the reset task handle it */
+#if 1
+       atomic_inc(&cp->reset_task_pending);
+       if ((cp->phy_type & CAS_PHY_SERDES)) {
+               atomic_inc(&cp->reset_task_pending_all);
+       } else {
+               atomic_inc(&cp->reset_task_pending_mtu);
+       }
+       schedule_work(&cp->reset_task);
+#else
+       atomic_set(&cp->reset_task_pending, (cp->phy_type & CAS_PHY_SERDES) ? 
+                  CAS_RESET_ALL : CAS_RESET_MTU);
+       printk(KERN_ERR "reset called in cas_change_mtu\n");
+       schedule_work(&cp->reset_task);
+#endif
+
+       flush_scheduled_work();
+       return 0;
+}
+
+static void cas_clean_txd(struct cas *cp, int ring)
+{
+       struct cas_tx_desc *txd = cp->init_txds[ring];
+       struct sk_buff *skb, **skbs = cp->tx_skbs[ring];
+       u64 daddr, dlen;
+       int i, size;
+
+       size = TX_DESC_RINGN_SIZE(ring);
+       for (i = 0; i < size; i++) {
+               int frag;
+
+               if (skbs[i] == NULL)
+                       continue;
+
+               skb = skbs[i];
+               skbs[i] = NULL;
+
+               for (frag = 0; frag <= skb_shinfo(skb)->nr_frags;  frag++) {
+                       int ent = i & (size - 1);
+
+                       /* first buffer is never a tiny buffer and so
+                        * needs to be unmapped.
+                        */
+                       daddr = le64_to_cpu(txd[ent].buffer);
+                       dlen  =  CAS_VAL(TX_DESC_BUFLEN, 
+                                        le64_to_cpu(txd[ent].control));
+                       pci_unmap_page(cp->pdev, daddr, dlen,
+                                      PCI_DMA_TODEVICE);
+
+                       if (frag != skb_shinfo(skb)->nr_frags) {
+                               i++;
+
+                               /* next buffer might by a tiny buffer.
+                                * skip past it.
+                                */
+                               ent = i & (size - 1);
+                               if (cp->tx_tiny_use[ring][ent].used)
+                                       i++;
+                       }
+               }
+               dev_kfree_skb_any(skb);
+       }
+
+       /* zero out tiny buf usage */
+       memset(cp->tx_tiny_use[ring], 0, size*sizeof(*cp->tx_tiny_use[ring]));
+}
+
+/* freed on close */
+static inline void cas_free_rx_desc(struct cas *cp, int ring)
+{
+       cas_page_t **page = cp->rx_pages[ring];
+       int i, size;
+
+       size = RX_DESC_RINGN_SIZE(ring);
+       for (i = 0; i < size; i++) {
+               if (page[i]) {
+                       cas_page_free(cp, page[i]);
+                       page[i] = NULL;
+               }
+       }
+}
+
+static void cas_free_rxds(struct cas *cp)
+{
+       int i;
+
+       for (i = 0; i < N_RX_DESC_RINGS; i++)
+               cas_free_rx_desc(cp, i);
+}
+
+/* Must be invoked under cp->lock. */
+static void cas_clean_rings(struct cas *cp)
+{
+       int i;
+
+       /* need to clean all tx rings */
+       memset(cp->tx_old, 0, sizeof(*cp->tx_old)*N_TX_RINGS);
+       memset(cp->tx_new, 0, sizeof(*cp->tx_new)*N_TX_RINGS);
+       for (i = 0; i < N_TX_RINGS; i++)
+               cas_clean_txd(cp, i);
+
+       /* zero out init block */
+       memset(cp->init_block, 0, sizeof(struct cas_init_block));
+       cas_clean_rxds(cp);
+       cas_clean_rxcs(cp);
+}
+
+/* allocated on open */
+static inline int cas_alloc_rx_desc(struct cas *cp, int ring)
+{
+       cas_page_t **page = cp->rx_pages[ring];
+       int size, i = 0;
+
+       size = RX_DESC_RINGN_SIZE(ring);
+       for (i = 0; i < size; i++) {
+               if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL) 
+                       return -1;
+       }
+       return 0;
+}
+
+static int cas_alloc_rxds(struct cas *cp)
+{
+       int i;
+
+       for (i = 0; i < N_RX_DESC_RINGS; i++) {
+               if (cas_alloc_rx_desc(cp, i) < 0) {
+                       cas_free_rxds(cp);
+                       return -1;
+               }
+       }
+       return 0;
+}
+
+static void cas_reset_task(void *data)
+{
+       struct cas *cp = (struct cas *) data;
+#if 0
+       int pending = atomic_read(&cp->reset_task_pending);
+#else
+       int pending_all = atomic_read(&cp->reset_task_pending_all);
+       int pending_spare = atomic_read(&cp->reset_task_pending_spare);
+       int pending_mtu = atomic_read(&cp->reset_task_pending_mtu);
+
+       if (pending_all == 0 && pending_spare == 0 && pending_mtu == 0) {
+               /* We can have more tasks scheduled than actually
+                * needed.
+                */
+               atomic_dec(&cp->reset_task_pending);
+               return;
+       }
+#endif
+       /* The link went down, we reset the ring, but keep
+        * DMA stopped. Use this function for reset
+        * on error as well.
+        */
+       if (cp->hw_running) {
+               unsigned long flags;
+
+               /* Make sure we don't get interrupts or tx packets */
+               netif_device_detach(cp->dev);
+               cas_lock_all_save(cp, flags);
+
+               if (cp->opened) {
+                       /* We call cas_spare_recover when we call cas_open.
+                        * but we do not initialize the lists cas_spare_recover
+                        * uses until cas_open is called.
+                        */
+                       cas_spare_recover(cp, GFP_ATOMIC);
+               }
+#if 1
+               /* test => only pending_spare set */
+               if (!pending_all && !pending_mtu)
+                       goto done;
+#else
+               if (pending == CAS_RESET_SPARE)
+                       goto done;
+#endif
+               /* when pending == CAS_RESET_ALL, the following
+                * call to cas_init_hw will restart auto negotiation.
+                * Setting the second argument of cas_reset to
+                * !(pending == CAS_RESET_ALL) will set this argument
+                * to 1 (avoiding reinitializing the PHY for the normal 
+                * PCS case) when auto negotiation is not restarted.
+                */
+#if 1
+               cas_reset(cp, !(pending_all > 0));
+               if (cp->opened)
+                       cas_clean_rings(cp);
+               cas_init_hw(cp, (pending_all > 0));
+#else
+               cas_reset(cp, !(pending == CAS_RESET_ALL));
+               if (cp->opened)
+                       cas_clean_rings(cp);
+               cas_init_hw(cp, pending == CAS_RESET_ALL);
+#endif
+
+done:
+               cas_unlock_all_restore(cp, flags);
+               netif_device_attach(cp->dev);
+       }
+#if 1
+       atomic_sub(pending_all, &cp->reset_task_pending_all);
+       atomic_sub(pending_spare, &cp->reset_task_pending_spare);
+       atomic_sub(pending_mtu, &cp->reset_task_pending_mtu);
+       atomic_dec(&cp->reset_task_pending);
+#else
+       atomic_set(&cp->reset_task_pending, 0);
+#endif
+}
+
+static void cas_link_timer(unsigned long data)
+{
+       struct cas *cp = (struct cas *) data;
+       int mask, pending = 0, reset = 0;
+       unsigned long flags;
+
+       if (link_transition_timeout != 0 &&
+           cp->link_transition_jiffies_valid &&
+           ((jiffies - cp->link_transition_jiffies) > 
+             (link_transition_timeout))) {
+               /* One-second counter so link-down workaround doesn't 
+                * cause resets to occur so fast as to fool the switch
+                * into thinking the link is down.
+                */
+               cp->link_transition_jiffies_valid = 0;
+       }
+
+       if (!cp->hw_running)
+               return;
+
+       spin_lock_irqsave(&cp->lock, flags);
+       cas_lock_tx(cp);
+       cas_entropy_gather(cp);
+
+       /* If the link task is still pending, we just
+        * reschedule the link timer
+        */
+#if 1
+       if (atomic_read(&cp->reset_task_pending_all) ||
+           atomic_read(&cp->reset_task_pending_spare) ||
+           atomic_read(&cp->reset_task_pending_mtu)) 
+               goto done;
+#else
+       if (atomic_read(&cp->reset_task_pending)) 
+               goto done;
+#endif
+
+       /* check for rx cleaning */
+       if ((mask = (cp->cas_flags & CAS_FLAG_RXD_POST_MASK))) {
+               int i, rmask;
+
+               for (i = 0; i < MAX_RX_DESC_RINGS; i++) {
+                       rmask = CAS_FLAG_RXD_POST(i);
+                       if ((mask & rmask) == 0)
+                               continue;
+
+                       /* post_rxds will do a mod_timer */
+                       if (cas_post_rxds_ringN(cp, i, cp->rx_last[i]) < 0) {
+                               pending = 1;
+                               continue;
+                       }
+                       cp->cas_flags &= ~rmask;
+               }
+       }
+
+       if (CAS_PHY_MII(cp->phy_type)) {
+               u16 bmsr;
+               cas_mif_poll(cp, 0);
+               bmsr = cas_phy_read(cp, MII_BMSR);
+               /* WTZ: Solaris driver reads this twice, but that
+                * may be due to the PCS case and the use of a
+                * common implementation. Read it twice here to be
+                * safe.
+                */
+               bmsr = cas_phy_read(cp, MII_BMSR);
+               cas_mif_poll(cp, 1);
+               readl(cp->regs + REG_MIF_STATUS); /* avoid dups */
+               reset = cas_mii_link_check(cp, bmsr);
+       } else {
+               reset = cas_pcs_link_check(cp);
+       }
+
+       if (reset)
+               goto done;
+
+       /* check for tx state machine confusion */
+       if ((readl(cp->regs + REG_MAC_TX_STATUS) & MAC_TX_FRAME_XMIT) == 0) {
+               u32 val = readl(cp->regs + REG_MAC_STATE_MACHINE);
+               u32 wptr, rptr;
+               int tlm  = CAS_VAL(MAC_SM_TLM, val);
+
+               if (((tlm == 0x5) || (tlm == 0x3)) &&
+                   (CAS_VAL(MAC_SM_ENCAP_SM, val) == 0)) {
+                       if (netif_msg_tx_err(cp))
+                               printk(KERN_DEBUG "%s: tx err: "
+                                      "MAC_STATE[%08x]\n",
+                                      cp->dev->name, val);
+                       reset = 1;
+                       goto done;
+               }
+
+               val  = readl(cp->regs + REG_TX_FIFO_PKT_CNT);
+               wptr = readl(cp->regs + REG_TX_FIFO_WRITE_PTR);
+               rptr = readl(cp->regs + REG_TX_FIFO_READ_PTR);
+               if ((val == 0) && (wptr != rptr)) {
+                       if (netif_msg_tx_err(cp))
+                               printk(KERN_DEBUG "%s: tx err: "
+                                      "TX_FIFO[%08x:%08x:%08x]\n",
+                                      cp->dev->name, val, wptr, rptr);
+                       reset = 1;
+               }
+
+               if (reset)
+                       cas_hard_reset(cp);
+       }
+
+done:
+       if (reset) {
+#if 1
+               atomic_inc(&cp->reset_task_pending);
+               atomic_inc(&cp->reset_task_pending_all);
+               schedule_work(&cp->reset_task);
+#else
+               atomic_set(&cp->reset_task_pending, CAS_RESET_ALL);
+               printk(KERN_ERR "reset called in cas_link_timer\n");
+               schedule_work(&cp->reset_task);
+#endif
+       }
+
+       if (!pending)
+               mod_timer(&cp->link_timer, jiffies + CAS_LINK_TIMEOUT);
+       cas_unlock_tx(cp);
+       spin_unlock_irqrestore(&cp->lock, flags);
+}
+
+/* tiny buffers are used to avoid target abort issues with 
+ * older cassini's
+ */
+static void cas_tx_tiny_free(struct cas *cp)
+{
+       struct pci_dev *pdev = cp->pdev;
+       int i;
+
+       for (i = 0; i < N_TX_RINGS; i++) {
+               if (!cp->tx_tiny_bufs[i])
+                       continue;
+
+               pci_free_consistent(pdev, TX_TINY_BUF_BLOCK, 
+                                   cp->tx_tiny_bufs[i],
+                                   cp->tx_tiny_dvma[i]);
+               cp->tx_tiny_bufs[i] = NULL;
+       }
+}
+
+static int cas_tx_tiny_alloc(struct cas *cp)
+{
+       struct pci_dev *pdev = cp->pdev;
+       int i;
+
+       for (i = 0; i < N_TX_RINGS; i++) {
+               cp->tx_tiny_bufs[i] = 
+                       pci_alloc_consistent(pdev, TX_TINY_BUF_BLOCK,
+                                            &cp->tx_tiny_dvma[i]);
+               if (!cp->tx_tiny_bufs[i]) {
+                       cas_tx_tiny_free(cp);
+                       return -1;
+               }
+       }
+       return 0;
+}
+
+
+static int cas_open(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       int hw_was_up, err;
+       unsigned long flags;
+
+       down(&cp->pm_sem);
+
+       hw_was_up = cp->hw_running;
+
+       /* The power-management semaphore protects the hw_running
+        * etc. state so it is safe to do this bit without cp->lock
+        */
+       if (!cp->hw_running) {
+               /* Reset the chip */
+               cas_lock_all_save(cp, flags);
+               /* We set the second arg to cas_reset to zero
+                * because cas_init_hw below will have its second 
+                * argument set to non-zero, which will force
+                * autonegotiation to start.
+                */
+               cas_reset(cp, 0);
+               cp->hw_running = 1;
+               cas_unlock_all_restore(cp, flags);
+       }
+
+       if (cas_tx_tiny_alloc(cp) < 0)
+               return -ENOMEM;
+
+       /* alloc rx descriptors */
+       err = -ENOMEM;
+       if (cas_alloc_rxds(cp) < 0)
+               goto err_tx_tiny;
+       
+       /* allocate spares */
+       cas_spare_init(cp);
+       cas_spare_recover(cp, GFP_KERNEL);
+
+       /* We can now request the interrupt as we know it's masked
+        * on the controller. cassini+ has up to 4 interrupts
+        * that can be used, but you need to do explicit pci interrupt 
+        * mapping to expose them
+        */
+       if (request_irq(cp->pdev->irq, cas_interrupt,
+                       SA_SHIRQ, dev->name, (void *) dev)) {
+               printk(KERN_ERR "%s: failed to request irq !\n", 
+                      cp->dev->name);
+               err = -EAGAIN;
+               goto err_spare;
+       }
+
+       /* init hw */
+       cas_lock_all_save(cp, flags);
+       cas_clean_rings(cp);
+       cas_init_hw(cp, !hw_was_up);
+       cp->opened = 1;
+       cas_unlock_all_restore(cp, flags);
+
+       netif_start_queue(dev);
+       up(&cp->pm_sem);
+       return 0;
+
+err_spare:
+       cas_spare_free(cp);
+       cas_free_rxds(cp);
+err_tx_tiny:
+       cas_tx_tiny_free(cp);
+       up(&cp->pm_sem);
+       return err;
+}
+
+static int cas_close(struct net_device *dev)
+{
+       unsigned long flags;
+       struct cas *cp = netdev_priv(dev);
+
+       /* Make sure we don't get distracted by suspend/resume */
+       down(&cp->pm_sem);
+
+       netif_stop_queue(dev);
+
+       /* Stop traffic, mark us closed */
+       cas_lock_all_save(cp, flags);
+       cp->opened = 0; 
+       cas_reset(cp, 0);
+       cas_phy_init(cp); 
+       cas_begin_auto_negotiation(cp, NULL);
+       cas_clean_rings(cp);
+       cas_unlock_all_restore(cp, flags);
+
+       free_irq(cp->pdev->irq, (void *) dev);
+       cas_spare_free(cp);
+       cas_free_rxds(cp);
+       cas_tx_tiny_free(cp);
+       up(&cp->pm_sem);
+       return 0;
+}
+
+static struct {
+       const char name[ETH_GSTRING_LEN];
+} ethtool_cassini_statnames[] = {
+       {"collisions"},
+       {"rx_bytes"},
+       {"rx_crc_errors"},
+       {"rx_dropped"},
+       {"rx_errors"},
+       {"rx_fifo_errors"},
+       {"rx_frame_errors"},
+       {"rx_length_errors"},
+       {"rx_over_errors"},
+       {"rx_packets"},
+       {"tx_aborted_errors"},
+       {"tx_bytes"},
+       {"tx_dropped"},
+       {"tx_errors"},
+       {"tx_fifo_errors"},
+       {"tx_packets"}
+};
+#define CAS_NUM_STAT_KEYS (sizeof(ethtool_cassini_statnames)/ETH_GSTRING_LEN)
+
+static struct {
+       const int offsets;      /* neg. values for 2nd arg to cas_read_phy */
+} ethtool_register_table[] = {
+       {-MII_BMSR},
+       {-MII_BMCR},
+       {REG_CAWR},
+       {REG_INF_BURST},
+       {REG_BIM_CFG},
+       {REG_RX_CFG},
+       {REG_HP_CFG},
+       {REG_MAC_TX_CFG},
+       {REG_MAC_RX_CFG},
+       {REG_MAC_CTRL_CFG},
+       {REG_MAC_XIF_CFG},
+       {REG_MIF_CFG},
+       {REG_PCS_CFG},
+       {REG_SATURN_PCFG},
+       {REG_PCS_MII_STATUS},
+       {REG_PCS_STATE_MACHINE},
+       {REG_MAC_COLL_EXCESS},
+       {REG_MAC_COLL_LATE}
+};
+#define CAS_REG_LEN    (sizeof(ethtool_register_table)/sizeof(int))
+#define CAS_MAX_REGS   (sizeof (u32)*CAS_REG_LEN)
+
+static void cas_read_regs(struct cas *cp, u8 *ptr, int len)
+{
+       u8 *p;
+       int i;
+       unsigned long flags;
+
+       spin_lock_irqsave(&cp->lock, flags);
+       for (i = 0, p = ptr; i < len ; i ++, p += sizeof(u32)) {
+               u16 hval;
+               u32 val;
+               if (ethtool_register_table[i].offsets < 0) {
+                       hval = cas_phy_read(cp,
+                                   -ethtool_register_table[i].offsets);
+                       val = hval;
+               } else {
+                       val= readl(cp->regs+ethtool_register_table[i].offsets);
+               }
+               memcpy(p, (u8 *)&val, sizeof(u32));
+       }
+       spin_unlock_irqrestore(&cp->lock, flags);
+}
+
+static struct net_device_stats *cas_get_stats(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       struct net_device_stats *stats = cp->net_stats;
+       unsigned long flags;
+       int i;
+       unsigned long tmp;
+
+       /* we collate all of the stats into net_stats[N_TX_RING] */
+       if (!cp->hw_running)
+               return stats + N_TX_RINGS;
+       
+       /* collect outstanding stats */
+       /* WTZ: the Cassini spec gives these as 16 bit counters but
+        * stored in 32-bit words.  Added a mask of 0xffff to be safe,
+        * in case the chip somehow puts any garbage in the other bits.
+        * Also, counter usage didn't seem to mach what Adrian did
+        * in the parts of the code that set these quantities. Made
+        * that consistent.
+        */
+       spin_lock_irqsave(&cp->stat_lock[N_TX_RINGS], flags);
+       stats[N_TX_RINGS].rx_crc_errors += 
+         readl(cp->regs + REG_MAC_FCS_ERR) & 0xffff;
+       stats[N_TX_RINGS].rx_frame_errors += 
+               readl(cp->regs + REG_MAC_ALIGN_ERR) &0xffff;
+       stats[N_TX_RINGS].rx_length_errors += 
+               readl(cp->regs + REG_MAC_LEN_ERR) & 0xffff;
+#if 1
+       tmp = (readl(cp->regs + REG_MAC_COLL_EXCESS) & 0xffff) +
+               (readl(cp->regs + REG_MAC_COLL_LATE) & 0xffff);
+       stats[N_TX_RINGS].tx_aborted_errors += tmp;
+       stats[N_TX_RINGS].collisions +=
+         tmp + (readl(cp->regs + REG_MAC_COLL_NORMAL) & 0xffff);
+#else
+       stats[N_TX_RINGS].tx_aborted_errors += 
+               readl(cp->regs + REG_MAC_COLL_EXCESS);
+       stats[N_TX_RINGS].collisions += readl(cp->regs + REG_MAC_COLL_EXCESS) +
+               readl(cp->regs + REG_MAC_COLL_LATE);
+#endif
+       cas_clear_mac_err(cp);
+
+       /* saved bits that are unique to ring 0 */
+       spin_lock(&cp->stat_lock[0]);
+       stats[N_TX_RINGS].collisions        += stats[0].collisions;
+       stats[N_TX_RINGS].rx_over_errors    += stats[0].rx_over_errors;
+       stats[N_TX_RINGS].rx_frame_errors   += stats[0].rx_frame_errors;
+       stats[N_TX_RINGS].rx_fifo_errors    += stats[0].rx_fifo_errors;
+       stats[N_TX_RINGS].tx_aborted_errors += stats[0].tx_aborted_errors;
+       stats[N_TX_RINGS].tx_fifo_errors    += stats[0].tx_fifo_errors;
+       spin_unlock(&cp->stat_lock[0]);
+
+       for (i = 0; i < N_TX_RINGS; i++) {
+               spin_lock(&cp->stat_lock[i]);
+               stats[N_TX_RINGS].rx_length_errors += 
+                       stats[i].rx_length_errors;
+               stats[N_TX_RINGS].rx_crc_errors += stats[i].rx_crc_errors;
+               stats[N_TX_RINGS].rx_packets    += stats[i].rx_packets;
+               stats[N_TX_RINGS].tx_packets    += stats[i].tx_packets;
+               stats[N_TX_RINGS].rx_bytes      += stats[i].rx_bytes;
+               stats[N_TX_RINGS].tx_bytes      += stats[i].tx_bytes;
+               stats[N_TX_RINGS].rx_errors     += stats[i].rx_errors;
+               stats[N_TX_RINGS].tx_errors     += stats[i].tx_errors;
+               stats[N_TX_RINGS].rx_dropped    += stats[i].rx_dropped;
+               stats[N_TX_RINGS].tx_dropped    += stats[i].tx_dropped;
+               memset(stats + i, 0, sizeof(struct net_device_stats));
+               spin_unlock(&cp->stat_lock[i]);
+       }
+       spin_unlock_irqrestore(&cp->stat_lock[N_TX_RINGS], flags);
+       return stats + N_TX_RINGS;
+}
+
+
+static void cas_set_multicast(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       u32 rxcfg, rxcfg_new;
+       unsigned long flags;
+       int limit = STOP_TRIES;
+       
+       if (!cp->hw_running)
+               return;
+               
+       spin_lock_irqsave(&cp->lock, flags);
+       rxcfg = readl(cp->regs + REG_MAC_RX_CFG);
+
+       /* disable RX MAC and wait for completion */
+       writel(rxcfg & ~MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
+       while (readl(cp->regs + REG_MAC_RX_CFG) & MAC_RX_CFG_EN) {
+               if (!limit--)
+                       break;
+               udelay(10);
+       }
+
+       /* disable hash filter and wait for completion */
+       limit = STOP_TRIES;
+       rxcfg &= ~(MAC_RX_CFG_PROMISC_EN | MAC_RX_CFG_HASH_FILTER_EN);
+       writel(rxcfg & ~MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
+       while (readl(cp->regs + REG_MAC_RX_CFG) & MAC_RX_CFG_HASH_FILTER_EN) {
+               if (!limit--)
+                       break;
+               udelay(10);
+       }
+
+       /* program hash filters */
+       cp->mac_rx_cfg = rxcfg_new = cas_setup_multicast(cp);
+       rxcfg |= rxcfg_new;
+       writel(rxcfg, cp->regs + REG_MAC_RX_CFG);
+       spin_unlock_irqrestore(&cp->lock, flags);
+}
+
+static void cas_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+       struct cas *cp = netdev_priv(dev);
+       strncpy(info->driver, DRV_MODULE_NAME, ETHTOOL_BUSINFO_LEN);
+       strncpy(info->version, DRV_MODULE_VERSION, ETHTOOL_BUSINFO_LEN);
+       info->fw_version[0] = '\0';
+       strncpy(info->bus_info, pci_name(cp->pdev), ETHTOOL_BUSINFO_LEN);
+       info->regdump_len = cp->casreg_len < CAS_MAX_REGS ?
+               cp->casreg_len : CAS_MAX_REGS;
+       info->n_stats = CAS_NUM_STAT_KEYS;
+}
+
+static int cas_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+       struct cas *cp = netdev_priv(dev);
+       u16 bmcr;
+       int full_duplex, speed, pause;
+       unsigned long flags;
+       enum link_state linkstate = link_up;
+
+       cmd->advertising = 0;
+       cmd->supported = SUPPORTED_Autoneg;
+       if (cp->cas_flags & CAS_FLAG_1000MB_CAP) {
+               cmd->supported |= SUPPORTED_1000baseT_Full;
+               cmd->advertising |= ADVERTISED_1000baseT_Full;
+       }
+
+       /* Record PHY settings if HW is on. */
+       spin_lock_irqsave(&cp->lock, flags);
+       bmcr = 0;
+       linkstate = cp->lstate;
+       if (CAS_PHY_MII(cp->phy_type)) {
+               cmd->port = PORT_MII;
+               cmd->transceiver = (cp->cas_flags & CAS_FLAG_SATURN) ?
+                       XCVR_INTERNAL : XCVR_EXTERNAL;
+               cmd->phy_address = cp->phy_addr;
+               cmd->advertising |= ADVERTISED_TP | ADVERTISED_MII |
+                       ADVERTISED_10baseT_Half | 
+                       ADVERTISED_10baseT_Full | 
+                       ADVERTISED_100baseT_Half | 
+                       ADVERTISED_100baseT_Full;
+
+               cmd->supported |=
+                       (SUPPORTED_10baseT_Half | 
+                        SUPPORTED_10baseT_Full |
+                        SUPPORTED_100baseT_Half | 
+                        SUPPORTED_100baseT_Full |
+                        SUPPORTED_TP | SUPPORTED_MII);
+
+               if (cp->hw_running) {
+                       cas_mif_poll(cp, 0);
+                       bmcr = cas_phy_read(cp, MII_BMCR);
+                       cas_read_mii_link_mode(cp, &full_duplex, 
+                                              &speed, &pause);
+                       cas_mif_poll(cp, 1);
+               }
+
+       } else {
+               cmd->port = PORT_FIBRE;
+               cmd->transceiver = XCVR_INTERNAL;
+               cmd->phy_address = 0;
+               cmd->supported   |= SUPPORTED_FIBRE;
+               cmd->advertising |= ADVERTISED_FIBRE;
+
+               if (cp->hw_running) {
+                       /* pcs uses the same bits as mii */ 
+                       bmcr = readl(cp->regs + REG_PCS_MII_CTRL);
+                       cas_read_pcs_link_mode(cp, &full_duplex, 
+                                              &speed, &pause);
+               }
+       }
+       spin_unlock_irqrestore(&cp->lock, flags);
+
+       if (bmcr & BMCR_ANENABLE) {
+               cmd->advertising |= ADVERTISED_Autoneg;
+               cmd->autoneg = AUTONEG_ENABLE;
+               cmd->speed = ((speed == 10) ?
+                             SPEED_10 :
+                             ((speed == 1000) ?
+                              SPEED_1000 : SPEED_100));
+               cmd->duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
+       } else {
+               cmd->autoneg = AUTONEG_DISABLE;
+               cmd->speed =
+                       (bmcr & CAS_BMCR_SPEED1000) ?
+                       SPEED_1000 : 
+                       ((bmcr & BMCR_SPEED100) ? SPEED_100: 
+                        SPEED_10);
+               cmd->duplex =
+                       (bmcr & BMCR_FULLDPLX) ?
+                       DUPLEX_FULL : DUPLEX_HALF;
+       }
+       if (linkstate != link_up) {
+               /* Force these to "unknown" if the link is not up and
+                * autonogotiation in enabled. We can set the link 
+                * speed to 0, but not cmd->duplex,
+                * because its legal values are 0 and 1.  Ethtool will
+                * print the value reported in parentheses after the
+                * word "Unknown" for unrecognized values.
+                *
+                * If in forced mode, we report the speed and duplex
+                * settings that we configured.
+                */
+               if (cp->link_cntl & BMCR_ANENABLE) {
+                       cmd->speed = 0;
+                       cmd->duplex = 0xff;
+               } else {
+                       cmd->speed = SPEED_10;
+                       if (cp->link_cntl & BMCR_SPEED100) {
+                               cmd->speed = SPEED_100;
+                       } else if (cp->link_cntl & CAS_BMCR_SPEED1000) {
+                               cmd->speed = SPEED_1000;
+                       }
+                       cmd->duplex = (cp->link_cntl & BMCR_FULLDPLX)?
+                               DUPLEX_FULL : DUPLEX_HALF;
+               }
+       }
+       return 0;
+}
+
+static int cas_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+       struct cas *cp = netdev_priv(dev);
+       unsigned long flags;
+
+       /* Verify the settings we care about. */
+       if (cmd->autoneg != AUTONEG_ENABLE &&
+           cmd->autoneg != AUTONEG_DISABLE)
+               return -EINVAL;
+
+       if (cmd->autoneg == AUTONEG_DISABLE &&
+           ((cmd->speed != SPEED_1000 &&
+             cmd->speed != SPEED_100 &&
+             cmd->speed != SPEED_10) ||
+            (cmd->duplex != DUPLEX_HALF &&
+             cmd->duplex != DUPLEX_FULL)))
+               return -EINVAL;
+
+       /* Apply settings and restart link process. */
+       spin_lock_irqsave(&cp->lock, flags);
+       cas_begin_auto_negotiation(cp, cmd);
+       spin_unlock_irqrestore(&cp->lock, flags);
+       return 0;
+}
+
+static int cas_nway_reset(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       unsigned long flags;
+
+       if ((cp->link_cntl & BMCR_ANENABLE) == 0)
+               return -EINVAL;
+
+       /* Restart link process. */
+       spin_lock_irqsave(&cp->lock, flags);
+       cas_begin_auto_negotiation(cp, NULL);
+       spin_unlock_irqrestore(&cp->lock, flags);
+
+       return 0;
+}
+
+static u32 cas_get_link(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       return cp->lstate == link_up;
+}
+
+static u32 cas_get_msglevel(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       return cp->msg_enable;
+}
+
+static void cas_set_msglevel(struct net_device *dev, u32 value)
+{
+       struct cas *cp = netdev_priv(dev);
+       cp->msg_enable = value;
+}
+
+static int cas_get_regs_len(struct net_device *dev)
+{
+       struct cas *cp = netdev_priv(dev);
+       return cp->casreg_len < CAS_MAX_REGS ? cp->casreg_len: CAS_MAX_REGS;
+}
+
+static void cas_get_regs(struct net_device *dev, struct ethtool_regs *regs,
+                            void *p)
+{
+       struct cas *cp = netdev_priv(dev);
+       regs->version = 0;
+       /* cas_read_regs handles locks (cp->lock).  */
+       cas_read_regs(cp, p, regs->len / sizeof(u32));
+}
+
+static int cas_get_stats_count(struct net_device *dev)
+{
+       return CAS_NUM_STAT_KEYS;
+}
+
+static void cas_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+{
+        memcpy(data, &ethtool_cassini_statnames, 
+                                        CAS_NUM_STAT_KEYS * ETH_GSTRING_LEN);
+}
+
+static void cas_get_ethtool_stats(struct net_device *dev,
+                                     struct ethtool_stats *estats, u64 *data)
+{
+       struct cas *cp = netdev_priv(dev);
+       struct net_device_stats *stats = cas_get_stats(cp->dev);
+       int i = 0;
+       data[i++] = stats->collisions;
+       data[i++] = stats->rx_bytes;
+       data[i++] = stats->rx_crc_errors;
+       data[i++] = stats->rx_dropped;
+       data[i++] = stats->rx_errors;
+       data[i++] = stats->rx_fifo_errors;
+       data[i++] = stats->rx_frame_errors;
+       data[i++] = stats->rx_length_errors;
+       data[i++] = stats->rx_over_errors;
+       data[i++] = stats->rx_packets;
+       data[i++] = stats->tx_aborted_errors;
+       data[i++] = stats->tx_bytes;
+       data[i++] = stats->tx_dropped;
+       data[i++] = stats->tx_errors;
+       data[i++] = stats->tx_fifo_errors;
+       data[i++] = stats->tx_packets;
+       BUG_ON(i != CAS_NUM_STAT_KEYS);
+}
+
+static struct ethtool_ops cas_ethtool_ops = {
+       .get_drvinfo            = cas_get_drvinfo,
+       .get_settings           = cas_get_settings,
+       .set_settings           = cas_set_settings,
+       .nway_reset             = cas_nway_reset,
+       .get_link               = cas_get_link,
+       .get_msglevel           = cas_get_msglevel,
+       .set_msglevel           = cas_set_msglevel,
+       .get_regs_len           = cas_get_regs_len,
+       .get_regs               = cas_get_regs,
+       .get_stats_count        = cas_get_stats_count,
+       .get_strings            = cas_get_strings,
+       .get_ethtool_stats      = cas_get_ethtool_stats,
+};
+
+static int cas_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+       struct cas *cp = netdev_priv(dev);
+       struct mii_ioctl_data *data = if_mii(ifr);
+       unsigned long flags;
+       int rc = -EOPNOTSUPP;
+       
+       /* Hold the PM semaphore while doing ioctl's or we may collide
+        * with open/close and power management and oops.
+        */
+       down(&cp->pm_sem);
+       switch (cmd) {
+       case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
+               data->phy_id = cp->phy_addr;
+               /* Fallthrough... */
+
+       case SIOCGMIIREG:               /* Read MII PHY register. */
+               spin_lock_irqsave(&cp->lock, flags);
+               cas_mif_poll(cp, 0);
+               data->val_out = cas_phy_read(cp, data->reg_num & 0x1f);
+               cas_mif_poll(cp, 1);
+               spin_unlock_irqrestore(&cp->lock, flags);
+               rc = 0;
+               break;
+
+       case SIOCSMIIREG:               /* Write MII PHY register. */
+               if (!capable(CAP_NET_ADMIN)) {
+                       rc = -EPERM;
+                       break;
+               }
+               spin_lock_irqsave(&cp->lock, flags);
+               cas_mif_poll(cp, 0);
+               rc = cas_phy_write(cp, data->reg_num & 0x1f, data->val_in);
+               cas_mif_poll(cp, 1);
+               spin_unlock_irqrestore(&cp->lock, flags);
+               break;
+       default:
+               break;
+       };
+
+       up(&cp->pm_sem);
+       return rc;
+}
+
+static int __devinit cas_init_one(struct pci_dev *pdev,
+                                 const struct pci_device_id *ent)
+{
+       static int cas_version_printed = 0;
+       unsigned long casreg_base, casreg_len;
+       struct net_device *dev;
+       struct cas *cp;
+       int i, err, pci_using_dac;
+       u16 pci_cmd;
+       u8 orig_cacheline_size = 0, cas_cacheline_size = 0;
+
+       if (cas_version_printed++ == 0)
+               printk(KERN_INFO "%s", version);
+
+       err = pci_enable_device(pdev);
+       if (err) {
+               printk(KERN_ERR PFX "Cannot enable PCI device, "
+                      "aborting.\n");
+               return err;
+       }
+
+       if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
+               printk(KERN_ERR PFX "Cannot find proper PCI device "
+                      "base address, aborting.\n");
+               err = -ENODEV;
+               goto err_out_disable_pdev;
+       }
+
+       dev = alloc_etherdev(sizeof(*cp));
+       if (!dev) {
+               printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
+               err = -ENOMEM;
+               goto err_out_disable_pdev;
+       }
+       SET_MODULE_OWNER(dev);
+       SET_NETDEV_DEV(dev, &pdev->dev);
+
+       err = pci_request_regions(pdev, dev->name);
+       if (err) {
+               printk(KERN_ERR PFX "Cannot obtain PCI resources, "
+                      "aborting.\n");
+               goto err_out_free_netdev;
+       }
+       pci_set_master(pdev);
+
+       /* we must always turn on parity response or else parity
+        * doesn't get generated properly. disable SERR/PERR as well.
+        * in addition, we want to turn MWI on.
+        */
+       pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);
+       pci_cmd &= ~PCI_COMMAND_SERR;
+       pci_cmd |= PCI_COMMAND_PARITY;
+       pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
+       pci_set_mwi(pdev);
+       /*
+        * On some architectures, the default cache line size set
+        * by pci_set_mwi reduces perforamnce.  We have to increase
+        * it for this case.  To start, we'll print some configuration
+        * data.
+        */
+#if 1
+       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE,
+                            &orig_cacheline_size);
+       if (orig_cacheline_size < CAS_PREF_CACHELINE_SIZE) {
+               cas_cacheline_size = 
+                       (CAS_PREF_CACHELINE_SIZE < SMP_CACHE_BYTES) ? 
+                       CAS_PREF_CACHELINE_SIZE : SMP_CACHE_BYTES;
+               if (pci_write_config_byte(pdev, 
+                                         PCI_CACHE_LINE_SIZE, 
+                                         cas_cacheline_size)) {
+                       printk(KERN_ERR PFX "Could not set PCI cache "
+                              "line size\n");
+                       goto err_write_cacheline;
+               }
+       }
+#endif
+
+
+       /* Configure DMA attributes. */
+       if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
+               pci_using_dac = 1;
+               err = pci_set_consistent_dma_mask(pdev,
+                                                 DMA_64BIT_MASK);
+               if (err < 0) {
+                       printk(KERN_ERR PFX "Unable to obtain 64-bit DMA "
+                              "for consistent allocations\n");
+                       goto err_out_free_res;
+               }
+
+       } else {
+               err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+               if (err) {
+                       printk(KERN_ERR PFX "No usable DMA configuration, "
+                              "aborting.\n");
+                       goto err_out_free_res;
+               }
+               pci_using_dac = 0;
+       }
+
+       casreg_base = pci_resource_start(pdev, 0);
+       casreg_len = pci_resource_len(pdev, 0);
+
+       cp = netdev_priv(dev);
+       cp->pdev = pdev;
+#if 1
+       /* A value of 0 indicates we never explicitly set it */
+       cp->orig_cacheline_size = cas_cacheline_size ? orig_cacheline_size: 0;
+#endif
+       cp->dev = dev;
+       cp->msg_enable = (cassini_debug < 0) ? CAS_DEF_MSG_ENABLE : 
+         cassini_debug;
+
+       cp->link_transition = LINK_TRANSITION_UNKNOWN;
+       cp->link_transition_jiffies_valid = 0;
+
+       spin_lock_init(&cp->lock);
+       spin_lock_init(&cp->rx_inuse_lock);
+       spin_lock_init(&cp->rx_spare_lock);
+       for (i = 0; i < N_TX_RINGS; i++) {
+               spin_lock_init(&cp->stat_lock[i]);
+               spin_lock_init(&cp->tx_lock[i]);
+       }
+       spin_lock_init(&cp->stat_lock[N_TX_RINGS]);
+       init_MUTEX(&cp->pm_sem);
+
+       init_timer(&cp->link_timer);
+       cp->link_timer.function = cas_link_timer;
+       cp->link_timer.data = (unsigned long) cp;
+
+#if 1
+       /* Just in case the implementation of atomic operations
+        * change so that an explicit initialization is necessary.
+        */
+       atomic_set(&cp->reset_task_pending, 0);
+       atomic_set(&cp->reset_task_pending_all, 0);
+       atomic_set(&cp->reset_task_pending_spare, 0);
+       atomic_set(&cp->reset_task_pending_mtu, 0);
+#endif
+       INIT_WORK(&cp->reset_task, cas_reset_task, cp);
+
+       /* Default link parameters */
+       if (link_mode >= 0 && link_mode <= 6)
+               cp->link_cntl = link_modes[link_mode];
+       else
+               cp->link_cntl = BMCR_ANENABLE;
+       cp->lstate = link_down;
+       cp->link_transition = LINK_TRANSITION_LINK_DOWN;
+       netif_carrier_off(cp->dev);
+       cp->timer_ticks = 0;
+
+       /* give us access to cassini registers */
+       cp->regs = ioremap(casreg_base, casreg_len);
+       if (cp->regs == 0UL) {
+               printk(KERN_ERR PFX "Cannot map device registers, "
+                      "aborting.\n");
+               goto err_out_free_res;
+       }
+       cp->casreg_len = casreg_len;
+
+       pci_save_state(pdev);
+       cas_check_pci_invariants(cp);
+       cas_hard_reset(cp);
+       cas_reset(cp, 0);
+       if (cas_check_invariants(cp))
+               goto err_out_iounmap;
+
+       cp->init_block = (struct cas_init_block *)
+               pci_alloc_consistent(pdev, sizeof(struct cas_init_block),
+                                    &cp->block_dvma);
+       if (!cp->init_block) {
+               printk(KERN_ERR PFX "Cannot allocate init block, "
+                      "aborting.\n");
+               goto err_out_iounmap;
+       }
+
+       for (i = 0; i < N_TX_RINGS; i++) 
+               cp->init_txds[i] = cp->init_block->txds[i];
+
+       for (i = 0; i < N_RX_DESC_RINGS; i++) 
+               cp->init_rxds[i] = cp->init_block->rxds[i];
+
+       for (i = 0; i < N_RX_COMP_RINGS; i++) 
+               cp->init_rxcs[i] = cp->init_block->rxcs[i];
+
+       for (i = 0; i < N_RX_FLOWS; i++)
+               skb_queue_head_init(&cp->rx_flows[i]);
+
+       dev->open = cas_open;
+       dev->stop = cas_close;
+       dev->hard_start_xmit = cas_start_xmit;
+       dev->get_stats = cas_get_stats;
+       dev->set_multicast_list = cas_set_multicast;
+       dev->do_ioctl = cas_ioctl;
+       dev->ethtool_ops = &cas_ethtool_ops;
+       dev->tx_timeout = cas_tx_timeout;
+       dev->watchdog_timeo = CAS_TX_TIMEOUT;
+       dev->change_mtu = cas_change_mtu;
+#ifdef USE_NAPI
+       dev->poll = cas_poll;
+       dev->weight = 64;
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       dev->poll_controller = cas_netpoll;
+#endif
+       dev->irq = pdev->irq;
+       dev->dma = 0;
+
+       /* Cassini features. */
+       if ((cp->cas_flags & CAS_FLAG_NO_HW_CSUM) == 0)
+               dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
+
+       if (pci_using_dac)
+               dev->features |= NETIF_F_HIGHDMA;
+
+       if (register_netdev(dev)) {
+               printk(KERN_ERR PFX "Cannot register net device, "
+                      "aborting.\n");
+               goto err_out_free_consistent;
+       }
+
+       i = readl(cp->regs + REG_BIM_CFG);
+       printk(KERN_INFO "%s: Sun Cassini%s (%sbit/%sMHz PCI/%s) "
+              "Ethernet[%d] ",  dev->name, 
+              (cp->cas_flags & CAS_FLAG_REG_PLUS) ? "+" : "", 
+              (i & BIM_CFG_32BIT) ? "32" : "64",
+              (i & BIM_CFG_66MHZ) ? "66" : "33",
+              (cp->phy_type == CAS_PHY_SERDES) ? "Fi" : "Cu", pdev->irq); 
+
+       for (i = 0; i < 6; i++)
+               printk("%2.2x%c", dev->dev_addr[i],
+                      i == 5 ? ' ' : ':');
+       printk("\n");
+
+       pci_set_drvdata(pdev, dev);
+       cp->hw_running = 1;
+       cas_entropy_reset(cp);
+       cas_phy_init(cp);
+       cas_begin_auto_negotiation(cp, NULL);
+       return 0;
+
+err_out_free_consistent:
+       pci_free_consistent(pdev, sizeof(struct cas_init_block),
+                           cp->init_block, cp->block_dvma);
+
+err_out_iounmap:
+       down(&cp->pm_sem);
+       if (cp->hw_running)
+               cas_shutdown(cp);
+       up(&cp->pm_sem);
+
+       iounmap(cp->regs);
+
+
+err_out_free_res:
+       pci_release_regions(pdev);
+
+err_write_cacheline:
+       /* Try to restore it in case the error occured after we
+        * set it. 
+        */
+       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, orig_cacheline_size);
+
+err_out_free_netdev:
+       free_netdev(dev);
+
+err_out_disable_pdev:
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+       return -ENODEV;
+}
+
+static void __devexit cas_remove_one(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct cas *cp;
+       if (!dev)
+               return;
+
+       cp = netdev_priv(dev);
+       unregister_netdev(dev);
+
+       down(&cp->pm_sem);
+       flush_scheduled_work();
+       if (cp->hw_running)
+               cas_shutdown(cp);
+       up(&cp->pm_sem);
+
+#if 1
+       if (cp->orig_cacheline_size) {
+               /* Restore the cache line size if we had modified
+                * it.
+                */
+               pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 
+                                     cp->orig_cacheline_size);
+       }
+#endif
+       pci_free_consistent(pdev, sizeof(struct cas_init_block),
+                           cp->init_block, cp->block_dvma);
+       iounmap(cp->regs);
+       free_netdev(dev);
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+       pci_set_drvdata(pdev, NULL);
+}
+
+#ifdef CONFIG_PM
+static int cas_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct cas *cp = netdev_priv(dev);
+       unsigned long flags;
+
+       /* We hold the PM semaphore during entire driver
+        * sleep time
+        */
+       down(&cp->pm_sem);
+       
+       /* If the driver is opened, we stop the DMA */
+       if (cp->opened) {
+               netif_device_detach(dev);
+
+               cas_lock_all_save(cp, flags);
+
+               /* We can set the second arg of cas_reset to 0
+                * because on resume, we'll call cas_init_hw with
+                * its second arg set so that autonegotiation is
+                * restarted.
+                */
+               cas_reset(cp, 0);
+               cas_clean_rings(cp);
+               cas_unlock_all_restore(cp, flags);
+       }
+
+       if (cp->hw_running)
+               cas_shutdown(cp);
+
+       return 0;
+}
+
+static int cas_resume(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct cas *cp = netdev_priv(dev);
+
+       printk(KERN_INFO "%s: resuming\n", dev->name);
+
+       cas_hard_reset(cp);
+       if (cp->opened) {
+               unsigned long flags;
+               cas_lock_all_save(cp, flags);
+               cas_reset(cp, 0);
+               cp->hw_running = 1;
+               cas_clean_rings(cp);
+               cas_init_hw(cp, 1);
+               cas_unlock_all_restore(cp, flags);
+
+               netif_device_attach(dev);
+       }
+       up(&cp->pm_sem);
+       return 0;
+}
+#endif /* CONFIG_PM */
+
+static struct pci_driver cas_driver = {
+       .name           = DRV_MODULE_NAME,
+       .id_table       = cas_pci_tbl,
+       .probe          = cas_init_one,
+       .remove         = __devexit_p(cas_remove_one),
+#ifdef CONFIG_PM
+       .suspend        = cas_suspend,
+       .resume         = cas_resume
+#endif
+};
+
+static int __init cas_init(void)
+{
+       if (linkdown_timeout > 0)
+               link_transition_timeout = linkdown_timeout * HZ;
+       else
+               link_transition_timeout = 0;
+
+       return pci_module_init(&cas_driver);
+}
+
+static void __exit cas_cleanup(void)
+{
+       pci_unregister_driver(&cas_driver);
+}
+
+module_init(cas_init);
+module_exit(cas_cleanup);
diff --git a/drivers/net/cassini.h b/drivers/net/cassini.h
new file mode 100644 (file)
index 0000000..88063ef
--- /dev/null
@@ -0,0 +1,4425 @@
+/* $Id: cassini.h,v 1.16 2004/08/17 21:15:16 zaumen Exp $
+ * cassini.h: Definitions for Sun Microsystems Cassini(+) ethernet driver.
+ *
+ * Copyright (C) 2004 Sun Microsystems Inc.
+ * Copyright (c) 2003 Adrian Sun (asun@darksunrising.com)
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * vendor id: 0x108E (Sun Microsystems, Inc.)
+ * device id: 0xabba (Cassini)
+ * revision ids: 0x01 = Cassini 
+ *               0x02 = Cassini rev 2
+ *               0x10 = Cassini+
+ *               0x11 = Cassini+ 0.2u
+ *
+ * vendor id: 0x100b (National Semiconductor)
+ * device id: 0x0035 (DP83065/Saturn)
+ * revision ids: 0x30 = Saturn B2
+ *
+ * rings are all offset from 0.
+ *
+ * there are two clock domains:
+ * PCI:  33/66MHz clock
+ * chip: 125MHz clock
+ */
+
+#ifndef _CASSINI_H
+#define _CASSINI_H
+
+/* cassini register map: 2M memory mapped in 32-bit memory space accessible as
+ * 32-bit words. there is no i/o port access. REG_ addresses are
+ * shared between cassini and cassini+. REG_PLUS_ addresses only
+ * appear in cassini+. REG_MINUS_ addresses only appear in cassini.
+ */
+#define CAS_ID_REV2          0x02
+#define CAS_ID_REVPLUS       0x10 
+#define CAS_ID_REVPLUS02u    0x11 
+#define CAS_ID_REVSATURNB2   0x30
+
+/** global resources **/
+
+/* this register sets the weights for the weighted round robin arbiter. e.g.,
+ * if rx weight == 1 and tx weight == 0, rx == 2x tx transfer credit
+ * for its next turn to access the pci bus. 
+ * map: 0x0 = x1, 0x1 = x2, 0x2 = x4, 0x3 = x8 
+ * DEFAULT: 0x0, SIZE: 5 bits
+ */
+#define  REG_CAWR                     0x0004  /* core arbitration weight */
+#define    CAWR_RX_DMA_WEIGHT_SHIFT    0
+#define    CAWR_RX_DMA_WEIGHT_MASK     0x03    /* [0:1] */
+#define    CAWR_TX_DMA_WEIGHT_SHIFT    2
+#define    CAWR_TX_DMA_WEIGHT_MASK     0x0C    /* [3:2] */
+#define    CAWR_RR_DIS                 0x10    /* [4] */
+
+/* if enabled, BIM can send bursts across PCI bus > cacheline size. burst
+ * sizes determined by length of packet or descriptor transfer and the 
+ * max length allowed by the target. 
+ * DEFAULT: 0x0, SIZE: 1 bit
+ */
+#define  REG_INF_BURST                 0x0008  /* infinite burst enable reg */
+#define    INF_BURST_EN                0x1     /* enable */
+
+/* top level interrupts [0-9] are auto-cleared to 0 when the status
+ * register is read. second level interrupts [13 - 18] are cleared at
+ * the source. tx completion register 3 is replicated in [19 - 31] 
+ * DEFAULT: 0x00000000, SIZE: 29 bits
+ */
+#define  REG_INTR_STATUS               0x000C  /* interrupt status register */
+#define    INTR_TX_INTME               0x00000001  /* frame w/ INT ME desc bit set 
+                                                     xferred from host queue to
+                                                     TX FIFO */
+#define    INTR_TX_ALL                 0x00000002  /* all xmit frames xferred into
+                                                     TX FIFO. i.e.,
+                                                     TX Kick == TX complete. if 
+                                                     PACED_MODE set, then TX FIFO
+                                                     also empty */
+#define    INTR_TX_DONE                0x00000004  /* any frame xferred into tx 
+                                                     FIFO */
+#define    INTR_TX_TAG_ERROR           0x00000008  /* TX FIFO tag framing 
+                                                     corrupted. FATAL ERROR */
+#define    INTR_RX_DONE                0x00000010  /* at least 1 frame xferred
+                                                     from RX FIFO to host mem.
+                                                     RX completion reg updated.
+                                                     may be delayed by recv
+                                                     intr blanking. */
+#define    INTR_RX_BUF_UNAVAIL         0x00000020  /* no more receive buffers.
+                                                     RX Kick == RX complete */
+#define    INTR_RX_TAG_ERROR           0x00000040  /* RX FIFO tag framing 
+                                                     corrupted. FATAL ERROR */
+#define    INTR_RX_COMP_FULL           0x00000080  /* no more room in completion
+                                                     ring to post descriptors.
+                                                     RX complete head incr to
+                                                     almost reach RX complete
+                                                     tail */
+#define    INTR_RX_BUF_AE              0x00000100  /* less than the 
+                                                     programmable threshold #
+                                                     of free descr avail for
+                                                     hw use */
+#define    INTR_RX_COMP_AF             0x00000200  /* less than the 
+                                                     programmable threshold #
+                                                     of descr spaces for hw
+                                                     use in completion descr
+                                                     ring */
+#define    INTR_RX_LEN_MISMATCH        0x00000400  /* len field from MAC !=
+                                                     len of non-reassembly pkt
+                                                     from fifo during DMA or
+                                                     header parser provides TCP
+                                                     header and payload size >
+                                                     MAC packet size. 
+                                                     FATAL ERROR */
+#define    INTR_SUMMARY                0x00001000  /* summary interrupt bit. this
+                                                     bit will be set if an interrupt 
+                                                     generated on the pci bus. useful
+                                                     when driver is polling for 
+                                                     interrupts */
+#define    INTR_PCS_STATUS             0x00002000  /* PCS interrupt status register */
+#define    INTR_TX_MAC_STATUS          0x00004000  /* TX MAC status register has at 
+                                                     least 1 unmasked interrupt set */
+#define    INTR_RX_MAC_STATUS          0x00008000  /* RX MAC status register has at 
+                                                     least 1 unmasked interrupt set */
+#define    INTR_MAC_CTRL_STATUS        0x00010000  /* MAC control status register has
+                                                     at least 1 unmasked interrupt
+                                                     set */
+#define    INTR_MIF_STATUS             0x00020000  /* MIF status register has at least
+                                                     1 unmasked interrupt set */
+#define    INTR_PCI_ERROR_STATUS       0x00040000  /* PCI error status register in the
+                                                     BIF has at least 1 unmasked 
+                                                     interrupt set */
+#define    INTR_TX_COMP_3_MASK         0xFFF80000  /* mask for TX completion 
+                                                     3 reg data */
+#define    INTR_TX_COMP_3_SHIFT        19
+#define    INTR_ERROR_MASK (INTR_MIF_STATUS | INTR_PCI_ERROR_STATUS | \
+                            INTR_PCS_STATUS | INTR_RX_LEN_MISMATCH | \
+                            INTR_TX_MAC_STATUS | INTR_RX_MAC_STATUS | \
+                            INTR_TX_TAG_ERROR | INTR_RX_TAG_ERROR | \
+                            INTR_MAC_CTRL_STATUS)
+
+/* determines which status events will cause an interrupt. layout same
+ * as REG_INTR_STATUS. 
+ * DEFAULT: 0xFFFFFFFF, SIZE: 16 bits
+ */
+#define  REG_INTR_MASK                 0x0010  /* Interrupt mask */
+
+/* top level interrupt bits that are cleared during read of REG_INTR_STATUS_ALIAS.
+ * useful when driver is polling for interrupts. layout same as REG_INTR_MASK.
+ * DEFAULT: 0x00000000, SIZE: 12 bits
+ */
+#define  REG_ALIAS_CLEAR               0x0014  /* alias clear mask 
+                                                 (used w/ status alias) */
+/* same as REG_INTR_STATUS except that only bits cleared are those selected by
+ * REG_ALIAS_CLEAR 
+ * DEFAULT: 0x00000000, SIZE: 29 bits
+ */
+#define  REG_INTR_STATUS_ALIAS         0x001C  /* interrupt status alias 
+                                                 (selective clear) */
+
+/* DEFAULT: 0x0, SIZE: 3 bits */
+#define  REG_PCI_ERR_STATUS            0x1000  /* PCI error status */
+#define    PCI_ERR_BADACK              0x01    /* reserved in Cassini+. 
+                                                 set if no ACK64# during ABS64 cycle
+                                                 in Cassini. */
+#define    PCI_ERR_DTRTO               0x02    /* delayed xaction timeout. set if
+                                                 no read retry after 2^15 clocks */
+#define    PCI_ERR_OTHER               0x04    /* other PCI errors */
+#define    PCI_ERR_BIM_DMA_WRITE       0x08    /* BIM received 0 count DMA write req.
+                                                 unused in Cassini. */
+#define    PCI_ERR_BIM_DMA_READ        0x10    /* BIM received 0 count DMA read req.
+                                                 unused in Cassini. */
+#define    PCI_ERR_BIM_DMA_TIMEOUT     0x20    /* BIM received 255 retries during 
+                                                 DMA. unused in cassini. */
+
+/* mask for PCI status events that will set PCI_ERR_STATUS. if cleared, event
+ * causes an interrupt to be generated. 
+ * DEFAULT: 0x7, SIZE: 3 bits
+ */
+#define  REG_PCI_ERR_STATUS_MASK       0x1004  /* PCI Error status mask */
+
+/* used to configure PCI related parameters that are not in PCI config space. 
+ * DEFAULT: 0bxx000, SIZE: 5 bits
+ */
+#define  REG_BIM_CFG                0x1008  /* BIM Configuration */
+#define    BIM_CFG_RESERVED0        0x001   /* reserved */
+#define    BIM_CFG_RESERVED1        0x002   /* reserved */
+#define    BIM_CFG_64BIT_DISABLE    0x004   /* disable 64-bit mode */
+#define    BIM_CFG_66MHZ            0x008   /* (ro) 1 = 66MHz, 0 = < 66MHz */
+#define    BIM_CFG_32BIT            0x010   /* (ro) 1 = 32-bit slot, 0 = 64-bit */
+#define    BIM_CFG_DPAR_INTR_ENABLE 0x020   /* detected parity err enable */
+#define    BIM_CFG_RMA_INTR_ENABLE  0x040   /* master abort intr enable */
+#define    BIM_CFG_RTA_INTR_ENABLE  0x080   /* target abort intr enable */
+#define    BIM_CFG_RESERVED2        0x100   /* reserved */
+#define    BIM_CFG_BIM_DISABLE      0x200   /* stop BIM DMA. use before global 
+                                              reset. reserved in Cassini. */
+#define    BIM_CFG_BIM_STATUS       0x400   /* (ro) 1 = BIM DMA suspended.
+                                                 reserved in Cassini. */
+#define    BIM_CFG_PERROR_BLOCK     0x800  /* block PERR# to pci bus. def: 0.
+                                                reserved in Cassini. */
+
+/* DEFAULT: 0x00000000, SIZE: 32 bits */
+#define  REG_BIM_DIAG                  0x100C  /* BIM Diagnostic */
+#define    BIM_DIAG_MSTR_SM_MASK       0x3FFFFF00 /* PCI master controller state
+                                                    machine bits [21:0] */
+#define    BIM_DIAG_BRST_SM_MASK       0x7F    /* PCI burst controller state 
+                                                 machine bits [6:0] */
+
+/* writing to SW_RESET_TX and SW_RESET_RX will issue a global
+ * reset. poll until TX and RX read back as 0's for completion.
+ */
+#define  REG_SW_RESET                  0x1010  /* Software reset */
+#define    SW_RESET_TX                 0x00000001  /* reset TX DMA engine. poll until
+                                                     cleared to 0.  */
+#define    SW_RESET_RX                 0x00000002  /* reset RX DMA engine. poll until
+                                                     cleared to 0. */
+#define    SW_RESET_RSTOUT             0x00000004  /* force RSTOUT# pin active (low).
+                                                     resets PHY and anything else 
+                                                     connected to RSTOUT#. RSTOUT#
+                                                     is also activated by local PCI
+                                                     reset when hot-swap is being 
+                                                     done. */
+#define    SW_RESET_BLOCK_PCS_SLINK    0x00000008  /* if a global reset is done with 
+                                                     this bit set, PCS and SLINK 
+                                                     modules won't be reset. 
+                                                     i.e., link won't drop. */
+#define    SW_RESET_BREQ_SM_MASK       0x00007F00  /* breq state machine [6:0] */
+#define    SW_RESET_PCIARB_SM_MASK     0x00070000  /* pci arbitration state bits:
+                                                     0b000: ARB_IDLE1
+                                                     0b001: ARB_IDLE2
+                                                     0b010: ARB_WB_ACK
+                                                     0b011: ARB_WB_WAT
+                                                     0b100: ARB_RB_ACK
+                                                     0b101: ARB_RB_WAT
+                                                     0b110: ARB_RB_END
+                                                     0b111: ARB_WB_END */
+#define    SW_RESET_RDPCI_SM_MASK      0x00300000  /* read pci state bits:
+                                                     0b00: RD_PCI_WAT
+                                                     0b01: RD_PCI_RDY
+                                                     0b11: RD_PCI_ACK */
+#define    SW_RESET_RDARB_SM_MASK      0x00C00000  /* read arbitration state bits:
+                                                     0b00: AD_IDL_RX
+                                                     0b01: AD_ACK_RX
+                                                     0b10: AD_ACK_TX
+                                                     0b11: AD_IDL_TX */
+#define    SW_RESET_WRPCI_SM_MASK      0x06000000  /* write pci state bits 
+                                                     0b00: WR_PCI_WAT
+                                                     0b01: WR_PCI_RDY
+                                                     0b11: WR_PCI_ACK */
+#define    SW_RESET_WRARB_SM_MASK      0x38000000  /* write arbitration state bits:
+                                                     0b000: ARB_IDLE1
+                                                     0b001: ARB_IDLE2
+                                                     0b010: ARB_TX_ACK
+                                                     0b011: ARB_TX_WAT
+                                                     0b100: ARB_RX_ACK
+                                                     0b110: ARB_RX_WAT */
+
+/* Cassini only. 64-bit register used to check PCI datapath. when read,
+ * value written has both lower and upper 32-bit halves rotated to the right
+ * one bit position. e.g., FFFFFFFF FFFFFFFF -> 7FFFFFFF 7FFFFFFF
+ */
+#define  REG_MINUS_BIM_DATAPATH_TEST   0x1018  /* Cassini: BIM datapath test 
+                                                 Cassini+: reserved */
+
+/* output enables are provided for each device's chip select and for the rest
+ * of the outputs from cassini to its local bus devices. two sw programmable
+ * bits are connected to general purpus control/status bits.
+ * DEFAULT: 0x7
+ */
+#define  REG_BIM_LOCAL_DEV_EN          0x1020  /* BIM local device 
+                                                 output EN. default: 0x7 */
+#define    BIM_LOCAL_DEV_PAD           0x01    /* address bus, RW signal, and
+                                                 OE signal output enable on the
+                                                 local bus interface. these
+                                                 are shared between both local 
+                                                 bus devices. tristate when 0. */
+#define    BIM_LOCAL_DEV_PROM          0x02    /* PROM chip select */
+#define    BIM_LOCAL_DEV_EXT           0x04    /* secondary local bus device chip
+                                                 select output enable */
+#define    BIM_LOCAL_DEV_SOFT_0        0x08    /* sw programmable ctrl bit 0 */
+#define    BIM_LOCAL_DEV_SOFT_1        0x10    /* sw programmable ctrl bit 1 */
+#define    BIM_LOCAL_DEV_HW_RESET      0x20    /* internal hw reset. Cassini+ only. */
+
+/* access 24 entry BIM read and write buffers. put address in REG_BIM_BUFFER_ADDR
+ * and read/write from/to it REG_BIM_BUFFER_DATA_LOW and _DATA_HI. 
+ * _DATA_HI should be the last access of the sequence. 
+ * DEFAULT: undefined
+ */
+#define  REG_BIM_BUFFER_ADDR           0x1024  /* BIM buffer address. for
+                                                 purposes. */
+#define    BIM_BUFFER_ADDR_MASK        0x3F    /* index (0 - 23) of buffer  */
+#define    BIM_BUFFER_WR_SELECT        0x40    /* write buffer access = 1
+                                                 read buffer access = 0 */
+/* DEFAULT: undefined */
+#define  REG_BIM_BUFFER_DATA_LOW       0x1028  /* BIM buffer data low */
+#define  REG_BIM_BUFFER_DATA_HI        0x102C  /* BIM buffer data high */
+
+/* set BIM_RAM_BIST_START to start built-in self test for BIM read buffer. 
+ * bit auto-clears when done with status read from _SUMMARY and _PASS bits.
+ */
+#define  REG_BIM_RAM_BIST              0x102C  /* BIM RAM (read buffer) BIST 
+                                                 control/status */
+#define    BIM_RAM_BIST_RD_START       0x01    /* start BIST for BIM read buffer */
+#define    BIM_RAM_BIST_WR_START       0x02    /* start BIST for BIM write buffer.
+                                                 Cassini only. reserved in
+                                                 Cassini+. */
+#define    BIM_RAM_BIST_RD_PASS        0x04    /* summary BIST pass status for read
+                                                 buffer. */
+#define    BIM_RAM_BIST_WR_PASS        0x08    /* summary BIST pass status for write
+                                                 buffer. Cassini only. reserved
+                                                 in Cassini+. */
+#define    BIM_RAM_BIST_RD_LOW_PASS    0x10    /* read low bank passes BIST */
+#define    BIM_RAM_BIST_RD_HI_PASS     0x20    /* read high bank passes BIST */
+#define    BIM_RAM_BIST_WR_LOW_PASS    0x40    /* write low bank passes BIST.
+                                                 Cassini only. reserved in 
+                                                 Cassini+. */
+#define    BIM_RAM_BIST_WR_HI_PASS     0x80    /* write high bank passes BIST.
+                                                 Cassini only. reserved in
+                                                 Cassini+. */
+
+/* ASUN: i'm not sure what this does as it's not in the spec.
+ * DEFAULT: 0xFC
+ */
+#define  REG_BIM_DIAG_MUX              0x1030  /* BIM diagnostic probe mux
+                                                 select register */
+
+/* enable probe monitoring mode and select data appearing on the P_A* bus. bit 
+ * values for _SEL_HI_MASK and _SEL_LOW_MASK:
+ * 0x0: internal probe[7:0] (pci arb state, wtc empty w, wtc full w, wtc empty w,
+ *                           wtc empty r, post pci)
+ * 0x1: internal probe[15:8] (pci wbuf comp, pci wpkt comp, pci rbuf comp,
+ *                            pci rpkt comp, txdma wr req, txdma wr ack,
+ *                           txdma wr rdy, txdma wr xfr done)
+ * 0x2: internal probe[23:16] (txdma rd req, txdma rd ack, txdma rd rdy, rxdma rd,
+ *                             rd arb state, rd pci state)
+ * 0x3: internal probe[31:24] (rxdma req, rxdma ack, rxdma rdy, wrarb state,
+ *                             wrpci state)
+ * 0x4: pci io probe[7:0]     0x5: pci io probe[15:8]
+ * 0x6: pci io probe[23:16]   0x7: pci io probe[31:24]
+ * 0x8: pci io probe[39:32]   0x9: pci io probe[47:40]
+ * 0xa: pci io probe[55:48]   0xb: pci io probe[63:56]
+ * the following are not available in Cassini:
+ * 0xc: rx probe[7:0]         0xd: tx probe[7:0]
+ * 0xe: hp probe[7:0]        0xf: mac probe[7:0]
+ */
+#define  REG_PLUS_PROBE_MUX_SELECT     0x1034 /* Cassini+: PROBE MUX SELECT */
+#define    PROBE_MUX_EN                0x80000000 /* allow probe signals to be 
+                                                    driven on local bus P_A[15:0]
+                                                    for debugging */
+#define    PROBE_MUX_SUB_MUX_MASK      0x0000FF00 /* select sub module probe signals:
+                                                    0x03 = mac[1:0]
+                                                    0x0C = rx[1:0]
+                                                    0x30 = tx[1:0]
+                                                    0xC0 = hp[1:0] */
+#define    PROBE_MUX_SEL_HI_MASK       0x000000F0 /* select which module to appear
+                                                    on P_A[15:8]. see above for 
+                                                    values. */
+#define    PROBE_MUX_SEL_LOW_MASK      0x0000000F /* select which module to appear
+                                                    on P_A[7:0]. see above for 
+                                                    values. */
+
+/* values mean the same thing as REG_INTR_MASK excep that it's for INTB. 
+ DEFAULT: 0x1F */
+#define  REG_PLUS_INTR_MASK_1          0x1038 /* Cassini+: interrupt mask
+                                                register 2 for INTB */
+#define  REG_PLUS_INTRN_MASK(x)       (REG_PLUS_INTR_MASK_1 + ((x) - 1)*16)
+/* bits correspond to both _MASK and _STATUS registers. _ALT corresponds to 
+ * all of the alternate (2-4) INTR registers while _1 corresponds to only 
+ * _MASK_1 and _STATUS_1 registers. 
+ * DEFAULT: 0x7 for MASK registers, 0x0 for ALIAS_CLEAR registers
+ */
+#define    INTR_RX_DONE_ALT              0x01  
+#define    INTR_RX_COMP_FULL_ALT         0x02
+#define    INTR_RX_COMP_AF_ALT           0x04
+#define    INTR_RX_BUF_UNAVAIL_1         0x08
+#define    INTR_RX_BUF_AE_1              0x10 /* almost empty */
+#define    INTRN_MASK_RX_EN              0x80     
+#define    INTRN_MASK_CLEAR_ALL          (INTR_RX_DONE_ALT | \
+                                          INTR_RX_COMP_FULL_ALT | \
+                                          INTR_RX_COMP_AF_ALT | \
+                                          INTR_RX_BUF_UNAVAIL_1 | \
+                                          INTR_RX_BUF_AE_1)
+#define  REG_PLUS_INTR_STATUS_1        0x103C /* Cassini+: interrupt status
+                                                register 2 for INTB. default: 0x1F */
+#define  REG_PLUS_INTRN_STATUS(x)       (REG_PLUS_INTR_STATUS_1 + ((x) - 1)*16)
+#define    INTR_STATUS_ALT_INTX_EN     0x80   /* generate INTX when one of the
+                                                flags are set. enables desc ring. */
+
+#define  REG_PLUS_ALIAS_CLEAR_1        0x1040 /* Cassini+: alias clear mask
+                                                register 2 for INTB */
+#define  REG_PLUS_ALIASN_CLEAR(x)      (REG_PLUS_ALIAS_CLEAR_1 + ((x) - 1)*16)
+
+#define  REG_PLUS_INTR_STATUS_ALIAS_1  0x1044 /* Cassini+: interrupt status 
+                                                register alias 2 for INTB */
+#define  REG_PLUS_INTRN_STATUS_ALIAS(x) (REG_PLUS_INTR_STATUS_ALIAS_1 + ((x) - 1)*16)
+
+#define REG_SATURN_PCFG               0x106c /* pin configuration register for
+                                               integrated macphy */
+
+#define   SATURN_PCFG_TLA             0x00000001 /* 1 = phy actled */
+#define   SATURN_PCFG_FLA             0x00000002 /* 1 = phy link10led */
+#define   SATURN_PCFG_CLA             0x00000004 /* 1 = phy link100led */
+#define   SATURN_PCFG_LLA             0x00000008 /* 1 = phy link1000led */
+#define   SATURN_PCFG_RLA             0x00000010 /* 1 = phy duplexled */
+#define   SATURN_PCFG_PDS             0x00000020 /* phy debug mode. 
+                                                   0 = normal */
+#define   SATURN_PCFG_MTP             0x00000080 /* test point select */ 
+#define   SATURN_PCFG_GMO             0x00000100 /* GMII observe. 1 = 
+                                                   GMII on SERDES pins for
+                                                   monitoring. */
+#define   SATURN_PCFG_FSI             0x00000200 /* 1 = freeze serdes/gmii. all
+                                                   pins configed as outputs.
+                                                   for power saving when using
+                                                   internal phy. */
+#define   SATURN_PCFG_LAD             0x00000800 /* 0 = mac core led ctrl 
+                                                   polarity from strapping 
+                                                   value.
+                                                   1 = mac core led ctrl
+                                                   polarity active low. */
+
+
+/** transmit dma registers **/
+#define MAX_TX_RINGS_SHIFT            2
+#define MAX_TX_RINGS                  (1 << MAX_TX_RINGS_SHIFT)
+#define MAX_TX_RINGS_MASK             (MAX_TX_RINGS - 1)
+
+/* TX configuration. 
+ * descr ring sizes size = 32 * (1 << n), n < 9. e.g., 0x8 = 8k. default: 0x8 
+ * DEFAULT: 0x3F000001
+ */
+#define  REG_TX_CFG                    0x2004  /* TX config */
+#define    TX_CFG_DMA_EN               0x00000001  /* enable TX DMA. if cleared, DMA
+                                                     will stop after xfer of current
+                                                     buffer has been completed. */
+#define    TX_CFG_FIFO_PIO_SEL         0x00000002  /* TX DMA FIFO can be 
+                                                     accessed w/ FIFO addr 
+                                                     and data registers. 
+                                                     TX DMA should be 
+                                                     disabled. */
+#define    TX_CFG_DESC_RING0_MASK      0x0000003C  /* # desc entries in
+                                                     ring 1. */
+#define    TX_CFG_DESC_RING0_SHIFT     2
+#define    TX_CFG_DESC_RINGN_MASK(a)   (TX_CFG_DESC_RING0_MASK << (a)*4)
+#define    TX_CFG_DESC_RINGN_SHIFT(a)  (TX_CFG_DESC_RING0_SHIFT + (a)*4)
+#define    TX_CFG_PACED_MODE           0x00100000  /* TX_ALL only set after 
+                                                     TX FIFO becomes empty. 
+                                                     if 0, TX_ALL set
+                                                     if descr queue empty. */
+#define    TX_CFG_DMA_RDPIPE_DIS       0x01000000  /* always set to 1 */
+#define    TX_CFG_COMPWB_Q1            0x02000000  /* completion writeback happens at
+                                                     the end of every packet kicked
+                                                     through Q1. */
+#define    TX_CFG_COMPWB_Q2            0x04000000  /* completion writeback happens at
+                                                     the end of every packet kicked
+                                                     through Q2. */
+#define    TX_CFG_COMPWB_Q3            0x08000000  /* completion writeback happens at
+                                                     the end of every packet kicked
+                                                     through Q3 */
+#define    TX_CFG_COMPWB_Q4            0x10000000  /* completion writeback happens at
+                                                     the end of every packet kicked
+                                                     through Q4 */
+#define    TX_CFG_INTR_COMPWB_DIS      0x20000000  /* disable pre-interrupt completion
+                                                     writeback */
+#define    TX_CFG_CTX_SEL_MASK         0xC0000000  /* selects tx test port 
+                                                     connection
+                                                     0b00: tx mac req, 
+                                                           tx mac retry req,
+                                                           tx ack and tx tag.
+                                                     0b01: txdma rd req, 
+                                                           txdma rd ack,
+                                                           txdma rd rdy,
+                                                           txdma rd type0
+                                                     0b11: txdma wr req, 
+                                                           txdma wr ack,
+                                                           txdma wr rdy,
+                                                           txdma wr xfr done. */
+#define    TX_CFG_CTX_SEL_SHIFT        30
+                                                     
+/* 11-bit counters that point to next location in FIFO to be loaded/retrieved.
+ * used for diagnostics only.
+ */
+#define  REG_TX_FIFO_WRITE_PTR         0x2014  /* TX FIFO write pointer */
+#define  REG_TX_FIFO_SHADOW_WRITE_PTR  0x2018  /* TX FIFO shadow write 
+                                                 pointer. temp hold reg.
+                                                 diagnostics only. */
+#define  REG_TX_FIFO_READ_PTR          0x201C  /* TX FIFO read pointer */
+#define  REG_TX_FIFO_SHADOW_READ_PTR   0x2020  /* TX FIFO shadow read
+                                                 pointer */
+
+/* (ro) 11-bit up/down counter w/ # of frames currently in TX FIFO */
+#define  REG_TX_FIFO_PKT_CNT           0x2024  /* TX FIFO packet counter */
+
+/* current state of all state machines in TX */
+#define  REG_TX_SM_1                   0x2028  /* TX state machine reg #1 */
+#define    TX_SM_1_CHAIN_MASK          0x000003FF   /* chaining state machine */
+#define    TX_SM_1_CSUM_MASK           0x00000C00   /* checksum state machine */
+#define    TX_SM_1_FIFO_LOAD_MASK      0x0003F000   /* FIFO load state machine.
+                                                      = 0x01 when TX disabled. */
+#define    TX_SM_1_FIFO_UNLOAD_MASK    0x003C0000   /* FIFO unload state machine */
+#define    TX_SM_1_CACHE_MASK          0x03C00000   /* desc. prefetch cache controller
+                                                      state machine */
+#define    TX_SM_1_CBQ_ARB_MASK        0xF8000000   /* CBQ arbiter state machine */
+                                                        
+#define  REG_TX_SM_2                   0x202C  /* TX state machine reg #2 */
+#define    TX_SM_2_COMP_WB_MASK        0x07    /* completion writeback sm */
+#define           TX_SM_2_SUB_LOAD_MASK       0x38    /* sub load state machine */
+#define           TX_SM_2_KICK_MASK           0xC0    /* kick state machine */
+
+/* 64-bit pointer to the transmit data buffer. only the 50 LSB are incremented
+ * while the upper 23 bits are taken from the TX descriptor
+ */
+#define  REG_TX_DATA_PTR_LOW           0x2030  /* TX data pointer low */
+#define  REG_TX_DATA_PTR_HI            0x2034  /* TX data pointer high */
+
+/* 13 bit registers written by driver w/ descriptor value that follows 
+ * last valid xmit descriptor. kick # and complete # values are used by
+ * the xmit dma engine to control tx descr fetching. if > 1 valid 
+ * tx descr is available within the cache line being read, cassini will
+ * internally cache up to 4 of them. 0 on reset. _KICK = rw, _COMP = ro.
+ */
+#define  REG_TX_KICK0                  0x2038  /* TX kick reg #1 */
+#define  REG_TX_KICKN(x)               (REG_TX_KICK0 + (x)*4)
+#define  REG_TX_COMP0                  0x2048  /* TX completion reg #1 */
+#define  REG_TX_COMPN(x)               (REG_TX_COMP0 + (x)*4)
+
+/* values of TX_COMPLETE_1-4 are written. each completion register 
+ * is 2bytes in size and contiguous. 8B allocation w/ 8B alignment. 
+ * NOTE: completion reg values are only written back prior to TX_INTME and
+ * TX_ALL interrupts. at all other times, the most up-to-date index values 
+ * should be obtained from the REG_TX_COMPLETE_# registers. 
+ * here's the layout: 
+ * offset from base addr      completion # byte
+ *           0                TX_COMPLETE_1_MSB
+ *          1                TX_COMPLETE_1_LSB
+ *           2                TX_COMPLETE_2_MSB
+ *          3                TX_COMPLETE_2_LSB
+ *           4                TX_COMPLETE_3_MSB
+ *          5                TX_COMPLETE_3_LSB
+ *           6                TX_COMPLETE_4_MSB
+ *          7                TX_COMPLETE_4_LSB
+ */
+#define  TX_COMPWB_SIZE             8
+#define  REG_TX_COMPWB_DB_LOW       0x2058  /* TX completion write back
+                                              base low */
+#define  REG_TX_COMPWB_DB_HI        0x205C  /* TX completion write back
+                                              base high */
+#define    TX_COMPWB_MSB_MASK       0x00000000000000FFULL
+#define    TX_COMPWB_MSB_SHIFT      0
+#define    TX_COMPWB_LSB_MASK       0x000000000000FF00ULL
+#define    TX_COMPWB_LSB_SHIFT      8
+#define    TX_COMPWB_NEXT(x)        ((x) >> 16)
+                                                     
+/* 53 MSB used as base address. 11 LSB assumed to be 0. TX desc pointer must
+ * be 2KB-aligned. */
+#define  REG_TX_DB0_LOW         0x2060  /* TX descriptor base low #1 */
+#define  REG_TX_DB0_HI          0x2064  /* TX descriptor base hi #1 */
+#define  REG_TX_DBN_LOW(x)      (REG_TX_DB0_LOW + (x)*8)
+#define  REG_TX_DBN_HI(x)       (REG_TX_DB0_HI + (x)*8)
+
+/* 16-bit registers hold weights for the weighted round-robin of the
+ * four CBQ TX descr rings. weights correspond to # bytes xferred from
+ * host to TXFIFO in a round of WRR arbitration. can be set
+ * dynamically with new weights set upon completion of the current
+ * packet transfer from host memory to TXFIFO. a dummy write to any of
+ * these registers causes a queue1 pre-emption with all historical bw
+ * deficit data reset to 0 (useful when congestion requires a
+ * pre-emption/re-allocation of network bandwidth
+ */
+#define  REG_TX_MAXBURST_0             0x2080  /* TX MaxBurst #1 */
+#define  REG_TX_MAXBURST_1             0x2084  /* TX MaxBurst #2 */
+#define  REG_TX_MAXBURST_2             0x2088  /* TX MaxBurst #3 */
+#define  REG_TX_MAXBURST_3             0x208C  /* TX MaxBurst #4 */
+
+/* diagnostics access to any TX FIFO location. every access is 65
+ * bits.  _DATA_LOW = 32 LSB, _DATA_HI_T1/T0 = 32 MSB. _TAG = tag bit.
+ * writing _DATA_HI_T0 sets tag bit low, writing _DATA_HI_T1 sets tag
+ * bit high.  TX_FIFO_PIO_SEL must be set for TX FIFO PIO access. if
+ * TX FIFO data integrity is desired, TX DMA should be
+ * disabled. _DATA_HI_Tx should be the last access of the sequence.
+ */
+#define  REG_TX_FIFO_ADDR              0x2104  /* TX FIFO address */
+#define  REG_TX_FIFO_TAG               0x2108  /* TX FIFO tag */
+#define  REG_TX_FIFO_DATA_LOW          0x210C  /* TX FIFO data low */
+#define  REG_TX_FIFO_DATA_HI_T1        0x2110  /* TX FIFO data high t1 */
+#define  REG_TX_FIFO_DATA_HI_T0        0x2114  /* TX FIFO data high t0 */
+#define  REG_TX_FIFO_SIZE              0x2118  /* (ro) TX FIFO size = 0x090 = 9KB */
+
+/* 9-bit register controls BIST of TX FIFO. bit set indicates that the BIST 
+ * passed for the specified memory
+ */
+#define  REG_TX_RAMBIST                0x211C /* TX RAMBIST control/status */
+#define    TX_RAMBIST_STATE            0x01C0 /* progress state of RAMBIST 
+                                                controller state machine */
+#define    TX_RAMBIST_RAM33A_PASS      0x0020 /* RAM33A passed */
+#define    TX_RAMBIST_RAM32A_PASS      0x0010 /* RAM32A passed */
+#define    TX_RAMBIST_RAM33B_PASS      0x0008 /* RAM33B passed */
+#define    TX_RAMBIST_RAM32B_PASS      0x0004 /* RAM32B passed */
+#define    TX_RAMBIST_SUMMARY          0x0002 /* all RAM passed */
+#define    TX_RAMBIST_START            0x0001 /* write 1 to start BIST. self
+                                                clears on completion. */
+
+/** receive dma registers **/
+#define MAX_RX_DESC_RINGS              2
+#define MAX_RX_COMP_RINGS              4
+
+/* receive DMA channel configuration. default: 0x80910 
+ * free ring size       = (1 << n)*32  -> [32 - 8k]
+ * completion ring size = (1 << n)*128 -> [128 - 32k], n < 9 
+ * DEFAULT: 0x80910
+ */
+#define  REG_RX_CFG                     0x4000  /* RX config */
+#define    RX_CFG_DMA_EN                0x00000001 /* enable RX DMA. 0 stops
+                                                        channel as soon as current
+                                                        frame xfer has completed.
+                                                        driver should disable MAC 
+                                                        for 200ms before disabling 
+                                                        RX */
+#define    RX_CFG_DESC_RING_MASK        0x0000001E /* # desc entries in RX 
+                                                        free desc ring. 
+                                                        def: 0x8 = 8k */
+#define    RX_CFG_DESC_RING_SHIFT       1
+#define    RX_CFG_COMP_RING_MASK        0x000001E0 /* # desc entries in RX complete
+                                                        ring. def: 0x8 = 32k */
+#define    RX_CFG_COMP_RING_SHIFT       5
+#define    RX_CFG_BATCH_DIS             0x00000200 /* disable receive desc 
+                                                     batching. def: 0x0 =
+                                                     enabled */
+#define    RX_CFG_SWIVEL_MASK           0x00001C00 /* byte offset of the 1st 
+                                                     data byte of the packet 
+                                                     w/in 8 byte boundares.
+                                                     this swivels the data 
+                                                     DMA'ed to header 
+                                                     buffers, jumbo buffers
+                                                     when header split is not
+                                                     requested and MTU sized
+                                                     buffers. def: 0x2 */
+#define    RX_CFG_SWIVEL_SHIFT          10
+
+/* cassini+ only */
+#define    RX_CFG_DESC_RING1_MASK       0x000F0000 /* # of desc entries in
+                                                        RX free desc ring 2. 
+                                                        def: 0x8 = 8k */
+#define    RX_CFG_DESC_RING1_SHIFT      16
+
+
+/* the page size register allows cassini chips to do the following with 
+ * received data:
+ * [--------------------------------------------------------------] page
+ * [off][buf1][pad][off][buf2][pad][off][buf3][pad][off][buf4][pad]
+ * |--------------| = PAGE_SIZE_BUFFER_STRIDE
+ * page = PAGE_SIZE 
+ * offset = PAGE_SIZE_MTU_OFF
+ * for the above example, MTU_BUFFER_COUNT = 4.
+ * NOTE: as is apparent, you need to ensure that the following holds:
+ * MTU_BUFFER_COUNT <= PAGE_SIZE/PAGE_SIZE_BUFFER_STRIDE
+ * DEFAULT: 0x48002002 (8k pages)
+ */
+#define  REG_RX_PAGE_SIZE               0x4004  /* RX page size */
+#define    RX_PAGE_SIZE_MASK            0x00000003 /* size of pages pointed to
+                                                     by receive descriptors.
+                                                     if jumbo buffers are 
+                                                     supported the page size 
+                                                     should not be < 8k.
+                                                     0b00 = 2k, 0b01 = 4k
+                                                     0b10 = 8k, 0b11 = 16k
+                                                     DEFAULT: 8k */
+#define    RX_PAGE_SIZE_SHIFT           0
+#define    RX_PAGE_SIZE_MTU_COUNT_MASK  0x00007800 /* # of MTU buffers the hw
+                                                     packs into a page. 
+                                                     DEFAULT: 4 */
+#define    RX_PAGE_SIZE_MTU_COUNT_SHIFT 11
+#define    RX_PAGE_SIZE_MTU_STRIDE_MASK 0x18000000 /* # of bytes that separate
+                                                        each MTU buffer + 
+                                                        offset from each 
+                                                        other.
+                                                        0b00 = 1k, 0b01 = 2k
+                                                        0b10 = 4k, 0b11 = 8k
+                                                        DEFAULT: 0x1 */
+#define    RX_PAGE_SIZE_MTU_STRIDE_SHIFT 27
+#define    RX_PAGE_SIZE_MTU_OFF_MASK    0xC0000000 /* offset in each page that
+                                                     hw writes the MTU buffer
+                                                     into. 
+                                                     0b00 = 0,  
+                                                     0b01 = 64 bytes
+                                                     0b10 = 96, 0b11 = 128
+                                                     DEFAULT: 0x1 */
+#define    RX_PAGE_SIZE_MTU_OFF_SHIFT   30
+                                                        
+/* 11-bit counter points to next location in RX FIFO to be loaded/read. 
+ * shadow write pointers enable retries in case of early receive aborts.
+ * DEFAULT: 0x0. generated on 64-bit boundaries.
+ */
+#define  REG_RX_FIFO_WRITE_PTR             0x4008  /* RX FIFO write pointer */
+#define  REG_RX_FIFO_READ_PTR              0x400C  /* RX FIFO read pointer */
+#define  REG_RX_IPP_FIFO_SHADOW_WRITE_PTR  0x4010  /* RX IPP FIFO shadow write 
+                                                     pointer */
+#define  REG_RX_IPP_FIFO_SHADOW_READ_PTR   0x4014  /* RX IPP FIFO shadow read
+                                                     pointer */
+#define  REG_RX_IPP_FIFO_READ_PTR          0x400C  /* RX IPP FIFO read 
+                                                     pointer. (8-bit counter) */
+
+/* current state of RX DMA state engines + other info
+ * DEFAULT: 0x0
+ */
+#define  REG_RX_DEBUG                      0x401C  /* RX debug */
+#define    RX_DEBUG_LOAD_STATE_MASK        0x0000000F /* load state machine w/ MAC:
+                                                        0x0 = idle,   0x1 = load_bop
+                                                        0x2 = load 1, 0x3 = load 2
+                                                        0x4 = load 3, 0x5 = load 4
+                                                        0x6 = last detect
+                                                        0x7 = wait req
+                                                        0x8 = wait req statuss 1st
+                                                        0x9 = load st
+                                                        0xa = bubble mac
+                                                        0xb = error */
+#define    RX_DEBUG_LM_STATE_MASK          0x00000070 /* load state machine w/ HP and
+                                                        RX FIFO:
+                                                        0x0 = idle,   0x1 = hp xfr
+                                                        0x2 = wait hp ready
+                                                        0x3 = wait flow code
+                                                        0x4 = fifo xfer
+                                                        0x5 = make status
+                                                        0x6 = csum ready
+                                                        0x7 = error */
+#define    RX_DEBUG_FC_STATE_MASK          0x000000180 /* flow control state machine
+                                                        w/ MAC:
+                                                        0x0 = idle
+                                                        0x1 = wait xoff ack
+                                                        0x2 = wait xon
+                                                        0x3 = wait xon ack */
+#define    RX_DEBUG_DATA_STATE_MASK        0x000001E00 /* unload data state machine
+                                                        states: 
+                                                        0x0 = idle data
+                                                        0x1 = header begin
+                                                        0x2 = xfer header
+                                                        0x3 = xfer header ld
+                                                        0x4 = mtu begin
+                                                        0x5 = xfer mtu
+                                                        0x6 = xfer mtu ld
+                                                        0x7 = jumbo begin
+                                                        0x8 = xfer jumbo 
+                                                        0x9 = xfer jumbo ld
+                                                        0xa = reas begin
+                                                        0xb = xfer reas
+                                                        0xc = flush tag
+                                                        0xd = xfer reas ld
+                                                        0xe = error
+                                                        0xf = bubble idle */
+#define    RX_DEBUG_DESC_STATE_MASK        0x0001E000 /* unload desc state machine
+                                                        states:
+                                                        0x0 = idle desc
+                                                        0x1 = wait ack
+                                                        0x9 = wait ack 2
+                                                        0x2 = fetch desc 1
+                                                        0xa = fetch desc 2
+                                                        0x3 = load ptrs
+                                                        0x4 = wait dma
+                                                        0x5 = wait ack batch
+                                                        0x6 = post batch
+                                                        0x7 = xfr done */
+#define    RX_DEBUG_INTR_READ_PTR_MASK     0x30000000 /* interrupt read ptr of the
+                                                        interrupt queue */
+#define    RX_DEBUG_INTR_WRITE_PTR_MASK    0xC0000000 /* interrupt write pointer
+                                                        of the interrupt queue */
+
+/* flow control frames are emmitted using two PAUSE thresholds:
+ * XOFF PAUSE uses pause time value pre-programmed in the Send PAUSE MAC reg
+ * XON PAUSE uses a pause time of 0. granularity of threshold is 64bytes.
+ * PAUSE thresholds defined in terms of FIFO occupancy and may be translated
+ * into FIFO vacancy using RX_FIFO_SIZE. setting ON will trigger XON frames 
+ * when FIFO reaches 0. OFF threshold should not be > size of RX FIFO. max
+ * value is is 0x6F. 
+ * DEFAULT: 0x00078
+ */
+#define  REG_RX_PAUSE_THRESH               0x4020  /* RX pause thresholds */
+#define    RX_PAUSE_THRESH_QUANTUM         64
+#define    RX_PAUSE_THRESH_OFF_MASK        0x000001FF /* XOFF PAUSE emitted when
+                                                        RX FIFO occupancy > 
+                                                        value*64B */
+#define    RX_PAUSE_THRESH_OFF_SHIFT       0
+#define    RX_PAUSE_THRESH_ON_MASK         0x001FF000 /* XON PAUSE emitted after
+                                                        emitting XOFF PAUSE when RX
+                                                        FIFO occupancy falls below
+                                                        this value*64B. must be
+                                                        < XOFF threshold. if =
+                                                        RX_FIFO_SIZE< XON frames are
+                                                        never emitted. */
+#define    RX_PAUSE_THRESH_ON_SHIFT        12
+
+/* 13-bit register used to control RX desc fetching and intr generation. if 4+
+ * valid RX descriptors are available, Cassini will read 4 at a time. 
+ * writing N means that all desc up to *but* excluding N are available. N must
+ * be a multiple of 4 (N % 4 = 0). first desc should be cache-line aligned. 
+ * DEFAULT: 0 on reset
+ */
+#define  REG_RX_KICK                    0x4024  /* RX kick reg */
+
+/* 8KB aligned 64-bit pointer to the base of the RX free/completion rings.
+ * lower 13 bits of the low register are hard-wired to 0.
+ */
+#define  REG_RX_DB_LOW                     0x4028  /* RX descriptor ring 
+                                                        base low */
+#define  REG_RX_DB_HI                      0x402C  /* RX descriptor ring
+                                                        base hi */
+#define  REG_RX_CB_LOW                     0x4030  /* RX completion ring
+                                                        base low */
+#define  REG_RX_CB_HI                      0x4034  /* RX completion ring 
+                                                        base hi */
+/* 13-bit register indicate desc used by cassini for receive frames. used
+ * for diagnostic purposes. 
+ * DEFAULT: 0 on reset
+ */
+#define  REG_RX_COMP                       0x4038  /* (ro) RX completion */
+
+/* HEAD and TAIL are used to control RX desc posting and interrupt
+ * generation.  hw moves the head register to pass ownership to sw. sw
+ * moves the tail register to pass ownership back to hw. to give all
+ * entries to hw, set TAIL = HEAD.  if HEAD and TAIL indicate that no
+ * more entries are available, DMA will pause and an interrupt will be
+ * generated to indicate no more entries are available.  sw can use
+ * this interrupt to reduce the # of times it must update the
+ * completion tail register.
+ * DEFAULT: 0 on reset
+ */
+#define  REG_RX_COMP_HEAD                  0x403C  /* RX completion head */
+#define  REG_RX_COMP_TAIL                  0x4040  /* RX completion tail */
+
+/* values used for receive interrupt blanking. loaded each time the ISR is read
+ * DEFAULT: 0x00000000
+ */
+#define  REG_RX_BLANK                      0x4044  /* RX blanking register 
+                                                        for ISR read */
+#define    RX_BLANK_INTR_PKT_MASK          0x000001FF /* RX_DONE intr asserted if 
+                                                        this many sets of completion
+                                                        writebacks (up to 2 packets)
+                                                        occur since the last time
+                                                        the ISR was read. 0 = no
+                                                        packet blanking */
+#define    RX_BLANK_INTR_PKT_SHIFT         0
+#define    RX_BLANK_INTR_TIME_MASK         0x3FFFF000 /* RX_DONE interrupt asserted
+                                                        if that many clocks were
+                                                        counted since last time the
+                                                        ISR was read. 
+                                                        each count is 512 core
+                                                        clocks (125MHz). 0 = no
+                                                        time blanking */
+#define    RX_BLANK_INTR_TIME_SHIFT        12
+
+/* values used for interrupt generation based on threshold values of how 
+ * many free desc and completion entries are available for hw use.
+ * DEFAULT: 0x00000000
+ */
+#define  REG_RX_AE_THRESH                  0x4048  /* RX almost empty 
+                                                        thresholds */
+#define    RX_AE_THRESH_FREE_MASK          0x00001FFF /* RX_BUF_AE will be 
+                                                        generated if # desc
+                                                        avail for hw use <= 
+                                                        # */
+#define    RX_AE_THRESH_FREE_SHIFT         0
+#define    RX_AE_THRESH_COMP_MASK          0x0FFFE000 /* RX_COMP_AE will be
+                                                        generated if # of 
+                                                        completion entries
+                                                        avail for hw use <= 
+                                                        # */
+#define    RX_AE_THRESH_COMP_SHIFT         13
+
+/* probabilities for random early drop (RED) thresholds on a FIFO threshold 
+ * basis. probability should increase when the FIFO level increases. control 
+ * packets are never dropped and not counted in stats. probability programmed 
+ * on a 12.5% granularity. e.g., 0x1 = 1/8 packets dropped.
+ * DEFAULT: 0x00000000
+ */
+#define  REG_RX_RED                      0x404C  /* RX random early detect enable */
+#define    RX_RED_4K_6K_FIFO_MASK        0x000000FF /*  4KB < FIFO thresh < 6KB */
+#define    RX_RED_6K_8K_FIFO_MASK        0x0000FF00 /*  6KB < FIFO thresh < 8KB */
+#define    RX_RED_8K_10K_FIFO_MASK       0x00FF0000 /*  8KB < FIFO thresh < 10KB */
+#define    RX_RED_10K_12K_FIFO_MASK      0xFF000000 /* 10KB < FIFO thresh < 12KB */
+
+/* FIFO fullness levels for RX FIFO, RX control FIFO, and RX IPP FIFO. 
+ * RX control FIFO = # of packets in RX FIFO. 
+ * DEFAULT: 0x0
+ */
+#define  REG_RX_FIFO_FULLNESS              0x4050  /* (ro) RX FIFO fullness */
+#define    RX_FIFO_FULLNESS_RX_FIFO_MASK   0x3FF80000 /* level w/ 8B granularity */
+#define    RX_FIFO_FULLNESS_IPP_FIFO_MASK  0x0007FF00 /* level w/ 8B granularity */
+#define    RX_FIFO_FULLNESS_RX_PKT_MASK    0x000000FF /* # packets in RX FIFO */
+#define  REG_RX_IPP_PACKET_COUNT           0x4054  /* RX IPP packet counter */
+#define  REG_RX_WORK_DMA_PTR_LOW           0x4058  /* RX working DMA ptr low */
+#define  REG_RX_WORK_DMA_PTR_HI            0x405C  /* RX working DMA ptr 
+                                                     high */
+
+/* BIST testing ro RX FIFO, RX control FIFO, and RX IPP FIFO. only RX BIST
+ * START/COMPLETE is writeable. START will clear when the BIST has completed
+ * checking all 17 RAMS. 
+ * DEFAULT: 0bxxxx xxxxx xxxx xxxx xxxx x000 0000 0000 00x0
+ */
+#define  REG_RX_BIST                       0x4060  /* (ro) RX BIST */
+#define    RX_BIST_32A_PASS                0x80000000 /* RX FIFO 32A passed */
+#define    RX_BIST_33A_PASS                0x40000000 /* RX FIFO 33A passed */
+#define    RX_BIST_32B_PASS                0x20000000 /* RX FIFO 32B passed */
+#define    RX_BIST_33B_PASS                0x10000000 /* RX FIFO 33B passed */
+#define    RX_BIST_32C_PASS                0x08000000 /* RX FIFO 32C passed */
+#define    RX_BIST_33C_PASS                0x04000000 /* RX FIFO 33C passed */
+#define    RX_BIST_IPP_32A_PASS            0x02000000 /* RX IPP FIFO 33B passed */
+#define    RX_BIST_IPP_33A_PASS            0x01000000 /* RX IPP FIFO 33A passed */
+#define    RX_BIST_IPP_32B_PASS            0x00800000 /* RX IPP FIFO 32B passed */
+#define    RX_BIST_IPP_33B_PASS            0x00400000 /* RX IPP FIFO 33B passed */
+#define    RX_BIST_IPP_32C_PASS            0x00200000 /* RX IPP FIFO 32C passed */
+#define    RX_BIST_IPP_33C_PASS            0x00100000 /* RX IPP FIFO 33C passed */
+#define    RX_BIST_CTRL_32_PASS            0x00800000 /* RX CTRL FIFO 32 passed */
+#define    RX_BIST_CTRL_33_PASS            0x00400000 /* RX CTRL FIFO 33 passed */
+#define    RX_BIST_REAS_26A_PASS           0x00200000 /* RX Reas 26A passed */
+#define    RX_BIST_REAS_26B_PASS           0x00100000 /* RX Reas 26B passed */
+#define    RX_BIST_REAS_27_PASS            0x00080000 /* RX Reas 27 passed */
+#define    RX_BIST_STATE_MASK              0x00078000 /* BIST state machine */
+#define    RX_BIST_SUMMARY                 0x00000002 /* when BIST complete,
+                                                        summary pass bit 
+                                                        contains AND of BIST
+                                                        results of all 16
+                                                        RAMS */
+#define    RX_BIST_START                   0x00000001 /* write 1 to start 
+                                                        BIST. self clears
+                                                        on completion. */
+
+/* next location in RX CTRL FIFO that will be loaded w/ data from RX IPP/read
+ * from to retrieve packet control info. 
+ * DEFAULT: 0
+ */
+#define  REG_RX_CTRL_FIFO_WRITE_PTR        0x4064  /* (ro) RX control FIFO 
+                                                     write ptr */
+#define  REG_RX_CTRL_FIFO_READ_PTR         0x4068  /* (ro) RX control FIFO read
+                                                     ptr */
+
+/* receive interrupt blanking. loaded each time interrupt alias register is
+ * read. 
+ * DEFAULT: 0x0
+ */
+#define  REG_RX_BLANK_ALIAS_READ           0x406C  /* RX blanking register for
+                                                     alias read */
+#define    RX_BAR_INTR_PACKET_MASK         0x000001FF /* assert RX_DONE if # 
+                                                        completion writebacks 
+                                                        > # since last ISR 
+                                                        read. 0 = no 
+                                                        blanking. up to 2 
+                                                        packets per 
+                                                        completion wb. */
+#define    RX_BAR_INTR_TIME_MASK           0x3FFFF000 /* assert RX_DONE if #
+                                                        clocks > # since last
+                                                        ISR read. each count
+                                                        is 512 core clocks
+                                                        (125MHz). 0 = no 
+                                                        blanking. */
+
+/* diagnostic access to RX FIFO. 32 LSB accessed via DATA_LOW. 32 MSB accessed
+ * via DATA_HI_T0 or DATA_HI_T1. TAG reads the tag bit. writing HI_T0
+ * will unset the tag bit while writing HI_T1 will set the tag bit. to reset
+ * to normal operation after diagnostics, write to address location 0x0.
+ * RX_DMA_EN bit must be set to 0x0 for RX FIFO PIO access. DATA_HI should
+ * be the last write access of a write sequence.
+ * DEFAULT: undefined
+ */
+#define  REG_RX_FIFO_ADDR                  0x4080  /* RX FIFO address */
+#define  REG_RX_FIFO_TAG                   0x4084  /* RX FIFO tag */
+#define  REG_RX_FIFO_DATA_LOW              0x4088  /* RX FIFO data low */
+#define  REG_RX_FIFO_DATA_HI_T0            0x408C  /* RX FIFO data high T0 */
+#define  REG_RX_FIFO_DATA_HI_T1            0x4090  /* RX FIFO data high T1 */
+
+/* diagnostic assess to RX CTRL FIFO. 8-bit FIFO_ADDR holds address of
+ * 81 bit control entry and 6 bit flow id. LOW and MID are both 32-bit
+ * accesses. HI is 7-bits with 6-bit flow id and 1 bit control
+ * word. RX_DMA_EN must be 0 for RX CTRL FIFO PIO access. DATA_HI
+ * should be last write access of the write sequence.
+ * DEFAULT: undefined
+ */
+#define  REG_RX_CTRL_FIFO_ADDR             0x4094  /* RX Control FIFO and 
+                                                     Batching FIFO addr */
+#define  REG_RX_CTRL_FIFO_DATA_LOW         0x4098  /* RX Control FIFO data 
+                                                     low */
+#define  REG_RX_CTRL_FIFO_DATA_MID         0x409C  /* RX Control FIFO data 
+                                                     mid */
+#define  REG_RX_CTRL_FIFO_DATA_HI          0x4100  /* RX Control FIFO data 
+                                                     hi and flow id */
+#define    RX_CTRL_FIFO_DATA_HI_CTRL       0x0001  /* upper bit of ctrl word */
+#define    RX_CTRL_FIFO_DATA_HI_FLOW_MASK  0x007E  /* flow id */
+
+/* diagnostic access to RX IPP FIFO. same semantics as RX_FIFO.
+ * DEFAULT: undefined
+ */
+#define  REG_RX_IPP_FIFO_ADDR              0x4104  /* RX IPP FIFO address */
+#define  REG_RX_IPP_FIFO_TAG               0x4108  /* RX IPP FIFO tag */
+#define  REG_RX_IPP_FIFO_DATA_LOW          0x410C  /* RX IPP FIFO data low */
+#define  REG_RX_IPP_FIFO_DATA_HI_T0        0x4110  /* RX IPP FIFO data high
+                                                     T0 */
+#define  REG_RX_IPP_FIFO_DATA_HI_T1        0x4114  /* RX IPP FIFO data high
+                                                     T1 */
+
+/* 64-bit pointer to receive data buffer in host memory used for headers and
+ * small packets. MSB in high register. loaded by DMA state machine and 
+ * increments as DMA writes receive data. only 50 LSB are incremented. top
+ * 13 bits taken from RX descriptor.
+ * DEFAULT: undefined
+ */
+#define  REG_RX_HEADER_PAGE_PTR_LOW        0x4118  /* (ro) RX header page ptr
+                                                     low */
+#define  REG_RX_HEADER_PAGE_PTR_HI         0x411C  /* (ro) RX header page ptr
+                                                     high */
+#define  REG_RX_MTU_PAGE_PTR_LOW           0x4120  /* (ro) RX MTU page pointer 
+                                                     low */
+#define  REG_RX_MTU_PAGE_PTR_HI            0x4124  /* (ro) RX MTU page pointer 
+                                                     high */
+
+/* PIO diagnostic access to RX reassembly DMA Table RAM. 6-bit register holds
+ * one of 64 79-bit locations in the RX Reassembly DMA table and the addr of
+ * one of the 64 byte locations in the Batching table. LOW holds 32 LSB. 
+ * MID holds the next 32 LSB. HIGH holds the 15 MSB. RX_DMA_EN must be set
+ * to 0 for PIO access. DATA_HIGH should be last write of write sequence.
+ * layout:  
+ * reassmbl ptr [78:15] | reassmbl index [14:1] | reassmbl entry valid [0]
+ * DEFAULT: undefined
+ */
+#define  REG_RX_TABLE_ADDR             0x4128  /* RX reassembly DMA table
+                                                 address */
+#define    RX_TABLE_ADDR_MASK          0x0000003F /* address mask */
+
+#define  REG_RX_TABLE_DATA_LOW         0x412C  /* RX reassembly DMA table
+                                                 data low */
+#define  REG_RX_TABLE_DATA_MID         0x4130  /* RX reassembly DMA table 
+                                                 data mid */
+#define  REG_RX_TABLE_DATA_HI          0x4134  /* RX reassembly DMA table
+                                                 data high */
+
+/* cassini+ only */
+/* 8KB aligned 64-bit pointer to base of RX rings. lower 13 bits hardwired to
+ * 0. same semantics as primary desc/complete rings.
+ */
+#define  REG_PLUS_RX_DB1_LOW            0x4200  /* RX descriptor ring
+                                                  2 base low */
+#define  REG_PLUS_RX_DB1_HI             0x4204  /* RX descriptor ring
+                                                  2 base high */
+#define  REG_PLUS_RX_CB1_LOW            0x4208  /* RX completion ring
+                                                  2 base low. 4 total */
+#define  REG_PLUS_RX_CB1_HI             0x420C  /* RX completion ring
+                                                  2 base high. 4 total */
+#define  REG_PLUS_RX_CBN_LOW(x)        (REG_PLUS_RX_CB1_LOW + 8*((x) - 1))
+#define  REG_PLUS_RX_CBN_HI(x)         (REG_PLUS_RX_CB1_HI + 8*((x) - 1))
+#define  REG_PLUS_RX_KICK1             0x4220  /* RX Kick 2 register */
+#define  REG_PLUS_RX_COMP1             0x4224  /* (ro) RX completion 2 
+                                                 reg */
+#define  REG_PLUS_RX_COMP1_HEAD        0x4228  /* (ro) RX completion 2 
+                                                 head reg. 4 total. */
+#define  REG_PLUS_RX_COMP1_TAIL        0x422C  /* RX completion 2 
+                                                 tail reg. 4 total. */
+#define  REG_PLUS_RX_COMPN_HEAD(x)    (REG_PLUS_RX_COMP1_HEAD + 8*((x) - 1))
+#define  REG_PLUS_RX_COMPN_TAIL(x)    (REG_PLUS_RX_COMP1_TAIL + 8*((x) - 1))
+#define  REG_PLUS_RX_AE1_THRESH        0x4240  /* RX almost empty 2
+                                                 thresholds */
+#define    RX_AE1_THRESH_FREE_MASK     RX_AE_THRESH_FREE_MASK
+#define    RX_AE1_THRESH_FREE_SHIFT    RX_AE_THRESH_FREE_SHIFT
+
+/** header parser registers **/
+
+/* RX parser configuration register. 
+ * DEFAULT: 0x1651004
+ */
+#define  REG_HP_CFG                       0x4140  /* header parser 
+                                                    configuration reg */
+#define    HP_CFG_PARSE_EN                0x00000001 /* enab header parsing */
+#define    HP_CFG_NUM_CPU_MASK            0x000000FC /* # processors 
+                                                     0 = 64. 0x3f = 63 */
+#define    HP_CFG_NUM_CPU_SHIFT           2
+#define    HP_CFG_SYN_INC_MASK            0x00000100 /* SYN bit won't increment
+                                                       TCP seq # by one when
+                                                       stored in FDBM */
+#define    HP_CFG_TCP_THRESH_MASK         0x000FFE00 /* # bytes of TCP data
+                                                       needed to be considered
+                                                       for reassembly */
+#define    HP_CFG_TCP_THRESH_SHIFT        9
+
+/* access to RX Instruction RAM. 5-bit register/counter holds addr
+ * of 39 bit entry to be read/written. 32 LSB in _DATA_LOW. 7 MSB in _DATA_HI.
+ * RX_DMA_EN must be 0 for RX instr PIO access. DATA_HI should be last access
+ * of sequence. 
+ * DEFAULT: undefined
+ */
+#define  REG_HP_INSTR_RAM_ADDR             0x4144  /* HP instruction RAM
+                                                     address */
+#define    HP_INSTR_RAM_ADDR_MASK          0x01F   /* 5-bit mask */
+#define  REG_HP_INSTR_RAM_DATA_LOW         0x4148  /* HP instruction RAM
+                                                     data low */
+#define    HP_INSTR_RAM_LOW_OUTMASK_MASK   0x0000FFFF
+#define    HP_INSTR_RAM_LOW_OUTMASK_SHIFT  0
+#define    HP_INSTR_RAM_LOW_OUTSHIFT_MASK  0x000F0000
+#define    HP_INSTR_RAM_LOW_OUTSHIFT_SHIFT 16
+#define    HP_INSTR_RAM_LOW_OUTEN_MASK     0x00300000
+#define    HP_INSTR_RAM_LOW_OUTEN_SHIFT    20
+#define    HP_INSTR_RAM_LOW_OUTARG_MASK    0xFFC00000
+#define    HP_INSTR_RAM_LOW_OUTARG_SHIFT   22
+#define  REG_HP_INSTR_RAM_DATA_MID         0x414C  /* HP instruction RAM 
+                                                     data mid */
+#define    HP_INSTR_RAM_MID_OUTARG_MASK    0x00000003
+#define    HP_INSTR_RAM_MID_OUTARG_SHIFT   0
+#define    HP_INSTR_RAM_MID_OUTOP_MASK     0x0000003C
+#define    HP_INSTR_RAM_MID_OUTOP_SHIFT    2
+#define    HP_INSTR_RAM_MID_FNEXT_MASK     0x000007C0
+#define    HP_INSTR_RAM_MID_FNEXT_SHIFT    6
+#define    HP_INSTR_RAM_MID_FOFF_MASK      0x0003F800
+#define    HP_INSTR_RAM_MID_FOFF_SHIFT     11
+#define    HP_INSTR_RAM_MID_SNEXT_MASK     0x007C0000
+#define    HP_INSTR_RAM_MID_SNEXT_SHIFT    18
+#define    HP_INSTR_RAM_MID_SOFF_MASK      0x3F800000
+#define    HP_INSTR_RAM_MID_SOFF_SHIFT     23
+#define    HP_INSTR_RAM_MID_OP_MASK        0xC0000000
+#define    HP_INSTR_RAM_MID_OP_SHIFT       30
+#define  REG_HP_INSTR_RAM_DATA_HI          0x4150  /* HP instruction RAM
+                                                     data high */
+#define    HP_INSTR_RAM_HI_VAL_MASK        0x0000FFFF
+#define    HP_INSTR_RAM_HI_VAL_SHIFT       0
+#define    HP_INSTR_RAM_HI_MASK_MASK       0xFFFF0000
+#define    HP_INSTR_RAM_HI_MASK_SHIFT      16
+
+/* PIO access into RX Header parser data RAM and flow database.
+ * 11-bit register. Data fills the LSB portion of bus if less than 32 bits.
+ * DATA_RAM: write RAM_FDB_DATA with index to access DATA_RAM.
+ * RAM bytes = 4*(x - 1) + [3:0]. e.g., 0 -> [3:0], 31 -> [123:120]
+ * FLOWDB: write DATA_RAM_FDB register and then read/write FDB1-12 to access 
+ * flow database.
+ * RX_DMA_EN must be 0 for RX parser RAM PIO access. RX Parser RAM data reg
+ * should be the last write access of the write sequence.
+ * DEFAULT: undefined
+ */
+#define  REG_HP_DATA_RAM_FDB_ADDR          0x4154  /* HP data and FDB
+                                                     RAM address */
+#define    HP_DATA_RAM_FDB_DATA_MASK       0x001F  /* select 1 of 86 byte 
+                                                     locations in header 
+                                                     parser data ram to 
+                                                     read/write */
+#define    HP_DATA_RAM_FDB_FDB_MASK        0x3F00  /* 1 of 64 353-bit locations
+                                                     in the flow database */
+#define  REG_HP_DATA_RAM_DATA              0x4158  /* HP data RAM data */
+
+/* HP flow database registers: 1 - 12, 0x415C - 0x4188, 4 8-bit bytes 
+ * FLOW_DB(1) = IP_SA[127:96], FLOW_DB(2) = IP_SA[95:64]
+ * FLOW_DB(3) = IP_SA[63:32],  FLOW_DB(4) = IP_SA[31:0] 
+ * FLOW_DB(5) = IP_DA[127:96], FLOW_DB(6) = IP_DA[95:64]
+ * FLOW_DB(7) = IP_DA[63:32],  FLOW_DB(8) = IP_DA[31:0]
+ * FLOW_DB(9) = {TCP_SP[15:0],TCP_DP[15:0]}
+ * FLOW_DB(10) = bit 0 has value for flow valid
+ * FLOW_DB(11) = TCP_SEQ[63:32], FLOW_DB(12) = TCP_SEQ[31:0]
+ */
+#define  REG_HP_FLOW_DB0                   0x415C  /* HP flow database 1 reg */
+#define  REG_HP_FLOW_DBN(x)                (REG_HP_FLOW_DB0 + (x)*4)
+
+/* diagnostics for RX Header Parser block. 
+ * ASUN: the header parser state machine register is used for diagnostics
+ * purposes. however, the spec doesn't have any details on it.
+ */
+#define  REG_HP_STATE_MACHINE              0x418C  /* (ro) HP state machine */
+#define  REG_HP_STATUS0                    0x4190  /* (ro) HP status 1 */
+#define    HP_STATUS0_SAP_MASK             0xFFFF0000 /* SAP */
+#define    HP_STATUS0_L3_OFF_MASK          0x0000FE00 /* L3 offset */
+#define    HP_STATUS0_LB_CPUNUM_MASK       0x000001F8 /* load balancing CPU 
+                                                        number */
+#define    HP_STATUS0_HRP_OPCODE_MASK      0x00000007 /* HRP opcode */
+
+#define  REG_HP_STATUS1                    0x4194  /* (ro) HP status 2 */
+#define    HP_STATUS1_ACCUR2_MASK          0xE0000000 /* accu R2[6:4] */
+#define    HP_STATUS1_FLOWID_MASK          0x1F800000 /* flow id */
+#define    HP_STATUS1_TCP_OFF_MASK         0x007F0000 /* tcp payload offset */
+#define    HP_STATUS1_TCP_SIZE_MASK        0x0000FFFF /* tcp payload size */
+
+#define  REG_HP_STATUS2                    0x4198  /* (ro) HP status 3 */
+#define    HP_STATUS2_ACCUR2_MASK          0xF0000000 /* accu R2[3:0] */
+#define    HP_STATUS2_CSUM_OFF_MASK        0x07F00000 /* checksum start 
+                                                        start offset */
+#define    HP_STATUS2_ACCUR1_MASK          0x000FE000 /* accu R1 */
+#define    HP_STATUS2_FORCE_DROP           0x00001000 /* force drop */
+#define    HP_STATUS2_BWO_REASSM           0x00000800 /* batching w/o 
+                                                        reassembly */
+#define    HP_STATUS2_JH_SPLIT_EN          0x00000400 /* jumbo header split
+                                                        enable */
+#define    HP_STATUS2_FORCE_TCP_NOCHECK    0x00000200 /* force tcp no payload
+                                                        check */
+#define    HP_STATUS2_DATA_MASK_ZERO       0x00000100 /* mask of data length
+                                                        equal to zero */
+#define    HP_STATUS2_FORCE_TCP_CHECK      0x00000080 /* force tcp payload 
+                                                        chk */
+#define    HP_STATUS2_MASK_TCP_THRESH      0x00000040 /* mask of payload 
+                                                        threshold */
+#define    HP_STATUS2_NO_ASSIST            0x00000020 /* no assist */
+#define    HP_STATUS2_CTRL_PACKET_FLAG     0x00000010 /* control packet flag */
+#define    HP_STATUS2_TCP_FLAG_CHECK       0x00000008 /* tcp flag check */
+#define    HP_STATUS2_SYN_FLAG             0x00000004 /* syn flag */
+#define    HP_STATUS2_TCP_CHECK            0x00000002 /* tcp payload chk */
+#define    HP_STATUS2_TCP_NOCHECK          0x00000001 /* tcp no payload chk */
+
+/* BIST for header parser(HP) and flow database memories (FDBM). set _START
+ * to start BIST. controller clears _START on completion. _START can also
+ * be cleared to force termination of BIST. a bit set indicates that that
+ * memory passed its BIST.
+ */
+#define  REG_HP_RAM_BIST                   0x419C  /* HP RAM BIST reg */
+#define    HP_RAM_BIST_HP_DATA_PASS        0x80000000 /* HP data ram */
+#define    HP_RAM_BIST_HP_INSTR0_PASS      0x40000000 /* HP instr ram 0 */
+#define    HP_RAM_BIST_HP_INSTR1_PASS      0x20000000 /* HP instr ram 1 */
+#define    HP_RAM_BIST_HP_INSTR2_PASS      0x10000000 /* HP instr ram 2 */
+#define    HP_RAM_BIST_FDBM_AGE0_PASS      0x08000000 /* FDBM aging RAM0 */
+#define    HP_RAM_BIST_FDBM_AGE1_PASS      0x04000000 /* FDBM aging RAM1 */
+#define    HP_RAM_BIST_FDBM_FLOWID00_PASS  0x02000000 /* FDBM flowid RAM0 
+                                                        bank 0 */
+#define    HP_RAM_BIST_FDBM_FLOWID10_PASS  0x01000000 /* FDBM flowid RAM1
+                                                        bank 0 */
+#define    HP_RAM_BIST_FDBM_FLOWID20_PASS  0x00800000 /* FDBM flowid RAM2
+                                                        bank 0 */
+#define    HP_RAM_BIST_FDBM_FLOWID30_PASS  0x00400000 /* FDBM flowid RAM3
+                                                        bank 0 */
+#define    HP_RAM_BIST_FDBM_FLOWID01_PASS  0x00200000 /* FDBM flowid RAM0
+                                                        bank 1 */
+#define    HP_RAM_BIST_FDBM_FLOWID11_PASS  0x00100000 /* FDBM flowid RAM1
+                                                        bank 2 */
+#define    HP_RAM_BIST_FDBM_FLOWID21_PASS  0x00080000 /* FDBM flowid RAM2
+                                                        bank 1 */
+#define    HP_RAM_BIST_FDBM_FLOWID31_PASS  0x00040000 /* FDBM flowid RAM3
+                                                        bank 1 */
+#define    HP_RAM_BIST_FDBM_TCPSEQ_PASS    0x00020000 /* FDBM tcp sequence
+                                                        RAM */
+#define    HP_RAM_BIST_SUMMARY             0x00000002 /* all BIST tests */
+#define    HP_RAM_BIST_START               0x00000001 /* start/stop BIST */
+
+
+/** MAC registers.  **/
+/* reset bits are set using a PIO write and self-cleared after the command
+ * execution has completed.
+ */
+#define  REG_MAC_TX_RESET                  0x6000  /* TX MAC software reset
+                                                     command (default: 0x0) */
+#define  REG_MAC_RX_RESET                  0x6004  /* RX MAC software reset
+                                                     command (default: 0x0) */
+/* execute a pause flow control frame transmission
+ DEFAULT: 0x0XXXX */
+#define  REG_MAC_SEND_PAUSE                0x6008  /* send pause command reg */
+#define    MAC_SEND_PAUSE_TIME_MASK        0x0000FFFF /* value of pause time 
+                                                        to be sent on network
+                                                        in units of slot 
+                                                        times */
+#define    MAC_SEND_PAUSE_SEND             0x00010000 /* send pause flow ctrl
+                                                        frame on network */
+
+/* bit set indicates that event occurred. auto-cleared when status register
+ * is read and have corresponding mask bits in mask register. events will 
+ * trigger an interrupt if the corresponding mask bit is 0. 
+ * status register default: 0x00000000
+ * mask register default = 0xFFFFFFFF on reset
+ */
+#define  REG_MAC_TX_STATUS                 0x6010  /* TX MAC status reg */
+#define    MAC_TX_FRAME_XMIT               0x0001  /* successful frame 
+                                                     transmision */
+#define    MAC_TX_UNDERRUN                 0x0002  /* terminated frame 
+                                                     transmission due to
+                                                     data starvation in the 
+                                                     xmit data path */
+#define    MAC_TX_MAX_PACKET_ERR           0x0004  /* frame exceeds max allowed
+                                                     length passed to TX MAC
+                                                     by the DMA engine */
+#define    MAC_TX_COLL_NORMAL              0x0008  /* rollover of the normal
+                                                     collision counter */
+#define    MAC_TX_COLL_EXCESS              0x0010  /* rollover of the excessive
+                                                     collision counter */
+#define    MAC_TX_COLL_LATE                0x0020  /* rollover of the late
+                                                     collision counter */
+#define    MAC_TX_COLL_FIRST               0x0040  /* rollover of the first
+                                                     collision counter */
+#define    MAC_TX_DEFER_TIMER              0x0080  /* rollover of the defer
+                                                     timer */
+#define    MAC_TX_PEAK_ATTEMPTS            0x0100  /* rollover of the peak
+                                                     attempts counter */
+
+#define  REG_MAC_RX_STATUS                 0x6014  /* RX MAC status reg */
+#define    MAC_RX_FRAME_RECV               0x0001  /* successful receipt of
+                                                     a frame */
+#define    MAC_RX_OVERFLOW                 0x0002  /* dropped frame due to 
+                                                     RX FIFO overflow */
+#define    MAC_RX_FRAME_COUNT              0x0004  /* rollover of receive frame
+                                                     counter */
+#define    MAC_RX_ALIGN_ERR                0x0008  /* rollover of alignment
+                                                     error counter */
+#define    MAC_RX_CRC_ERR                  0x0010  /* rollover of crc error
+                                                     counter */
+#define    MAC_RX_LEN_ERR                  0x0020  /* rollover of length 
+                                                     error counter */
+#define    MAC_RX_VIOL_ERR                 0x0040  /* rollover of code 
+                                                     violation error */
+
+/* DEFAULT: 0xXXXX0000 on reset */
+#define  REG_MAC_CTRL_STATUS               0x6018  /* MAC control status reg */
+#define    MAC_CTRL_PAUSE_RECEIVED         0x00000001  /* successful 
+                                                         reception of a 
+                                                         pause control 
+                                                         frame */
+#define    MAC_CTRL_PAUSE_STATE            0x00000002  /* MAC has made a 
+                                                         transition from 
+                                                         "not paused" to 
+                                                         "paused" */
+#define    MAC_CTRL_NOPAUSE_STATE          0x00000004  /* MAC has made a 
+                                                         transition from 
+                                                         "paused" to "not
+                                                         paused" */
+#define    MAC_CTRL_PAUSE_TIME_MASK        0xFFFF0000  /* value of pause time
+                                                         operand that was 
+                                                         received in the last
+                                                         pause flow control
+                                                         frame */
+
+/* layout identical to TX MAC[8:0] */
+#define  REG_MAC_TX_MASK                   0x6020  /* TX MAC mask reg */
+/* layout identical to RX MAC[6:0] */
+#define  REG_MAC_RX_MASK                   0x6024  /* RX MAC mask reg */
+/* layout identical to CTRL MAC[2:0] */
+#define  REG_MAC_CTRL_MASK                 0x6028  /* MAC control mask reg */
+
+/* to ensure proper operation, CFG_EN must be cleared to 0 and a delay 
+ * imposed before writes to other bits in the TX_MAC_CFG register or any of
+ * the MAC parameters is performed. delay dependent upon time required to
+ * transmit a maximum size frame (= MAC_FRAMESIZE_MAX*8/Mbps). e.g.,
+ * the delay for a 1518-byte frame on a 100Mbps network is 125us. 
+ * alternatively, just poll TX_CFG_EN until it reads back as 0. 
+ * NOTE: on half-duplex 1Gbps, TX_CFG_CARRIER_EXTEND and 
+ * RX_CFG_CARRIER_EXTEND should be set and the SLOT_TIME register should
+ * be 0x200 (slot time of 512 bytes)
+ */
+#define  REG_MAC_TX_CFG                 0x6030  /* TX MAC config reg */
+#define    MAC_TX_CFG_EN                0x0001  /* enable TX MAC. 0 will
+                                                     force TXMAC state
+                                                     machine to remain in
+                                                     idle state or to 
+                                                     transition to idle state
+                                                     on completion of an
+                                                     ongoing packet. */
+#define    MAC_TX_CFG_IGNORE_CARRIER    0x0002  /* disable CSMA/CD deferral
+                                                  process. set to 1 when 
+                                                  full duplex and 0 when
+                                                  half duplex */
+#define    MAC_TX_CFG_IGNORE_COLL       0x0004  /* disable CSMA/CD backoff
+                                                  algorithm. set to 1 when
+                                                  full duplex and 0 when
+                                                  half duplex */
+#define    MAC_TX_CFG_IPG_EN            0x0008  /* enable extension of the
+                                                  Rx-to-TX IPG. after 
+                                                  receiving a frame, TX 
+                                                  MAC will reset its 
+                                                  deferral process to 
+                                                  carrier sense for the
+                                                  amount of time = IPG0 +
+                                                  IPG1 and commit to 
+                                                  transmission for time
+                                                  specified in IPG2. when
+                                                  0 or when xmitting frames
+                                                  back-to-pack (Tx-to-Tx
+                                                  IPG), TX MAC ignores 
+                                                  IPG0 and will only use
+                                                  IPG1 for deferral time.
+                                                  IPG2 still used. */
+#define    MAC_TX_CFG_NEVER_GIVE_UP_EN  0x0010  /* TX MAC will not easily
+                                                  give up on frame 
+                                                  xmission. if backoff 
+                                                  algorithm reaches the
+                                                  ATTEMPT_LIMIT, it will
+                                                  clear attempts counter
+                                                  and continue trying to
+                                                  send the frame as 
+                                                  specified by 
+                                                  GIVE_UP_LIM. when 0,
+                                                  TX MAC will execute 
+                                                  standard CSMA/CD prot. */
+#define    MAC_TX_CFG_NEVER_GIVE_UP_LIM 0x0020  /* when set, TX MAC will
+                                                  continue to try to xmit
+                                                  until successful. when
+                                                  0, TX MAC will continue
+                                                  to try xmitting until
+                                                  successful or backoff
+                                                  algorithm reaches 
+                                                  ATTEMPT_LIMIT*16 */
+#define    MAC_TX_CFG_NO_BACKOFF        0x0040  /* modify CSMA/CD to disable
+                                                  backoff algorithm. TX
+                                                  MAC will not back off
+                                                  after a xmission attempt
+                                                  that resulted in a 
+                                                  collision. */
+#define    MAC_TX_CFG_SLOW_DOWN         0x0080  /* modify CSMA/CD so that
+                                                  deferral process is reset
+                                                  in response to carrier
+                                                  sense during the entire
+                                                  duration of IPG. TX MAC
+                                                  will only commit to frame
+                                                  xmission after frame
+                                                  xmission has actually
+                                                  begun. */
+#define    MAC_TX_CFG_NO_FCS            0x0100  /* TX MAC will not generate
+                                                  CRC for all xmitted
+                                                  packets. when clear, CRC
+                                                  generation is dependent
+                                                  upon NO_CRC bit in the
+                                                  xmit control word from 
+                                                  TX DMA */
+#define    MAC_TX_CFG_CARRIER_EXTEND    0x0200  /* enables xmit part of the
+                                                  carrier extension 
+                                                  feature. this allows for 
+                                                  longer collision domains
+                                                  by extending the carrier
+                                                  and collision window
+                                                  from the end of FCS until
+                                                  the end of the slot time
+                                                  if necessary. Required
+                                                  for half-duplex at 1Gbps,
+                                                  clear otherwise. */
+
+/* when CRC is not stripped, reassembly packets will not contain the CRC. 
+ * these will be stripped by HRP because it reassembles layer 4 data, and the
+ * CRC is layer 2. however, non-reassembly packets will still contain the CRC 
+ * when passed to the host. to ensure proper operation, need to wait 3.2ms
+ * after clearing RX_CFG_EN before writing to any other RX MAC registers
+ * or other MAC parameters. alternatively, poll RX_CFG_EN until it clears
+ * to 0. similary, HASH_FILTER_EN and ADDR_FILTER_EN have the same 
+ * restrictions as CFG_EN.
+ */
+#define  REG_MAC_RX_CFG                 0x6034  /* RX MAC config reg */
+#define    MAC_RX_CFG_EN                0x0001  /* enable RX MAC */
+#define    MAC_RX_CFG_STRIP_PAD         0x0002  /* always program to 0.
+                                                  feature not supported */
+#define    MAC_RX_CFG_STRIP_FCS         0x0004  /* RX MAC will strip the 
+                                                  last 4 bytes of a 
+                                                  received frame. */
+#define    MAC_RX_CFG_PROMISC_EN        0x0008  /* promiscuous mode */
+#define    MAC_RX_CFG_PROMISC_GROUP_EN  0x0010  /* accept all valid 
+                                                  multicast frames (group
+                                                  bit in DA field set) */
+#define    MAC_RX_CFG_HASH_FILTER_EN    0x0020  /* use hash table to filter
+                                                  multicast addresses */
+#define    MAC_RX_CFG_ADDR_FILTER_EN    0x0040  /* cause RX MAC to use 
+                                                  address filtering regs 
+                                                  to filter both unicast
+                                                  and multicast 
+                                                  addresses */
+#define    MAC_RX_CFG_DISABLE_DISCARD   0x0080  /* pass errored frames to
+                                                  RX DMA by setting BAD
+                                                  bit but not Abort bit
+                                                  in the status. CRC, 
+                                                  framing, and length errs
+                                                  will not increment 
+                                                  error counters. frames
+                                                  which don't match dest
+                                                  addr will be passed up
+                                                  w/ BAD bit set. */
+#define    MAC_RX_CFG_CARRIER_EXTEND    0x0100  /* enable reception of 
+                                                  packet bursts generated
+                                                  by carrier extension
+                                                  with packet bursting
+                                                  senders. only applies
+                                                  to half-duplex 1Gbps */
+
+/* DEFAULT: 0x0 */
+#define  REG_MAC_CTRL_CFG               0x6038  /* MAC control config reg */
+#define    MAC_CTRL_CFG_SEND_PAUSE_EN   0x0001  /* respond to requests for 
+                                                  sending pause flow ctrl 
+                                                  frames */
+#define    MAC_CTRL_CFG_RECV_PAUSE_EN   0x0002  /* respond to received 
+                                                  pause flow ctrl frames */
+#define    MAC_CTRL_CFG_PASS_CTRL       0x0004  /* pass valid MAC ctrl
+                                                  packets to RX DMA */
+
+/* to ensure proper operation, a global initialization sequence should be
+ * performed when a loopback config is entered or exited. if programmed after
+ * a hw or global sw reset, RX/TX MAC software reset and initialization 
+ * should be done to ensure stable clocking. 
+ * DEFAULT: 0x0
+ */
+#define  REG_MAC_XIF_CFG                0x603C  /* XIF config reg */
+#define    MAC_XIF_TX_MII_OUTPUT_EN        0x0001  /* enable output drivers
+                                                     on MII xmit bus */
+#define    MAC_XIF_MII_INT_LOOPBACK        0x0002  /* loopback GMII xmit data
+                                                     path to GMII recv data
+                                                     path. phy mode register
+                                                     clock selection must be
+                                                     set to GMII mode and 
+                                                     GMII_MODE should be set
+                                                     to 1. in loopback mode,
+                                                     REFCLK will drive the
+                                                     entire mac core. 0 for
+                                                     normal operation. */
+#define    MAC_XIF_DISABLE_ECHO            0x0004  /* disables receive data
+                                                     path during packet 
+                                                     xmission. clear to 0
+                                                     in any full duplex mode,
+                                                     in any loopback mode,
+                                                     or in half-duplex SERDES
+                                                     or SLINK modes. set when
+                                                     in half-duplex when 
+                                                     using external phy. */
+#define    MAC_XIF_GMII_MODE               0x0008  /* MAC operates with GMII
+                                                     clocks and datapath */
+#define    MAC_XIF_MII_BUFFER_OUTPUT_EN    0x0010  /* MII_BUF_EN pin. enable
+                                                     external tristate buffer
+                                                     on the MII receive 
+                                                     bus. */
+#define    MAC_XIF_LINK_LED                0x0020  /* LINKLED# active (low) */
+#define    MAC_XIF_FDPLX_LED               0x0040  /* FDPLXLED# active (low) */
+
+#define  REG_MAC_IPG0                      0x6040  /* inter-packet gap0 reg.
+                                                     recommended: 0x00 */
+#define  REG_MAC_IPG1                      0x6044  /* inter-packet gap1 reg
+                                                     recommended: 0x08 */
+#define  REG_MAC_IPG2                      0x6048  /* inter-packet gap2 reg
+                                                     recommended: 0x04 */
+#define  REG_MAC_SLOT_TIME                 0x604C  /* slot time reg
+                                                     recommended: 0x40 */
+#define  REG_MAC_FRAMESIZE_MIN             0x6050  /* min frame size reg 
+                                                     recommended: 0x40 */
+
+/* FRAMESIZE_MAX holds both the max frame size as well as the max burst size.
+ * recommended value:  0x2000.05EE
+ */
+#define  REG_MAC_FRAMESIZE_MAX             0x6054  /* max frame size reg */
+#define    MAC_FRAMESIZE_MAX_BURST_MASK    0x3FFF0000 /* max burst size */
+#define    MAC_FRAMESIZE_MAX_BURST_SHIFT   16
+#define    MAC_FRAMESIZE_MAX_FRAME_MASK    0x00007FFF /* max frame size */
+#define    MAC_FRAMESIZE_MAX_FRAME_SHIFT   0
+#define  REG_MAC_PA_SIZE                   0x6058  /* PA size reg. number of
+                                                     preamble bytes that the
+                                                     TX MAC will xmit at the
+                                                     beginning of each frame
+                                                     value should be 2 or 
+                                                     greater. recommended 
+                                                     value: 0x07 */
+#define  REG_MAC_JAM_SIZE                  0x605C  /* jam size reg. duration 
+                                                     of jam in units of media
+                                                     byte time. recommended
+                                                     value: 0x04 */
+#define  REG_MAC_ATTEMPT_LIMIT             0x6060  /* attempt limit reg. #
+                                                     of attempts TX MAC will
+                                                     make to xmit a frame 
+                                                     before it resets its
+                                                     attempts counter. after
+                                                     the limit has been 
+                                                     reached, TX MAC may or
+                                                     may not drop the frame
+                                                     dependent upon value
+                                                     in TX_MAC_CFG. 
+                                                     recommended 
+                                                     value: 0x10 */
+#define  REG_MAC_CTRL_TYPE                 0x6064  /* MAC control type reg.
+                                                     type field of a MAC 
+                                                     ctrl frame. recommended
+                                                     value: 0x8808 */
+
+/* mac address registers: 0 - 44, 0x6080 - 0x6130, 4 8-bit bytes.
+ * register           contains                   comparison  
+ *    0        16 MSB of primary MAC addr        [47:32] of DA field
+ *    1        16 middle bits ""                 [31:16] of DA field
+ *    2        16 LSB ""                         [15:0] of DA field
+ *    3*x      16MSB of alt MAC addr 1-15        [47:32] of DA field
+ *    4*x      16 middle bits ""                 [31:16]
+ *    5*x      16 LSB ""                         [15:0]
+ *    42       16 MSB of MAC CTRL addr           [47:32] of DA. 
+ *    43       16 middle bits ""                 [31:16]
+ *    44       16 LSB ""                         [15:0]
+ *    MAC CTRL addr must be the reserved multicast addr for MAC CTRL frames.
+ *    if there is a match, MAC will set the bit for alternative address
+ *    filter pass [15]
+
+ *    here is the map of registers given MAC address notation: a:b:c:d:e:f
+ *                     ab             cd             ef
+ *    primary addr     reg 2          reg 1          reg 0
+ *    alt addr 1       reg 5          reg 4          reg 3
+ *    alt addr x       reg 5*x        reg 4*x        reg 3*x
+ *    ctrl addr        reg 44         reg 43         reg 42
+ */
+#define  REG_MAC_ADDR0                     0x6080  /* MAC address 0 reg */
+#define  REG_MAC_ADDRN(x)                  (REG_MAC_ADDR0 + (x)*4)
+#define  REG_MAC_ADDR_FILTER0              0x614C  /* address filter 0 reg
+                                                     [47:32] */
+#define  REG_MAC_ADDR_FILTER1              0x6150  /* address filter 1 reg 
+                                                     [31:16] */
+#define  REG_MAC_ADDR_FILTER2              0x6154  /* address filter 2 reg 
+                                                     [15:0] */
+#define  REG_MAC_ADDR_FILTER2_1_MASK       0x6158  /* address filter 2 and 1
+                                                     mask reg. 8-bit reg
+                                                     contains nibble mask for
+                                                     reg 2 and 1. */
+#define  REG_MAC_ADDR_FILTER0_MASK         0x615C  /* address filter 0 mask 
+                                                     reg */
+
+/* hash table registers: 0 - 15, 0x6160 - 0x619C, 4 8-bit bytes 
+ * 16-bit registers contain bits of the hash table.
+ * reg x  -> [16*(15 - x) + 15 : 16*(15 - x)]. 
+ * e.g., 15 -> [15:0], 0 -> [255:240]
+ */
+#define  REG_MAC_HASH_TABLE0               0x6160  /* hash table 0 reg */
+#define  REG_MAC_HASH_TABLEN(x)            (REG_MAC_HASH_TABLE0 + (x)*4)
+
+/* statistics registers. these registers generate an interrupt on 
+ * overflow. recommended initialization: 0x0000. most are 16-bits except
+ * for PEAK_ATTEMPTS register which is 8 bits.
+ */
+#define  REG_MAC_COLL_NORMAL               0x61A0 /* normal collision 
+                                                    counter. */
+#define  REG_MAC_COLL_FIRST                0x61A4 /* first attempt
+                                                    successful collision 
+                                                    counter */
+#define  REG_MAC_COLL_EXCESS               0x61A8 /* excessive collision 
+                                                    counter */
+#define  REG_MAC_COLL_LATE                 0x61AC /* late collision counter */
+#define  REG_MAC_TIMER_DEFER               0x61B0 /* defer timer. time base 
+                                                    is the media byte 
+                                                    clock/256 */
+#define  REG_MAC_ATTEMPTS_PEAK             0x61B4 /* peak attempts reg */
+#define  REG_MAC_RECV_FRAME                0x61B8 /* receive frame counter */
+#define  REG_MAC_LEN_ERR                   0x61BC /* length error counter */
+#define  REG_MAC_ALIGN_ERR                 0x61C0 /* alignment error counter */
+#define  REG_MAC_FCS_ERR                   0x61C4 /* FCS error counter */
+#define  REG_MAC_RX_CODE_ERR               0x61C8 /* RX code violation
+                                                    error counter */
+
+/* misc registers */
+#define  REG_MAC_RANDOM_SEED               0x61CC /* random number seed reg.
+                                                  10-bit register used as a
+                                                  seed  for the random number
+                                                  generator for the CSMA/CD
+                                                  backoff algorithm. only 
+                                                  programmed after power-on
+                                                  reset and should be a 
+                                                  random value which has a 
+                                                  high likelihood of being 
+                                                  unique for each MAC 
+                                                  attached to a network 
+                                                  segment (e.g., 10 LSB of
+                                                  MAC address) */
+
+/* ASUN: there's a PAUSE_TIMER (ro) described, but it's not in the address
+ *       map
+ */
+
+/* 27-bit register has the current state for key state machines in the MAC */
+#define  REG_MAC_STATE_MACHINE             0x61D0 /* (ro) state machine reg */
+#define    MAC_SM_RLM_MASK                 0x07800000 
+#define    MAC_SM_RLM_SHIFT                23
+#define    MAC_SM_RX_FC_MASK               0x00700000
+#define    MAC_SM_RX_FC_SHIFT              20
+#define    MAC_SM_TLM_MASK                 0x000F0000
+#define    MAC_SM_TLM_SHIFT                16
+#define    MAC_SM_ENCAP_SM_MASK            0x0000F000
+#define    MAC_SM_ENCAP_SM_SHIFT           12
+#define    MAC_SM_TX_REQ_MASK              0x00000C00
+#define    MAC_SM_TX_REQ_SHIFT             10
+#define    MAC_SM_TX_FC_MASK               0x000003C0
+#define    MAC_SM_TX_FC_SHIFT              6
+#define    MAC_SM_FIFO_WRITE_SEL_MASK      0x00000038
+#define    MAC_SM_FIFO_WRITE_SEL_SHIFT     3
+#define    MAC_SM_TX_FIFO_EMPTY_MASK       0x00000007
+#define    MAC_SM_TX_FIFO_EMPTY_SHIFT      0
+
+/** MIF registers. the MIF can be programmed in either bit-bang or 
+ *  frame mode.
+ **/
+#define  REG_MIF_BIT_BANG_CLOCK            0x6200 /* MIF bit-bang clock.
+                                                  1 -> 0 will generate a 
+                                                  rising edge. 0 -> 1 will
+                                                  generate a falling edge. */
+#define  REG_MIF_BIT_BANG_DATA             0x6204 /* MIF bit-bang data. 1-bit
+                                                    register generates data */
+#define  REG_MIF_BIT_BANG_OUTPUT_EN        0x6208 /* MIF bit-bang output 
+                                                    enable. enable when 
+                                                    xmitting data from MIF to
+                                                    transceiver. */
+
+/* 32-bit register serves as an instruction register when the MIF is 
+ * programmed in frame mode. load this register w/ a valid instruction
+ * (as per IEEE 802.3u MII spec). poll this register to check for instruction
+ * execution completion. during a read operation, this register will also
+ * contain the 16-bit data returned by the tranceiver. unless specified 
+ * otherwise, fields are considered "don't care" when polling for 
+ * completion.
+ */
+#define  REG_MIF_FRAME                     0x620C /* MIF frame/output reg */
+#define    MIF_FRAME_START_MASK            0xC0000000 /* start of frame.
+                                                        load w/ 01 when
+                                                        issuing an instr */
+#define    MIF_FRAME_ST                    0x40000000 /* STart of frame */
+#define    MIF_FRAME_OPCODE_MASK           0x30000000 /* opcode. 01 for a 
+                                                        write. 10 for a 
+                                                        read */
+#define    MIF_FRAME_OP_READ               0x20000000 /* read OPcode */
+#define    MIF_FRAME_OP_WRITE              0x10000000 /* write OPcode */
+#define    MIF_FRAME_PHY_ADDR_MASK         0x0F800000 /* phy address. when
+                                                        issuing an instr,
+                                                        this field should be 
+                                                        loaded w/ the XCVR
+                                                        addr */
+#define    MIF_FRAME_PHY_ADDR_SHIFT        23
+#define    MIF_FRAME_REG_ADDR_MASK         0x007C0000 /* register address.
+                                                        when issuing an instr,
+                                                        addr of register
+                                                        to be read/written */
+#define    MIF_FRAME_REG_ADDR_SHIFT        18
+#define    MIF_FRAME_TURN_AROUND_MSB       0x00020000 /* turn around, MSB.
+                                                        when issuing an instr,
+                                                        set this bit to 1 */
+#define    MIF_FRAME_TURN_AROUND_LSB       0x00010000 /* turn around, LSB.
+                                                        when issuing an instr,
+                                                        set this bit to 0.
+                                                        when polling for
+                                                        completion, 1 means
+                                                        that instr execution
+                                                        has been completed */
+#define    MIF_FRAME_DATA_MASK             0x0000FFFF /* instruction payload
+                                                        load with 16-bit data
+                                                        to be written in
+                                                        transceiver reg for a
+                                                        write. doesn't matter
+                                                        in a read. when 
+                                                        polling for 
+                                                        completion, field is
+                                                        "don't care" for write
+                                                        and 16-bit data 
+                                                        returned by the 
+                                                        transceiver for a
+                                                        read (if valid bit
+                                                        is set) */
+#define  REG_MIF_CFG                    0x6210 /* MIF config reg */
+#define    MIF_CFG_PHY_SELECT           0x0001 /* 1 -> select MDIO_1
+                                                 0 -> select MDIO_0 */
+#define    MIF_CFG_POLL_EN              0x0002 /* enable polling
+                                                 mechanism. if set,
+                                                 BB_MODE should be 0 */
+#define    MIF_CFG_BB_MODE              0x0004 /* 1 -> bit-bang mode
+                                                 0 -> frame mode */
+#define    MIF_CFG_POLL_REG_MASK        0x00F8 /* register address to be
+                                                 used by polling mode.
+                                                 only meaningful if POLL_EN
+                                                 is set to 1 */
+#define    MIF_CFG_POLL_REG_SHIFT       3
+#define    MIF_CFG_MDIO_0               0x0100 /* (ro) dual purpose.
+                                                 when MDIO_0 is idle,
+                                                 1 -> tranceiver is 
+                                                 connected to MDIO_0.
+                                                 when MIF is communicating
+                                                 w/ MDIO_0 in bit-bang 
+                                                 mode, this bit indicates
+                                                 the incoming bit stream
+                                                 during a read op */
+#define    MIF_CFG_MDIO_1               0x0200 /* (ro) dual purpose.
+                                                 when MDIO_1 is idle, 
+                                                 1 -> transceiver is 
+                                                 connected to MDIO_1.
+                                                 when MIF is communicating
+                                                 w/ MDIO_1 in bit-bang
+                                                 mode, this bit indicates
+                                                 the incoming bit stream
+                                                 during a read op */
+#define    MIF_CFG_POLL_PHY_MASK        0x7C00 /* tranceiver address to
+                                                 be polled */
+#define    MIF_CFG_POLL_PHY_SHIFT       10
+
+/* 16-bit register used to determine which bits in the POLL_STATUS portion of
+ * the MIF_STATUS register will cause an interrupt. if a mask bit is 0,
+ * corresponding bit of the POLL_STATUS will generate a MIF interrupt when 
+ * set. DEFAULT: 0xFFFF
+ */
+#define  REG_MIF_MASK                      0x6214 /* MIF mask reg */
+
+/* 32-bit register used when in poll mode. auto-cleared after being read */
+#define  REG_MIF_STATUS                    0x6218 /* MIF status reg */
+#define    MIF_STATUS_POLL_DATA_MASK       0xFFFF0000 /* poll data contains
+                                                        the "latest image"
+                                                        update of the XCVR 
+                                                        reg being read */
+#define    MIF_STATUS_POLL_DATA_SHIFT      16
+#define    MIF_STATUS_POLL_STATUS_MASK     0x0000FFFF /* poll status indicates
+                                                        which bits in the
+                                                        POLL_DATA field have
+                                                        changed since the
+                                                        MIF_STATUS reg was
+                                                        last read */
+#define    MIF_STATUS_POLL_STATUS_SHIFT    0
+
+/* 7-bit register has current state for all state machines in the MIF */
+#define  REG_MIF_STATE_MACHINE             0x621C /* MIF state machine reg */
+#define    MIF_SM_CONTROL_MASK             0x07   /* control state machine 
+                                                    state */
+#define    MIF_SM_EXECUTION_MASK           0x60   /* execution state machine
+                                                    state */
+
+/** PCS/Serialink. the following registers are equivalent to the standard
+ *  MII management registers except that they're directly mapped in 
+ *  Cassini's register space.
+ **/
+
+/* the auto-negotiation enable bit should be programmed the same at
+ * the link partner as in the local device to enable auto-negotiation to
+ * complete. when that bit is reprogrammed, auto-neg/manual config is 
+ * restarted automatically.
+ * DEFAULT: 0x1040
+ */
+#define  REG_PCS_MII_CTRL                  0x9000 /* PCS MII control reg */
+#define    PCS_MII_CTRL_1000_SEL           0x0040 /* reads 1. ignored on
+                                                    writes */
+#define    PCS_MII_CTRL_COLLISION_TEST     0x0080 /* COL signal at the PCS
+                                                    to MAC interface is
+                                                    activated regardless
+                                                    of activity */
+#define    PCS_MII_CTRL_DUPLEX             0x0100 /* forced 0x0. PCS 
+                                                    behaviour same for
+                                                    half and full dplx */
+#define    PCS_MII_RESTART_AUTONEG         0x0200 /* self clearing. 
+                                                    restart auto-
+                                                    negotiation */
+#define    PCS_MII_ISOLATE                 0x0400 /* read as 0. ignored
+                                                    on writes */
+#define    PCS_MII_POWER_DOWN              0x0800 /* read as 0. ignored
+                                                    on writes */
+#define    PCS_MII_AUTONEG_EN              0x1000 /* default 1. PCS goes
+                                                    through automatic
+                                                    link config before it
+                                                    can be used. when 0,
+                                                    link can be used 
+                                                    w/out any link config
+                                                    phase */
+#define    PCS_MII_10_100_SEL              0x2000 /* read as 0. ignored on 
+                                                    writes */
+#define    PCS_MII_RESET                   0x8000 /* reset PCS. self-clears
+                                                    when done */
+
+/* DEFAULT: 0x0108 */
+#define  REG_PCS_MII_STATUS                0x9004 /* PCS MII status reg */
+#define    PCS_MII_STATUS_EXTEND_CAP       0x0001 /* reads 0 */
+#define    PCS_MII_STATUS_JABBER_DETECT    0x0002 /* reads 0 */
+#define    PCS_MII_STATUS_LINK_STATUS      0x0004 /* 1 -> link up. 
+                                                    0 -> link down. 0 is
+                                                    latched so that 0 is
+                                                    kept until read. read
+                                                    2x to determine if the
+                                                    link has gone up again */
+#define    PCS_MII_STATUS_AUTONEG_ABLE     0x0008 /* reads 1 (able to perform
+                                                    auto-neg) */
+#define    PCS_MII_STATUS_REMOTE_FAULT     0x0010 /* 1 -> remote fault detected
+                                                    from received link code
+                                                    word. only valid after
+                                                    auto-neg completed */
+#define    PCS_MII_STATUS_AUTONEG_COMP     0x0020 /* 1 -> auto-negotiation 
+                                                         completed
+                                                    0 -> auto-negotiation not
+                                                    completed */
+#define    PCS_MII_STATUS_EXTEND_STATUS    0x0100 /* reads as 1. used as an
+                                                    indication that this is
+                                                    a 1000 Base-X PHY. writes
+                                                    to it are ignored */
+
+/* used during auto-negotiation. 
+ * DEFAULT: 0x00E0
+ */
+#define  REG_PCS_MII_ADVERT                0x9008 /* PCS MII advertisement
+                                                    reg */
+#define    PCS_MII_ADVERT_FD               0x0020  /* advertise full duplex
+                                                     1000 Base-X */
+#define    PCS_MII_ADVERT_HD               0x0040  /* advertise half-duplex
+                                                     1000 Base-X */
+#define    PCS_MII_ADVERT_SYM_PAUSE        0x0080  /* advertise PAUSE
+                                                     symmetric capability */
+#define    PCS_MII_ADVERT_ASYM_PAUSE       0x0100  /* advertises PAUSE 
+                                                     asymmetric capability */
+#define    PCS_MII_ADVERT_RF_MASK          0x3000 /* remote fault. write bit13
+                                                    to optionally indicate to
+                                                    link partner that chip is
+                                                    going off-line. bit12 will
+                                                    get set when signal
+                                                    detect == FAIL and will
+                                                    remain set until 
+                                                    successful negotiation */
+#define    PCS_MII_ADVERT_ACK              0x4000 /* (ro) */
+#define    PCS_MII_ADVERT_NEXT_PAGE        0x8000 /* (ro) forced 0x0 */
+
+/* contents updated as a result of autonegotiation. layout and definitions
+ * identical to PCS_MII_ADVERT
+ */
+#define  REG_PCS_MII_LPA                   0x900C /* PCS MII link partner
+                                                    ability reg */
+#define    PCS_MII_LPA_FD             PCS_MII_ADVERT_FD
+#define    PCS_MII_LPA_HD             PCS_MII_ADVERT_HD
+#define    PCS_MII_LPA_SYM_PAUSE      PCS_MII_ADVERT_SYM_PAUSE
+#define    PCS_MII_LPA_ASYM_PAUSE     PCS_MII_ADVERT_ASYM_PAUSE
+#define    PCS_MII_LPA_RF_MASK        PCS_MII_ADVERT_RF_MASK
+#define    PCS_MII_LPA_ACK            PCS_MII_ADVERT_ACK
+#define    PCS_MII_LPA_NEXT_PAGE      PCS_MII_ADVERT_NEXT_PAGE
+
+/* DEFAULT: 0x0 */
+#define  REG_PCS_CFG                       0x9010 /* PCS config reg */
+#define    PCS_CFG_EN                      0x01   /* enable PCS. must be
+                                                    0 when modifying
+                                                    PCS_MII_ADVERT */
+#define    PCS_CFG_SD_OVERRIDE             0x02   /* sets signal detect to
+                                                    OK. bit is 
+                                                    non-resettable */
+#define    PCS_CFG_SD_ACTIVE_LOW           0x04   /* changes interpretation
+                                                    of optical signal to make
+                                                    signal detect okay when
+                                                    signal is low */
+#define    PCS_CFG_JITTER_STUDY_MASK       0x18   /* used to make jitter
+                                                    measurements. a single
+                                                    code group is xmitted
+                                                    regularly. 
+                                                    0x0 = normal operation
+                                                    0x1 = high freq test 
+                                                          pattern, D21.5
+                                                    0x2 = low freq test
+                                                          pattern, K28.7
+                                                    0x3 = reserved */
+#define    PCS_CFG_10MS_TIMER_OVERRIDE     0x20   /* shortens 10-20ms auto-
+                                                    negotiation timer to 
+                                                    a few cycles for test
+                                                    purposes */
+
+/* used for diagnostic purposes. bits 20-22 autoclear on read */
+#define  REG_PCS_STATE_MACHINE             0x9014 /* (ro) PCS state machine 
+                                                    and diagnostic reg */
+#define    PCS_SM_TX_STATE_MASK            0x0000000F /* 0 and 1 indicate 
+                                                        xmission of idle. 
+                                                        otherwise, xmission of
+                                                        a packet */
+#define    PCS_SM_RX_STATE_MASK            0x000000F0 /* 0 indicates reception
+                                                        of idle. otherwise,
+                                                        reception of packet */
+#define    PCS_SM_WORD_SYNC_STATE_MASK     0x00000700 /* 0 indicates loss of
+                                                        sync */
+#define    PCS_SM_SEQ_DETECT_STATE_MASK    0x00001800 /* cycling through 0-3
+                                                        indicates reception of
+                                                        Config codes. cycling
+                                                        through 0-1 indicates
+                                                        reception of idles */
+#define    PCS_SM_LINK_STATE_MASK          0x0001E000 
+#define        SM_LINK_STATE_UP            0x00016000 /* link state is up */
+
+#define    PCS_SM_LOSS_LINK_C              0x00100000 /* loss of link due to
+                                                        recept of Config 
+                                                        codes */
+#define    PCS_SM_LOSS_LINK_SYNC           0x00200000 /* loss of link due to
+                                                        loss of sync */
+#define    PCS_SM_LOSS_SIGNAL_DETECT       0x00400000 /* signal detect goes 
+                                                        from OK to FAIL. bit29
+                                                        will also be set if 
+                                                        this is set */
+#define    PCS_SM_NO_LINK_BREAKLINK        0x01000000 /* link not up due to
+                                                       receipt of breaklink
+                                                       C codes from partner.
+                                                       C codes w/ 0 content
+                                                       received triggering
+                                                       start/restart of 
+                                                       autonegotiation. 
+                                                       should be sent for
+                                                       no longer than 20ms */
+#define    PCS_SM_NO_LINK_SERDES           0x02000000 /* serdes being 
+                                                       initialized. see serdes
+                                                       state reg */
+#define    PCS_SM_NO_LINK_C                0x04000000 /* C codes not stable or
+                                                        not received */
+#define    PCS_SM_NO_LINK_SYNC             0x08000000 /* word sync not 
+                                                        achieved */
+#define    PCS_SM_NO_LINK_WAIT_C           0x10000000 /* waiting for C codes 
+                                                        w/ ack bit set */
+#define    PCS_SM_NO_LINK_NO_IDLE          0x20000000 /* link partner continues
+                                                        to send C codes 
+                                                        instead of idle 
+                                                        symbols or pkt data */
+
+/* this register indicates interrupt changes in specific PCS MII status bits.
+ * PCS_INT may be masked at the ISR level. only a single bit is implemented
+ * for link status change.
+ */
+#define  REG_PCS_INTR_STATUS               0x9018 /* PCS interrupt status */
+#define    PCS_INTR_STATUS_LINK_CHANGE     0x04   /* link status has changed
+                                                    since last read */
+
+/* control which network interface is used. no more than one bit should
+ * be set.
+ * DEFAULT: none
+ */
+#define  REG_PCS_DATAPATH_MODE             0x9050 /* datapath mode reg */
+#define    PCS_DATAPATH_MODE_MII           0x00 /* PCS is not used and 
+                                                  MII/GMII is selected. 
+                                                  selection between MII and
+                                                  GMII is controlled by 
+                                                  XIF_CFG */
+#define    PCS_DATAPATH_MODE_SERDES        0x02 /* PCS is used via the
+                                                  10-bit interface */
+
+/* input to serdes chip or serialink block */
+#define  REG_PCS_SERDES_CTRL              0x9054 /* serdes control reg */
+#define    PCS_SERDES_CTRL_LOOPBACK       0x01   /* enable loopback on 
+                                                   serdes interface */
+#define    PCS_SERDES_CTRL_SYNCD_EN       0x02   /* enable sync carrier
+                                                   detection. should be
+                                                   0x0 for normal 
+                                                   operation */
+#define    PCS_SERDES_CTRL_LOCKREF       0x04   /* frequency-lock RBC[0:1]
+                                                  to REFCLK when set.
+                                                  when clear, receiver
+                                                  clock locks to incoming
+                                                  serial data */
+
+/* multiplex test outputs into the PROM address (PA_3 through PA_0) pins.
+ * should be 0x0 for normal operations. 
+ * 0b000          normal operation, PROM address[3:0] selected
+ * 0b001          rxdma req, rxdma ack, rxdma ready, rxdma read 
+ * 0b010          rxmac req, rx ack, rx tag, rx clk shared 
+ * 0b011          txmac req, tx ack, tx tag, tx retry req 
+ * 0b100          tx tp3, tx tp2, tx tp1, tx tp0 
+ * 0b101          R period RX, R period TX, R period HP, R period BIM
+ * DEFAULT: 0x0
+ */
+#define  REG_PCS_SHARED_OUTPUT_SEL         0x9058 /* shared output select */
+#define    PCS_SOS_PROM_ADDR_MASK          0x0007
+
+/* used for diagnostics. this register indicates progress of the SERDES 
+ * boot up. 
+ * 0b00       undergoing reset
+ * 0b01       waiting 500us while lockrefn is asserted
+ * 0b10       waiting for comma detect
+ * 0b11       receive data is synchronized 
+ * DEFAULT: 0x0
+ */
+#define  REG_PCS_SERDES_STATE              0x905C /* (ro) serdes state */
+#define    PCS_SERDES_STATE_MASK           0x03   
+
+/* used for diagnostics. indicates number of packets transmitted or received.
+ * counters rollover w/out generating an interrupt.
+ * DEFAULT: 0x0
+ */
+#define  REG_PCS_PACKET_COUNT              0x9060 /* (ro) PCS packet counter */
+#define    PCS_PACKET_COUNT_TX             0x000007FF /* pkts xmitted by PCS */
+#define    PCS_PACKET_COUNT_RX             0x07FF0000 /* pkts recvd by PCS
+                                                        whether they 
+                                                        encountered an error
+                                                        or not */
+
+/** LocalBus Devices. the following provides run-time access to the 
+ *  Cassini's PROM
+ ***/
+#define  REG_EXPANSION_ROM_RUN_START       0x100000 /* expansion rom run time
+                                                      access */
+#define  REG_EXPANSION_ROM_RUN_END         0x17FFFF
+
+#define  REG_SECOND_LOCALBUS_START         0x180000 /* secondary local bus 
+                                                      device */
+#define  REG_SECOND_LOCALBUS_END           0x1FFFFF
+
+/* entropy device */
+#define  REG_ENTROPY_START                 REG_SECOND_LOCALBUS_START
+#define  REG_ENTROPY_DATA                  (REG_ENTROPY_START + 0x00)
+#define  REG_ENTROPY_STATUS                (REG_ENTROPY_START + 0x04)
+#define      ENTROPY_STATUS_DRDY           0x01
+#define      ENTROPY_STATUS_BUSY           0x02
+#define      ENTROPY_STATUS_CIPHER         0x04
+#define      ENTROPY_STATUS_BYPASS_MASK    0x18
+#define  REG_ENTROPY_MODE                  (REG_ENTROPY_START + 0x05)
+#define      ENTROPY_MODE_KEY_MASK         0x07
+#define      ENTROPY_MODE_ENCRYPT          0x40
+#define  REG_ENTROPY_RAND_REG              (REG_ENTROPY_START + 0x06)
+#define  REG_ENTROPY_RESET                 (REG_ENTROPY_START + 0x07)
+#define      ENTROPY_RESET_DES_IO          0x01
+#define      ENTROPY_RESET_STC_MODE        0x02
+#define      ENTROPY_RESET_KEY_CACHE       0x04
+#define      ENTROPY_RESET_IV              0x08
+#define  REG_ENTROPY_IV                    (REG_ENTROPY_START + 0x08)
+#define  REG_ENTROPY_KEY0                  (REG_ENTROPY_START + 0x10)
+#define  REG_ENTROPY_KEYN(x)               (REG_ENTROPY_KEY0 + 4*(x))
+
+/* phys of interest w/ their special mii registers */
+#define PHY_LUCENT_B0     0x00437421
+#define   LUCENT_MII_REG      0x1F
+
+#define PHY_NS_DP83065    0x20005c78
+#define   DP83065_MII_MEM     0x16
+#define   DP83065_MII_REGD    0x1D
+#define   DP83065_MII_REGE    0x1E
+
+#define PHY_BROADCOM_5411 0x00206071
+#define PHY_BROADCOM_B0   0x00206050
+#define   BROADCOM_MII_REG4   0x14
+#define   BROADCOM_MII_REG5   0x15
+#define   BROADCOM_MII_REG7   0x17
+#define   BROADCOM_MII_REG8   0x18
+
+#define   CAS_MII_ANNPTR          0x07
+#define   CAS_MII_ANNPRR          0x08
+#define   CAS_MII_1000_CTRL       0x09
+#define   CAS_MII_1000_STATUS     0x0A
+#define   CAS_MII_1000_EXTEND     0x0F
+
+#define   CAS_BMSR_1000_EXTEND    0x0100 /* supports 1000Base-T extended status */
+/* 
+ * if autoneg is disabled, here's the table:
+ * BMCR_SPEED100 = 100Mbps
+ * BMCR_SPEED1000 = 1000Mbps
+ * ~(BMCR_SPEED100 | BMCR_SPEED1000) = 10Mbps
+ */
+#define   CAS_BMCR_SPEED1000      0x0040  /* Select 1000Mbps */
+
+#define   CAS_ADVERTISE_1000HALF   0x0100
+#define   CAS_ADVERTISE_1000FULL   0x0200
+#define   CAS_ADVERTISE_PAUSE      0x0400
+#define   CAS_ADVERTISE_ASYM_PAUSE 0x0800
+
+/* regular lpa register */
+#define   CAS_LPA_PAUSE                   CAS_ADVERTISE_PAUSE
+#define   CAS_LPA_ASYM_PAUSE       CAS_ADVERTISE_ASYM_PAUSE
+
+/* 1000_STATUS register */
+#define   CAS_LPA_1000HALF        0x0400
+#define   CAS_LPA_1000FULL        0x0800
+
+#define   CAS_EXTEND_1000XFULL    0x8000
+#define   CAS_EXTEND_1000XHALF    0x4000
+#define   CAS_EXTEND_1000TFULL    0x2000
+#define   CAS_EXTEND_1000THALF    0x1000
+
+/* cassini header parser firmware */
+typedef struct cas_hp_inst {
+       const char *note;
+
+       u16 mask, val;
+
+       u8 op;
+       u8 soff, snext; /* if match succeeds, new offset and match */
+       u8 foff, fnext; /* if match fails, new offset and match */
+       /* output info */
+       u8 outop;    /* output opcode */
+
+       u16 outarg;  /* output argument */
+       u8 outenab;  /* output enable: 0 = not, 1 = if match
+                        2 = if !match, 3 = always */
+       u8 outshift; /* barrel shift right, 4 bits */
+       u16 outmask; 
+} cas_hp_inst_t;
+
+/* comparison */
+#define OP_EQ     0 /* packet == value */
+#define OP_LT     1 /* packet < value */
+#define OP_GT     2 /* packet > value */
+#define OP_NP     3 /* new packet */
+
+/* output opcodes */
+#define        CL_REG  0
+#define        LD_FID  1
+#define        LD_SEQ  2
+#define        LD_CTL  3
+#define        LD_SAP  4
+#define        LD_R1   5
+#define        LD_L3   6
+#define        LD_SUM  7
+#define        LD_HDR  8
+#define        IM_FID  9
+#define        IM_SEQ  10
+#define        IM_SAP  11
+#define        IM_R1   12
+#define        IM_CTL  13
+#define        LD_LEN  14
+#define        ST_FLG  15
+
+/* match setp #s for IP4TCP4 */
+#define S1_PCKT         0
+#define S1_VLAN         1
+#define S1_CFI          2
+#define S1_8023         3
+#define S1_LLC          4
+#define S1_LLCc         5
+#define S1_IPV4         6
+#define S1_IPV4c        7
+#define S1_IPV4F        8
+#define S1_TCP44        9
+#define S1_IPV6         10
+#define S1_IPV6L        11
+#define S1_IPV6c        12
+#define S1_TCP64        13
+#define S1_TCPSQ        14
+#define S1_TCPFG        15
+#define        S1_TCPHL        16
+#define        S1_TCPHc        17
+#define        S1_CLNP         18
+#define        S1_CLNP2        19
+#define        S1_DROP         20
+#define        S2_HTTP         21
+#define        S1_ESP4         22
+#define        S1_AH4          23
+#define        S1_ESP6         24
+#define        S1_AH6          25
+
+#define CAS_PROG_IP46TCP4_PREAMBLE \
+{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, S1_PCKT,  \
+  CL_REG, 0x3ff, 1, 0x0, 0x0000}, \
+{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,  \
+  IM_CTL, 0x00a,  3, 0x0, 0xffff}, \
+{ "CFI?", 0x1000, 0x1000, OP_EQ,  0, S1_DROP,  1, S1_8023, \
+  CL_REG, 0x000,  0, 0x0, 0x0000}, \
+{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4, \
+  CL_REG, 0x000,  0, 0x0, 0x0000}, \
+{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP, \
+  CL_REG, 0x000,  0, 0x0, 0x0000}, \
+{ "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP, \
+  CL_REG, 0x000,  0, 0x0, 0x0000}, \
+{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6, \
+  LD_SAP, 0x100,  3, 0x0, 0xffff}, \
+{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP, \
+  LD_SUM, 0x00a,  1, 0x0, 0x0000}, \
+{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP, \
+  LD_LEN, 0x03e,  1, 0x0, 0xffff}, \
+{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_CLNP, \
+  LD_FID, 0x182,  1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */ \
+{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,  \
+  LD_SUM, 0x015,  1, 0x0, 0x0000}, \
+{ "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP, \
+  IM_R1,  0x128,  1, 0x0, 0xffff}, \
+{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP, \
+  LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */ \
+{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP, \
+  LD_LEN, 0x03f,  1, 0x0, 0xffff}
+
+#ifdef USE_HP_IP46TCP4
+static cas_hp_inst_t cas_prog_ip46tcp4tab[] = {
+       CAS_PROG_IP46TCP4_PREAMBLE, 
+       { "TCP seq", /* DADDR should point to dest port */ 
+         0x0000, 0x0000, OP_EQ, 0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ, 
+         0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
+       { "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
+         S1_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
+       { "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0,
+         S1_TCPHc, LD_R1,  0x205,  3, 0xB, 0xf000},
+       { "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
+         S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
+       { "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
+         IM_CTL, 0x001,  3, 0x0, 0x0001},
+       { "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x000,  0, 0x0, 0x0000},
+       { "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x080,  3, 0x0, 0xffff},
+       { NULL },
+};
+#ifdef HP_IP46TCP4_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_ip46tcp4tab
+#endif
+#endif
+
+/*
+ * Alternate table load which excludes HTTP server traffic from reassembly.
+ * It is substantially similar to the basic table, with one extra state
+ * and a few extra compares. */
+#ifdef USE_HP_IP46TCP4NOHTTP
+static cas_hp_inst_t cas_prog_ip46tcp4nohttptab[] = {
+       CAS_PROG_IP46TCP4_PREAMBLE,
+       { "TCP seq", /* DADDR should point to dest port */
+         0xFFFF, 0x0080, OP_EQ,  0, S2_HTTP,  0, S1_TCPFG, LD_SEQ, 
+         0x081,  3, 0x0, 0xffff} , /* Load TCP seq # */
+       { "TCP control flags", 0xFFFF, 0x8080, OP_EQ,  0, S2_HTTP,  0,
+         S1_TCPHL, ST_FLG, 0x145,  2, 0x0, 0x002f, }, /* Load TCP flags */
+       { "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
+         LD_R1,  0x205,  3, 0xB, 0xf000},
+       { "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         LD_HDR, 0x0ff,  3, 0x0, 0xffff},
+       { "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
+         IM_CTL, 0x001,  3, 0x0, 0x0001},
+       { "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         CL_REG, 0x002,  3, 0x0, 0x0000},
+       { "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x080,  3, 0x0, 0xffff},
+       { "No HTTP", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x044,  3, 0x0, 0xffff},
+       { NULL },
+};
+#ifdef HP_IP46TCP4NOHTTP_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_ip46tcp4nohttptab
+#endif
+#endif
+
+/* match step #s for IP4FRAG */
+#define        S3_IPV6c        11
+#define        S3_TCP64        12
+#define        S3_TCPSQ        13
+#define        S3_TCPFG        14
+#define        S3_TCPHL        15
+#define        S3_TCPHc        16
+#define        S3_FRAG         17
+#define        S3_FOFF         18
+#define        S3_CLNP         19
+
+#ifdef USE_HP_IP4FRAG
+static cas_hp_inst_t cas_prog_ip4fragtab[] = {
+       { "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, S1_PCKT,
+         CL_REG, 0x3ff, 1, 0x0, 0x0000},
+       { "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,
+         IM_CTL, 0x00a,  3, 0x0, 0xffff},
+       { "CFI?", 0x1000, 0x1000, OP_EQ,  0, S3_CLNP,  1, S1_8023,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S3_CLNP,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "LLCc?",0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S3_CLNP,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
+         LD_SAP, 0x100,  3, 0x0, 0xffff},
+       { "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S3_CLNP,
+         LD_SUM, 0x00a,  1, 0x0, 0x0000},
+       { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S3_FRAG,
+         LD_LEN, 0x03e,  3, 0x0, 0xffff},
+       { "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S3_TCPSQ, 0, S3_CLNP,
+         LD_FID, 0x182,  3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
+       { "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S3_IPV6c, 0, S3_CLNP,
+         LD_SUM, 0x015,  1, 0x0, 0x0000},
+       { "IPV6 cont?", 0xf000, 0x6000, OP_EQ,  3, S3_TCP64, 0, S3_CLNP,
+         LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
+       { "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S3_TCPSQ, 0, S3_CLNP,
+         LD_LEN, 0x03f,  1, 0x0, 0xffff},
+       { "TCP seq",    /* DADDR should point to dest port */
+         0x0000, 0x0000, OP_EQ,  0, S3_TCPFG, 4, S3_TCPFG, LD_SEQ,
+         0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
+       { "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S3_TCPHL, 0, 
+         S3_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
+       { "TCP length", 0x0000, 0x0000, OP_EQ,  0, S3_TCPHc, 0, S3_TCPHc,
+         LD_R1,  0x205,  3, 0xB, 0xf000},
+       { "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         LD_HDR, 0x0ff,  3, 0x0, 0xffff},
+       { "IP4 Fragment", 0x0000, 0x0000, OP_EQ,  0, S3_FOFF,  0, S3_FOFF,
+         LD_FID, 0x103,  3, 0x0, 0xffff}, /* FID IP4 src+dst */
+       { "IP4 frag offset", 0x0000, 0x0000, OP_EQ,  0, S3_FOFF,  0, S3_FOFF,
+         LD_SEQ, 0x040,  1, 0xD, 0xfff8},
+       { "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,  
+         IM_CTL, 0x001,  3, 0x0, 0x0001},
+       { NULL },
+};
+#ifdef HP_IP4FRAG_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_ip4fragtab
+#endif
+#endif
+
+/*
+ * Alternate table which does batching without reassembly
+ */
+#ifdef USE_HP_IP46TCP4BATCH
+static cas_hp_inst_t cas_prog_ip46tcp4batchtab[] = {
+       CAS_PROG_IP46TCP4_PREAMBLE,
+       { "TCP seq",    /* DADDR should point to dest port */
+         0x0000, 0x0000, OP_EQ,  0, S1_TCPFG, 0, S1_TCPFG, LD_SEQ,
+         0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
+       { "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0, 
+         S1_TCPHL, ST_FLG, 0x000,  3, 0x0, 0x0000}, /* Load TCP flags */
+       { "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, 
+         S1_TCPHc, LD_R1,  0x205,  3, 0xB, 0xf000},
+       { "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, 
+         S1_PCKT,  IM_CTL, 0x040,  3, 0x0, 0xffff}, /* set batch bit */
+       { "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x001,  3, 0x0, 0x0001},
+       { "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
+         S1_PCKT,  IM_CTL, 0x080,  3, 0x0, 0xffff},
+       { NULL },
+};
+#ifdef HP_IP46TCP4BATCH_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_ip46tcp4batchtab
+#endif
+#endif
+
+/* Workaround for Cassini rev2 descriptor corruption problem.
+ * Does batching without reassembly, and sets the SAP to a known
+ * data pattern for all packets.
+ */
+#ifdef USE_HP_WORKAROUND
+static cas_hp_inst_t  cas_prog_workaroundtab[] = {
+       { "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0,
+         S1_PCKT,  CL_REG, 0x3ff,  1, 0x0, 0x0000} ,
+       { "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI, 0, S1_8023, 
+         IM_CTL, 0x04a,  3, 0x0, 0xffff},
+       { "CFI?", 0x1000, 0x1000, OP_EQ,  0, S1_CLNP,  1, S1_8023,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
+         IM_SAP, 0x6AE,  3, 0x0, 0xffff},
+       { "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP,
+         LD_SUM, 0x00a,  1, 0x0, 0x0000},
+       { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP,  
+         LD_LEN, 0x03e,  1, 0x0, 0xffff},
+       { "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_CLNP,
+         LD_FID, 0x182,  3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
+       { "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,
+         LD_SUM, 0x015,  1, 0x0, 0x0000},
+       { "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP,
+         IM_R1,  0x128,  1, 0x0, 0xffff},
+       { "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP,
+         LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
+       { "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP,
+         LD_LEN, 0x03f,  1, 0x0, 0xffff},
+       { "TCP seq",      /* DADDR should point to dest port */
+         0x0000, 0x0000, OP_EQ,  0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ, 
+         0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
+       { "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
+         S1_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
+       { "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
+         LD_R1,  0x205,  3, 0xB, 0xf000},
+       { "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
+         S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
+       { "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP2,
+         IM_SAP, 0x6AE,  3, 0x0, 0xffff} ,
+       { "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x001,  3, 0x0, 0x0001},
+       { NULL },
+};
+#ifdef HP_WORKAROUND_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_workaroundtab
+#endif
+#endif
+
+#ifdef USE_HP_ENCRYPT
+static cas_hp_inst_t  cas_prog_encryptiontab[] = {
+       { "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, 
+         S1_PCKT,  CL_REG, 0x3ff,  1, 0x0, 0x0000},
+       { "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,
+         IM_CTL, 0x00a,  3, 0x0, 0xffff},
+#if 0
+//"CFI?", /* 02 FIND CFI and If FIND go to S1_DROP */
+//0x1000, 0x1000, OP_EQ,  0, S1_DROP,  1, S1_8023,  CL_REG, 0x000,  0, 0x0, 0x00
+       00,
+#endif
+       { "CFI?", /* FIND CFI and If FIND go to CleanUP1 (ignore and send to host) */
+         0x1000, 0x1000, OP_EQ,  0, S1_CLNP,  1, S1_8023,  
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4, 
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP, 
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP,
+         CL_REG, 0x000,  0, 0x0, 0x0000},
+       { "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,  
+         LD_SAP, 0x100,  3, 0x0, 0xffff},
+       { "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP,  
+         LD_SUM, 0x00a,  1, 0x0, 0x0000},
+       { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP, 
+         LD_LEN, 0x03e,  1, 0x0, 0xffff},
+       { "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_ESP4,
+         LD_FID, 0x182,  1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
+       { "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,
+         LD_SUM, 0x015,  1, 0x0, 0x0000},
+       { "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP,
+         IM_R1,  0x128,  1, 0x0, 0xffff},
+       { "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP, 
+         LD_FID, 0x484,  1, 0x0, 0xffff}, /*  FID IP6&TCP src+dst */
+       { "TCP64?", 
+#if 0
+//@@@0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_ESP6,  LD_LEN, 0x03f,  1, 0x0, 0xffff,
+#endif
+         0xff00, 0x0600, OP_EQ, 12, S1_TCPSQ, 0, S1_ESP6,  LD_LEN,
+         0x03f,  1, 0x0, 0xffff},
+       { "TCP seq", /* 14:DADDR should point to dest port */
+         0xFFFF, 0x0080, OP_EQ,  0, S2_HTTP,  0, S1_TCPFG, LD_SEQ,
+         0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
+       { "TCP control flags", 0xFFFF, 0x8080, OP_EQ,  0, S2_HTTP,  0,
+         S1_TCPHL, ST_FLG, 0x145,  2, 0x0, 0x002f}, /* Load TCP flags */
+       { "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc, 
+         LD_R1,  0x205,  3, 0xB, 0xf000} ,
+       { "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
+         S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff}, 
+       { "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
+         IM_CTL, 0x001,  3, 0x0, 0x0001},
+       { "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         CL_REG, 0x002,  3, 0x0, 0x0000},
+       { "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x080,  3, 0x0, 0xffff},
+       { "No HTTP", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
+         IM_CTL, 0x044,  3, 0x0, 0xffff}, 
+       { "IPV4 ESP encrypted?",  /* S1_ESP4 */
+         0x00ff, 0x0032, OP_EQ,  0, S1_CLNP2, 0, S1_AH4, IM_CTL,
+         0x021, 1,  0x0, 0xffff},
+       { "IPV4 AH encrypted?",   /* S1_AH4 */
+         0x00ff, 0x0033, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
+         0x021, 1,  0x0, 0xffff},
+       { "IPV6 ESP encrypted?",  /* S1_ESP6 */
+#if 0
+//@@@0x00ff, 0x0032, OP_EQ,  0, S1_CLNP2, 0, S1_AH6, IM_CTL, 0x021, 1,  0x0, 0xffff,
+#endif
+         0xff00, 0x3200, OP_EQ,  0, S1_CLNP2, 0, S1_AH6, IM_CTL,
+         0x021, 1,  0x0, 0xffff},
+       { "IPV6 AH encrypted?",   /* S1_AH6 */
+#if 0
+//@@@0x00ff, 0x0033, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL, 0x021, 1,  0x0, 0xffff,
+#endif
+         0xff00, 0x3300, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
+         0x021, 1,  0x0, 0xffff},
+       { NULL },
+};
+#ifdef HP_ENCRYPT_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_encryptiontab
+#endif
+#endif
+
+static cas_hp_inst_t cas_prog_null[] = { {NULL} };
+#ifdef HP_NULL_DEFAULT
+#define CAS_HP_FIRMWARE               cas_prog_null
+#endif
+
+/* firmware patch for NS_DP83065 */
+typedef struct cas_saturn_patch {
+       u16 addr;
+       u16 val;
+} cas_saturn_patch_t;
+
+#if 1
+cas_saturn_patch_t cas_saturn_patch[] = {
+{0x8200,    0x007e}, {0x8201,    0x0082}, {0x8202,    0x0009},
+{0x8203,    0x0000}, {0x8204,    0x0000}, {0x8205,    0x0000},
+{0x8206,    0x0000}, {0x8207,    0x0000}, {0x8208,    0x0000},
+{0x8209,    0x008e}, {0x820a,    0x008e}, {0x820b,    0x00ff},
+{0x820c,    0x00ce}, {0x820d,    0x0082}, {0x820e,    0x0025},
+{0x820f,    0x00ff}, {0x8210,    0x0001}, {0x8211,    0x000f},
+{0x8212,    0x00ce}, {0x8213,    0x0084}, {0x8214,    0x0026},
+{0x8215,    0x00ff}, {0x8216,    0x0001}, {0x8217,    0x0011},
+{0x8218,    0x00ce}, {0x8219,    0x0085}, {0x821a,    0x003d},
+{0x821b,    0x00df}, {0x821c,    0x00e5}, {0x821d,    0x0086},
+{0x821e,    0x0039}, {0x821f,    0x00b7}, {0x8220,    0x008f},
+{0x8221,    0x00f8}, {0x8222,    0x007e}, {0x8223,    0x00c3},
+{0x8224,    0x00c2}, {0x8225,    0x0096}, {0x8226,    0x0047},
+{0x8227,    0x0084}, {0x8228,    0x00f3}, {0x8229,    0x008a},
+{0x822a,    0x0000}, {0x822b,    0x0097}, {0x822c,    0x0047},
+{0x822d,    0x00ce}, {0x822e,    0x0082}, {0x822f,    0x0033},
+{0x8230,    0x00ff}, {0x8231,    0x0001}, {0x8232,    0x000f},
+{0x8233,    0x0096}, {0x8234,    0x0046}, {0x8235,    0x0084},
+{0x8236,    0x000c}, {0x8237,    0x0081}, {0x8238,    0x0004},
+{0x8239,    0x0027}, {0x823a,    0x000b}, {0x823b,    0x0096},
+{0x823c,    0x0046}, {0x823d,    0x0084}, {0x823e,    0x000c},
+{0x823f,    0x0081}, {0x8240,    0x0008}, {0x8241,    0x0027},
+{0x8242,    0x0057}, {0x8243,    0x007e}, {0x8244,    0x0084},
+{0x8245,    0x0025}, {0x8246,    0x0096}, {0x8247,    0x0047},
+{0x8248,    0x0084}, {0x8249,    0x00f3}, {0x824a,    0x008a},
+{0x824b,    0x0004}, {0x824c,    0x0097}, {0x824d,    0x0047},
+{0x824e,    0x00ce}, {0x824f,    0x0082}, {0x8250,    0x0054},
+{0x8251,    0x00ff}, {0x8252,    0x0001}, {0x8253,    0x000f},
+{0x8254,    0x0096}, {0x8255,    0x0046}, {0x8256,    0x0084},
+{0x8257,    0x000c}, {0x8258,    0x0081}, {0x8259,    0x0004},
+{0x825a,    0x0026}, {0x825b,    0x0038}, {0x825c,    0x00b6},
+{0x825d,    0x0012}, {0x825e,    0x0020}, {0x825f,    0x0084},
+{0x8260,    0x0020}, {0x8261,    0x0026}, {0x8262,    0x0003},
+{0x8263,    0x007e}, {0x8264,    0x0084}, {0x8265,    0x0025},
+{0x8266,    0x0096}, {0x8267,    0x007b}, {0x8268,    0x00d6},
+{0x8269,    0x007c}, {0x826a,    0x00fe}, {0x826b,    0x008f},
+{0x826c,    0x0056}, {0x826d,    0x00bd}, {0x826e,    0x00f7},
+{0x826f,    0x00b6}, {0x8270,    0x00fe}, {0x8271,    0x008f},
+{0x8272,    0x004e}, {0x8273,    0x00bd}, {0x8274,    0x00ec},
+{0x8275,    0x008e}, {0x8276,    0x00bd}, {0x8277,    0x00fa},
+{0x8278,    0x00f7}, {0x8279,    0x00bd}, {0x827a,    0x00f7},
+{0x827b,    0x0028}, {0x827c,    0x00ce}, {0x827d,    0x0082},
+{0x827e,    0x0082}, {0x827f,    0x00ff}, {0x8280,    0x0001},
+{0x8281,    0x000f}, {0x8282,    0x0096}, {0x8283,    0x0046},
+{0x8284,    0x0084}, {0x8285,    0x000c}, {0x8286,    0x0081},
+{0x8287,    0x0004}, {0x8288,    0x0026}, {0x8289,    0x000a},
+{0x828a,    0x00b6}, {0x828b,    0x0012}, {0x828c,    0x0020},
+{0x828d,    0x0084}, {0x828e,    0x0020}, {0x828f,    0x0027},
+{0x8290,    0x00b5}, {0x8291,    0x007e}, {0x8292,    0x0084},
+{0x8293,    0x0025}, {0x8294,    0x00bd}, {0x8295,    0x00f7},
+{0x8296,    0x001f}, {0x8297,    0x007e}, {0x8298,    0x0084},
+{0x8299,    0x001f}, {0x829a,    0x0096}, {0x829b,    0x0047},
+{0x829c,    0x0084}, {0x829d,    0x00f3}, {0x829e,    0x008a},
+{0x829f,    0x0008}, {0x82a0,    0x0097}, {0x82a1,    0x0047},
+{0x82a2,    0x00de}, {0x82a3,    0x00e1}, {0x82a4,    0x00ad},
+{0x82a5,    0x0000}, {0x82a6,    0x00ce}, {0x82a7,    0x0082},
+{0x82a8,    0x00af}, {0x82a9,    0x00ff}, {0x82aa,    0x0001},
+{0x82ab,    0x000f}, {0x82ac,    0x007e}, {0x82ad,    0x0084},
+{0x82ae,    0x0025}, {0x82af,    0x0096}, {0x82b0,    0x0041},
+{0x82b1,    0x0085}, {0x82b2,    0x0010}, {0x82b3,    0x0026},
+{0x82b4,    0x0006}, {0x82b5,    0x0096}, {0x82b6,    0x0023},
+{0x82b7,    0x0085}, {0x82b8,    0x0040}, {0x82b9,    0x0027},
+{0x82ba,    0x0006}, {0x82bb,    0x00bd}, {0x82bc,    0x00ed},
+{0x82bd,    0x0000}, {0x82be,    0x007e}, {0x82bf,    0x0083},
+{0x82c0,    0x00a2}, {0x82c1,    0x00de}, {0x82c2,    0x0042},
+{0x82c3,    0x00bd}, {0x82c4,    0x00eb}, {0x82c5,    0x008e},
+{0x82c6,    0x0096}, {0x82c7,    0x0024}, {0x82c8,    0x0084},
+{0x82c9,    0x0008}, {0x82ca,    0x0027}, {0x82cb,    0x0003},
+{0x82cc,    0x007e}, {0x82cd,    0x0083}, {0x82ce,    0x00df},
+{0x82cf,    0x0096}, {0x82d0,    0x007b}, {0x82d1,    0x00d6},
+{0x82d2,    0x007c}, {0x82d3,    0x00fe}, {0x82d4,    0x008f},
+{0x82d5,    0x0056}, {0x82d6,    0x00bd}, {0x82d7,    0x00f7},
+{0x82d8,    0x00b6}, {0x82d9,    0x00fe}, {0x82da,    0x008f},
+{0x82db,    0x0050}, {0x82dc,    0x00bd}, {0x82dd,    0x00ec},
+{0x82de,    0x008e}, {0x82df,    0x00bd}, {0x82e0,    0x00fa},
+{0x82e1,    0x00f7}, {0x82e2,    0x0086}, {0x82e3,    0x0011},
+{0x82e4,    0x00c6}, {0x82e5,    0x0049}, {0x82e6,    0x00bd},
+{0x82e7,    0x00e4}, {0x82e8,    0x0012}, {0x82e9,    0x00ce},
+{0x82ea,    0x0082}, {0x82eb,    0x00ef}, {0x82ec,    0x00ff},
+{0x82ed,    0x0001}, {0x82ee,    0x000f}, {0x82ef,    0x0096},
+{0x82f0,    0x0046}, {0x82f1,    0x0084}, {0x82f2,    0x000c},
+{0x82f3,    0x0081}, {0x82f4,    0x0000}, {0x82f5,    0x0027},
+{0x82f6,    0x0017}, {0x82f7,    0x00c6}, {0x82f8,    0x0049},
+{0x82f9,    0x00bd}, {0x82fa,    0x00e4}, {0x82fb,    0x0091},
+{0x82fc,    0x0024}, {0x82fd,    0x000d}, {0x82fe,    0x00b6},
+{0x82ff,    0x0012}, {0x8300,    0x0020}, {0x8301,    0x0085},
+{0x8302,    0x0020}, {0x8303,    0x0026}, {0x8304,    0x000c},
+{0x8305,    0x00ce}, {0x8306,    0x0082}, {0x8307,    0x00c1},
+{0x8308,    0x00ff}, {0x8309,    0x0001}, {0x830a,    0x000f},
+{0x830b,    0x007e}, {0x830c,    0x0084}, {0x830d,    0x0025},
+{0x830e,    0x007e}, {0x830f,    0x0084}, {0x8310,    0x0016},
+{0x8311,    0x00fe}, {0x8312,    0x008f}, {0x8313,    0x0052},
+{0x8314,    0x00bd}, {0x8315,    0x00ec}, {0x8316,    0x008e},
+{0x8317,    0x00bd}, {0x8318,    0x00fa}, {0x8319,    0x00f7},
+{0x831a,    0x0086}, {0x831b,    0x006a}, {0x831c,    0x00c6},
+{0x831d,    0x0049}, {0x831e,    0x00bd}, {0x831f,    0x00e4},
+{0x8320,    0x0012}, {0x8321,    0x00ce}, {0x8322,    0x0083},
+{0x8323,    0x0027}, {0x8324,    0x00ff}, {0x8325,    0x0001},
+{0x8326,    0x000f}, {0x8327,    0x0096}, {0x8328,    0x0046},
+{0x8329,    0x0084}, {0x832a,    0x000c}, {0x832b,    0x0081},
+{0x832c,    0x0000}, {0x832d,    0x0027}, {0x832e,    0x000a},
+{0x832f,    0x00c6}, {0x8330,    0x0049}, {0x8331,    0x00bd},
+{0x8332,    0x00e4}, {0x8333,    0x0091}, {0x8334,    0x0025},
+{0x8335,    0x0006}, {0x8336,    0x007e}, {0x8337,    0x0084},
+{0x8338,    0x0025}, {0x8339,    0x007e}, {0x833a,    0x0084},
+{0x833b,    0x0016}, {0x833c,    0x00b6}, {0x833d,    0x0018},
+{0x833e,    0x0070}, {0x833f,    0x00bb}, {0x8340,    0x0019},
+{0x8341,    0x0070}, {0x8342,    0x002a}, {0x8343,    0x0004},
+{0x8344,    0x0081}, {0x8345,    0x00af}, {0x8346,    0x002e},
+{0x8347,    0x0019}, {0x8348,    0x0096}, {0x8349,    0x007b},
+{0x834a,    0x00f6}, {0x834b,    0x0020}, {0x834c,    0x0007},
+{0x834d,    0x00fa}, {0x834e,    0x0020}, {0x834f,    0x0027},
+{0x8350,    0x00c4}, {0x8351,    0x0038}, {0x8352,    0x0081},
+{0x8353,    0x0038}, {0x8354,    0x0027}, {0x8355,    0x000b},
+{0x8356,    0x00f6}, {0x8357,    0x0020}, {0x8358,    0x0007},
+{0x8359,    0x00fa}, {0x835a,    0x0020}, {0x835b,    0x0027},
+{0x835c,    0x00cb}, {0x835d,    0x0008}, {0x835e,    0x007e},
+{0x835f,    0x0082}, {0x8360,    0x00d3}, {0x8361,    0x00bd},
+{0x8362,    0x00f7}, {0x8363,    0x0066}, {0x8364,    0x0086},
+{0x8365,    0x0074}, {0x8366,    0x00c6}, {0x8367,    0x0049},
+{0x8368,    0x00bd}, {0x8369,    0x00e4}, {0x836a,    0x0012},
+{0x836b,    0x00ce}, {0x836c,    0x0083}, {0x836d,    0x0071},
+{0x836e,    0x00ff}, {0x836f,    0x0001}, {0x8370,    0x000f},
+{0x8371,    0x0096}, {0x8372,    0x0046}, {0x8373,    0x0084},
+{0x8374,    0x000c}, {0x8375,    0x0081}, {0x8376,    0x0008},
+{0x8377,    0x0026}, {0x8378,    0x000a}, {0x8379,    0x00c6},
+{0x837a,    0x0049}, {0x837b,    0x00bd}, {0x837c,    0x00e4},
+{0x837d,    0x0091}, {0x837e,    0x0025}, {0x837f,    0x0006},
+{0x8380,    0x007e}, {0x8381,    0x0084}, {0x8382,    0x0025},
+{0x8383,    0x007e}, {0x8384,    0x0084}, {0x8385,    0x0016},
+{0x8386,    0x00bd}, {0x8387,    0x00f7}, {0x8388,    0x003e},
+{0x8389,    0x0026}, {0x838a,    0x000e}, {0x838b,    0x00bd},
+{0x838c,    0x00e5}, {0x838d,    0x0009}, {0x838e,    0x0026},
+{0x838f,    0x0006}, {0x8390,    0x00ce}, {0x8391,    0x0082},
+{0x8392,    0x00c1}, {0x8393,    0x00ff}, {0x8394,    0x0001},
+{0x8395,    0x000f}, {0x8396,    0x007e}, {0x8397,    0x0084},
+{0x8398,    0x0025}, {0x8399,    0x00fe}, {0x839a,    0x008f},
+{0x839b,    0x0054}, {0x839c,    0x00bd}, {0x839d,    0x00ec},
+{0x839e,    0x008e}, {0x839f,    0x00bd}, {0x83a0,    0x00fa},
+{0x83a1,    0x00f7}, {0x83a2,    0x00bd}, {0x83a3,    0x00f7},
+{0x83a4,    0x0033}, {0x83a5,    0x0086}, {0x83a6,    0x000f},
+{0x83a7,    0x00c6}, {0x83a8,    0x0051}, {0x83a9,    0x00bd},
+{0x83aa,    0x00e4}, {0x83ab,    0x0012}, {0x83ac,    0x00ce},
+{0x83ad,    0x0083}, {0x83ae,    0x00b2}, {0x83af,    0x00ff},
+{0x83b0,    0x0001}, {0x83b1,    0x000f}, {0x83b2,    0x0096},
+{0x83b3,    0x0046}, {0x83b4,    0x0084}, {0x83b5,    0x000c},
+{0x83b6,    0x0081}, {0x83b7,    0x0008}, {0x83b8,    0x0026},
+{0x83b9,    0x005c}, {0x83ba,    0x00b6}, {0x83bb,    0x0012},
+{0x83bc,    0x0020}, {0x83bd,    0x0084}, {0x83be,    0x003f},
+{0x83bf,    0x0081}, {0x83c0,    0x003a}, {0x83c1,    0x0027},
+{0x83c2,    0x001c}, {0x83c3,    0x0096}, {0x83c4,    0x0023},
+{0x83c5,    0x0085}, {0x83c6,    0x0040}, {0x83c7,    0x0027},
+{0x83c8,    0x0003}, {0x83c9,    0x007e}, {0x83ca,    0x0084},
+{0x83cb,    0x0025}, {0x83cc,    0x00c6}, {0x83cd,    0x0051},
+{0x83ce,    0x00bd}, {0x83cf,    0x00e4}, {0x83d0,    0x0091},
+{0x83d1,    0x0025}, {0x83d2,    0x0003}, {0x83d3,    0x007e},
+{0x83d4,    0x0084}, {0x83d5,    0x0025}, {0x83d6,    0x00ce},
+{0x83d7,    0x0082}, {0x83d8,    0x00c1}, {0x83d9,    0x00ff},
+{0x83da,    0x0001}, {0x83db,    0x000f}, {0x83dc,    0x007e},
+{0x83dd,    0x0084}, {0x83de,    0x0025}, {0x83df,    0x00bd},
+{0x83e0,    0x00f8}, {0x83e1,    0x0037}, {0x83e2,    0x007c},
+{0x83e3,    0x0000}, {0x83e4,    0x007a}, {0x83e5,    0x00ce},
+{0x83e6,    0x0083}, {0x83e7,    0x00ee}, {0x83e8,    0x00ff},
+{0x83e9,    0x0001}, {0x83ea,    0x000f}, {0x83eb,    0x007e},
+{0x83ec,    0x0084}, {0x83ed,    0x0025}, {0x83ee,    0x0096},
+{0x83ef,    0x0046}, {0x83f0,    0x0084}, {0x83f1,    0x000c},
+{0x83f2,    0x0081}, {0x83f3,    0x0008}, {0x83f4,    0x0026},
+{0x83f5,    0x0020}, {0x83f6,    0x0096}, {0x83f7,    0x0024},
+{0x83f8,    0x0084}, {0x83f9,    0x0008}, {0x83fa,    0x0026},
+{0x83fb,    0x0029}, {0x83fc,    0x00b6}, {0x83fd,    0x0018},
+{0x83fe,    0x0082}, {0x83ff,    0x00bb}, {0x8400,    0x0019},
+{0x8401,    0x0082}, {0x8402,    0x00b1}, {0x8403,    0x0001},
+{0x8404,    0x003b}, {0x8405,    0x0022}, {0x8406,    0x0009},
+{0x8407,    0x00b6}, {0x8408,    0x0012}, {0x8409,    0x0020},
+{0x840a,    0x0084}, {0x840b,    0x0037}, {0x840c,    0x0081},
+{0x840d,    0x0032}, {0x840e,    0x0027}, {0x840f,    0x0015},
+{0x8410,    0x00bd}, {0x8411,    0x00f8}, {0x8412,    0x0044},
+{0x8413,    0x007e}, {0x8414,    0x0082}, {0x8415,    0x00c1},
+{0x8416,    0x00bd}, {0x8417,    0x00f7}, {0x8418,    0x001f},
+{0x8419,    0x00bd}, {0x841a,    0x00f8}, {0x841b,    0x0044},
+{0x841c,    0x00bd}, {0x841d,    0x00fc}, {0x841e,    0x0029},
+{0x841f,    0x00ce}, {0x8420,    0x0082}, {0x8421,    0x0025},
+{0x8422,    0x00ff}, {0x8423,    0x0001}, {0x8424,    0x000f},
+{0x8425,    0x0039}, {0x8426,    0x0096}, {0x8427,    0x0047},
+{0x8428,    0x0084}, {0x8429,    0x00fc}, {0x842a,    0x008a},
+{0x842b,    0x0000}, {0x842c,    0x0097}, {0x842d,    0x0047},
+{0x842e,    0x00ce}, {0x842f,    0x0084}, {0x8430,    0x0034},
+{0x8431,    0x00ff}, {0x8432,    0x0001}, {0x8433,    0x0011},
+{0x8434,    0x0096}, {0x8435,    0x0046}, {0x8436,    0x0084},
+{0x8437,    0x0003}, {0x8438,    0x0081}, {0x8439,    0x0002},
+{0x843a,    0x0027}, {0x843b,    0x0003}, {0x843c,    0x007e},
+{0x843d,    0x0085}, {0x843e,    0x001e}, {0x843f,    0x0096},
+{0x8440,    0x0047}, {0x8441,    0x0084}, {0x8442,    0x00fc},
+{0x8443,    0x008a}, {0x8444,    0x0002}, {0x8445,    0x0097},
+{0x8446,    0x0047}, {0x8447,    0x00de}, {0x8448,    0x00e1},
+{0x8449,    0x00ad}, {0x844a,    0x0000}, {0x844b,    0x0086},
+{0x844c,    0x0001}, {0x844d,    0x00b7}, {0x844e,    0x0012},
+{0x844f,    0x0051}, {0x8450,    0x00bd}, {0x8451,    0x00f7},
+{0x8452,    0x0014}, {0x8453,    0x00b6}, {0x8454,    0x0010},
+{0x8455,    0x0031}, {0x8456,    0x0084}, {0x8457,    0x00fd},
+{0x8458,    0x00b7}, {0x8459,    0x0010}, {0x845a,    0x0031},
+{0x845b,    0x00bd}, {0x845c,    0x00f8}, {0x845d,    0x001e},
+{0x845e,    0x0096}, {0x845f,    0x0081}, {0x8460,    0x00d6},
+{0x8461,    0x0082}, {0x8462,    0x00fe}, {0x8463,    0x008f},
+{0x8464,    0x005a}, {0x8465,    0x00bd}, {0x8466,    0x00f7},
+{0x8467,    0x00b6}, {0x8468,    0x00fe}, {0x8469,    0x008f},
+{0x846a,    0x005c}, {0x846b,    0x00bd}, {0x846c,    0x00ec},
+{0x846d,    0x008e}, {0x846e,    0x00bd}, {0x846f,    0x00fa},
+{0x8470,    0x00f7}, {0x8471,    0x0086}, {0x8472,    0x0008},
+{0x8473,    0x00d6}, {0x8474,    0x0000}, {0x8475,    0x00c5},
+{0x8476,    0x0010}, {0x8477,    0x0026}, {0x8478,    0x0002},
+{0x8479,    0x008b}, {0x847a,    0x0020}, {0x847b,    0x00c6},
+{0x847c,    0x0051}, {0x847d,    0x00bd}, {0x847e,    0x00e4},
+{0x847f,    0x0012}, {0x8480,    0x00ce}, {0x8481,    0x0084},
+{0x8482,    0x0086}, {0x8483,    0x00ff}, {0x8484,    0x0001},
+{0x8485,    0x0011}, {0x8486,    0x0096}, {0x8487,    0x0046},
+{0x8488,    0x0084}, {0x8489,    0x0003}, {0x848a,    0x0081},
+{0x848b,    0x0002}, {0x848c,    0x0027}, {0x848d,    0x0003},
+{0x848e,    0x007e}, {0x848f,    0x0085}, {0x8490,    0x000f},
+{0x8491,    0x00c6}, {0x8492,    0x0051}, {0x8493,    0x00bd},
+{0x8494,    0x00e4}, {0x8495,    0x0091}, {0x8496,    0x0025},
+{0x8497,    0x0003}, {0x8498,    0x007e}, {0x8499,    0x0085},
+{0x849a,    0x001e}, {0x849b,    0x0096}, {0x849c,    0x0044},
+{0x849d,    0x0085}, {0x849e,    0x0010}, {0x849f,    0x0026},
+{0x84a0,    0x000a}, {0x84a1,    0x00b6}, {0x84a2,    0x0012},
+{0x84a3,    0x0050}, {0x84a4,    0x00ba}, {0x84a5,    0x0001},
+{0x84a6,    0x003c}, {0x84a7,    0x0085}, {0x84a8,    0x0010},
+{0x84a9,    0x0027}, {0x84aa,    0x00a8}, {0x84ab,    0x00bd},
+{0x84ac,    0x00f7}, {0x84ad,    0x0066}, {0x84ae,    0x00ce},
+{0x84af,    0x0084}, {0x84b0,    0x00b7}, {0x84b1,    0x00ff},
+{0x84b2,    0x0001}, {0x84b3,    0x0011}, {0x84b4,    0x007e},
+{0x84b5,    0x0085}, {0x84b6,    0x001e}, {0x84b7,    0x0096},
+{0x84b8,    0x0046}, {0x84b9,    0x0084}, {0x84ba,    0x0003},
+{0x84bb,    0x0081}, {0x84bc,    0x0002}, {0x84bd,    0x0026},
+{0x84be,    0x0050}, {0x84bf,    0x00b6}, {0x84c0,    0x0012},
+{0x84c1,    0x0030}, {0x84c2,    0x0084}, {0x84c3,    0x0003},
+{0x84c4,    0x0081}, {0x84c5,    0x0001}, {0x84c6,    0x0027},
+{0x84c7,    0x0003}, {0x84c8,    0x007e}, {0x84c9,    0x0085},
+{0x84ca,    0x001e}, {0x84cb,    0x0096}, {0x84cc,    0x0044},
+{0x84cd,    0x0085}, {0x84ce,    0x0010}, {0x84cf,    0x0026},
+{0x84d0,    0x0013}, {0x84d1,    0x00b6}, {0x84d2,    0x0012},
+{0x84d3,    0x0050}, {0x84d4,    0x00ba}, {0x84d5,    0x0001},
+{0x84d6,    0x003c}, {0x84d7,    0x0085}, {0x84d8,    0x0010},
+{0x84d9,    0x0026}, {0x84da,    0x0009}, {0x84db,    0x00ce},
+{0x84dc,    0x0084}, {0x84dd,    0x0053}, {0x84de,    0x00ff},
+{0x84df,    0x0001}, {0x84e0,    0x0011}, {0x84e1,    0x007e},
+{0x84e2,    0x0085}, {0x84e3,    0x001e}, {0x84e4,    0x00b6},
+{0x84e5,    0x0010}, {0x84e6,    0x0031}, {0x84e7,    0x008a},
+{0x84e8,    0x0002}, {0x84e9,    0x00b7}, {0x84ea,    0x0010},
+{0x84eb,    0x0031}, {0x84ec,    0x00bd}, {0x84ed,    0x0085},
+{0x84ee,    0x001f}, {0x84ef,    0x00bd}, {0x84f0,    0x00f8},
+{0x84f1,    0x0037}, {0x84f2,    0x007c}, {0x84f3,    0x0000},
+{0x84f4,    0x0080}, {0x84f5,    0x00ce}, {0x84f6,    0x0084},
+{0x84f7,    0x00fe}, {0x84f8,    0x00ff}, {0x84f9,    0x0001},
+{0x84fa,    0x0011}, {0x84fb,    0x007e}, {0x84fc,    0x0085},
+{0x84fd,    0x001e}, {0x84fe,    0x0096}, {0x84ff,    0x0046},
+{0x8500,    0x0084}, {0x8501,    0x0003}, {0x8502,    0x0081},
+{0x8503,    0x0002}, {0x8504,    0x0026}, {0x8505,    0x0009},
+{0x8506,    0x00b6}, {0x8507,    0x0012}, {0x8508,    0x0030},
+{0x8509,    0x0084}, {0x850a,    0x0003}, {0x850b,    0x0081},
+{0x850c,    0x0001}, {0x850d,    0x0027}, {0x850e,    0x000f},
+{0x850f,    0x00bd}, {0x8510,    0x00f8}, {0x8511,    0x0044},
+{0x8512,    0x00bd}, {0x8513,    0x00f7}, {0x8514,    0x000b},
+{0x8515,    0x00bd}, {0x8516,    0x00fc}, {0x8517,    0x0029},
+{0x8518,    0x00ce}, {0x8519,    0x0084}, {0x851a,    0x0026},
+{0x851b,    0x00ff}, {0x851c,    0x0001}, {0x851d,    0x0011},
+{0x851e,    0x0039}, {0x851f,    0x00d6}, {0x8520,    0x0022},
+{0x8521,    0x00c4}, {0x8522,    0x000f}, {0x8523,    0x00b6},
+{0x8524,    0x0012}, {0x8525,    0x0030}, {0x8526,    0x00ba},
+{0x8527,    0x0012}, {0x8528,    0x0032}, {0x8529,    0x0084},
+{0x852a,    0x0004}, {0x852b,    0x0027}, {0x852c,    0x000d},
+{0x852d,    0x0096}, {0x852e,    0x0022}, {0x852f,    0x0085},
+{0x8530,    0x0004}, {0x8531,    0x0027}, {0x8532,    0x0005},
+{0x8533,    0x00ca}, {0x8534,    0x0010}, {0x8535,    0x007e},
+{0x8536,    0x0085}, {0x8537,    0x003a}, {0x8538,    0x00ca},
+{0x8539,    0x0020}, {0x853a,    0x00d7}, {0x853b,    0x0022},
+{0x853c,    0x0039}, {0x853d,    0x0086}, {0x853e,    0x0000},
+{0x853f,    0x0097}, {0x8540,    0x0083}, {0x8541,    0x0018},
+{0x8542,    0x00ce}, {0x8543,    0x001c}, {0x8544,    0x0000},
+{0x8545,    0x00bd}, {0x8546,    0x00eb}, {0x8547,    0x0046},
+{0x8548,    0x0096}, {0x8549,    0x0057}, {0x854a,    0x0085},
+{0x854b,    0x0001}, {0x854c,    0x0027}, {0x854d,    0x0002},
+{0x854e,    0x004f}, {0x854f,    0x0039}, {0x8550,    0x0085},
+{0x8551,    0x0002}, {0x8552,    0x0027}, {0x8553,    0x0001},
+{0x8554,    0x0039}, {0x8555,    0x007f}, {0x8556,    0x008f},
+{0x8557,    0x007d}, {0x8558,    0x0086}, {0x8559,    0x0004},
+{0x855a,    0x00b7}, {0x855b,    0x0012}, {0x855c,    0x0004},
+{0x855d,    0x0086}, {0x855e,    0x0008}, {0x855f,    0x00b7},
+{0x8560,    0x0012}, {0x8561,    0x0007}, {0x8562,    0x0086},
+{0x8563,    0x0010}, {0x8564,    0x00b7}, {0x8565,    0x0012},
+{0x8566,    0x000c}, {0x8567,    0x0086}, {0x8568,    0x0007},
+{0x8569,    0x00b7}, {0x856a,    0x0012}, {0x856b,    0x0006},
+{0x856c,    0x00b6}, {0x856d,    0x008f}, {0x856e,    0x007d},
+{0x856f,    0x00b7}, {0x8570,    0x0012}, {0x8571,    0x0070},
+{0x8572,    0x0086}, {0x8573,    0x0001}, {0x8574,    0x00ba},
+{0x8575,    0x0012}, {0x8576,    0x0004}, {0x8577,    0x00b7},
+{0x8578,    0x0012}, {0x8579,    0x0004}, {0x857a,    0x0001},
+{0x857b,    0x0001}, {0x857c,    0x0001}, {0x857d,    0x0001},
+{0x857e,    0x0001}, {0x857f,    0x0001}, {0x8580,    0x00b6},
+{0x8581,    0x0012}, {0x8582,    0x0004}, {0x8583,    0x0084},
+{0x8584,    0x00fe}, {0x8585,    0x008a}, {0x8586,    0x0002},
+{0x8587,    0x00b7}, {0x8588,    0x0012}, {0x8589,    0x0004},
+{0x858a,    0x0001}, {0x858b,    0x0001}, {0x858c,    0x0001},
+{0x858d,    0x0001}, {0x858e,    0x0001}, {0x858f,    0x0001},
+{0x8590,    0x0086}, {0x8591,    0x00fd}, {0x8592,    0x00b4},
+{0x8593,    0x0012}, {0x8594,    0x0004}, {0x8595,    0x00b7},
+{0x8596,    0x0012}, {0x8597,    0x0004}, {0x8598,    0x00b6},
+{0x8599,    0x0012}, {0x859a,    0x0000}, {0x859b,    0x0084},
+{0x859c,    0x0008}, {0x859d,    0x0081}, {0x859e,    0x0008},
+{0x859f,    0x0027}, {0x85a0,    0x0016}, {0x85a1,    0x00b6},
+{0x85a2,    0x008f}, {0x85a3,    0x007d}, {0x85a4,    0x0081},
+{0x85a5,    0x000c}, {0x85a6,    0x0027}, {0x85a7,    0x0008},
+{0x85a8,    0x008b}, {0x85a9,    0x0004}, {0x85aa,    0x00b7},
+{0x85ab,    0x008f}, {0x85ac,    0x007d}, {0x85ad,    0x007e},
+{0x85ae,    0x0085}, {0x85af,    0x006c}, {0x85b0,    0x0086},
+{0x85b1,    0x0003}, {0x85b2,    0x0097}, {0x85b3,    0x0040},
+{0x85b4,    0x007e}, {0x85b5,    0x0089}, {0x85b6,    0x006e},
+{0x85b7,    0x0086}, {0x85b8,    0x0007}, {0x85b9,    0x00b7},
+{0x85ba,    0x0012}, {0x85bb,    0x0006}, {0x85bc,    0x005f},
+{0x85bd,    0x00f7}, {0x85be,    0x008f}, {0x85bf,    0x0082},
+{0x85c0,    0x005f}, {0x85c1,    0x00f7}, {0x85c2,    0x008f},
+{0x85c3,    0x007f}, {0x85c4,    0x00f7}, {0x85c5,    0x008f},
+{0x85c6,    0x0070}, {0x85c7,    0x00f7}, {0x85c8,    0x008f},
+{0x85c9,    0x0071}, {0x85ca,    0x00f7}, {0x85cb,    0x008f},
+{0x85cc,    0x0072}, {0x85cd,    0x00f7}, {0x85ce,    0x008f},
+{0x85cf,    0x0073}, {0x85d0,    0x00f7}, {0x85d1,    0x008f},
+{0x85d2,    0x0074}, {0x85d3,    0x00f7}, {0x85d4,    0x008f},
+{0x85d5,    0x0075}, {0x85d6,    0x00f7}, {0x85d7,    0x008f},
+{0x85d8,    0x0076}, {0x85d9,    0x00f7}, {0x85da,    0x008f},
+{0x85db,    0x0077}, {0x85dc,    0x00f7}, {0x85dd,    0x008f},
+{0x85de,    0x0078}, {0x85df,    0x00f7}, {0x85e0,    0x008f},
+{0x85e1,    0x0079}, {0x85e2,    0x00f7}, {0x85e3,    0x008f},
+{0x85e4,    0x007a}, {0x85e5,    0x00f7}, {0x85e6,    0x008f},
+{0x85e7,    0x007b}, {0x85e8,    0x00b6}, {0x85e9,    0x0012},
+{0x85ea,    0x0004}, {0x85eb,    0x008a}, {0x85ec,    0x0010},
+{0x85ed,    0x00b7}, {0x85ee,    0x0012}, {0x85ef,    0x0004},
+{0x85f0,    0x0086}, {0x85f1,    0x00e4}, {0x85f2,    0x00b7},
+{0x85f3,    0x0012}, {0x85f4,    0x0070}, {0x85f5,    0x00b7},
+{0x85f6,    0x0012}, {0x85f7,    0x0007}, {0x85f8,    0x00f7},
+{0x85f9,    0x0012}, {0x85fa,    0x0005}, {0x85fb,    0x00f7},
+{0x85fc,    0x0012}, {0x85fd,    0x0009}, {0x85fe,    0x0086},
+{0x85ff,    0x0008}, {0x8600,    0x00ba}, {0x8601,    0x0012},
+{0x8602,    0x0004}, {0x8603,    0x00b7}, {0x8604,    0x0012},
+{0x8605,    0x0004}, {0x8606,    0x0086}, {0x8607,    0x00f7},
+{0x8608,    0x00b4}, {0x8609,    0x0012}, {0x860a,    0x0004},
+{0x860b,    0x00b7}, {0x860c,    0x0012}, {0x860d,    0x0004},
+{0x860e,    0x0001}, {0x860f,    0x0001}, {0x8610,    0x0001},
+{0x8611,    0x0001}, {0x8612,    0x0001}, {0x8613,    0x0001},
+{0x8614,    0x00b6}, {0x8615,    0x0012}, {0x8616,    0x0008},
+{0x8617,    0x0027}, {0x8618,    0x007f}, {0x8619,    0x0081},
+{0x861a,    0x0080}, {0x861b,    0x0026}, {0x861c,    0x000b},
+{0x861d,    0x0086}, {0x861e,    0x0008}, {0x861f,    0x00ce},
+{0x8620,    0x008f}, {0x8621,    0x0079}, {0x8622,    0x00bd},
+{0x8623,    0x0089}, {0x8624,    0x007b}, {0x8625,    0x007e},
+{0x8626,    0x0086}, {0x8627,    0x008e}, {0x8628,    0x0081},
+{0x8629,    0x0040}, {0x862a,    0x0026}, {0x862b,    0x000b},
+{0x862c,    0x0086}, {0x862d,    0x0004}, {0x862e,    0x00ce},
+{0x862f,    0x008f}, {0x8630,    0x0076}, {0x8631,    0x00bd},
+{0x8632,    0x0089}, {0x8633,    0x007b}, {0x8634,    0x007e},
+{0x8635,    0x0086}, {0x8636,    0x008e}, {0x8637,    0x0081},
+{0x8638,    0x0020}, {0x8639,    0x0026}, {0x863a,    0x000b},
+{0x863b,    0x0086}, {0x863c,    0x0002}, {0x863d,    0x00ce},
+{0x863e,    0x008f}, {0x863f,    0x0073}, {0x8640,    0x00bd},
+{0x8641,    0x0089}, {0x8642,    0x007b}, {0x8643,    0x007e},
+{0x8644,    0x0086}, {0x8645,    0x008e}, {0x8646,    0x0081},
+{0x8647,    0x0010}, {0x8648,    0x0026}, {0x8649,    0x000b},
+{0x864a,    0x0086}, {0x864b,    0x0001}, {0x864c,    0x00ce},
+{0x864d,    0x008f}, {0x864e,    0x0070}, {0x864f,    0x00bd},
+{0x8650,    0x0089}, {0x8651,    0x007b}, {0x8652,    0x007e},
+{0x8653,    0x0086}, {0x8654,    0x008e}, {0x8655,    0x0081},
+{0x8656,    0x0008}, {0x8657,    0x0026}, {0x8658,    0x000b},
+{0x8659,    0x0086}, {0x865a,    0x0008}, {0x865b,    0x00ce},
+{0x865c,    0x008f}, {0x865d,    0x0079}, {0x865e,    0x00bd},
+{0x865f,    0x0089}, {0x8660,    0x007f}, {0x8661,    0x007e},
+{0x8662,    0x0086}, {0x8663,    0x008e}, {0x8664,    0x0081},
+{0x8665,    0x0004}, {0x8666,    0x0026}, {0x8667,    0x000b},
+{0x8668,    0x0086}, {0x8669,    0x0004}, {0x866a,    0x00ce},
+{0x866b,    0x008f}, {0x866c,    0x0076}, {0x866d,    0x00bd},
+{0x866e,    0x0089}, {0x866f,    0x007f}, {0x8670,    0x007e},
+{0x8671,    0x0086}, {0x8672,    0x008e}, {0x8673,    0x0081},
+{0x8674,    0x0002}, {0x8675,    0x0026}, {0x8676,    0x000b},
+{0x8677,    0x008a}, {0x8678,    0x0002}, {0x8679,    0x00ce},
+{0x867a,    0x008f}, {0x867b,    0x0073}, {0x867c,    0x00bd},
+{0x867d,    0x0089}, {0x867e,    0x007f}, {0x867f,    0x007e},
+{0x8680,    0x0086}, {0x8681,    0x008e}, {0x8682,    0x0081},
+{0x8683,    0x0001}, {0x8684,    0x0026}, {0x8685,    0x0008},
+{0x8686,    0x0086}, {0x8687,    0x0001}, {0x8688,    0x00ce},
+{0x8689,    0x008f}, {0x868a,    0x0070}, {0x868b,    0x00bd},
+{0x868c,    0x0089}, {0x868d,    0x007f}, {0x868e,    0x00b6},
+{0x868f,    0x008f}, {0x8690,    0x007f}, {0x8691,    0x0081},
+{0x8692,    0x000f}, {0x8693,    0x0026}, {0x8694,    0x0003},
+{0x8695,    0x007e}, {0x8696,    0x0087}, {0x8697,    0x0047},
+{0x8698,    0x00b6}, {0x8699,    0x0012}, {0x869a,    0x0009},
+{0x869b,    0x0084}, {0x869c,    0x0003}, {0x869d,    0x0081},
+{0x869e,    0x0003}, {0x869f,    0x0027}, {0x86a0,    0x0006},
+{0x86a1,    0x007c}, {0x86a2,    0x0012}, {0x86a3,    0x0009},
+{0x86a4,    0x007e}, {0x86a5,    0x0085}, {0x86a6,    0x00fe},
+{0x86a7,    0x00b6}, {0x86a8,    0x0012}, {0x86a9,    0x0006},
+{0x86aa,    0x0084}, {0x86ab,    0x0007}, {0x86ac,    0x0081},
+{0x86ad,    0x0007}, {0x86ae,    0x0027}, {0x86af,    0x0008},
+{0x86b0,    0x008b}, {0x86b1,    0x0001}, {0x86b2,    0x00b7},
+{0x86b3,    0x0012}, {0x86b4,    0x0006}, {0x86b5,    0x007e},
+{0x86b6,    0x0086}, {0x86b7,    0x00d5}, {0x86b8,    0x00b6},
+{0x86b9,    0x008f}, {0x86ba,    0x0082}, {0x86bb,    0x0026},
+{0x86bc,    0x000a}, {0x86bd,    0x007c}, {0x86be,    0x008f},
+{0x86bf,    0x0082}, {0x86c0,    0x004f}, {0x86c1,    0x00b7},
+{0x86c2,    0x0012}, {0x86c3,    0x0006}, {0x86c4,    0x007e},
+{0x86c5,    0x0085}, {0x86c6,    0x00c0}, {0x86c7,    0x00b6},
+{0x86c8,    0x0012}, {0x86c9,    0x0006}, {0x86ca,    0x0084},
+{0x86cb,    0x003f}, {0x86cc,    0x0081}, {0x86cd,    0x003f},
+{0x86ce,    0x0027}, {0x86cf,    0x0010}, {0x86d0,    0x008b},
+{0x86d1,    0x0008}, {0x86d2,    0x00b7}, {0x86d3,    0x0012},
+{0x86d4,    0x0006}, {0x86d5,    0x00b6}, {0x86d6,    0x0012},
+{0x86d7,    0x0009}, {0x86d8,    0x0084}, {0x86d9,    0x00fc},
+{0x86da,    0x00b7}, {0x86db,    0x0012}, {0x86dc,    0x0009},
+{0x86dd,    0x007e}, {0x86de,    0x0085}, {0x86df,    0x00fe},
+{0x86e0,    0x00ce}, {0x86e1,    0x008f}, {0x86e2,    0x0070},
+{0x86e3,    0x0018}, {0x86e4,    0x00ce}, {0x86e5,    0x008f},
+{0x86e6,    0x0084}, {0x86e7,    0x00c6}, {0x86e8,    0x000c},
+{0x86e9,    0x00bd}, {0x86ea,    0x0089}, {0x86eb,    0x006f},
+{0x86ec,    0x00ce}, {0x86ed,    0x008f}, {0x86ee,    0x0084},
+{0x86ef,    0x0018}, {0x86f0,    0x00ce}, {0x86f1,    0x008f},
+{0x86f2,    0x0070}, {0x86f3,    0x00c6}, {0x86f4,    0x000c},
+{0x86f5,    0x00bd}, {0x86f6,    0x0089}, {0x86f7,    0x006f},
+{0x86f8,    0x00d6}, {0x86f9,    0x0083}, {0x86fa,    0x00c1},
+{0x86fb,    0x004f}, {0x86fc,    0x002d}, {0x86fd,    0x0003},
+{0x86fe,    0x007e}, {0x86ff,    0x0087}, {0x8700,    0x0040},
+{0x8701,    0x00b6}, {0x8702,    0x008f}, {0x8703,    0x007f},
+{0x8704,    0x0081}, {0x8705,    0x0007}, {0x8706,    0x0027},
+{0x8707,    0x000f}, {0x8708,    0x0081}, {0x8709,    0x000b},
+{0x870a,    0x0027}, {0x870b,    0x0015}, {0x870c,    0x0081},
+{0x870d,    0x000d}, {0x870e,    0x0027}, {0x870f,    0x001b},
+{0x8710,    0x0081}, {0x8711,    0x000e}, {0x8712,    0x0027},
+{0x8713,    0x0021}, {0x8714,    0x007e}, {0x8715,    0x0087},
+{0x8716,    0x0040}, {0x8717,    0x00f7}, {0x8718,    0x008f},
+{0x8719,    0x007b}, {0x871a,    0x0086}, {0x871b,    0x0002},
+{0x871c,    0x00b7}, {0x871d,    0x008f}, {0x871e,    0x007a},
+{0x871f,    0x0020}, {0x8720,    0x001c}, {0x8721,    0x00f7},
+{0x8722,    0x008f}, {0x8723,    0x0078}, {0x8724,    0x0086},
+{0x8725,    0x0002}, {0x8726,    0x00b7}, {0x8727,    0x008f},
+{0x8728,    0x0077}, {0x8729,    0x0020}, {0x872a,    0x0012},
+{0x872b,    0x00f7}, {0x872c,    0x008f}, {0x872d,    0x0075},
+{0x872e,    0x0086}, {0x872f,    0x0002}, {0x8730,    0x00b7},
+{0x8731,    0x008f}, {0x8732,    0x0074}, {0x8733,    0x0020},
+{0x8734,    0x0008}, {0x8735,    0x00f7}, {0x8736,    0x008f},
+{0x8737,    0x0072}, {0x8738,    0x0086}, {0x8739,    0x0002},
+{0x873a,    0x00b7}, {0x873b,    0x008f}, {0x873c,    0x0071},
+{0x873d,    0x007e}, {0x873e,    0x0087}, {0x873f,    0x0047},
+{0x8740,    0x0086}, {0x8741,    0x0004}, {0x8742,    0x0097},
+{0x8743,    0x0040}, {0x8744,    0x007e}, {0x8745,    0x0089},
+{0x8746,    0x006e}, {0x8747,    0x00ce}, {0x8748,    0x008f},
+{0x8749,    0x0072}, {0x874a,    0x00bd}, {0x874b,    0x0089},
+{0x874c,    0x00f7}, {0x874d,    0x00ce}, {0x874e,    0x008f},
+{0x874f,    0x0075}, {0x8750,    0x00bd}, {0x8751,    0x0089},
+{0x8752,    0x00f7}, {0x8753,    0x00ce}, {0x8754,    0x008f},
+{0x8755,    0x0078}, {0x8756,    0x00bd}, {0x8757,    0x0089},
+{0x8758,    0x00f7}, {0x8759,    0x00ce}, {0x875a,    0x008f},
+{0x875b,    0x007b}, {0x875c,    0x00bd}, {0x875d,    0x0089},
+{0x875e,    0x00f7}, {0x875f,    0x004f}, {0x8760,    0x00b7},
+{0x8761,    0x008f}, {0x8762,    0x007d}, {0x8763,    0x00b7},
+{0x8764,    0x008f}, {0x8765,    0x0081}, {0x8766,    0x00b6},
+{0x8767,    0x008f}, {0x8768,    0x0072}, {0x8769,    0x0027},
+{0x876a,    0x0047}, {0x876b,    0x007c}, {0x876c,    0x008f},
+{0x876d,    0x007d}, {0x876e,    0x00b6}, {0x876f,    0x008f},
+{0x8770,    0x0075}, {0x8771,    0x0027}, {0x8772,    0x003f},
+{0x8773,    0x007c}, {0x8774,    0x008f}, {0x8775,    0x007d},
+{0x8776,    0x00b6}, {0x8777,    0x008f}, {0x8778,    0x0078},
+{0x8779,    0x0027}, {0x877a,    0x0037}, {0x877b,    0x007c},
+{0x877c,    0x008f}, {0x877d,    0x007d}, {0x877e,    0x00b6},
+{0x877f,    0x008f}, {0x8780,    0x007b}, {0x8781,    0x0027},
+{0x8782,    0x002f}, {0x8783,    0x007f}, {0x8784,    0x008f},
+{0x8785,    0x007d}, {0x8786,    0x007c}, {0x8787,    0x008f},
+{0x8788,    0x0081}, {0x8789,    0x007a}, {0x878a,    0x008f},
+{0x878b,    0x0072}, {0x878c,    0x0027}, {0x878d,    0x001b},
+{0x878e,    0x007c}, {0x878f,    0x008f}, {0x8790,    0x007d},
+{0x8791,    0x007a}, {0x8792,    0x008f}, {0x8793,    0x0075},
+{0x8794,    0x0027}, {0x8795,    0x0016}, {0x8796,    0x007c},
+{0x8797,    0x008f}, {0x8798,    0x007d}, {0x8799,    0x007a},
+{0x879a,    0x008f}, {0x879b,    0x0078}, {0x879c,    0x0027},
+{0x879d,    0x0011}, {0x879e,    0x007c}, {0x879f,    0x008f},
+{0x87a0,    0x007d}, {0x87a1,    0x007a}, {0x87a2,    0x008f},
+{0x87a3,    0x007b}, {0x87a4,    0x0027}, {0x87a5,    0x000c},
+{0x87a6,    0x007e}, {0x87a7,    0x0087}, {0x87a8,    0x0083},
+{0x87a9,    0x007a}, {0x87aa,    0x008f}, {0x87ab,    0x0075},
+{0x87ac,    0x007a}, {0x87ad,    0x008f}, {0x87ae,    0x0078},
+{0x87af,    0x007a}, {0x87b0,    0x008f}, {0x87b1,    0x007b},
+{0x87b2,    0x00ce}, {0x87b3,    0x00c1}, {0x87b4,    0x00fc},
+{0x87b5,    0x00f6}, {0x87b6,    0x008f}, {0x87b7,    0x007d},
+{0x87b8,    0x003a}, {0x87b9,    0x00a6}, {0x87ba,    0x0000},
+{0x87bb,    0x00b7}, {0x87bc,    0x0012}, {0x87bd,    0x0070},
+{0x87be,    0x00b6}, {0x87bf,    0x008f}, {0x87c0,    0x0072},
+{0x87c1,    0x0026}, {0x87c2,    0x0003}, {0x87c3,    0x007e},
+{0x87c4,    0x0087}, {0x87c5,    0x00fa}, {0x87c6,    0x00b6},
+{0x87c7,    0x008f}, {0x87c8,    0x0075}, {0x87c9,    0x0026},
+{0x87ca,    0x000a}, {0x87cb,    0x0018}, {0x87cc,    0x00ce},
+{0x87cd,    0x008f}, {0x87ce,    0x0073}, {0x87cf,    0x00bd},
+{0x87d0,    0x0089}, {0x87d1,    0x00d5}, {0x87d2,    0x007e},
+{0x87d3,    0x0087}, {0x87d4,    0x00fa}, {0x87d5,    0x00b6},
+{0x87d6,    0x008f}, {0x87d7,    0x0078}, {0x87d8,    0x0026},
+{0x87d9,    0x000a}, {0x87da,    0x0018}, {0x87db,    0x00ce},
+{0x87dc,    0x008f}, {0x87dd,    0x0076}, {0x87de,    0x00bd},
+{0x87df,    0x0089}, {0x87e0,    0x00d5}, {0x87e1,    0x007e},
+{0x87e2,    0x0087}, {0x87e3,    0x00fa}, {0x87e4,    0x00b6},
+{0x87e5,    0x008f}, {0x87e6,    0x007b}, {0x87e7,    0x0026},
+{0x87e8,    0x000a}, {0x87e9,    0x0018}, {0x87ea,    0x00ce},
+{0x87eb,    0x008f}, {0x87ec,    0x0079}, {0x87ed,    0x00bd},
+{0x87ee,    0x0089}, {0x87ef,    0x00d5}, {0x87f0,    0x007e},
+{0x87f1,    0x0087}, {0x87f2,    0x00fa}, {0x87f3,    0x0086},
+{0x87f4,    0x0005}, {0x87f5,    0x0097}, {0x87f6,    0x0040},
+{0x87f7,    0x007e}, {0x87f8,    0x0089}, {0x87f9,    0x0000},
+{0x87fa,    0x00b6}, {0x87fb,    0x008f}, {0x87fc,    0x0075},
+{0x87fd,    0x0081}, {0x87fe,    0x0007}, {0x87ff,    0x002e},
+{0x8800,    0x00f2}, {0x8801,    0x00f6}, {0x8802,    0x0012},
+{0x8803,    0x0006}, {0x8804,    0x00c4}, {0x8805,    0x00f8},
+{0x8806,    0x001b}, {0x8807,    0x00b7}, {0x8808,    0x0012},
+{0x8809,    0x0006}, {0x880a,    0x00b6}, {0x880b,    0x008f},
+{0x880c,    0x0078}, {0x880d,    0x0081}, {0x880e,    0x0007},
+{0x880f,    0x002e}, {0x8810,    0x00e2}, {0x8811,    0x0048},
+{0x8812,    0x0048}, {0x8813,    0x0048}, {0x8814,    0x00f6},
+{0x8815,    0x0012}, {0x8816,    0x0006}, {0x8817,    0x00c4},
+{0x8818,    0x00c7}, {0x8819,    0x001b}, {0x881a,    0x00b7},
+{0x881b,    0x0012}, {0x881c,    0x0006}, {0x881d,    0x00b6},
+{0x881e,    0x008f}, {0x881f,    0x007b}, {0x8820,    0x0081},
+{0x8821,    0x0007}, {0x8822,    0x002e}, {0x8823,    0x00cf},
+{0x8824,    0x00f6}, {0x8825,    0x0012}, {0x8826,    0x0005},
+{0x8827,    0x00c4}, {0x8828,    0x00f8}, {0x8829,    0x001b},
+{0x882a,    0x00b7}, {0x882b,    0x0012}, {0x882c,    0x0005},
+{0x882d,    0x0086}, {0x882e,    0x0000}, {0x882f,    0x00f6},
+{0x8830,    0x008f}, {0x8831,    0x0071}, {0x8832,    0x00bd},
+{0x8833,    0x0089}, {0x8834,    0x0094}, {0x8835,    0x0086},
+{0x8836,    0x0001}, {0x8837,    0x00f6}, {0x8838,    0x008f},
+{0x8839,    0x0074}, {0x883a,    0x00bd}, {0x883b,    0x0089},
+{0x883c,    0x0094}, {0x883d,    0x0086}, {0x883e,    0x0002},
+{0x883f,    0x00f6}, {0x8840,    0x008f}, {0x8841,    0x0077},
+{0x8842,    0x00bd}, {0x8843,    0x0089}, {0x8844,    0x0094},
+{0x8845,    0x0086}, {0x8846,    0x0003}, {0x8847,    0x00f6},
+{0x8848,    0x008f}, {0x8849,    0x007a}, {0x884a,    0x00bd},
+{0x884b,    0x0089}, {0x884c,    0x0094}, {0x884d,    0x00ce},
+{0x884e,    0x008f}, {0x884f,    0x0070}, {0x8850,    0x00a6},
+{0x8851,    0x0001}, {0x8852,    0x0081}, {0x8853,    0x0001},
+{0x8854,    0x0027}, {0x8855,    0x0007}, {0x8856,    0x0081},
+{0x8857,    0x0003}, {0x8858,    0x0027}, {0x8859,    0x0003},
+{0x885a,    0x007e}, {0x885b,    0x0088}, {0x885c,    0x0066},
+{0x885d,    0x00a6}, {0x885e,    0x0000}, {0x885f,    0x00b8},
+{0x8860,    0x008f}, {0x8861,    0x0081}, {0x8862,    0x0084},
+{0x8863,    0x0001}, {0x8864,    0x0026}, {0x8865,    0x000b},
+{0x8866,    0x008c}, {0x8867,    0x008f}, {0x8868,    0x0079},
+{0x8869,    0x002c}, {0x886a,    0x000e}, {0x886b,    0x0008},
+{0x886c,    0x0008}, {0x886d,    0x0008}, {0x886e,    0x007e},
+{0x886f,    0x0088}, {0x8870,    0x0050}, {0x8871,    0x00b6},
+{0x8872,    0x0012}, {0x8873,    0x0004}, {0x8874,    0x008a},
+{0x8875,    0x0040}, {0x8876,    0x00b7}, {0x8877,    0x0012},
+{0x8878,    0x0004}, {0x8879,    0x00b6}, {0x887a,    0x0012},
+{0x887b,    0x0004}, {0x887c,    0x0084}, {0x887d,    0x00fb},
+{0x887e,    0x0084}, {0x887f,    0x00ef}, {0x8880,    0x00b7},
+{0x8881,    0x0012}, {0x8882,    0x0004}, {0x8883,    0x00b6},
+{0x8884,    0x0012}, {0x8885,    0x0007}, {0x8886,    0x0036},
+{0x8887,    0x00b6}, {0x8888,    0x008f}, {0x8889,    0x007c},
+{0x888a,    0x0048}, {0x888b,    0x0048}, {0x888c,    0x00b7},
+{0x888d,    0x0012}, {0x888e,    0x0007}, {0x888f,    0x0086},
+{0x8890,    0x0001}, {0x8891,    0x00ba}, {0x8892,    0x0012},
+{0x8893,    0x0004}, {0x8894,    0x00b7}, {0x8895,    0x0012},
+{0x8896,    0x0004}, {0x8897,    0x0001}, {0x8898,    0x0001},
+{0x8899,    0x0001}, {0x889a,    0x0001}, {0x889b,    0x0001},
+{0x889c,    0x0001}, {0x889d,    0x0086}, {0x889e,    0x00fe},
+{0x889f,    0x00b4}, {0x88a0,    0x0012}, {0x88a1,    0x0004},
+{0x88a2,    0x00b7}, {0x88a3,    0x0012}, {0x88a4,    0x0004},
+{0x88a5,    0x0086}, {0x88a6,    0x0002}, {0x88a7,    0x00ba},
+{0x88a8,    0x0012}, {0x88a9,    0x0004}, {0x88aa,    0x00b7},
+{0x88ab,    0x0012}, {0x88ac,    0x0004}, {0x88ad,    0x0086},
+{0x88ae,    0x00fd}, {0x88af,    0x00b4}, {0x88b0,    0x0012},
+{0x88b1,    0x0004}, {0x88b2,    0x00b7}, {0x88b3,    0x0012},
+{0x88b4,    0x0004}, {0x88b5,    0x0032}, {0x88b6,    0x00b7},
+{0x88b7,    0x0012}, {0x88b8,    0x0007}, {0x88b9,    0x00b6},
+{0x88ba,    0x0012}, {0x88bb,    0x0000}, {0x88bc,    0x0084},
+{0x88bd,    0x0008}, {0x88be,    0x0081}, {0x88bf,    0x0008},
+{0x88c0,    0x0027}, {0x88c1,    0x000f}, {0x88c2,    0x007c},
+{0x88c3,    0x0082}, {0x88c4,    0x0008}, {0x88c5,    0x0026},
+{0x88c6,    0x0007}, {0x88c7,    0x0086}, {0x88c8,    0x0076},
+{0x88c9,    0x0097}, {0x88ca,    0x0040}, {0x88cb,    0x007e},
+{0x88cc,    0x0089}, {0x88cd,    0x006e}, {0x88ce,    0x007e},
+{0x88cf,    0x0086}, {0x88d0,    0x00ec}, {0x88d1,    0x00b6},
+{0x88d2,    0x008f}, {0x88d3,    0x007f}, {0x88d4,    0x0081},
+{0x88d5,    0x000f}, {0x88d6,    0x0027}, {0x88d7,    0x003c},
+{0x88d8,    0x00bd}, {0x88d9,    0x00e6}, {0x88da,    0x00c7},
+{0x88db,    0x00b7}, {0x88dc,    0x0012}, {0x88dd,    0x000d},
+{0x88de,    0x00bd}, {0x88df,    0x00e6}, {0x88e0,    0x00cb},
+{0x88e1,    0x00b6}, {0x88e2,    0x0012}, {0x88e3,    0x0004},
+{0x88e4,    0x008a}, {0x88e5,    0x0020}, {0x88e6,    0x00b7},
+{0x88e7,    0x0012}, {0x88e8,    0x0004}, {0x88e9,    0x00ce},
+{0x88ea,    0x00ff}, {0x88eb,    0x00ff}, {0x88ec,    0x00b6},
+{0x88ed,    0x0012}, {0x88ee,    0x0000}, {0x88ef,    0x0081},
+{0x88f0,    0x000c}, {0x88f1,    0x0026}, {0x88f2,    0x0005},
+{0x88f3,    0x0009}, {0x88f4,    0x0026}, {0x88f5,    0x00f6},
+{0x88f6,    0x0027}, {0x88f7,    0x001c}, {0x88f8,    0x00b6},
+{0x88f9,    0x0012}, {0x88fa,    0x0004}, {0x88fb,    0x0084},
+{0x88fc,    0x00df}, {0x88fd,    0x00b7}, {0x88fe,    0x0012},
+{0x88ff,    0x0004}, {0x8900,    0x0096}, {0x8901,    0x0083},
+{0x8902,    0x0081}, {0x8903,    0x0007}, {0x8904,    0x002c},
+{0x8905,    0x0005}, {0x8906,    0x007c}, {0x8907,    0x0000},
+{0x8908,    0x0083}, {0x8909,    0x0020}, {0x890a,    0x0006},
+{0x890b,    0x0096}, {0x890c,    0x0083}, {0x890d,    0x008b},
+{0x890e,    0x0008}, {0x890f,    0x0097}, {0x8910,    0x0083},
+{0x8911,    0x007e}, {0x8912,    0x0085}, {0x8913,    0x0041},
+{0x8914,    0x007f}, {0x8915,    0x008f}, {0x8916,    0x007e},
+{0x8917,    0x0086}, {0x8918,    0x0080}, {0x8919,    0x00b7},
+{0x891a,    0x0012}, {0x891b,    0x000c}, {0x891c,    0x0086},
+{0x891d,    0x0001}, {0x891e,    0x00b7}, {0x891f,    0x008f},
+{0x8920,    0x007d}, {0x8921,    0x00b6}, {0x8922,    0x0012},
+{0x8923,    0x000c}, {0x8924,    0x0084}, {0x8925,    0x007f},
+{0x8926,    0x00b7}, {0x8927,    0x0012}, {0x8928,    0x000c},
+{0x8929,    0x008a}, {0x892a,    0x0080}, {0x892b,    0x00b7},
+{0x892c,    0x0012}, {0x892d,    0x000c}, {0x892e,    0x0086},
+{0x892f,    0x000a}, {0x8930,    0x00bd}, {0x8931,    0x008a},
+{0x8932,    0x0006}, {0x8933,    0x00b6}, {0x8934,    0x0012},
+{0x8935,    0x000a}, {0x8936,    0x002a}, {0x8937,    0x0009},
+{0x8938,    0x00b6}, {0x8939,    0x0012}, {0x893a,    0x000c},
+{0x893b,    0x00ba}, {0x893c,    0x008f}, {0x893d,    0x007d},
+{0x893e,    0x00b7}, {0x893f,    0x0012}, {0x8940,    0x000c},
+{0x8941,    0x00b6}, {0x8942,    0x008f}, {0x8943,    0x007e},
+{0x8944,    0x0081}, {0x8945,    0x0060}, {0x8946,    0x0027},
+{0x8947,    0x001a}, {0x8948,    0x008b}, {0x8949,    0x0020},
+{0x894a,    0x00b7}, {0x894b,    0x008f}, {0x894c,    0x007e},
+{0x894d,    0x00b6}, {0x894e,    0x0012}, {0x894f,    0x000c},
+{0x8950,    0x0084}, {0x8951,    0x009f}, {0x8952,    0x00ba},
+{0x8953,    0x008f}, {0x8954,    0x007e}, {0x8955,    0x00b7},
+{0x8956,    0x0012}, {0x8957,    0x000c}, {0x8958,    0x00b6},
+{0x8959,    0x008f}, {0x895a,    0x007d}, {0x895b,    0x0048},
+{0x895c,    0x00b7}, {0x895d,    0x008f}, {0x895e,    0x007d},
+{0x895f,    0x007e}, {0x8960,    0x0089}, {0x8961,    0x0021},
+{0x8962,    0x00b6}, {0x8963,    0x0012}, {0x8964,    0x0004},
+{0x8965,    0x008a}, {0x8966,    0x0020}, {0x8967,    0x00b7},
+{0x8968,    0x0012}, {0x8969,    0x0004}, {0x896a,    0x00bd},
+{0x896b,    0x008a}, {0x896c,    0x000a}, {0x896d,    0x004f},
+{0x896e,    0x0039}, {0x896f,    0x00a6}, {0x8970,    0x0000},
+{0x8971,    0x0018}, {0x8972,    0x00a7}, {0x8973,    0x0000},
+{0x8974,    0x0008}, {0x8975,    0x0018}, {0x8976,    0x0008},
+{0x8977,    0x005a}, {0x8978,    0x0026}, {0x8979,    0x00f5},
+{0x897a,    0x0039}, {0x897b,    0x0036}, {0x897c,    0x006c},
+{0x897d,    0x0000}, {0x897e,    0x0032}, {0x897f,    0x00ba},
+{0x8980,    0x008f}, {0x8981,    0x007f}, {0x8982,    0x00b7},
+{0x8983,    0x008f}, {0x8984,    0x007f}, {0x8985,    0x00b6},
+{0x8986,    0x0012}, {0x8987,    0x0009}, {0x8988,    0x0084},
+{0x8989,    0x0003}, {0x898a,    0x00a7}, {0x898b,    0x0001},
+{0x898c,    0x00b6}, {0x898d,    0x0012}, {0x898e,    0x0006},
+{0x898f,    0x0084}, {0x8990,    0x003f}, {0x8991,    0x00a7},
+{0x8992,    0x0002}, {0x8993,    0x0039}, {0x8994,    0x0036},
+{0x8995,    0x0086}, {0x8996,    0x0003}, {0x8997,    0x00b7},
+{0x8998,    0x008f}, {0x8999,    0x0080}, {0x899a,    0x0032},
+{0x899b,    0x00c1}, {0x899c,    0x0000}, {0x899d,    0x0026},
+{0x899e,    0x0006}, {0x899f,    0x00b7}, {0x89a0,    0x008f},
+{0x89a1,    0x007c}, {0x89a2,    0x007e}, {0x89a3,    0x0089},
+{0x89a4,    0x00c9}, {0x89a5,    0x00c1}, {0x89a6,    0x0001},
+{0x89a7,    0x0027}, {0x89a8,    0x0018}, {0x89a9,    0x00c1},
+{0x89aa,    0x0002}, {0x89ab,    0x0027}, {0x89ac,    0x000c},
+{0x89ad,    0x00c1}, {0x89ae,    0x0003}, {0x89af,    0x0027},
+{0x89b0,    0x0000}, {0x89b1,    0x00f6}, {0x89b2,    0x008f},
+{0x89b3,    0x0080}, {0x89b4,    0x0005}, {0x89b5,    0x0005},
+{0x89b6,    0x00f7}, {0x89b7,    0x008f}, {0x89b8,    0x0080},
+{0x89b9,    0x00f6}, {0x89ba,    0x008f}, {0x89bb,    0x0080},
+{0x89bc,    0x0005}, {0x89bd,    0x0005}, {0x89be,    0x00f7},
+{0x89bf,    0x008f}, {0x89c0,    0x0080}, {0x89c1,    0x00f6},
+{0x89c2,    0x008f}, {0x89c3,    0x0080}, {0x89c4,    0x0005},
+{0x89c5,    0x0005}, {0x89c6,    0x00f7}, {0x89c7,    0x008f},
+{0x89c8,    0x0080}, {0x89c9,    0x00f6}, {0x89ca,    0x008f},
+{0x89cb,    0x0080}, {0x89cc,    0x0053}, {0x89cd,    0x00f4},
+{0x89ce,    0x0012}, {0x89cf,    0x0007}, {0x89d0,    0x001b},
+{0x89d1,    0x00b7}, {0x89d2,    0x0012}, {0x89d3,    0x0007},
+{0x89d4,    0x0039}, {0x89d5,    0x00ce}, {0x89d6,    0x008f},
+{0x89d7,    0x0070}, {0x89d8,    0x00a6}, {0x89d9,    0x0000},
+{0x89da,    0x0018}, {0x89db,    0x00e6}, {0x89dc,    0x0000},
+{0x89dd,    0x0018}, {0x89de,    0x00a7}, {0x89df,    0x0000},
+{0x89e0,    0x00e7}, {0x89e1,    0x0000}, {0x89e2,    0x00a6},
+{0x89e3,    0x0001}, {0x89e4,    0x0018}, {0x89e5,    0x00e6},
+{0x89e6,    0x0001}, {0x89e7,    0x0018}, {0x89e8,    0x00a7},
+{0x89e9,    0x0001}, {0x89ea,    0x00e7}, {0x89eb,    0x0001},
+{0x89ec,    0x00a6}, {0x89ed,    0x0002}, {0x89ee,    0x0018},
+{0x89ef,    0x00e6}, {0x89f0,    0x0002}, {0x89f1,    0x0018},
+{0x89f2,    0x00a7}, {0x89f3,    0x0002}, {0x89f4,    0x00e7},
+{0x89f5,    0x0002}, {0x89f6,    0x0039}, {0x89f7,    0x00a6},
+{0x89f8,    0x0000}, {0x89f9,    0x0084}, {0x89fa,    0x0007},
+{0x89fb,    0x00e6}, {0x89fc,    0x0000}, {0x89fd,    0x00c4},
+{0x89fe,    0x0038}, {0x89ff,    0x0054}, {0x8a00,    0x0054},
+{0x8a01,    0x0054}, {0x8a02,    0x001b}, {0x8a03,    0x00a7},
+{0x8a04,    0x0000}, {0x8a05,    0x0039}, {0x8a06,    0x004a},
+{0x8a07,    0x0026}, {0x8a08,    0x00fd}, {0x8a09,    0x0039},
+{0x8a0a,    0x0096}, {0x8a0b,    0x0022}, {0x8a0c,    0x0084},
+{0x8a0d,    0x000f}, {0x8a0e,    0x0097}, {0x8a0f,    0x0022},
+{0x8a10,    0x0086}, {0x8a11,    0x0001}, {0x8a12,    0x00b7},
+{0x8a13,    0x008f}, {0x8a14,    0x0070}, {0x8a15,    0x00b6},
+{0x8a16,    0x0012}, {0x8a17,    0x0007}, {0x8a18,    0x00b7},
+{0x8a19,    0x008f}, {0x8a1a,    0x0071}, {0x8a1b,    0x00f6},
+{0x8a1c,    0x0012}, {0x8a1d,    0x000c}, {0x8a1e,    0x00c4},
+{0x8a1f,    0x000f}, {0x8a20,    0x00c8}, {0x8a21,    0x000f},
+{0x8a22,    0x00f7}, {0x8a23,    0x008f}, {0x8a24,    0x0072},
+{0x8a25,    0x00f6}, {0x8a26,    0x008f}, {0x8a27,    0x0072},
+{0x8a28,    0x00b6}, {0x8a29,    0x008f}, {0x8a2a,    0x0071},
+{0x8a2b,    0x0084}, {0x8a2c,    0x0003}, {0x8a2d,    0x0027},
+{0x8a2e,    0x0014}, {0x8a2f,    0x0081}, {0x8a30,    0x0001},
+{0x8a31,    0x0027}, {0x8a32,    0x001c}, {0x8a33,    0x0081},
+{0x8a34,    0x0002}, {0x8a35,    0x0027}, {0x8a36,    0x0024},
+{0x8a37,    0x00f4}, {0x8a38,    0x008f}, {0x8a39,    0x0070},
+{0x8a3a,    0x0027}, {0x8a3b,    0x002a}, {0x8a3c,    0x0096},
+{0x8a3d,    0x0022}, {0x8a3e,    0x008a}, {0x8a3f,    0x0080},
+{0x8a40,    0x007e}, {0x8a41,    0x008a}, {0x8a42,    0x0064},
+{0x8a43,    0x00f4}, {0x8a44,    0x008f}, {0x8a45,    0x0070},
+{0x8a46,    0x0027}, {0x8a47,    0x001e}, {0x8a48,    0x0096},
+{0x8a49,    0x0022}, {0x8a4a,    0x008a}, {0x8a4b,    0x0010},
+{0x8a4c,    0x007e}, {0x8a4d,    0x008a}, {0x8a4e,    0x0064},
+{0x8a4f,    0x00f4}, {0x8a50,    0x008f}, {0x8a51,    0x0070},
+{0x8a52,    0x0027}, {0x8a53,    0x0012}, {0x8a54,    0x0096},
+{0x8a55,    0x0022}, {0x8a56,    0x008a}, {0x8a57,    0x0020},
+{0x8a58,    0x007e}, {0x8a59,    0x008a}, {0x8a5a,    0x0064},
+{0x8a5b,    0x00f4}, {0x8a5c,    0x008f}, {0x8a5d,    0x0070},
+{0x8a5e,    0x0027}, {0x8a5f,    0x0006}, {0x8a60,    0x0096},
+{0x8a61,    0x0022}, {0x8a62,    0x008a}, {0x8a63,    0x0040},
+{0x8a64,    0x0097}, {0x8a65,    0x0022}, {0x8a66,    0x0074},
+{0x8a67,    0x008f}, {0x8a68,    0x0071}, {0x8a69,    0x0074},
+{0x8a6a,    0x008f}, {0x8a6b,    0x0071}, {0x8a6c,    0x0078},
+{0x8a6d,    0x008f}, {0x8a6e,    0x0070}, {0x8a6f,    0x00b6},
+{0x8a70,    0x008f}, {0x8a71,    0x0070}, {0x8a72,    0x0085},
+{0x8a73,    0x0010}, {0x8a74,    0x0027}, {0x8a75,    0x00af},
+{0x8a76,    0x00d6}, {0x8a77,    0x0022}, {0x8a78,    0x00c4},
+{0x8a79,    0x0010}, {0x8a7a,    0x0058}, {0x8a7b,    0x00b6},
+{0x8a7c,    0x0012}, {0x8a7d,    0x0070}, {0x8a7e,    0x0081},
+{0x8a7f,    0x00e4}, {0x8a80,    0x0027}, {0x8a81,    0x0036},
+{0x8a82,    0x0081}, {0x8a83,    0x00e1}, {0x8a84,    0x0026},
+{0x8a85,    0x000c}, {0x8a86,    0x0096}, {0x8a87,    0x0022},
+{0x8a88,    0x0084}, {0x8a89,    0x0020}, {0x8a8a,    0x0044},
+{0x8a8b,    0x001b}, {0x8a8c,    0x00d6}, {0x8a8d,    0x0022},
+{0x8a8e,    0x00c4}, {0x8a8f,    0x00cf}, {0x8a90,    0x0020},
+{0x8a91,    0x0023}, {0x8a92,    0x0058}, {0x8a93,    0x0081},
+{0x8a94,    0x00c6}, {0x8a95,    0x0026}, {0x8a96,    0x000d},
+{0x8a97,    0x0096}, {0x8a98,    0x0022}, {0x8a99,    0x0084},
+{0x8a9a,    0x0040}, {0x8a9b,    0x0044}, {0x8a9c,    0x0044},
+{0x8a9d,    0x001b}, {0x8a9e,    0x00d6}, {0x8a9f,    0x0022},
+{0x8aa0,    0x00c4}, {0x8aa1,    0x00af}, {0x8aa2,    0x0020},
+{0x8aa3,    0x0011}, {0x8aa4,    0x0058}, {0x8aa5,    0x0081},
+{0x8aa6,    0x0027}, {0x8aa7,    0x0026}, {0x8aa8,    0x000f},
+{0x8aa9,    0x0096}, {0x8aaa,    0x0022}, {0x8aab,    0x0084},
+{0x8aac,    0x0080}, {0x8aad,    0x0044}, {0x8aae,    0x0044},
+{0x8aaf,    0x0044}, {0x8ab0,    0x001b}, {0x8ab1,    0x00d6},
+{0x8ab2,    0x0022}, {0x8ab3,    0x00c4}, {0x8ab4,    0x006f},
+{0x8ab5,    0x001b}, {0x8ab6,    0x0097}, {0x8ab7,    0x0022},
+{0x8ab8,    0x0039}, {0x8ab9,    0x0027}, {0x8aba,    0x000c},
+{0x8abb,    0x007c}, {0x8abc,    0x0082}, {0x8abd,    0x0006},
+{0x8abe,    0x00bd}, {0x8abf,    0x00d9}, {0x8ac0,    0x00ed},
+{0x8ac1,    0x00b6}, {0x8ac2,    0x0082}, {0x8ac3,    0x0007},
+{0x8ac4,    0x007e}, {0x8ac5,    0x008a}, {0x8ac6,    0x00b9},
+{0x8ac7,    0x007f}, {0x8ac8,    0x0082}, {0x8ac9,    0x0006},
+{0x8aca,    0x0039}, { 0x0, 0x0 }
+};
+#else
+cas_saturn_patch_t cas_saturn_patch[] = {
+{0x8200,    0x007e}, {0x8201,    0x0082}, {0x8202,    0x0009},
+{0x8203,    0x0000}, {0x8204,    0x0000}, {0x8205,    0x0000},
+{0x8206,    0x0000}, {0x8207,    0x0000}, {0x8208,    0x0000},
+{0x8209,    0x008e}, {0x820a,    0x008e}, {0x820b,    0x00ff},
+{0x820c,    0x00ce}, {0x820d,    0x0082}, {0x820e,    0x0025},
+{0x820f,    0x00ff}, {0x8210,    0x0001}, {0x8211,    0x000f},
+{0x8212,    0x00ce}, {0x8213,    0x0084}, {0x8214,    0x0026},
+{0x8215,    0x00ff}, {0x8216,    0x0001}, {0x8217,    0x0011},
+{0x8218,    0x00ce}, {0x8219,    0x0085}, {0x821a,    0x003d},
+{0x821b,    0x00df}, {0x821c,    0x00e5}, {0x821d,    0x0086},
+{0x821e,    0x0039}, {0x821f,    0x00b7}, {0x8220,    0x008f},
+{0x8221,    0x00f8}, {0x8222,    0x007e}, {0x8223,    0x00c3},
+{0x8224,    0x00c2}, {0x8225,    0x0096}, {0x8226,    0x0047},
+{0x8227,    0x0084}, {0x8228,    0x00f3}, {0x8229,    0x008a},
+{0x822a,    0x0000}, {0x822b,    0x0097}, {0x822c,    0x0047},
+{0x822d,    0x00ce}, {0x822e,    0x0082}, {0x822f,    0x0033},
+{0x8230,    0x00ff}, {0x8231,    0x0001}, {0x8232,    0x000f},
+{0x8233,    0x0096}, {0x8234,    0x0046}, {0x8235,    0x0084},
+{0x8236,    0x000c}, {0x8237,    0x0081}, {0x8238,    0x0004},
+{0x8239,    0x0027}, {0x823a,    0x000b}, {0x823b,    0x0096},
+{0x823c,    0x0046}, {0x823d,    0x0084}, {0x823e,    0x000c},
+{0x823f,    0x0081}, {0x8240,    0x0008}, {0x8241,    0x0027},
+{0x8242,    0x0057}, {0x8243,    0x007e}, {0x8244,    0x0084},
+{0x8245,    0x0025}, {0x8246,    0x0096}, {0x8247,    0x0047},
+{0x8248,    0x0084}, {0x8249,    0x00f3}, {0x824a,    0x008a},
+{0x824b,    0x0004}, {0x824c,    0x0097}, {0x824d,    0x0047},
+{0x824e,    0x00ce}, {0x824f,    0x0082}, {0x8250,    0x0054},
+{0x8251,    0x00ff}, {0x8252,    0x0001}, {0x8253,    0x000f},
+{0x8254,    0x0096}, {0x8255,    0x0046}, {0x8256,    0x0084},
+{0x8257,    0x000c}, {0x8258,    0x0081}, {0x8259,    0x0004},
+{0x825a,    0x0026}, {0x825b,    0x0038}, {0x825c,    0x00b6},
+{0x825d,    0x0012}, {0x825e,    0x0020}, {0x825f,    0x0084},
+{0x8260,    0x0020}, {0x8261,    0x0026}, {0x8262,    0x0003},
+{0x8263,    0x007e}, {0x8264,    0x0084}, {0x8265,    0x0025},
+{0x8266,    0x0096}, {0x8267,    0x007b}, {0x8268,    0x00d6},
+{0x8269,    0x007c}, {0x826a,    0x00fe}, {0x826b,    0x008f},
+{0x826c,    0x0056}, {0x826d,    0x00bd}, {0x826e,    0x00f7},
+{0x826f,    0x00b6}, {0x8270,    0x00fe}, {0x8271,    0x008f},
+{0x8272,    0x004e}, {0x8273,    0x00bd}, {0x8274,    0x00ec},
+{0x8275,    0x008e}, {0x8276,    0x00bd}, {0x8277,    0x00fa},
+{0x8278,    0x00f7}, {0x8279,    0x00bd}, {0x827a,    0x00f7},
+{0x827b,    0x0028}, {0x827c,    0x00ce}, {0x827d,    0x0082},
+{0x827e,    0x0082}, {0x827f,    0x00ff}, {0x8280,    0x0001},
+{0x8281,    0x000f}, {0x8282,    0x0096}, {0x8283,    0x0046},
+{0x8284,    0x0084}, {0x8285,    0x000c}, {0x8286,    0x0081},
+{0x8287,    0x0004}, {0x8288,    0x0026}, {0x8289,    0x000a},
+{0x828a,    0x00b6}, {0x828b,    0x0012}, {0x828c,    0x0020},
+{0x828d,    0x0084}, {0x828e,    0x0020}, {0x828f,    0x0027},
+{0x8290,    0x00b5}, {0x8291,    0x007e}, {0x8292,    0x0084},
+{0x8293,    0x0025}, {0x8294,    0x00bd}, {0x8295,    0x00f7},
+{0x8296,    0x001f}, {0x8297,    0x007e}, {0x8298,    0x0084},
+{0x8299,    0x001f}, {0x829a,    0x0096}, {0x829b,    0x0047},
+{0x829c,    0x0084}, {0x829d,    0x00f3}, {0x829e,    0x008a},
+{0x829f,    0x0008}, {0x82a0,    0x0097}, {0x82a1,    0x0047},
+{0x82a2,    0x00de}, {0x82a3,    0x00e1}, {0x82a4,    0x00ad},
+{0x82a5,    0x0000}, {0x82a6,    0x00ce}, {0x82a7,    0x0082},
+{0x82a8,    0x00af}, {0x82a9,    0x00ff}, {0x82aa,    0x0001},
+{0x82ab,    0x000f}, {0x82ac,    0x007e}, {0x82ad,    0x0084},
+{0x82ae,    0x0025}, {0x82af,    0x0096}, {0x82b0,    0x0041},
+{0x82b1,    0x0085}, {0x82b2,    0x0010}, {0x82b3,    0x0026},
+{0x82b4,    0x0006}, {0x82b5,    0x0096}, {0x82b6,    0x0023},
+{0x82b7,    0x0085}, {0x82b8,    0x0040}, {0x82b9,    0x0027},
+{0x82ba,    0x0006}, {0x82bb,    0x00bd}, {0x82bc,    0x00ed},
+{0x82bd,    0x0000}, {0x82be,    0x007e}, {0x82bf,    0x0083},
+{0x82c0,    0x00a2}, {0x82c1,    0x00de}, {0x82c2,    0x0042},
+{0x82c3,    0x00bd}, {0x82c4,    0x00eb}, {0x82c5,    0x008e},
+{0x82c6,    0x0096}, {0x82c7,    0x0024}, {0x82c8,    0x0084},
+{0x82c9,    0x0008}, {0x82ca,    0x0027}, {0x82cb,    0x0003},
+{0x82cc,    0x007e}, {0x82cd,    0x0083}, {0x82ce,    0x00df},
+{0x82cf,    0x0096}, {0x82d0,    0x007b}, {0x82d1,    0x00d6},
+{0x82d2,    0x007c}, {0x82d3,    0x00fe}, {0x82d4,    0x008f},
+{0x82d5,    0x0056}, {0x82d6,    0x00bd}, {0x82d7,    0x00f7},
+{0x82d8,    0x00b6}, {0x82d9,    0x00fe}, {0x82da,    0x008f},
+{0x82db,    0x0050}, {0x82dc,    0x00bd}, {0x82dd,    0x00ec},
+{0x82de,    0x008e}, {0x82df,    0x00bd}, {0x82e0,    0x00fa},
+{0x82e1,    0x00f7}, {0x82e2,    0x0086}, {0x82e3,    0x0011},
+{0x82e4,    0x00c6}, {0x82e5,    0x0049}, {0x82e6,    0x00bd},
+{0x82e7,    0x00e4}, {0x82e8,    0x0012}, {0x82e9,    0x00ce},
+{0x82ea,    0x0082}, {0x82eb,    0x00ef}, {0x82ec,    0x00ff},
+{0x82ed,    0x0001}, {0x82ee,    0x000f}, {0x82ef,    0x0096},
+{0x82f0,    0x0046}, {0x82f1,    0x0084}, {0x82f2,    0x000c},
+{0x82f3,    0x0081}, {0x82f4,    0x0000}, {0x82f5,    0x0027},
+{0x82f6,    0x0017}, {0x82f7,    0x00c6}, {0x82f8,    0x0049},
+{0x82f9,    0x00bd}, {0x82fa,    0x00e4}, {0x82fb,    0x0091},
+{0x82fc,    0x0024}, {0x82fd,    0x000d}, {0x82fe,    0x00b6},
+{0x82ff,    0x0012}, {0x8300,    0x0020}, {0x8301,    0x0085},
+{0x8302,    0x0020}, {0x8303,    0x0026}, {0x8304,    0x000c},
+{0x8305,    0x00ce}, {0x8306,    0x0082}, {0x8307,    0x00c1},
+{0x8308,    0x00ff}, {0x8309,    0x0001}, {0x830a,    0x000f},
+{0x830b,    0x007e}, {0x830c,    0x0084}, {0x830d,    0x0025},
+{0x830e,    0x007e}, {0x830f,    0x0084}, {0x8310,    0x0016},
+{0x8311,    0x00fe}, {0x8312,    0x008f}, {0x8313,    0x0052},
+{0x8314,    0x00bd}, {0x8315,    0x00ec}, {0x8316,    0x008e},
+{0x8317,    0x00bd}, {0x8318,    0x00fa}, {0x8319,    0x00f7},
+{0x831a,    0x0086}, {0x831b,    0x006a}, {0x831c,    0x00c6},
+{0x831d,    0x0049}, {0x831e,    0x00bd}, {0x831f,    0x00e4},
+{0x8320,    0x0012}, {0x8321,    0x00ce}, {0x8322,    0x0083},
+{0x8323,    0x0027}, {0x8324,    0x00ff}, {0x8325,    0x0001},
+{0x8326,    0x000f}, {0x8327,    0x0096}, {0x8328,    0x0046},
+{0x8329,    0x0084}, {0x832a,    0x000c}, {0x832b,    0x0081},
+{0x832c,    0x0000}, {0x832d,    0x0027}, {0x832e,    0x000a},
+{0x832f,    0x00c6}, {0x8330,    0x0049}, {0x8331,    0x00bd},
+{0x8332,    0x00e4}, {0x8333,    0x0091}, {0x8334,    0x0025},
+{0x8335,    0x0006}, {0x8336,    0x007e}, {0x8337,    0x0084},
+{0x8338,    0x0025}, {0x8339,    0x007e}, {0x833a,    0x0084},
+{0x833b,    0x0016}, {0x833c,    0x00b6}, {0x833d,    0x0018},
+{0x833e,    0x0070}, {0x833f,    0x00bb}, {0x8340,    0x0019},
+{0x8341,    0x0070}, {0x8342,    0x002a}, {0x8343,    0x0004},
+{0x8344,    0x0081}, {0x8345,    0x00af}, {0x8346,    0x002e},
+{0x8347,    0x0019}, {0x8348,    0x0096}, {0x8349,    0x007b},
+{0x834a,    0x00f6}, {0x834b,    0x0020}, {0x834c,    0x0007},
+{0x834d,    0x00fa}, {0x834e,    0x0020}, {0x834f,    0x0027},
+{0x8350,    0x00c4}, {0x8351,    0x0038}, {0x8352,    0x0081},
+{0x8353,    0x0038}, {0x8354,    0x0027}, {0x8355,    0x000b},
+{0x8356,    0x00f6}, {0x8357,    0x0020}, {0x8358,    0x0007},
+{0x8359,    0x00fa}, {0x835a,    0x0020}, {0x835b,    0x0027},
+{0x835c,    0x00cb}, {0x835d,    0x0008}, {0x835e,    0x007e},
+{0x835f,    0x0082}, {0x8360,    0x00d3}, {0x8361,    0x00bd},
+{0x8362,    0x00f7}, {0x8363,    0x0066}, {0x8364,    0x0086},
+{0x8365,    0x0074}, {0x8366,    0x00c6}, {0x8367,    0x0049},
+{0x8368,    0x00bd}, {0x8369,    0x00e4}, {0x836a,    0x0012},
+{0x836b,    0x00ce}, {0x836c,    0x0083}, {0x836d,    0x0071},
+{0x836e,    0x00ff}, {0x836f,    0x0001}, {0x8370,    0x000f},
+{0x8371,    0x0096}, {0x8372,    0x0046}, {0x8373,    0x0084},
+{0x8374,    0x000c}, {0x8375,    0x0081}, {0x8376,    0x0008},
+{0x8377,    0x0026}, {0x8378,    0x000a}, {0x8379,    0x00c6},
+{0x837a,    0x0049}, {0x837b,    0x00bd}, {0x837c,    0x00e4},
+{0x837d,    0x0091}, {0x837e,    0x0025}, {0x837f,    0x0006},
+{0x8380,    0x007e}, {0x8381,    0x0084}, {0x8382,    0x0025},
+{0x8383,    0x007e}, {0x8384,    0x0084}, {0x8385,    0x0016},
+{0x8386,    0x00bd}, {0x8387,    0x00f7}, {0x8388,    0x003e},
+{0x8389,    0x0026}, {0x838a,    0x000e}, {0x838b,    0x00bd},
+{0x838c,    0x00e5}, {0x838d,    0x0009}, {0x838e,    0x0026},
+{0x838f,    0x0006}, {0x8390,    0x00ce}, {0x8391,    0x0082},
+{0x8392,    0x00c1}, {0x8393,    0x00ff}, {0x8394,    0x0001},
+{0x8395,    0x000f}, {0x8396,    0x007e}, {0x8397,    0x0084},
+{0x8398,    0x0025}, {0x8399,    0x00fe}, {0x839a,    0x008f},
+{0x839b,    0x0054}, {0x839c,    0x00bd}, {0x839d,    0x00ec},
+{0x839e,    0x008e}, {0x839f,    0x00bd}, {0x83a0,    0x00fa},
+{0x83a1,    0x00f7}, {0x83a2,    0x00bd}, {0x83a3,    0x00f7},
+{0x83a4,    0x0033}, {0x83a5,    0x0086}, {0x83a6,    0x000f},
+{0x83a7,    0x00c6}, {0x83a8,    0x0051}, {0x83a9,    0x00bd},
+{0x83aa,    0x00e4}, {0x83ab,    0x0012}, {0x83ac,    0x00ce},
+{0x83ad,    0x0083}, {0x83ae,    0x00b2}, {0x83af,    0x00ff},
+{0x83b0,    0x0001}, {0x83b1,    0x000f}, {0x83b2,    0x0096},
+{0x83b3,    0x0046}, {0x83b4,    0x0084}, {0x83b5,    0x000c},
+{0x83b6,    0x0081}, {0x83b7,    0x0008}, {0x83b8,    0x0026},
+{0x83b9,    0x005c}, {0x83ba,    0x00b6}, {0x83bb,    0x0012},
+{0x83bc,    0x0020}, {0x83bd,    0x0084}, {0x83be,    0x003f},
+{0x83bf,    0x0081}, {0x83c0,    0x003a}, {0x83c1,    0x0027},
+{0x83c2,    0x001c}, {0x83c3,    0x0096}, {0x83c4,    0x0023},
+{0x83c5,    0x0085}, {0x83c6,    0x0040}, {0x83c7,    0x0027},
+{0x83c8,    0x0003}, {0x83c9,    0x007e}, {0x83ca,    0x0084},
+{0x83cb,    0x0025}, {0x83cc,    0x00c6}, {0x83cd,    0x0051},
+{0x83ce,    0x00bd}, {0x83cf,    0x00e4}, {0x83d0,    0x0091},
+{0x83d1,    0x0025}, {0x83d2,    0x0003}, {0x83d3,    0x007e},
+{0x83d4,    0x0084}, {0x83d5,    0x0025}, {0x83d6,    0x00ce},
+{0x83d7,    0x0082}, {0x83d8,    0x00c1}, {0x83d9,    0x00ff},
+{0x83da,    0x0001}, {0x83db,    0x000f}, {0x83dc,    0x007e},
+{0x83dd,    0x0084}, {0x83de,    0x0025}, {0x83df,    0x00bd},
+{0x83e0,    0x00f8}, {0x83e1,    0x0037}, {0x83e2,    0x007c},
+{0x83e3,    0x0000}, {0x83e4,    0x007a}, {0x83e5,    0x00ce},
+{0x83e6,    0x0083}, {0x83e7,    0x00ee}, {0x83e8,    0x00ff},
+{0x83e9,    0x0001}, {0x83ea,    0x000f}, {0x83eb,    0x007e},
+{0x83ec,    0x0084}, {0x83ed,    0x0025}, {0x83ee,    0x0096},
+{0x83ef,    0x0046}, {0x83f0,    0x0084}, {0x83f1,    0x000c},
+{0x83f2,    0x0081}, {0x83f3,    0x0008}, {0x83f4,    0x0026},
+{0x83f5,    0x0020}, {0x83f6,    0x0096}, {0x83f7,    0x0024},
+{0x83f8,    0x0084}, {0x83f9,    0x0008}, {0x83fa,    0x0026},
+{0x83fb,    0x0029}, {0x83fc,    0x00b6}, {0x83fd,    0x0018},
+{0x83fe,    0x0082}, {0x83ff,    0x00bb}, {0x8400,    0x0019},
+{0x8401,    0x0082}, {0x8402,    0x00b1}, {0x8403,    0x0001},
+{0x8404,    0x003b}, {0x8405,    0x0022}, {0x8406,    0x0009},
+{0x8407,    0x00b6}, {0x8408,    0x0012}, {0x8409,    0x0020},
+{0x840a,    0x0084}, {0x840b,    0x0037}, {0x840c,    0x0081},
+{0x840d,    0x0032}, {0x840e,    0x0027}, {0x840f,    0x0015},
+{0x8410,    0x00bd}, {0x8411,    0x00f8}, {0x8412,    0x0044},
+{0x8413,    0x007e}, {0x8414,    0x0082}, {0x8415,    0x00c1},
+{0x8416,    0x00bd}, {0x8417,    0x00f7}, {0x8418,    0x001f},
+{0x8419,    0x00bd}, {0x841a,    0x00f8}, {0x841b,    0x0044},
+{0x841c,    0x00bd}, {0x841d,    0x00fc}, {0x841e,    0x0029},
+{0x841f,    0x00ce}, {0x8420,    0x0082}, {0x8421,    0x0025},
+{0x8422,    0x00ff}, {0x8423,    0x0001}, {0x8424,    0x000f},
+{0x8425,    0x0039}, {0x8426,    0x0096}, {0x8427,    0x0047},
+{0x8428,    0x0084}, {0x8429,    0x00fc}, {0x842a,    0x008a},
+{0x842b,    0x0000}, {0x842c,    0x0097}, {0x842d,    0x0047},
+{0x842e,    0x00ce}, {0x842f,    0x0084}, {0x8430,    0x0034},
+{0x8431,    0x00ff}, {0x8432,    0x0001}, {0x8433,    0x0011},
+{0x8434,    0x0096}, {0x8435,    0x0046}, {0x8436,    0x0084},
+{0x8437,    0x0003}, {0x8438,    0x0081}, {0x8439,    0x0002},
+{0x843a,    0x0027}, {0x843b,    0x0003}, {0x843c,    0x007e},
+{0x843d,    0x0085}, {0x843e,    0x001e}, {0x843f,    0x0096},
+{0x8440,    0x0047}, {0x8441,    0x0084}, {0x8442,    0x00fc},
+{0x8443,    0x008a}, {0x8444,    0x0002}, {0x8445,    0x0097},
+{0x8446,    0x0047}, {0x8447,    0x00de}, {0x8448,    0x00e1},
+{0x8449,    0x00ad}, {0x844a,    0x0000}, {0x844b,    0x0086},
+{0x844c,    0x0001}, {0x844d,    0x00b7}, {0x844e,    0x0012},
+{0x844f,    0x0051}, {0x8450,    0x00bd}, {0x8451,    0x00f7},
+{0x8452,    0x0014}, {0x8453,    0x00b6}, {0x8454,    0x0010},
+{0x8455,    0x0031}, {0x8456,    0x0084}, {0x8457,    0x00fd},
+{0x8458,    0x00b7}, {0x8459,    0x0010}, {0x845a,    0x0031},
+{0x845b,    0x00bd}, {0x845c,    0x00f8}, {0x845d,    0x001e},
+{0x845e,    0x0096}, {0x845f,    0x0081}, {0x8460,    0x00d6},
+{0x8461,    0x0082}, {0x8462,    0x00fe}, {0x8463,    0x008f},
+{0x8464,    0x005a}, {0x8465,    0x00bd}, {0x8466,    0x00f7},
+{0x8467,    0x00b6}, {0x8468,    0x00fe}, {0x8469,    0x008f},
+{0x846a,    0x005c}, {0x846b,    0x00bd}, {0x846c,    0x00ec},
+{0x846d,    0x008e}, {0x846e,    0x00bd}, {0x846f,    0x00fa},
+{0x8470,    0x00f7}, {0x8471,    0x0086}, {0x8472,    0x0008},
+{0x8473,    0x00d6}, {0x8474,    0x0000}, {0x8475,    0x00c5},
+{0x8476,    0x0010}, {0x8477,    0x0026}, {0x8478,    0x0002},
+{0x8479,    0x008b}, {0x847a,    0x0020}, {0x847b,    0x00c6},
+{0x847c,    0x0051}, {0x847d,    0x00bd}, {0x847e,    0x00e4},
+{0x847f,    0x0012}, {0x8480,    0x00ce}, {0x8481,    0x0084},
+{0x8482,    0x0086}, {0x8483,    0x00ff}, {0x8484,    0x0001},
+{0x8485,    0x0011}, {0x8486,    0x0096}, {0x8487,    0x0046},
+{0x8488,    0x0084}, {0x8489,    0x0003}, {0x848a,    0x0081},
+{0x848b,    0x0002}, {0x848c,    0x0027}, {0x848d,    0x0003},
+{0x848e,    0x007e}, {0x848f,    0x0085}, {0x8490,    0x000f},
+{0x8491,    0x00c6}, {0x8492,    0x0051}, {0x8493,    0x00bd},
+{0x8494,    0x00e4}, {0x8495,    0x0091}, {0x8496,    0x0025},
+{0x8497,    0x0003}, {0x8498,    0x007e}, {0x8499,    0x0085},
+{0x849a,    0x001e}, {0x849b,    0x0096}, {0x849c,    0x0044},
+{0x849d,    0x0085}, {0x849e,    0x0010}, {0x849f,    0x0026},
+{0x84a0,    0x000a}, {0x84a1,    0x00b6}, {0x84a2,    0x0012},
+{0x84a3,    0x0050}, {0x84a4,    0x00ba}, {0x84a5,    0x0001},
+{0x84a6,    0x003c}, {0x84a7,    0x0085}, {0x84a8,    0x0010},
+{0x84a9,    0x0027}, {0x84aa,    0x00a8}, {0x84ab,    0x00bd},
+{0x84ac,    0x00f7}, {0x84ad,    0x0066}, {0x84ae,    0x00ce},
+{0x84af,    0x0084}, {0x84b0,    0x00b7}, {0x84b1,    0x00ff},
+{0x84b2,    0x0001}, {0x84b3,    0x0011}, {0x84b4,    0x007e},
+{0x84b5,    0x0085}, {0x84b6,    0x001e}, {0x84b7,    0x0096},
+{0x84b8,    0x0046}, {0x84b9,    0x0084}, {0x84ba,    0x0003},
+{0x84bb,    0x0081}, {0x84bc,    0x0002}, {0x84bd,    0x0026},
+{0x84be,    0x0050}, {0x84bf,    0x00b6}, {0x84c0,    0x0012},
+{0x84c1,    0x0030}, {0x84c2,    0x0084}, {0x84c3,    0x0003},
+{0x84c4,    0x0081}, {0x84c5,    0x0001}, {0x84c6,    0x0027},
+{0x84c7,    0x0003}, {0x84c8,    0x007e}, {0x84c9,    0x0085},
+{0x84ca,    0x001e}, {0x84cb,    0x0096}, {0x84cc,    0x0044},
+{0x84cd,    0x0085}, {0x84ce,    0x0010}, {0x84cf,    0x0026},
+{0x84d0,    0x0013}, {0x84d1,    0x00b6}, {0x84d2,    0x0012},
+{0x84d3,    0x0050}, {0x84d4,    0x00ba}, {0x84d5,    0x0001},
+{0x84d6,    0x003c}, {0x84d7,    0x0085}, {0x84d8,    0x0010},
+{0x84d9,    0x0026}, {0x84da,    0x0009}, {0x84db,    0x00ce},
+{0x84dc,    0x0084}, {0x84dd,    0x0053}, {0x84de,    0x00ff},
+{0x84df,    0x0001}, {0x84e0,    0x0011}, {0x84e1,    0x007e},
+{0x84e2,    0x0085}, {0x84e3,    0x001e}, {0x84e4,    0x00b6},
+{0x84e5,    0x0010}, {0x84e6,    0x0031}, {0x84e7,    0x008a},
+{0x84e8,    0x0002}, {0x84e9,    0x00b7}, {0x84ea,    0x0010},
+{0x84eb,    0x0031}, {0x84ec,    0x00bd}, {0x84ed,    0x0085},
+{0x84ee,    0x001f}, {0x84ef,    0x00bd}, {0x84f0,    0x00f8},
+{0x84f1,    0x0037}, {0x84f2,    0x007c}, {0x84f3,    0x0000},
+{0x84f4,    0x0080}, {0x84f5,    0x00ce}, {0x84f6,    0x0084},
+{0x84f7,    0x00fe}, {0x84f8,    0x00ff}, {0x84f9,    0x0001},
+{0x84fa,    0x0011}, {0x84fb,    0x007e}, {0x84fc,    0x0085},
+{0x84fd,    0x001e}, {0x84fe,    0x0096}, {0x84ff,    0x0046},
+{0x8500,    0x0084}, {0x8501,    0x0003}, {0x8502,    0x0081},
+{0x8503,    0x0002}, {0x8504,    0x0026}, {0x8505,    0x0009},
+{0x8506,    0x00b6}, {0x8507,    0x0012}, {0x8508,    0x0030},
+{0x8509,    0x0084}, {0x850a,    0x0003}, {0x850b,    0x0081},
+{0x850c,    0x0001}, {0x850d,    0x0027}, {0x850e,    0x000f},
+{0x850f,    0x00bd}, {0x8510,    0x00f8}, {0x8511,    0x0044},
+{0x8512,    0x00bd}, {0x8513,    0x00f7}, {0x8514,    0x000b},
+{0x8515,    0x00bd}, {0x8516,    0x00fc}, {0x8517,    0x0029},
+{0x8518,    0x00ce}, {0x8519,    0x0084}, {0x851a,    0x0026},
+{0x851b,    0x00ff}, {0x851c,    0x0001}, {0x851d,    0x0011},
+{0x851e,    0x0039}, {0x851f,    0x00d6}, {0x8520,    0x0022},
+{0x8521,    0x00c4}, {0x8522,    0x000f}, {0x8523,    0x00b6},
+{0x8524,    0x0012}, {0x8525,    0x0030}, {0x8526,    0x00ba},
+{0x8527,    0x0012}, {0x8528,    0x0032}, {0x8529,    0x0084},
+{0x852a,    0x0004}, {0x852b,    0x0027}, {0x852c,    0x000d},
+{0x852d,    0x0096}, {0x852e,    0x0022}, {0x852f,    0x0085},
+{0x8530,    0x0004}, {0x8531,    0x0027}, {0x8532,    0x0005},
+{0x8533,    0x00ca}, {0x8534,    0x0010}, {0x8535,    0x007e},
+{0x8536,    0x0085}, {0x8537,    0x003a}, {0x8538,    0x00ca},
+{0x8539,    0x0020}, {0x853a,    0x00d7}, {0x853b,    0x0022},
+{0x853c,    0x0039}, {0x853d,    0x0086}, {0x853e,    0x0000},
+{0x853f,    0x0097}, {0x8540,    0x0083}, {0x8541,    0x0018},
+{0x8542,    0x00ce}, {0x8543,    0x001c}, {0x8544,    0x0000},
+{0x8545,    0x00bd}, {0x8546,    0x00eb}, {0x8547,    0x0046},
+{0x8548,    0x0096}, {0x8549,    0x0057}, {0x854a,    0x0085},
+{0x854b,    0x0001}, {0x854c,    0x0027}, {0x854d,    0x0002},
+{0x854e,    0x004f}, {0x854f,    0x0039}, {0x8550,    0x0085},
+{0x8551,    0x0002}, {0x8552,    0x0027}, {0x8553,    0x0001},
+{0x8554,    0x0039}, {0x8555,    0x007f}, {0x8556,    0x008f},
+{0x8557,    0x007d}, {0x8558,    0x0086}, {0x8559,    0x0004},
+{0x855a,    0x00b7}, {0x855b,    0x0012}, {0x855c,    0x0004},
+{0x855d,    0x0086}, {0x855e,    0x0008}, {0x855f,    0x00b7},
+{0x8560,    0x0012}, {0x8561,    0x0007}, {0x8562,    0x0086},
+{0x8563,    0x0010}, {0x8564,    0x00b7}, {0x8565,    0x0012},
+{0x8566,    0x000c}, {0x8567,    0x0086}, {0x8568,    0x0007},
+{0x8569,    0x00b7}, {0x856a,    0x0012}, {0x856b,    0x0006},
+{0x856c,    0x00b6}, {0x856d,    0x008f}, {0x856e,    0x007d},
+{0x856f,    0x00b7}, {0x8570,    0x0012}, {0x8571,    0x0070},
+{0x8572,    0x0086}, {0x8573,    0x0001}, {0x8574,    0x00ba},
+{0x8575,    0x0012}, {0x8576,    0x0004}, {0x8577,    0x00b7},
+{0x8578,    0x0012}, {0x8579,    0x0004}, {0x857a,    0x0001},
+{0x857b,    0x0001}, {0x857c,    0x0001}, {0x857d,    0x0001},
+{0x857e,    0x0001}, {0x857f,    0x0001}, {0x8580,    0x00b6},
+{0x8581,    0x0012}, {0x8582,    0x0004}, {0x8583,    0x0084},
+{0x8584,    0x00fe}, {0x8585,    0x008a}, {0x8586,    0x0002},
+{0x8587,    0x00b7}, {0x8588,    0x0012}, {0x8589,    0x0004},
+{0x858a,    0x0001}, {0x858b,    0x0001}, {0x858c,    0x0001},
+{0x858d,    0x0001}, {0x858e,    0x0001}, {0x858f,    0x0001},
+{0x8590,    0x0086}, {0x8591,    0x00fd}, {0x8592,    0x00b4},
+{0x8593,    0x0012}, {0x8594,    0x0004}, {0x8595,    0x00b7},
+{0x8596,    0x0012}, {0x8597,    0x0004}, {0x8598,    0x00b6},
+{0x8599,    0x0012}, {0x859a,    0x0000}, {0x859b,    0x0084},
+{0x859c,    0x0008}, {0x859d,    0x0081}, {0x859e,    0x0008},
+{0x859f,    0x0027}, {0x85a0,    0x0016}, {0x85a1,    0x00b6},
+{0x85a2,    0x008f}, {0x85a3,    0x007d}, {0x85a4,    0x0081},
+{0x85a5,    0x000c}, {0x85a6,    0x0027}, {0x85a7,    0x0008},
+{0x85a8,    0x008b}, {0x85a9,    0x0004}, {0x85aa,    0x00b7},
+{0x85ab,    0x008f}, {0x85ac,    0x007d}, {0x85ad,    0x007e},
+{0x85ae,    0x0085}, {0x85af,    0x006c}, {0x85b0,    0x0086},
+{0x85b1,    0x0003}, {0x85b2,    0x0097}, {0x85b3,    0x0040},
+{0x85b4,    0x007e}, {0x85b5,    0x0089}, {0x85b6,    0x006e},
+{0x85b7,    0x0086}, {0x85b8,    0x0007}, {0x85b9,    0x00b7},
+{0x85ba,    0x0012}, {0x85bb,    0x0006}, {0x85bc,    0x005f},
+{0x85bd,    0x00f7}, {0x85be,    0x008f}, {0x85bf,    0x0082},
+{0x85c0,    0x005f}, {0x85c1,    0x00f7}, {0x85c2,    0x008f},
+{0x85c3,    0x007f}, {0x85c4,    0x00f7}, {0x85c5,    0x008f},
+{0x85c6,    0x0070}, {0x85c7,    0x00f7}, {0x85c8,    0x008f},
+{0x85c9,    0x0071}, {0x85ca,    0x00f7}, {0x85cb,    0x008f},
+{0x85cc,    0x0072}, {0x85cd,    0x00f7}, {0x85ce,    0x008f},
+{0x85cf,    0x0073}, {0x85d0,    0x00f7}, {0x85d1,    0x008f},
+{0x85d2,    0x0074}, {0x85d3,    0x00f7}, {0x85d4,    0x008f},
+{0x85d5,    0x0075}, {0x85d6,    0x00f7}, {0x85d7,    0x008f},
+{0x85d8,    0x0076}, {0x85d9,    0x00f7}, {0x85da,    0x008f},
+{0x85db,    0x0077}, {0x85dc,    0x00f7}, {0x85dd,    0x008f},
+{0x85de,    0x0078}, {0x85df,    0x00f7}, {0x85e0,    0x008f},
+{0x85e1,    0x0079}, {0x85e2,    0x00f7}, {0x85e3,    0x008f},
+{0x85e4,    0x007a}, {0x85e5,    0x00f7}, {0x85e6,    0x008f},
+{0x85e7,    0x007b}, {0x85e8,    0x00b6}, {0x85e9,    0x0012},
+{0x85ea,    0x0004}, {0x85eb,    0x008a}, {0x85ec,    0x0010},
+{0x85ed,    0x00b7}, {0x85ee,    0x0012}, {0x85ef,    0x0004},
+{0x85f0,    0x0086}, {0x85f1,    0x00e4}, {0x85f2,    0x00b7},
+{0x85f3,    0x0012}, {0x85f4,    0x0070}, {0x85f5,    0x00b7},
+{0x85f6,    0x0012}, {0x85f7,    0x0007}, {0x85f8,    0x00f7},
+{0x85f9,    0x0012}, {0x85fa,    0x0005}, {0x85fb,    0x00f7},
+{0x85fc,    0x0012}, {0x85fd,    0x0009}, {0x85fe,    0x0086},
+{0x85ff,    0x0008}, {0x8600,    0x00ba}, {0x8601,    0x0012},
+{0x8602,    0x0004}, {0x8603,    0x00b7}, {0x8604,    0x0012},
+{0x8605,    0x0004}, {0x8606,    0x0086}, {0x8607,    0x00f7},
+{0x8608,    0x00b4}, {0x8609,    0x0012}, {0x860a,    0x0004},
+{0x860b,    0x00b7}, {0x860c,    0x0012}, {0x860d,    0x0004},
+{0x860e,    0x0001}, {0x860f,    0x0001}, {0x8610,    0x0001},
+{0x8611,    0x0001}, {0x8612,    0x0001}, {0x8613,    0x0001},
+{0x8614,    0x00b6}, {0x8615,    0x0012}, {0x8616,    0x0008},
+{0x8617,    0x0027}, {0x8618,    0x007f}, {0x8619,    0x0081},
+{0x861a,    0x0080}, {0x861b,    0x0026}, {0x861c,    0x000b},
+{0x861d,    0x0086}, {0x861e,    0x0008}, {0x861f,    0x00ce},
+{0x8620,    0x008f}, {0x8621,    0x0079}, {0x8622,    0x00bd},
+{0x8623,    0x0089}, {0x8624,    0x007b}, {0x8625,    0x007e},
+{0x8626,    0x0086}, {0x8627,    0x008e}, {0x8628,    0x0081},
+{0x8629,    0x0040}, {0x862a,    0x0026}, {0x862b,    0x000b},
+{0x862c,    0x0086}, {0x862d,    0x0004}, {0x862e,    0x00ce},
+{0x862f,    0x008f}, {0x8630,    0x0076}, {0x8631,    0x00bd},
+{0x8632,    0x0089}, {0x8633,    0x007b}, {0x8634,    0x007e},
+{0x8635,    0x0086}, {0x8636,    0x008e}, {0x8637,    0x0081},
+{0x8638,    0x0020}, {0x8639,    0x0026}, {0x863a,    0x000b},
+{0x863b,    0x0086}, {0x863c,    0x0002}, {0x863d,    0x00ce},
+{0x863e,    0x008f}, {0x863f,    0x0073}, {0x8640,    0x00bd},
+{0x8641,    0x0089}, {0x8642,    0x007b}, {0x8643,    0x007e},
+{0x8644,    0x0086}, {0x8645,    0x008e}, {0x8646,    0x0081},
+{0x8647,    0x0010}, {0x8648,    0x0026}, {0x8649,    0x000b},
+{0x864a,    0x0086}, {0x864b,    0x0001}, {0x864c,    0x00ce},
+{0x864d,    0x008f}, {0x864e,    0x0070}, {0x864f,    0x00bd},
+{0x8650,    0x0089}, {0x8651,    0x007b}, {0x8652,    0x007e},
+{0x8653,    0x0086}, {0x8654,    0x008e}, {0x8655,    0x0081},
+{0x8656,    0x0008}, {0x8657,    0x0026}, {0x8658,    0x000b},
+{0x8659,    0x0086}, {0x865a,    0x0008}, {0x865b,    0x00ce},
+{0x865c,    0x008f}, {0x865d,    0x0079}, {0x865e,    0x00bd},
+{0x865f,    0x0089}, {0x8660,    0x007f}, {0x8661,    0x007e},
+{0x8662,    0x0086}, {0x8663,    0x008e}, {0x8664,    0x0081},
+{0x8665,    0x0004}, {0x8666,    0x0026}, {0x8667,    0x000b},
+{0x8668,    0x0086}, {0x8669,    0x0004}, {0x866a,    0x00ce},
+{0x866b,    0x008f}, {0x866c,    0x0076}, {0x866d,    0x00bd},
+{0x866e,    0x0089}, {0x866f,    0x007f}, {0x8670,    0x007e},
+{0x8671,    0x0086}, {0x8672,    0x008e}, {0x8673,    0x0081},
+{0x8674,    0x0002}, {0x8675,    0x0026}, {0x8676,    0x000b},
+{0x8677,    0x008a}, {0x8678,    0x0002}, {0x8679,    0x00ce},
+{0x867a,    0x008f}, {0x867b,    0x0073}, {0x867c,    0x00bd},
+{0x867d,    0x0089}, {0x867e,    0x007f}, {0x867f,    0x007e},
+{0x8680,    0x0086}, {0x8681,    0x008e}, {0x8682,    0x0081},
+{0x8683,    0x0001}, {0x8684,    0x0026}, {0x8685,    0x0008},
+{0x8686,    0x0086}, {0x8687,    0x0001}, {0x8688,    0x00ce},
+{0x8689,    0x008f}, {0x868a,    0x0070}, {0x868b,    0x00bd},
+{0x868c,    0x0089}, {0x868d,    0x007f}, {0x868e,    0x00b6},
+{0x868f,    0x008f}, {0x8690,    0x007f}, {0x8691,    0x0081},
+{0x8692,    0x000f}, {0x8693,    0x0026}, {0x8694,    0x0003},
+{0x8695,    0x007e}, {0x8696,    0x0087}, {0x8697,    0x0047},
+{0x8698,    0x00b6}, {0x8699,    0x0012}, {0x869a,    0x0009},
+{0x869b,    0x0084}, {0x869c,    0x0003}, {0x869d,    0x0081},
+{0x869e,    0x0003}, {0x869f,    0x0027}, {0x86a0,    0x0006},
+{0x86a1,    0x007c}, {0x86a2,    0x0012}, {0x86a3,    0x0009},
+{0x86a4,    0x007e}, {0x86a5,    0x0085}, {0x86a6,    0x00fe},
+{0x86a7,    0x00b6}, {0x86a8,    0x0012}, {0x86a9,    0x0006},
+{0x86aa,    0x0084}, {0x86ab,    0x0007}, {0x86ac,    0x0081},
+{0x86ad,    0x0007}, {0x86ae,    0x0027}, {0x86af,    0x0008},
+{0x86b0,    0x008b}, {0x86b1,    0x0001}, {0x86b2,    0x00b7},
+{0x86b3,    0x0012}, {0x86b4,    0x0006}, {0x86b5,    0x007e},
+{0x86b6,    0x0086}, {0x86b7,    0x00d5}, {0x86b8,    0x00b6},
+{0x86b9,    0x008f}, {0x86ba,    0x0082}, {0x86bb,    0x0026},
+{0x86bc,    0x000a}, {0x86bd,    0x007c}, {0x86be,    0x008f},
+{0x86bf,    0x0082}, {0x86c0,    0x004f}, {0x86c1,    0x00b7},
+{0x86c2,    0x0012}, {0x86c3,    0x0006}, {0x86c4,    0x007e},
+{0x86c5,    0x0085}, {0x86c6,    0x00c0}, {0x86c7,    0x00b6},
+{0x86c8,    0x0012}, {0x86c9,    0x0006}, {0x86ca,    0x0084},
+{0x86cb,    0x003f}, {0x86cc,    0x0081}, {0x86cd,    0x003f},
+{0x86ce,    0x0027}, {0x86cf,    0x0010}, {0x86d0,    0x008b},
+{0x86d1,    0x0008}, {0x86d2,    0x00b7}, {0x86d3,    0x0012},
+{0x86d4,    0x0006}, {0x86d5,    0x00b6}, {0x86d6,    0x0012},
+{0x86d7,    0x0009}, {0x86d8,    0x0084}, {0x86d9,    0x00fc},
+{0x86da,    0x00b7}, {0x86db,    0x0012}, {0x86dc,    0x0009},
+{0x86dd,    0x007e}, {0x86de,    0x0085}, {0x86df,    0x00fe},
+{0x86e0,    0x00ce}, {0x86e1,    0x008f}, {0x86e2,    0x0070},
+{0x86e3,    0x0018}, {0x86e4,    0x00ce}, {0x86e5,    0x008f},
+{0x86e6,    0x0084}, {0x86e7,    0x00c6}, {0x86e8,    0x000c},
+{0x86e9,    0x00bd}, {0x86ea,    0x0089}, {0x86eb,    0x006f},
+{0x86ec,    0x00ce}, {0x86ed,    0x008f}, {0x86ee,    0x0084},
+{0x86ef,    0x0018}, {0x86f0,    0x00ce}, {0x86f1,    0x008f},
+{0x86f2,    0x0070}, {0x86f3,    0x00c6}, {0x86f4,    0x000c},
+{0x86f5,    0x00bd}, {0x86f6,    0x0089}, {0x86f7,    0x006f},
+{0x86f8,    0x00d6}, {0x86f9,    0x0083}, {0x86fa,    0x00c1},
+{0x86fb,    0x004f}, {0x86fc,    0x002d}, {0x86fd,    0x0003},
+{0x86fe,    0x007e}, {0x86ff,    0x0087}, {0x8700,    0x0040},
+{0x8701,    0x00b6}, {0x8702,    0x008f}, {0x8703,    0x007f},
+{0x8704,    0x0081}, {0x8705,    0x0007}, {0x8706,    0x0027},
+{0x8707,    0x000f}, {0x8708,    0x0081}, {0x8709,    0x000b},
+{0x870a,    0x0027}, {0x870b,    0x0015}, {0x870c,    0x0081},
+{0x870d,    0x000d}, {0x870e,    0x0027}, {0x870f,    0x001b},
+{0x8710,    0x0081}, {0x8711,    0x000e}, {0x8712,    0x0027},
+{0x8713,    0x0021}, {0x8714,    0x007e}, {0x8715,    0x0087},
+{0x8716,    0x0040}, {0x8717,    0x00f7}, {0x8718,    0x008f},
+{0x8719,    0x007b}, {0x871a,    0x0086}, {0x871b,    0x0002},
+{0x871c,    0x00b7}, {0x871d,    0x008f}, {0x871e,    0x007a},
+{0x871f,    0x0020}, {0x8720,    0x001c}, {0x8721,    0x00f7},
+{0x8722,    0x008f}, {0x8723,    0x0078}, {0x8724,    0x0086},
+{0x8725,    0x0002}, {0x8726,    0x00b7}, {0x8727,    0x008f},
+{0x8728,    0x0077}, {0x8729,    0x0020}, {0x872a,    0x0012},
+{0x872b,    0x00f7}, {0x872c,    0x008f}, {0x872d,    0x0075},
+{0x872e,    0x0086}, {0x872f,    0x0002}, {0x8730,    0x00b7},
+{0x8731,    0x008f}, {0x8732,    0x0074}, {0x8733,    0x0020},
+{0x8734,    0x0008}, {0x8735,    0x00f7}, {0x8736,    0x008f},
+{0x8737,    0x0072}, {0x8738,    0x0086}, {0x8739,    0x0002},
+{0x873a,    0x00b7}, {0x873b,    0x008f}, {0x873c,    0x0071},
+{0x873d,    0x007e}, {0x873e,    0x0087}, {0x873f,    0x0047},
+{0x8740,    0x0086}, {0x8741,    0x0004}, {0x8742,    0x0097},
+{0x8743,    0x0040}, {0x8744,    0x007e}, {0x8745,    0x0089},
+{0x8746,    0x006e}, {0x8747,    0x00ce}, {0x8748,    0x008f},
+{0x8749,    0x0072}, {0x874a,    0x00bd}, {0x874b,    0x0089},
+{0x874c,    0x00f7}, {0x874d,    0x00ce}, {0x874e,    0x008f},
+{0x874f,    0x0075}, {0x8750,    0x00bd}, {0x8751,    0x0089},
+{0x8752,    0x00f7}, {0x8753,    0x00ce}, {0x8754,    0x008f},
+{0x8755,    0x0078}, {0x8756,    0x00bd}, {0x8757,    0x0089},
+{0x8758,    0x00f7}, {0x8759,    0x00ce}, {0x875a,    0x008f},
+{0x875b,    0x007b}, {0x875c,    0x00bd}, {0x875d,    0x0089},
+{0x875e,    0x00f7}, {0x875f,    0x004f}, {0x8760,    0x00b7},
+{0x8761,    0x008f}, {0x8762,    0x007d}, {0x8763,    0x00b7},
+{0x8764,    0x008f}, {0x8765,    0x0081}, {0x8766,    0x00b6},
+{0x8767,    0x008f}, {0x8768,    0x0072}, {0x8769,    0x0027},
+{0x876a,    0x0047}, {0x876b,    0x007c}, {0x876c,    0x008f},
+{0x876d,    0x007d}, {0x876e,    0x00b6}, {0x876f,    0x008f},
+{0x8770,    0x0075}, {0x8771,    0x0027}, {0x8772,    0x003f},
+{0x8773,    0x007c}, {0x8774,    0x008f}, {0x8775,    0x007d},
+{0x8776,    0x00b6}, {0x8777,    0x008f}, {0x8778,    0x0078},
+{0x8779,    0x0027}, {0x877a,    0x0037}, {0x877b,    0x007c},
+{0x877c,    0x008f}, {0x877d,    0x007d}, {0x877e,    0x00b6},
+{0x877f,    0x008f}, {0x8780,    0x007b}, {0x8781,    0x0027},
+{0x8782,    0x002f}, {0x8783,    0x007f}, {0x8784,    0x008f},
+{0x8785,    0x007d}, {0x8786,    0x007c}, {0x8787,    0x008f},
+{0x8788,    0x0081}, {0x8789,    0x007a}, {0x878a,    0x008f},
+{0x878b,    0x0072}, {0x878c,    0x0027}, {0x878d,    0x001b},
+{0x878e,    0x007c}, {0x878f,    0x008f}, {0x8790,    0x007d},
+{0x8791,    0x007a}, {0x8792,    0x008f}, {0x8793,    0x0075},
+{0x8794,    0x0027}, {0x8795,    0x0016}, {0x8796,    0x007c},
+{0x8797,    0x008f}, {0x8798,    0x007d}, {0x8799,    0x007a},
+{0x879a,    0x008f}, {0x879b,    0x0078}, {0x879c,    0x0027},
+{0x879d,    0x0011}, {0x879e,    0x007c}, {0x879f,    0x008f},
+{0x87a0,    0x007d}, {0x87a1,    0x007a}, {0x87a2,    0x008f},
+{0x87a3,    0x007b}, {0x87a4,    0x0027}, {0x87a5,    0x000c},
+{0x87a6,    0x007e}, {0x87a7,    0x0087}, {0x87a8,    0x0083},
+{0x87a9,    0x007a}, {0x87aa,    0x008f}, {0x87ab,    0x0075},
+{0x87ac,    0x007a}, {0x87ad,    0x008f}, {0x87ae,    0x0078},
+{0x87af,    0x007a}, {0x87b0,    0x008f}, {0x87b1,    0x007b},
+{0x87b2,    0x00ce}, {0x87b3,    0x00c1}, {0x87b4,    0x00fc},
+{0x87b5,    0x00f6}, {0x87b6,    0x008f}, {0x87b7,    0x007d},
+{0x87b8,    0x003a}, {0x87b9,    0x00a6}, {0x87ba,    0x0000},
+{0x87bb,    0x00b7}, {0x87bc,    0x0012}, {0x87bd,    0x0070},
+{0x87be,    0x00b6}, {0x87bf,    0x008f}, {0x87c0,    0x0072},
+{0x87c1,    0x0026}, {0x87c2,    0x0003}, {0x87c3,    0x007e},
+{0x87c4,    0x0087}, {0x87c5,    0x00fa}, {0x87c6,    0x00b6},
+{0x87c7,    0x008f}, {0x87c8,    0x0075}, {0x87c9,    0x0026},
+{0x87ca,    0x000a}, {0x87cb,    0x0018}, {0x87cc,    0x00ce},
+{0x87cd,    0x008f}, {0x87ce,    0x0073}, {0x87cf,    0x00bd},
+{0x87d0,    0x0089}, {0x87d1,    0x00d5}, {0x87d2,    0x007e},
+{0x87d3,    0x0087}, {0x87d4,    0x00fa}, {0x87d5,    0x00b6},
+{0x87d6,    0x008f}, {0x87d7,    0x0078}, {0x87d8,    0x0026},
+{0x87d9,    0x000a}, {0x87da,    0x0018}, {0x87db,    0x00ce},
+{0x87dc,    0x008f}, {0x87dd,    0x0076}, {0x87de,    0x00bd},
+{0x87df,    0x0089}, {0x87e0,    0x00d5}, {0x87e1,    0x007e},
+{0x87e2,    0x0087}, {0x87e3,    0x00fa}, {0x87e4,    0x00b6},
+{0x87e5,    0x008f}, {0x87e6,    0x007b}, {0x87e7,    0x0026},
+{0x87e8,    0x000a}, {0x87e9,    0x0018}, {0x87ea,    0x00ce},
+{0x87eb,    0x008f}, {0x87ec,    0x0079}, {0x87ed,    0x00bd},
+{0x87ee,    0x0089}, {0x87ef,    0x00d5}, {0x87f0,    0x007e},
+{0x87f1,    0x0087}, {0x87f2,    0x00fa}, {0x87f3,    0x0086},
+{0x87f4,    0x0005}, {0x87f5,    0x0097}, {0x87f6,    0x0040},
+{0x87f7,    0x007e}, {0x87f8,    0x0089}, {0x87f9,    0x006e},
+{0x87fa,    0x00b6}, {0x87fb,    0x008f}, {0x87fc,    0x0075},
+{0x87fd,    0x0081}, {0x87fe,    0x0007}, {0x87ff,    0x002e},
+{0x8800,    0x00f2}, {0x8801,    0x00f6}, {0x8802,    0x0012},
+{0x8803,    0x0006}, {0x8804,    0x00c4}, {0x8805,    0x00f8},
+{0x8806,    0x001b}, {0x8807,    0x00b7}, {0x8808,    0x0012},
+{0x8809,    0x0006}, {0x880a,    0x00b6}, {0x880b,    0x008f},
+{0x880c,    0x0078}, {0x880d,    0x0081}, {0x880e,    0x0007},
+{0x880f,    0x002e}, {0x8810,    0x00e2}, {0x8811,    0x0048},
+{0x8812,    0x0048}, {0x8813,    0x0048}, {0x8814,    0x00f6},
+{0x8815,    0x0012}, {0x8816,    0x0006}, {0x8817,    0x00c4},
+{0x8818,    0x00c7}, {0x8819,    0x001b}, {0x881a,    0x00b7},
+{0x881b,    0x0012}, {0x881c,    0x0006}, {0x881d,    0x00b6},
+{0x881e,    0x008f}, {0x881f,    0x007b}, {0x8820,    0x0081},
+{0x8821,    0x0007}, {0x8822,    0x002e}, {0x8823,    0x00cf},
+{0x8824,    0x00f6}, {0x8825,    0x0012}, {0x8826,    0x0005},
+{0x8827,    0x00c4}, {0x8828,    0x00f8}, {0x8829,    0x001b},
+{0x882a,    0x00b7}, {0x882b,    0x0012}, {0x882c,    0x0005},
+{0x882d,    0x0086}, {0x882e,    0x0000}, {0x882f,    0x00f6},
+{0x8830,    0x008f}, {0x8831,    0x0071}, {0x8832,    0x00bd},
+{0x8833,    0x0089}, {0x8834,    0x0094}, {0x8835,    0x0086},
+{0x8836,    0x0001}, {0x8837,    0x00f6}, {0x8838,    0x008f},
+{0x8839,    0x0074}, {0x883a,    0x00bd}, {0x883b,    0x0089},
+{0x883c,    0x0094}, {0x883d,    0x0086}, {0x883e,    0x0002},
+{0x883f,    0x00f6}, {0x8840,    0x008f}, {0x8841,    0x0077},
+{0x8842,    0x00bd}, {0x8843,    0x0089}, {0x8844,    0x0094},
+{0x8845,    0x0086}, {0x8846,    0x0003}, {0x8847,    0x00f6},
+{0x8848,    0x008f}, {0x8849,    0x007a}, {0x884a,    0x00bd},
+{0x884b,    0x0089}, {0x884c,    0x0094}, {0x884d,    0x00ce},
+{0x884e,    0x008f}, {0x884f,    0x0070}, {0x8850,    0x00a6},
+{0x8851,    0x0001}, {0x8852,    0x0081}, {0x8853,    0x0001},
+{0x8854,    0x0027}, {0x8855,    0x0007}, {0x8856,    0x0081},
+{0x8857,    0x0003}, {0x8858,    0x0027}, {0x8859,    0x0003},
+{0x885a,    0x007e}, {0x885b,    0x0088}, {0x885c,    0x0066},
+{0x885d,    0x00a6}, {0x885e,    0x0000}, {0x885f,    0x00b8},
+{0x8860,    0x008f}, {0x8861,    0x0081}, {0x8862,    0x0084},
+{0x8863,    0x0001}, {0x8864,    0x0026}, {0x8865,    0x000b},
+{0x8866,    0x008c}, {0x8867,    0x008f}, {0x8868,    0x0079},
+{0x8869,    0x002c}, {0x886a,    0x000e}, {0x886b,    0x0008},
+{0x886c,    0x0008}, {0x886d,    0x0008}, {0x886e,    0x007e},
+{0x886f,    0x0088}, {0x8870,    0x0050}, {0x8871,    0x00b6},
+{0x8872,    0x0012}, {0x8873,    0x0004}, {0x8874,    0x008a},
+{0x8875,    0x0040}, {0x8876,    0x00b7}, {0x8877,    0x0012},
+{0x8878,    0x0004}, {0x8879,    0x00b6}, {0x887a,    0x0012},
+{0x887b,    0x0004}, {0x887c,    0x0084}, {0x887d,    0x00fb},
+{0x887e,    0x0084}, {0x887f,    0x00ef}, {0x8880,    0x00b7},
+{0x8881,    0x0012}, {0x8882,    0x0004}, {0x8883,    0x00b6},
+{0x8884,    0x0012}, {0x8885,    0x0007}, {0x8886,    0x0036},
+{0x8887,    0x00b6}, {0x8888,    0x008f}, {0x8889,    0x007c},
+{0x888a,    0x0048}, {0x888b,    0x0048}, {0x888c,    0x00b7},
+{0x888d,    0x0012}, {0x888e,    0x0007}, {0x888f,    0x0086},
+{0x8890,    0x0001}, {0x8891,    0x00ba}, {0x8892,    0x0012},
+{0x8893,    0x0004}, {0x8894,    0x00b7}, {0x8895,    0x0012},
+{0x8896,    0x0004}, {0x8897,    0x0001}, {0x8898,    0x0001},
+{0x8899,    0x0001}, {0x889a,    0x0001}, {0x889b,    0x0001},
+{0x889c,    0x0001}, {0x889d,    0x0086}, {0x889e,    0x00fe},
+{0x889f,    0x00b4}, {0x88a0,    0x0012}, {0x88a1,    0x0004},
+{0x88a2,    0x00b7}, {0x88a3,    0x0012}, {0x88a4,    0x0004},
+{0x88a5,    0x0086}, {0x88a6,    0x0002}, {0x88a7,    0x00ba},
+{0x88a8,    0x0012}, {0x88a9,    0x0004}, {0x88aa,    0x00b7},
+{0x88ab,    0x0012}, {0x88ac,    0x0004}, {0x88ad,    0x0086},
+{0x88ae,    0x00fd}, {0x88af,    0x00b4}, {0x88b0,    0x0012},
+{0x88b1,    0x0004}, {0x88b2,    0x00b7}, {0x88b3,    0x0012},
+{0x88b4,    0x0004}, {0x88b5,    0x0032}, {0x88b6,    0x00b7},
+{0x88b7,    0x0012}, {0x88b8,    0x0007}, {0x88b9,    0x00b6},
+{0x88ba,    0x0012}, {0x88bb,    0x0000}, {0x88bc,    0x0084},
+{0x88bd,    0x0008}, {0x88be,    0x0081}, {0x88bf,    0x0008},
+{0x88c0,    0x0027}, {0x88c1,    0x000f}, {0x88c2,    0x007c},
+{0x88c3,    0x0082}, {0x88c4,    0x0008}, {0x88c5,    0x0026},
+{0x88c6,    0x0007}, {0x88c7,    0x0086}, {0x88c8,    0x0076},
+{0x88c9,    0x0097}, {0x88ca,    0x0040}, {0x88cb,    0x007e},
+{0x88cc,    0x0089}, {0x88cd,    0x006e}, {0x88ce,    0x007e},
+{0x88cf,    0x0086}, {0x88d0,    0x00ec}, {0x88d1,    0x00b6},
+{0x88d2,    0x008f}, {0x88d3,    0x007f}, {0x88d4,    0x0081},
+{0x88d5,    0x000f}, {0x88d6,    0x0027}, {0x88d7,    0x003c},
+{0x88d8,    0x00bd}, {0x88d9,    0x00e6}, {0x88da,    0x00c7},
+{0x88db,    0x00b7}, {0x88dc,    0x0012}, {0x88dd,    0x000d},
+{0x88de,    0x00bd}, {0x88df,    0x00e6}, {0x88e0,    0x00cb},
+{0x88e1,    0x00b6}, {0x88e2,    0x0012}, {0x88e3,    0x0004},
+{0x88e4,    0x008a}, {0x88e5,    0x0020}, {0x88e6,    0x00b7},
+{0x88e7,    0x0012}, {0x88e8,    0x0004}, {0x88e9,    0x00ce},
+{0x88ea,    0x00ff}, {0x88eb,    0x00ff}, {0x88ec,    0x00b6},
+{0x88ed,    0x0012}, {0x88ee,    0x0000}, {0x88ef,    0x0081},
+{0x88f0,    0x000c}, {0x88f1,    0x0026}, {0x88f2,    0x0005},
+{0x88f3,    0x0009}, {0x88f4,    0x0026}, {0x88f5,    0x00f6},
+{0x88f6,    0x0027}, {0x88f7,    0x001c}, {0x88f8,    0x00b6},
+{0x88f9,    0x0012}, {0x88fa,    0x0004}, {0x88fb,    0x0084},
+{0x88fc,    0x00df}, {0x88fd,    0x00b7}, {0x88fe,    0x0012},
+{0x88ff,    0x0004}, {0x8900,    0x0096}, {0x8901,    0x0083},
+{0x8902,    0x0081}, {0x8903,    0x0007}, {0x8904,    0x002c},
+{0x8905,    0x0005}, {0x8906,    0x007c}, {0x8907,    0x0000},
+{0x8908,    0x0083}, {0x8909,    0x0020}, {0x890a,    0x0006},
+{0x890b,    0x0096}, {0x890c,    0x0083}, {0x890d,    0x008b},
+{0x890e,    0x0008}, {0x890f,    0x0097}, {0x8910,    0x0083},
+{0x8911,    0x007e}, {0x8912,    0x0085}, {0x8913,    0x0041},
+{0x8914,    0x007f}, {0x8915,    0x008f}, {0x8916,    0x007e},
+{0x8917,    0x0086}, {0x8918,    0x0080}, {0x8919,    0x00b7},
+{0x891a,    0x0012}, {0x891b,    0x000c}, {0x891c,    0x0086},
+{0x891d,    0x0001}, {0x891e,    0x00b7}, {0x891f,    0x008f},
+{0x8920,    0x007d}, {0x8921,    0x00b6}, {0x8922,    0x0012},
+{0x8923,    0x000c}, {0x8924,    0x0084}, {0x8925,    0x007f},
+{0x8926,    0x00b7}, {0x8927,    0x0012}, {0x8928,    0x000c},
+{0x8929,    0x008a}, {0x892a,    0x0080}, {0x892b,    0x00b7},
+{0x892c,    0x0012}, {0x892d,    0x000c}, {0x892e,    0x0086},
+{0x892f,    0x000a}, {0x8930,    0x00bd}, {0x8931,    0x008a},
+{0x8932,    0x0006}, {0x8933,    0x00b6}, {0x8934,    0x0012},
+{0x8935,    0x000a}, {0x8936,    0x002a}, {0x8937,    0x0009},
+{0x8938,    0x00b6}, {0x8939,    0x0012}, {0x893a,    0x000c},
+{0x893b,    0x00ba}, {0x893c,    0x008f}, {0x893d,    0x007d},
+{0x893e,    0x00b7}, {0x893f,    0x0012}, {0x8940,    0x000c},
+{0x8941,    0x00b6}, {0x8942,    0x008f}, {0x8943,    0x007e},
+{0x8944,    0x0081}, {0x8945,    0x0060}, {0x8946,    0x0027},
+{0x8947,    0x001a}, {0x8948,    0x008b}, {0x8949,    0x0020},
+{0x894a,    0x00b7}, {0x894b,    0x008f}, {0x894c,    0x007e},
+{0x894d,    0x00b6}, {0x894e,    0x0012}, {0x894f,    0x000c},
+{0x8950,    0x0084}, {0x8951,    0x009f}, {0x8952,    0x00ba},
+{0x8953,    0x008f}, {0x8954,    0x007e}, {0x8955,    0x00b7},
+{0x8956,    0x0012}, {0x8957,    0x000c}, {0x8958,    0x00b6},
+{0x8959,    0x008f}, {0x895a,    0x007d}, {0x895b,    0x0048},
+{0x895c,    0x00b7}, {0x895d,    0x008f}, {0x895e,    0x007d},
+{0x895f,    0x007e}, {0x8960,    0x0089}, {0x8961,    0x0021},
+{0x8962,    0x00b6}, {0x8963,    0x0012}, {0x8964,    0x0004},
+{0x8965,    0x008a}, {0x8966,    0x0020}, {0x8967,    0x00b7},
+{0x8968,    0x0012}, {0x8969,    0x0004}, {0x896a,    0x00bd},
+{0x896b,    0x008a}, {0x896c,    0x000a}, {0x896d,    0x004f},
+{0x896e,    0x0039}, {0x896f,    0x00a6}, {0x8970,    0x0000},
+{0x8971,    0x0018}, {0x8972,    0x00a7}, {0x8973,    0x0000},
+{0x8974,    0x0008}, {0x8975,    0x0018}, {0x8976,    0x0008},
+{0x8977,    0x005a}, {0x8978,    0x0026}, {0x8979,    0x00f5},
+{0x897a,    0x0039}, {0x897b,    0x0036}, {0x897c,    0x006c},
+{0x897d,    0x0000}, {0x897e,    0x0032}, {0x897f,    0x00ba},
+{0x8980,    0x008f}, {0x8981,    0x007f}, {0x8982,    0x00b7},
+{0x8983,    0x008f}, {0x8984,    0x007f}, {0x8985,    0x00b6},
+{0x8986,    0x0012}, {0x8987,    0x0009}, {0x8988,    0x0084},
+{0x8989,    0x0003}, {0x898a,    0x00a7}, {0x898b,    0x0001},
+{0x898c,    0x00b6}, {0x898d,    0x0012}, {0x898e,    0x0006},
+{0x898f,    0x0084}, {0x8990,    0x003f}, {0x8991,    0x00a7},
+{0x8992,    0x0002}, {0x8993,    0x0039}, {0x8994,    0x0036},
+{0x8995,    0x0086}, {0x8996,    0x0003}, {0x8997,    0x00b7},
+{0x8998,    0x008f}, {0x8999,    0x0080}, {0x899a,    0x0032},
+{0x899b,    0x00c1}, {0x899c,    0x0000}, {0x899d,    0x0026},
+{0x899e,    0x0006}, {0x899f,    0x00b7}, {0x89a0,    0x008f},
+{0x89a1,    0x007c}, {0x89a2,    0x007e}, {0x89a3,    0x0089},
+{0x89a4,    0x00c9}, {0x89a5,    0x00c1}, {0x89a6,    0x0001},
+{0x89a7,    0x0027}, {0x89a8,    0x0018}, {0x89a9,    0x00c1},
+{0x89aa,    0x0002}, {0x89ab,    0x0027}, {0x89ac,    0x000c},
+{0x89ad,    0x00c1}, {0x89ae,    0x0003}, {0x89af,    0x0027},
+{0x89b0,    0x0000}, {0x89b1,    0x00f6}, {0x89b2,    0x008f},
+{0x89b3,    0x0080}, {0x89b4,    0x0005}, {0x89b5,    0x0005},
+{0x89b6,    0x00f7}, {0x89b7,    0x008f}, {0x89b8,    0x0080},
+{0x89b9,    0x00f6}, {0x89ba,    0x008f}, {0x89bb,    0x0080},
+{0x89bc,    0x0005}, {0x89bd,    0x0005}, {0x89be,    0x00f7},
+{0x89bf,    0x008f}, {0x89c0,    0x0080}, {0x89c1,    0x00f6},
+{0x89c2,    0x008f}, {0x89c3,    0x0080}, {0x89c4,    0x0005},
+{0x89c5,    0x0005}, {0x89c6,    0x00f7}, {0x89c7,    0x008f},
+{0x89c8,    0x0080}, {0x89c9,    0x00f6}, {0x89ca,    0x008f},
+{0x89cb,    0x0080}, {0x89cc,    0x0053}, {0x89cd,    0x00f4},
+{0x89ce,    0x0012}, {0x89cf,    0x0007}, {0x89d0,    0x001b},
+{0x89d1,    0x00b7}, {0x89d2,    0x0012}, {0x89d3,    0x0007},
+{0x89d4,    0x0039}, {0x89d5,    0x00ce}, {0x89d6,    0x008f},
+{0x89d7,    0x0070}, {0x89d8,    0x00a6}, {0x89d9,    0x0000},
+{0x89da,    0x0018}, {0x89db,    0x00e6}, {0x89dc,    0x0000},
+{0x89dd,    0x0018}, {0x89de,    0x00a7}, {0x89df,    0x0000},
+{0x89e0,    0x00e7}, {0x89e1,    0x0000}, {0x89e2,    0x00a6},
+{0x89e3,    0x0001}, {0x89e4,    0x0018}, {0x89e5,    0x00e6},
+{0x89e6,    0x0001}, {0x89e7,    0x0018}, {0x89e8,    0x00a7},
+{0x89e9,    0x0001}, {0x89ea,    0x00e7}, {0x89eb,    0x0001},
+{0x89ec,    0x00a6}, {0x89ed,    0x0002}, {0x89ee,    0x0018},
+{0x89ef,    0x00e6}, {0x89f0,    0x0002}, {0x89f1,    0x0018},
+{0x89f2,    0x00a7}, {0x89f3,    0x0002}, {0x89f4,    0x00e7},
+{0x89f5,    0x0002}, {0x89f6,    0x0039}, {0x89f7,    0x00a6},
+{0x89f8,    0x0000}, {0x89f9,    0x0084}, {0x89fa,    0x0007},
+{0x89fb,    0x00e6}, {0x89fc,    0x0000}, {0x89fd,    0x00c4},
+{0x89fe,    0x0038}, {0x89ff,    0x0054}, {0x8a00,    0x0054},
+{0x8a01,    0x0054}, {0x8a02,    0x001b}, {0x8a03,    0x00a7},
+{0x8a04,    0x0000}, {0x8a05,    0x0039}, {0x8a06,    0x004a},
+{0x8a07,    0x0026}, {0x8a08,    0x00fd}, {0x8a09,    0x0039},
+{0x8a0a,    0x0096}, {0x8a0b,    0x0022}, {0x8a0c,    0x0084},
+{0x8a0d,    0x000f}, {0x8a0e,    0x0097}, {0x8a0f,    0x0022},
+{0x8a10,    0x0086}, {0x8a11,    0x0001}, {0x8a12,    0x00b7},
+{0x8a13,    0x008f}, {0x8a14,    0x0070}, {0x8a15,    0x00b6},
+{0x8a16,    0x0012}, {0x8a17,    0x0007}, {0x8a18,    0x00b7},
+{0x8a19,    0x008f}, {0x8a1a,    0x0071}, {0x8a1b,    0x00f6},
+{0x8a1c,    0x0012}, {0x8a1d,    0x000c}, {0x8a1e,    0x00c4},
+{0x8a1f,    0x000f}, {0x8a20,    0x00c8}, {0x8a21,    0x000f},
+{0x8a22,    0x00f7}, {0x8a23,    0x008f}, {0x8a24,    0x0072},
+{0x8a25,    0x00f6}, {0x8a26,    0x008f}, {0x8a27,    0x0072},
+{0x8a28,    0x00b6}, {0x8a29,    0x008f}, {0x8a2a,    0x0071},
+{0x8a2b,    0x0084}, {0x8a2c,    0x0003}, {0x8a2d,    0x0027},
+{0x8a2e,    0x0014}, {0x8a2f,    0x0081}, {0x8a30,    0x0001},
+{0x8a31,    0x0027}, {0x8a32,    0x001c}, {0x8a33,    0x0081},
+{0x8a34,    0x0002}, {0x8a35,    0x0027}, {0x8a36,    0x0024},
+{0x8a37,    0x00f4}, {0x8a38,    0x008f}, {0x8a39,    0x0070},
+{0x8a3a,    0x0027}, {0x8a3b,    0x002a}, {0x8a3c,    0x0096},
+{0x8a3d,    0x0022}, {0x8a3e,    0x008a}, {0x8a3f,    0x0080},
+{0x8a40,    0x007e}, {0x8a41,    0x008a}, {0x8a42,    0x0064},
+{0x8a43,    0x00f4}, {0x8a44,    0x008f}, {0x8a45,    0x0070},
+{0x8a46,    0x0027}, {0x8a47,    0x001e}, {0x8a48,    0x0096},
+{0x8a49,    0x0022}, {0x8a4a,    0x008a}, {0x8a4b,    0x0010},
+{0x8a4c,    0x007e}, {0x8a4d,    0x008a}, {0x8a4e,    0x0064},
+{0x8a4f,    0x00f4}, {0x8a50,    0x008f}, {0x8a51,    0x0070},
+{0x8a52,    0x0027}, {0x8a53,    0x0012}, {0x8a54,    0x0096},
+{0x8a55,    0x0022}, {0x8a56,    0x008a}, {0x8a57,    0x0020},
+{0x8a58,    0x007e}, {0x8a59,    0x008a}, {0x8a5a,    0x0064},
+{0x8a5b,    0x00f4}, {0x8a5c,    0x008f}, {0x8a5d,    0x0070},
+{0x8a5e,    0x0027}, {0x8a5f,    0x0006}, {0x8a60,    0x0096},
+{0x8a61,    0x0022}, {0x8a62,    0x008a}, {0x8a63,    0x0040},
+{0x8a64,    0x0097}, {0x8a65,    0x0022}, {0x8a66,    0x0074},
+{0x8a67,    0x008f}, {0x8a68,    0x0071}, {0x8a69,    0x0074},
+{0x8a6a,    0x008f}, {0x8a6b,    0x0071}, {0x8a6c,    0x0078},
+{0x8a6d,    0x008f}, {0x8a6e,    0x0070}, {0x8a6f,    0x00b6},
+{0x8a70,    0x008f}, {0x8a71,    0x0070}, {0x8a72,    0x0085},
+{0x8a73,    0x0010}, {0x8a74,    0x0027}, {0x8a75,    0x00af},
+{0x8a76,    0x00d6}, {0x8a77,    0x0022}, {0x8a78,    0x00c4},
+{0x8a79,    0x0010}, {0x8a7a,    0x0058}, {0x8a7b,    0x00b6},
+{0x8a7c,    0x0012}, {0x8a7d,    0x0070}, {0x8a7e,    0x0081},
+{0x8a7f,    0x00e4}, {0x8a80,    0x0027}, {0x8a81,    0x0036},
+{0x8a82,    0x0081}, {0x8a83,    0x00e1}, {0x8a84,    0x0026},
+{0x8a85,    0x000c}, {0x8a86,    0x0096}, {0x8a87,    0x0022},
+{0x8a88,    0x0084}, {0x8a89,    0x0020}, {0x8a8a,    0x0044},
+{0x8a8b,    0x001b}, {0x8a8c,    0x00d6}, {0x8a8d,    0x0022},
+{0x8a8e,    0x00c4}, {0x8a8f,    0x00cf}, {0x8a90,    0x0020},
+{0x8a91,    0x0023}, {0x8a92,    0x0058}, {0x8a93,    0x0081},
+{0x8a94,    0x00c6}, {0x8a95,    0x0026}, {0x8a96,    0x000d},
+{0x8a97,    0x0096}, {0x8a98,    0x0022}, {0x8a99,    0x0084},
+{0x8a9a,    0x0040}, {0x8a9b,    0x0044}, {0x8a9c,    0x0044},
+{0x8a9d,    0x001b}, {0x8a9e,    0x00d6}, {0x8a9f,    0x0022},
+{0x8aa0,    0x00c4}, {0x8aa1,    0x00af}, {0x8aa2,    0x0020},
+{0x8aa3,    0x0011}, {0x8aa4,    0x0058}, {0x8aa5,    0x0081},
+{0x8aa6,    0x0027}, {0x8aa7,    0x0026}, {0x8aa8,    0x000f},
+{0x8aa9,    0x0096}, {0x8aaa,    0x0022}, {0x8aab,    0x0084},
+{0x8aac,    0x0080}, {0x8aad,    0x0044}, {0x8aae,    0x0044},
+{0x8aaf,    0x0044}, {0x8ab0,    0x001b}, {0x8ab1,    0x00d6},
+{0x8ab2,    0x0022}, {0x8ab3,    0x00c4}, {0x8ab4,    0x006f},
+{0x8ab5,    0x001b}, {0x8ab6,    0x0097}, {0x8ab7,    0x0022},
+{0x8ab8,    0x0039}, {0x8ab9,    0x0027}, {0x8aba,    0x000c},
+{0x8abb,    0x007c}, {0x8abc,    0x0082}, {0x8abd,    0x0006},
+{0x8abe,    0x00bd}, {0x8abf,    0x00d9}, {0x8ac0,    0x00ed},
+{0x8ac1,    0x00b6}, {0x8ac2,    0x0082}, {0x8ac3,    0x0007},
+{0x8ac4,    0x007e}, {0x8ac5,    0x008a}, {0x8ac6,    0x00b9},
+{0x8ac7,    0x007f}, {0x8ac8,    0x0082}, {0x8ac9,    0x0006},
+{0x8aca,    0x0039}, { 0x0, 0x0 }
+};
+#endif
+
+
+/* phy types */
+#define   CAS_PHY_UNKNOWN       0x00
+#define   CAS_PHY_SERDES        0x01
+#define   CAS_PHY_MII_MDIO0     0x02
+#define   CAS_PHY_MII_MDIO1     0x04
+#define   CAS_PHY_MII(x)        ((x) & (CAS_PHY_MII_MDIO0 | CAS_PHY_MII_MDIO1))
+
+/* _RING_INDEX is the index for the ring sizes to be used.  _RING_SIZE
+ * is the actual size. the default index for the various rings is
+ * 8. NOTE: there a bunch of alignment constraints for the rings. to
+ * deal with that, i just allocate rings to create the desired
+ * alignment. here are the constraints:
+ *   RX DESC and COMP rings must be 8KB aligned
+ *   TX DESC must be 2KB aligned. 
+ * if you change the numbers, be cognizant of how the alignment will change
+ * in INIT_BLOCK as well.
+ */
+
+#define DESC_RING_I_TO_S(x)  (32*(1 << (x)))
+#define COMP_RING_I_TO_S(x)  (128*(1 << (x)))
+#define TX_DESC_RING_INDEX 4  /* 512 = 8k */
+#define RX_DESC_RING_INDEX 4  /* 512 = 8k */
+#define RX_COMP_RING_INDEX 4  /* 2048 = 64k: should be 4x rx ring size */
+
+#if (TX_DESC_RING_INDEX > 8) || (TX_DESC_RING_INDEX < 0)
+#error TX_DESC_RING_INDEX must be between 0 and 8
+#endif
+
+#if (RX_DESC_RING_INDEX > 8) || (RX_DESC_RING_INDEX < 0)
+#error RX_DESC_RING_INDEX must be between 0 and 8
+#endif
+
+#if (RX_COMP_RING_INDEX > 8) || (RX_COMP_RING_INDEX < 0)
+#error RX_COMP_RING_INDEX must be between 0 and 8
+#endif
+
+#define N_TX_RINGS                    MAX_TX_RINGS      /* for QoS */
+#define N_TX_RINGS_MASK               MAX_TX_RINGS_MASK
+#define N_RX_DESC_RINGS               MAX_RX_DESC_RINGS /* 1 for ipsec */
+#define N_RX_COMP_RINGS               0x1 /* for mult. PCI interrupts */
+
+/* number of flows that can go through re-assembly */
+#define N_RX_FLOWS                    64
+
+#define TX_DESC_RING_SIZE  DESC_RING_I_TO_S(TX_DESC_RING_INDEX)
+#define RX_DESC_RING_SIZE  DESC_RING_I_TO_S(RX_DESC_RING_INDEX)
+#define RX_COMP_RING_SIZE  COMP_RING_I_TO_S(RX_COMP_RING_INDEX)
+#define TX_DESC_RINGN_INDEX(x) TX_DESC_RING_INDEX
+#define RX_DESC_RINGN_INDEX(x) RX_DESC_RING_INDEX
+#define RX_COMP_RINGN_INDEX(x) RX_COMP_RING_INDEX
+#define TX_DESC_RINGN_SIZE(x)  TX_DESC_RING_SIZE
+#define RX_DESC_RINGN_SIZE(x)  RX_DESC_RING_SIZE
+#define RX_COMP_RINGN_SIZE(x)  RX_COMP_RING_SIZE
+
+/* convert values */
+#define CAS_BASE(x, y)                (((y) << (x ## _SHIFT)) & (x ## _MASK))
+#define CAS_VAL(x, y)                 (((y) & (x ## _MASK)) >> (x ## _SHIFT))
+#define CAS_TX_RINGN_BASE(y)          ((TX_DESC_RINGN_INDEX(y) << \
+                                        TX_CFG_DESC_RINGN_SHIFT(y)) & \
+                                        TX_CFG_DESC_RINGN_MASK(y))
+
+/* min is 2k, but we can't do jumbo frames unless it's at least 8k */
+#define CAS_MIN_PAGE_SHIFT            11 /* 2048 */
+#define CAS_JUMBO_PAGE_SHIFT          13 /* 8192 */
+#define CAS_MAX_PAGE_SHIFT            14 /* 16384 */             
+
+#define TX_DESC_BUFLEN_MASK         0x0000000000003FFFULL /* buffer length in
+                                                            bytes. 0 - 9256 */
+#define TX_DESC_BUFLEN_SHIFT        0
+#define TX_DESC_CSUM_START_MASK     0x00000000001F8000ULL /* checksum start. #
+                                                            of bytes to be 
+                                                            skipped before
+                                                            csum calc begins.
+                                                            value must be
+                                                            even */
+#define TX_DESC_CSUM_START_SHIFT    15
+#define TX_DESC_CSUM_STUFF_MASK     0x000000001FE00000ULL /* checksum stuff.
+                                                            byte offset w/in 
+                                                            the pkt for the
+                                                            1st csum byte.
+                                                            must be > 8 */
+#define TX_DESC_CSUM_STUFF_SHIFT    21
+#define TX_DESC_CSUM_EN             0x0000000020000000ULL /* enable checksum */
+#define TX_DESC_EOF                 0x0000000040000000ULL /* end of frame */
+#define TX_DESC_SOF                 0x0000000080000000ULL /* start of frame */
+#define TX_DESC_INTME               0x0000000100000000ULL /* interrupt me */
+#define TX_DESC_NO_CRC              0x0000000200000000ULL /* debugging only.
+                                                            CRC will not be
+                                                            inserted into
+                                                            outgoing frame. */
+struct cas_tx_desc {
+       u64     control;
+       u64     buffer;
+};
+
+/* descriptor ring for free buffers contains page-sized buffers. the index
+ * value is not used by the hw in any way. it's just stored and returned in
+ * the completion ring.
+ */
+struct cas_rx_desc {
+       u64     index;
+       u64     buffer;
+};
+
+/* received packets are put on the completion ring. */
+/* word 1 */
+#define RX_COMP1_DATA_SIZE_MASK           0x0000000007FFE000ULL   
+#define RX_COMP1_DATA_SIZE_SHIFT          13
+#define RX_COMP1_DATA_OFF_MASK            0x000001FFF8000000ULL
+#define RX_COMP1_DATA_OFF_SHIFT           27
+#define RX_COMP1_DATA_INDEX_MASK          0x007FFE0000000000ULL
+#define RX_COMP1_DATA_INDEX_SHIFT         41
+#define RX_COMP1_SKIP_MASK                0x0180000000000000ULL
+#define RX_COMP1_SKIP_SHIFT               55
+#define RX_COMP1_RELEASE_NEXT             0x0200000000000000ULL
+#define RX_COMP1_SPLIT_PKT                0x0400000000000000ULL
+#define RX_COMP1_RELEASE_FLOW             0x0800000000000000ULL  
+#define RX_COMP1_RELEASE_DATA             0x1000000000000000ULL  
+#define RX_COMP1_RELEASE_HDR              0x2000000000000000ULL
+#define RX_COMP1_TYPE_MASK                0xC000000000000000ULL
+#define RX_COMP1_TYPE_SHIFT               62
+
+/* word 2 */
+#define RX_COMP2_NEXT_INDEX_MASK          0x00000007FFE00000ULL
+#define RX_COMP2_NEXT_INDEX_SHIFT         21
+#define RX_COMP2_HDR_SIZE_MASK            0x00000FF800000000ULL
+#define RX_COMP2_HDR_SIZE_SHIFT           35
+#define RX_COMP2_HDR_OFF_MASK             0x0003F00000000000ULL
+#define RX_COMP2_HDR_OFF_SHIFT            44
+#define RX_COMP2_HDR_INDEX_MASK           0xFFFC000000000000ULL
+#define RX_COMP2_HDR_INDEX_SHIFT          50
+
+/* word 3 */
+#define RX_COMP3_SMALL_PKT                0x0000000000000001ULL
+#define RX_COMP3_JUMBO_PKT                0x0000000000000002ULL
+#define RX_COMP3_JUMBO_HDR_SPLIT_EN       0x0000000000000004ULL
+#define RX_COMP3_CSUM_START_MASK          0x000000000007F000ULL
+#define RX_COMP3_CSUM_START_SHIFT         12
+#define RX_COMP3_FLOWID_MASK              0x0000000001F80000ULL
+#define RX_COMP3_FLOWID_SHIFT             19
+#define RX_COMP3_OPCODE_MASK              0x000000000E000000ULL
+#define RX_COMP3_OPCODE_SHIFT             25
+#define RX_COMP3_FORCE_FLAG               0x0000000010000000ULL
+#define RX_COMP3_NO_ASSIST                0x0000000020000000ULL
+#define RX_COMP3_LOAD_BAL_MASK            0x000001F800000000ULL
+#define RX_COMP3_LOAD_BAL_SHIFT           35
+#define RX_PLUS_COMP3_ENC_PKT             0x0000020000000000ULL /* cas+ */
+#define RX_COMP3_L3_HEAD_OFF_MASK         0x0000FE0000000000ULL /* cas */
+#define RX_COMP3_L3_HEAD_OFF_SHIFT        41
+#define RX_PLUS_COMP_L3_HEAD_OFF_MASK     0x0000FC0000000000ULL /* cas+ */
+#define RX_PLUS_COMP_L3_HEAD_OFF_SHIFT    42
+#define RX_COMP3_SAP_MASK                 0xFFFF000000000000ULL
+#define RX_COMP3_SAP_SHIFT                48
+
+/* word 4 */
+#define RX_COMP4_TCP_CSUM_MASK            0x000000000000FFFFULL
+#define RX_COMP4_TCP_CSUM_SHIFT           0
+#define RX_COMP4_PKT_LEN_MASK             0x000000003FFF0000ULL
+#define RX_COMP4_PKT_LEN_SHIFT            16
+#define RX_COMP4_PERFECT_MATCH_MASK       0x00000003C0000000ULL
+#define RX_COMP4_PERFECT_MATCH_SHIFT      30
+#define RX_COMP4_ZERO                     0x0000080000000000ULL
+#define RX_COMP4_HASH_VAL_MASK            0x0FFFF00000000000ULL
+#define RX_COMP4_HASH_VAL_SHIFT           44
+#define RX_COMP4_HASH_PASS                0x1000000000000000ULL
+#define RX_COMP4_BAD                      0x4000000000000000ULL
+#define RX_COMP4_LEN_MISMATCH             0x8000000000000000ULL
+
+/* we encode the following: ring/index/release. only 14 bits
+ * are usable.
+ * NOTE: the encoding is dependent upon RX_DESC_RING_SIZE and 
+ *       MAX_RX_DESC_RINGS. */
+#define RX_INDEX_NUM_MASK                 0x0000000000000FFFULL
+#define RX_INDEX_NUM_SHIFT                0
+#define RX_INDEX_RING_MASK                0x0000000000001000ULL
+#define RX_INDEX_RING_SHIFT               12
+#define RX_INDEX_RELEASE                  0x0000000000002000ULL
+
+struct cas_rx_comp {
+       u64     word1;
+       u64     word2;
+       u64     word3;
+       u64     word4;
+}; 
+
+enum link_state {
+       link_down = 0,  /* No link, will retry */
+       link_aneg,      /* Autoneg in progress */
+       link_force_try, /* Try Forced link speed */
+       link_force_ret, /* Forced mode worked, retrying autoneg */
+       link_force_ok,  /* Stay in forced mode */
+       link_up         /* Link is up */
+};
+
+typedef struct cas_page {
+       struct list_head list;
+       struct page *buffer;
+       dma_addr_t dma_addr;
+       int used;
+} cas_page_t;
+
+
+/* some alignment constraints:
+ * TX DESC, RX DESC, and RX COMP must each be 8K aligned.
+ * TX COMPWB must be 8-byte aligned. 
+ * to accomplish this, here's what we do:
+ * 
+ * INIT_BLOCK_RX_COMP  = 64k (already aligned)
+ * INIT_BLOCK_RX_DESC  = 8k
+ * INIT_BLOCK_TX       = 8k
+ * INIT_BLOCK_RX1_DESC = 8k
+ * TX COMPWB
+ */
+#define INIT_BLOCK_TX           (TX_DESC_RING_SIZE)
+#define INIT_BLOCK_RX_DESC      (RX_DESC_RING_SIZE)
+#define INIT_BLOCK_RX_COMP      (RX_COMP_RING_SIZE)
+
+struct cas_init_block {
+       struct cas_rx_comp rxcs[N_RX_COMP_RINGS][INIT_BLOCK_RX_COMP];
+       struct cas_rx_desc rxds[N_RX_DESC_RINGS][INIT_BLOCK_RX_DESC]; 
+       struct cas_tx_desc txds[N_TX_RINGS][INIT_BLOCK_TX];
+       u64 tx_compwb; 
+};
+
+/* tiny buffers to deal with target abort issue. we allocate a bit
+ * over so that we don't have target abort issues with these buffers
+ * as well.
+ */
+#define TX_TINY_BUF_LEN    0x100
+#define TX_TINY_BUF_BLOCK  ((INIT_BLOCK_TX + 1)*TX_TINY_BUF_LEN)
+
+struct cas_tiny_count {
+       int nbufs;
+       int used;
+};
+
+struct cas {
+       spinlock_t lock; /* for most bits */
+       spinlock_t tx_lock[N_TX_RINGS]; /* tx bits */
+       spinlock_t stat_lock[N_TX_RINGS + 1]; /* for stat gathering */
+       spinlock_t rx_inuse_lock; /* rx inuse list */
+       spinlock_t rx_spare_lock; /* rx spare list */
+
+       void __iomem *regs;
+       int tx_new[N_TX_RINGS], tx_old[N_TX_RINGS];
+       int rx_old[N_RX_DESC_RINGS];
+       int rx_cur[N_RX_COMP_RINGS], rx_new[N_RX_COMP_RINGS];
+       int rx_last[N_RX_DESC_RINGS]; 
+
+       /* Set when chip is actually in operational state
+        * (ie. not power managed) */
+       int hw_running;
+       int opened;
+       struct semaphore pm_sem; /* open/close/suspend/resume */
+
+       struct cas_init_block *init_block;
+       struct cas_tx_desc *init_txds[MAX_TX_RINGS];
+       struct cas_rx_desc *init_rxds[MAX_RX_DESC_RINGS];
+       struct cas_rx_comp *init_rxcs[MAX_RX_COMP_RINGS];
+
+       /* we use sk_buffs for tx and pages for rx. the rx skbuffs
+        * are there for flow re-assembly. */
+       struct sk_buff      *tx_skbs[N_TX_RINGS][TX_DESC_RING_SIZE];
+       struct sk_buff_head  rx_flows[N_RX_FLOWS];
+       cas_page_t          *rx_pages[N_RX_DESC_RINGS][RX_DESC_RING_SIZE];
+       struct list_head     rx_spare_list, rx_inuse_list;
+       int                  rx_spares_needed;
+
+       /* for small packets when copying would be quicker than
+          mapping */
+       struct cas_tiny_count tx_tiny_use[N_TX_RINGS][TX_DESC_RING_SIZE];
+       u8 *tx_tiny_bufs[N_TX_RINGS];
+
+       u32                     msg_enable;
+
+       /* N_TX_RINGS must be >= N_RX_DESC_RINGS */
+       struct net_device_stats net_stats[N_TX_RINGS + 1];
+
+       u32                     pci_cfg[64 >> 2];
+       u8                      pci_revision;
+
+       int                     phy_type;
+       int                     phy_addr;
+       u32                     phy_id;
+#define CAS_FLAG_1000MB_CAP     0x00000001
+#define CAS_FLAG_REG_PLUS       0x00000002
+#define CAS_FLAG_TARGET_ABORT   0x00000004
+#define CAS_FLAG_SATURN         0x00000008
+#define CAS_FLAG_RXD_POST_MASK  0x000000F0
+#define CAS_FLAG_RXD_POST_SHIFT 4
+#define CAS_FLAG_RXD_POST(x)    ((1 << (CAS_FLAG_RXD_POST_SHIFT + (x))) & \
+                                 CAS_FLAG_RXD_POST_MASK)
+#define CAS_FLAG_ENTROPY_DEV    0x00000100
+#define CAS_FLAG_NO_HW_CSUM     0x00000200
+       u32                     cas_flags;
+       int                     packet_min; /* minimum packet size */
+       int                     tx_fifo_size;
+       int                     rx_fifo_size;
+       int                     rx_pause_off;
+       int                     rx_pause_on;
+       int                     crc_size;      /* 4 if half-duplex */
+
+       int                     pci_irq_INTC;
+       int                     min_frame_size; /* for tx fifo workaround */
+
+       /* page size allocation */
+       int                     page_size; 
+       int                     page_order;
+       int                     mtu_stride;
+
+       u32                     mac_rx_cfg;
+
+       /* Autoneg & PHY control */
+       int                     link_cntl;
+       int                     link_fcntl;
+       enum link_state         lstate;
+       struct timer_list       link_timer;
+       int                     timer_ticks;
+       struct work_struct      reset_task;
+#if 0
+       atomic_t                reset_task_pending;
+#else
+       atomic_t                reset_task_pending;
+       atomic_t                reset_task_pending_mtu;
+       atomic_t                reset_task_pending_spare;
+       atomic_t                reset_task_pending_all;
+#endif
+
+#ifdef CONFIG_CASSINI_QGE_DEBUG
+       atomic_t interrupt_seen; /* 1 if any interrupts are getting through */
+#endif
+       
+       /* Link-down problem workaround */
+#define LINK_TRANSITION_UNKNOWN        0
+#define LINK_TRANSITION_ON_FAILURE     1
+#define LINK_TRANSITION_STILL_FAILED   2
+#define LINK_TRANSITION_LINK_UP        3
+#define LINK_TRANSITION_LINK_CONFIG    4
+#define LINK_TRANSITION_LINK_DOWN      5
+#define LINK_TRANSITION_REQUESTED_RESET        6
+       int                     link_transition;
+       int                     link_transition_jiffies_valid;
+       unsigned long           link_transition_jiffies;
+
+       /* Tuning */
+       u8 orig_cacheline_size; /* value when loaded */
+#define CAS_PREF_CACHELINE_SIZE         0x20   /* Minimum desired */
+
+       /* Diagnostic counters and state. */
+       int                     casreg_len; /* reg-space size for dumping */
+       u64                     pause_entered;
+       u16                     pause_last_time_recvd;
+  
+       dma_addr_t block_dvma, tx_tiny_dvma[N_TX_RINGS];
+       struct pci_dev *pdev;
+       struct net_device *dev;
+};
+
+#define TX_DESC_NEXT(r, x)  (((x) + 1) & (TX_DESC_RINGN_SIZE(r) - 1))
+#define RX_DESC_ENTRY(r, x) ((x) & (RX_DESC_RINGN_SIZE(r) - 1))
+#define RX_COMP_ENTRY(r, x) ((x) & (RX_COMP_RINGN_SIZE(r) - 1))
+
+#define TX_BUFF_COUNT(r, x, y)    ((x) <= (y) ? ((y) - (x)) : \
+        (TX_DESC_RINGN_SIZE(r) - (x) + (y)))    
+
+#define TX_BUFFS_AVAIL(cp, i)  ((cp)->tx_old[(i)] <= (cp)->tx_new[(i)] ? \
+        (cp)->tx_old[(i)] + (TX_DESC_RINGN_SIZE(i) - 1) - (cp)->tx_new[(i)] : \
+        (cp)->tx_old[(i)] - (cp)->tx_new[(i)] - 1)
+
+#define CAS_ALIGN(addr, align) \
+     (((unsigned long) (addr) + ((align) - 1UL)) & ~((align) - 1))
+
+#define RX_FIFO_SIZE                  16384
+#define EXPANSION_ROM_SIZE            65536
+
+#define CAS_MC_EXACT_MATCH_SIZE       15
+#define CAS_MC_HASH_SIZE              256
+#define CAS_MC_HASH_MAX              (CAS_MC_EXACT_MATCH_SIZE + \
+                                      CAS_MC_HASH_SIZE)
+
+#define TX_TARGET_ABORT_LEN           0x20
+#define RX_SWIVEL_OFF_VAL             0x2
+#define RX_AE_FREEN_VAL(x)            (RX_DESC_RINGN_SIZE(x) >> 1)
+#define RX_AE_COMP_VAL                (RX_COMP_RING_SIZE >> 1)
+#define RX_BLANK_INTR_PKT_VAL         0x05
+#define RX_BLANK_INTR_TIME_VAL        0x0F
+#define HP_TCP_THRESH_VAL             1530 /* reduce to enable reassembly */
+
+#define RX_SPARE_COUNT                (RX_DESC_RING_SIZE >> 1)
+#define RX_SPARE_RECOVER_VAL          (RX_SPARE_COUNT >> 2)
+
+#endif /* _CASSINI_H */
index 0de3bb9061741bca16cf853d89941b27355354a9..14e9b6315f208feab806c2838eba5a6911a04852 100644 (file)
@@ -1875,6 +1875,9 @@ static int emac_init_device(struct ocp_device *ocpdev, struct ibm_ocp_mal *mal)
                rc = -ENODEV;
                goto bail;
        }
+       
+       /* Disable any PHY features not supported by the platform */
+       ep->phy_mii.def->features &= ~emacdata->phy_feat_exc;
 
        /* Setup initial PHY config & startup aneg */
        if (ep->phy_mii.def->ops->init)
@@ -1882,6 +1885,34 @@ static int emac_init_device(struct ocp_device *ocpdev, struct ibm_ocp_mal *mal)
        netif_carrier_off(ndev);
        if (ep->phy_mii.def->features & SUPPORTED_Autoneg)
                ep->want_autoneg = 1;
+       else {
+               ep->want_autoneg = 0;
+               
+               /* Select highest supported speed/duplex */
+               if (ep->phy_mii.def->features & SUPPORTED_1000baseT_Full) {
+                       ep->phy_mii.speed = SPEED_1000;
+                       ep->phy_mii.duplex = DUPLEX_FULL;
+               } else if (ep->phy_mii.def->features & 
+                          SUPPORTED_1000baseT_Half) {
+                       ep->phy_mii.speed = SPEED_1000;
+                       ep->phy_mii.duplex = DUPLEX_HALF;
+               } else if (ep->phy_mii.def->features & 
+                          SUPPORTED_100baseT_Full) {
+                       ep->phy_mii.speed = SPEED_100;
+                       ep->phy_mii.duplex = DUPLEX_FULL;
+               } else if (ep->phy_mii.def->features & 
+                          SUPPORTED_100baseT_Half) {
+                       ep->phy_mii.speed = SPEED_100;
+                       ep->phy_mii.duplex = DUPLEX_HALF;
+               } else if (ep->phy_mii.def->features & 
+                          SUPPORTED_10baseT_Full) {
+                       ep->phy_mii.speed = SPEED_10;
+                       ep->phy_mii.duplex = DUPLEX_FULL;
+               } else {
+                       ep->phy_mii.speed = SPEED_10;
+                       ep->phy_mii.duplex = DUPLEX_HALF;
+               }
+       }
        emac_start_link(ep, NULL);
 
        /* read the MAC Address */
index 32d5fabd4b1019a2c26378f72dbd7d6d518fb2e4..a2c4dd4fb2218071fbffb8aa9f9438ddacff359a 100644 (file)
@@ -99,7 +99,7 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs
 static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*);
 
 #ifdef CONFIG_PROC_FS
-#define IBMVETH_PROC_DIR "ibmveth"
+#define IBMVETH_PROC_DIR "net/ibmveth"
 static struct proc_dir_entry *ibmveth_proc_dir;
 #endif
 
@@ -1010,7 +1010,7 @@ static int __devexit ibmveth_remove(struct vio_dev *dev)
 #ifdef CONFIG_PROC_FS
 static void ibmveth_proc_register_driver(void)
 {
-       ibmveth_proc_dir = create_proc_entry(IBMVETH_PROC_DIR, S_IFDIR, proc_net);
+       ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, NULL);
        if (ibmveth_proc_dir) {
                SET_MODULE_OWNER(ibmveth_proc_dir);
        }
@@ -1018,7 +1018,7 @@ static void ibmveth_proc_register_driver(void)
 
 static void ibmveth_proc_unregister_driver(void)
 {
-       remove_proc_entry(IBMVETH_PROC_DIR, proc_net);
+       remove_proc_entry(IBMVETH_PROC_DIR, NULL);
 }
 
 static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) 
index 6d9de626c9670db8e0f4d436cfbfda6913fd6ceb..651c5a6578fd35cc8dd69a3e70ff3341c5366329 100644 (file)
@@ -1875,11 +1875,11 @@ static int __init vlsi_mod_init(void)
 
        sirpulse = !!sirpulse;
 
-       /* create_proc_entry returns NULL if !CONFIG_PROC_FS.
+       /* proc_mkdir returns NULL if !CONFIG_PROC_FS.
         * Failure to create the procfs entry is handled like running
         * without procfs - it's not required for the driver to work.
         */
-       vlsi_proc_root = create_proc_entry(PROC_DIR, S_IFDIR, NULL);
+       vlsi_proc_root = proc_mkdir(PROC_DIR, NULL);
        if (vlsi_proc_root) {
                /* protect registered procdir against module removal.
                 * Because we are in the module init path there's no race
index e64df4d0800b2a1802f5e350871f62f5ad58d85f..83334db2921c98349bf737aeeee00c630b931d0f 100644 (file)
@@ -584,7 +584,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
        return 0;
 }
 
-static inline int rx_refill(struct net_device *ndev, int gfp)
+static inline int rx_refill(struct net_device *ndev, unsigned int __nocast gfp)
 {
        struct ns83820 *dev = PRIV(ndev);
        unsigned i;
index d652e1eddb4588c0b6f1322457debaa62e28cef2..c7cca842e5ee25668b9104e77e5a0b4bea00497b 100644 (file)
@@ -1832,7 +1832,7 @@ static void fill_multicast_tbl(int count, struct dev_mc_list *addrs,
 {
     struct dev_mc_list *mc_addr;
 
-    for (mc_addr = addrs;  mc_addr && --count > 0;  mc_addr = mc_addr->next) {
+    for (mc_addr = addrs;  mc_addr && count-- > 0;  mc_addr = mc_addr->next) {
        u_int position = ether_crc(6, mc_addr->dmi_addr);
 #ifndef final_version          /* Verify multicast address. */
        if ((mc_addr->dmi_addr[0] & 1) == 0)
index 82f236cc3b9b31e4aa9df662a639456d519ea103..a842ecc60a34000d746c7d96aff16ca1f661f3e2 100644 (file)
@@ -1070,7 +1070,7 @@ static int __init pppoe_proc_init(void)
 {
        struct proc_dir_entry *p;
 
-       p = create_proc_entry("pppoe", S_IRUGO, proc_net);
+       p = create_proc_entry("net/pppoe", S_IRUGO, NULL);
        if (!p)
                return -ENOMEM;
 
@@ -1142,7 +1142,7 @@ static void __exit pppoe_exit(void)
        dev_remove_pack(&pppoes_ptype);
        dev_remove_pack(&pppoed_ptype);
        unregister_netdevice_notifier(&pppoe_notifier);
-       remove_proc_entry("pppoe", proc_net);
+       remove_proc_entry("net/pppoe", NULL);
        proto_unregister(&pppoe_sk_proto);
 }
 
index f9223c1c5aa45f95cb501252a341073ff8e19483..afb3f186b8843b96b4ad0214c18e40515a11b091 100644 (file)
@@ -92,8 +92,7 @@ VERSION 2.2LK <2005/01/25>
 #endif /* RTL8169_DEBUG */
 
 #define R8169_MSG_DEFAULT \
-       (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFUP | \
-        NETIF_MSG_IFDOWN)
+       (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
 
 #define TX_BUFFS_AVAIL(tp) \
        (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1)
index 2e72d79a143c1ae4c57959eae8cfbcccd76f6968..b18c92cb629e8a34ee95888f0ecd8498eacddf6a 100644 (file)
@@ -235,7 +235,7 @@ static int      SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
  * Extern Function Prototypes
  *
  ******************************************************************************/
-static const char      SKRootName[] = "sk98lin";
+static const char      SKRootName[] = "net/sk98lin";
 static struct          proc_dir_entry *pSkRootDir;
 extern struct  file_operations sk_proc_fops;
 
@@ -5242,20 +5242,20 @@ static int __init skge_init(void)
 {
        int error;
 
-       pSkRootDir = proc_mkdir(SKRootName, proc_net);
+       pSkRootDir = proc_mkdir(SKRootName, NULL);
        if (pSkRootDir) 
                pSkRootDir->owner = THIS_MODULE;
        
        error = pci_register_driver(&skge_driver);
        if (error)
-               proc_net_remove(SKRootName);
+               remove_proc_entry(SKRootName, NULL);
        return error;
 }
 
 static void __exit skge_exit(void)
 {
        pci_unregister_driver(&skge_driver);
-       proc_net_remove(SKRootName);
+       remove_proc_entry(SKRootName, NULL);
 
 }
 
index fd398da4993b37f1a1399933b98287c2772bb4e0..c2e6484ef138f6e0c8d7548fd340a61028c85c81 100644 (file)
@@ -2837,21 +2837,29 @@ static void skge_netpoll(struct net_device *dev)
 static int skge_set_mac_address(struct net_device *dev, void *p)
 {
        struct skge_port *skge = netdev_priv(dev);
-       struct sockaddr *addr = p;
-       int err = 0;
+       struct skge_hw *hw = skge->hw;
+       unsigned port = skge->port;
+       const struct sockaddr *addr = p;
 
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
 
-       skge_down(dev);
+       spin_lock_bh(&hw->phy_lock);
        memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
-       memcpy_toio(skge->hw->regs + B2_MAC_1 + skge->port*8,
+       memcpy_toio(hw->regs + B2_MAC_1 + port*8,
                    dev->dev_addr, ETH_ALEN);
-       memcpy_toio(skge->hw->regs + B2_MAC_2 + skge->port*8,
+       memcpy_toio(hw->regs + B2_MAC_2 + port*8,
                    dev->dev_addr, ETH_ALEN);
-       if (dev->flags & IFF_UP)
-               err = skge_up(dev);
-       return err;
+
+       if (hw->chip_id == CHIP_ID_GENESIS)
+               xm_outaddr(hw, port, XM_SA, dev->dev_addr);
+       else {
+               gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
+               gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
+       }
+       spin_unlock_bh(&hw->phy_lock);
+
+       return 0;
 }
 
 static const struct {
index 88b89dc95c77c8b2643745bf06618c6e2742ccf8..efdb179ecc8c9cffa49be61b8b8ec2a88cf449b3 100644 (file)
        - finally added firmware (GPL'ed by Adaptec)
        - removed compatibility code for 2.2.x
 
+       LK1.4.2.1 (Ion Badulescu)
+       - fixed 32/64 bit issues on i386 + CONFIG_HIGHMEM
+       - added 32-bit padding to outgoing skb's, removed previous workaround
+
 TODO:  - fix forced speed/duplexing code (broken a long time ago, when
        somebody converted the driver to use the generic MII code)
        - fix VLAN support
 */
 
 #define DRV_NAME       "starfire"
-#define DRV_VERSION    "1.03+LK1.4.2"
-#define DRV_RELDATE    "January 19, 2005"
+#define DRV_VERSION    "1.03+LK1.4.2.1"
+#define DRV_RELDATE    "October 3, 2005"
 
 #include <linux/config.h>
 #include <linux/version.h>
@@ -165,6 +169,14 @@ TODO:      - fix forced speed/duplexing code (broken a long time ago, when
  * of length 1. If and when this is fixed, the #define below can be removed.
  */
 #define HAS_BROKEN_FIRMWARE
+
+/*
+ * If using the broken firmware, data must be padded to the next 32-bit boundary.
+ */
+#ifdef HAS_BROKEN_FIRMWARE
+#define PADDING_MASK 3
+#endif
+
 /*
  * Define this if using the driver with the zero-copy patch
  */
@@ -257,9 +269,10 @@ static int full_duplex[MAX_UNITS] = {0, };
  * This SUCKS.
  * We need a much better method to determine if dma_addr_t is 64-bit.
  */
-#if (defined(__i386__) && defined(CONFIG_HIGHMEM) && (LINUX_VERSION_CODE > 0x20500 || defined(CONFIG_HIGHMEM64G))) || defined(__x86_64__) || defined (__ia64__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR))
+#if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR))
 /* 64-bit dma_addr_t */
 #define ADDR_64BITS    /* This chip uses 64 bit addresses. */
+#define netdrv_addr_t u64
 #define cpu_to_dma(x) cpu_to_le64(x)
 #define dma_to_cpu(x) le64_to_cpu(x)
 #define RX_DESC_Q_ADDR_SIZE RxDescQAddr64bit
@@ -268,6 +281,7 @@ static int full_duplex[MAX_UNITS] = {0, };
 #define TX_COMPL_Q_ADDR_SIZE TxComplQAddr64bit
 #define RX_DESC_ADDR_SIZE RxDescAddr64bit
 #else  /* 32-bit dma_addr_t */
+#define netdrv_addr_t u32
 #define cpu_to_dma(x) cpu_to_le32(x)
 #define dma_to_cpu(x) le32_to_cpu(x)
 #define RX_DESC_Q_ADDR_SIZE RxDescQAddr32bit
@@ -1333,21 +1347,10 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        }
 
 #if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE)
-       {
-               int has_bad_length = 0;
-
-               if (skb_first_frag_len(skb) == 1)
-                       has_bad_length = 1;
-               else {
-                       for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
-                               if (skb_shinfo(skb)->frags[i].size == 1) {
-                                       has_bad_length = 1;
-                                       break;
-                               }
-               }
-
-               if (has_bad_length)
-                       skb_checksum_help(skb, 0);
+       if (skb->ip_summed == CHECKSUM_HW) {
+               skb = skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK);
+               if (skb == NULL)
+                       return NETDEV_TX_OK;
        }
 #endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */
 
@@ -2127,13 +2130,12 @@ static int __init starfire_init (void)
 #endif
 #endif
 
-#ifndef ADDR_64BITS
        /* we can do this test only at run-time... sigh */
-       if (sizeof(dma_addr_t) == sizeof(u64)) {
-               printk("This driver has not been ported to this 64-bit architecture yet\n");
+       if (sizeof(dma_addr_t) != sizeof(netdrv_addr_t)) {
+               printk("This driver has dma_addr_t issues, please send email to maintainer\n");
                return -ENODEV;
        }
-#endif /* not ADDR_64BITS */
+
        return pci_module_init (&starfire_driver);
 }
 
index ff8ae5f7997001f3725a0d943f89e5937dc57f87..16edbb1a4a7a147677ff5485653bf64a968f8e38 100644 (file)
@@ -1035,7 +1035,8 @@ struct gem {
                        
 #define ALIGNED_RX_SKB_ADDR(addr) \
         ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr))
-static __inline__ struct sk_buff *gem_alloc_skb(int size, int gfp_flags)
+static __inline__ struct sk_buff *gem_alloc_skb(int size,
+                                               unsigned int __nocast gfp_flags)
 {
        struct sk_buff *skb = alloc_skb(size + 64, gfp_flags);
 
index 25f85fb9df46d33b16fafa3f0be04b2dd757aef6..1802c3b48799db5a4789038ed372110fa0ad9af9 100644 (file)
@@ -67,8 +67,8 @@
 
 #define DRV_MODULE_NAME                "tg3"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "3.41"
-#define DRV_MODULE_RELDATE     "September 27, 2005"
+#define DRV_MODULE_VERSION     "3.42"
+#define DRV_MODULE_RELDATE     "Oct 3, 2005"
 
 #define TG3_DEF_MAC_MODE       0
 #define TG3_DEF_RX_MODE                0
@@ -9284,8 +9284,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
        static struct pci_device_id write_reorder_chipsets[] = {
                { PCI_DEVICE(PCI_VENDOR_ID_AMD,
                             PCI_DEVICE_ID_AMD_FE_GATE_700C) },
-               { PCI_DEVICE(PCI_VENDOR_ID_AMD,
-                            PCI_DEVICE_ID_AMD_K8_NB) },
+               { PCI_DEVICE(PCI_VENDOR_ID_VIA,
+                            PCI_DEVICE_ID_VIA_8385_0) },
                { },
        };
        u32 misc_ctrl_reg;
@@ -9300,15 +9300,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
                tp->tg3_flags2 |= TG3_FLG2_SUN_570X;
 #endif
 
-       /* If we have an AMD 762 or K8 chipset, write
-        * reordering to the mailbox registers done by the host
-        * controller can cause major troubles.  We read back from
-        * every mailbox register write to force the writes to be
-        * posted to the chip in order.
-        */
-       if (pci_dev_present(write_reorder_chipsets))
-               tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
-
        /* Force memory write invalidate off.  If we leave it on,
         * then on 5700_BX chips we have to enable a workaround.
         * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary
@@ -9439,6 +9430,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
        if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0)
                tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
 
+       /* If we have an AMD 762 or VIA K8T800 chipset, write
+        * reordering to the mailbox registers done by the host
+        * controller can cause major troubles.  We read back from
+        * every mailbox register write to force the writes to be
+        * posted to the chip in order.
+        */
+       if (pci_dev_present(write_reorder_chipsets) &&
+           !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))
+               tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
+
        if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&
            tp->pci_lat_timer < 64) {
                tp->pci_lat_timer = 64;
index e7b001017b9a18dd5184f95604f14b6cfb7b6773..32057e65808bdafe5a9ed826800eb1f7e1ff747e 100644 (file)
@@ -531,7 +531,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
                        if (!time_after(jiffies, timeout)) continue;
                        DPRINTK( "Hardware timeout during initialization.\n");
                        iounmap(t_mmio);
-                       kfree(ti);
                        return -ENODEV;
                }
                ti->sram_phys =
@@ -645,7 +644,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
                        DPRINTK("Unknown shared ram paging info %01X\n",
                                                        ti->shared_ram_paging);
                        iounmap(t_mmio); 
-                       kfree(ti);
                        return -ENODEV;
                        break;
                } /*end switch shared_ram_paging */
@@ -675,7 +673,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
                        "driver limit (%05x), adapter not started.\n",
                        chk_base, ibmtr_mem_base + IBMTR_SHARED_RAM_SIZE);
                        iounmap(t_mmio);
-                       kfree(ti);
                        return -ENODEV;
                } else { /* seems cool, record what we have figured out */
                        ti->sram_base = new_base >> 12;
@@ -690,7 +687,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
                DPRINTK("Could not grab irq %d.  Halting Token Ring driver.\n",
                                        irq);
                iounmap(t_mmio);
-               kfree(ti);
                return -ENODEV;
        }
        /*?? Now, allocate some of the PIO PORTs for this driver.. */
@@ -699,7 +695,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
                DPRINTK("Could not grab PIO range. Halting driver.\n");
                free_irq(dev->irq, dev);
                iounmap(t_mmio);
-               kfree(ti);
                return -EBUSY;
        }
 
index 5db694c4eb020cc6c2ba7164dc5889ed0d34115b..683f14b01c066f4a9622b778005ebc93d7bab72d 100644 (file)
@@ -172,7 +172,7 @@ void t21142_lnk_change(struct net_device *dev, int csr5)
                        int i;
                        for (i = 0; i < tp->mtable->leafcount; i++)
                                if (tp->mtable->mleaf[i].media == dev->if_port) {
-                                       int startup = ! ((tp->chip_id == DC21143 && tp->revision == 65));
+                                       int startup = ! ((tp->chip_id == DC21143 && (tp->revision == 48 || tp->revision == 65)));
                                        tp->cur_index = i;
                                        tulip_select_media(dev, startup);
                                        setup_done = 1;
index 74e151acef3e7e3d1893d1313e631c7d3c49a229..7a8b22a7ea31e9f58660b4cad62b17d1ff6b1c09 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/ioport.h>      /* request_region(), release_region() */
 #include <linux/wanrouter.h>   /* WAN router definitions */
 #include <linux/wanpipe.h>     /* WANPIPE common user API definitions */
+#include <linux/rcupdate.h>
 
 #include <linux/in.h>
 #include <asm/io.h>            /* phys_to_virt() */
@@ -1268,37 +1269,41 @@ unsigned long get_ip_address(struct net_device *dev, int option)
        
        struct in_ifaddr *ifaddr;
        struct in_device *in_dev;
+       unsigned long addr = 0;
 
-       if ((in_dev = __in_dev_get(dev)) == NULL){
-               return 0;
+       rcu_read_lock();
+       if ((in_dev = __in_dev_get_rcu(dev)) == NULL){
+               goto out;
        }
 
        if ((ifaddr = in_dev->ifa_list)== NULL ){
-               return 0;
+               goto out;
        }
        
        switch (option){
 
        case WAN_LOCAL_IP:
-               return ifaddr->ifa_local;
+               addr = ifaddr->ifa_local;
                break;
        
        case WAN_POINTOPOINT_IP:
-               return ifaddr->ifa_address;
+               addr = ifaddr->ifa_address;
                break;  
 
        case WAN_NETMASK_IP:
-               return ifaddr->ifa_mask;
+               addr = ifaddr->ifa_mask;
                break;
 
        case WAN_BROADCAST_IP:
-               return ifaddr->ifa_broadcast;
+               addr = ifaddr->ifa_broadcast;
                break;
        default:
-               return 0;
+               break;
        }
 
-       return 0;
+out:
+       rcu_read_unlock();
+       return addr;
 }      
 
 void add_gateway(sdla_t *card, struct net_device *dev)
index b56a7b516d2479a228598bb3a3651f333f9ac89c..a6d3b55013a5106b379bd5bddf47b4e89f1ad3f4 100644 (file)
@@ -769,7 +769,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb)
                u32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */
 #ifdef CONFIG_INET
                rcu_read_lock();
-               if ((in_dev = __in_dev_get(dev)) != NULL)
+               if ((in_dev = __in_dev_get_rcu(dev)) != NULL)
                {
                        for (ifa=in_dev->ifa_list; ifa != NULL;
                                ifa=ifa->ifa_next) {
index 6deb7cc810cca9574356a0f84172e2057dce3869..cf3daaa1b369fbf7470e36c6055efa890774331d 100644 (file)
@@ -503,9 +503,14 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
                return 0;
        }
 
-       /* Length of the packet body */
-       /* FIXME: what if the skb is smaller than this? */
-       len = max_t(int,skb->len - ETH_HLEN, ETH_ZLEN - ETH_HLEN);
+       /* Check packet length, pad short packets, round up odd length */
+       len = max_t(int, ALIGN(skb->len, 2), ETH_ZLEN);
+       if (skb->len < len) {
+               skb = skb_padto(skb, len);
+               if (skb == NULL)
+                       goto fail;
+       }
+       len -= ETH_HLEN;
 
        eh = (struct ethhdr *)skb->data;
 
@@ -557,8 +562,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
                p = skb->data;
        }
 
-       /* Round up for odd length packets */
-       err = hermes_bap_pwrite(hw, USER_BAP, p, ALIGN(data_len, 2),
+       err = hermes_bap_pwrite(hw, USER_BAP, p, data_len,
                                txfid, data_off);
        if (err) {
                printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
index 4b0acae22b0d67e01d11f3b1c2f3ee991222d9f4..7bc7fc823128001f90a01e1c2246a589b7da7ce0 100644 (file)
@@ -1352,7 +1352,7 @@ static unsigned char *strip_make_packet(unsigned char *buffer,
                struct in_device *in_dev;
 
                rcu_read_lock();
-               in_dev = __in_dev_get(strip_info->dev);
+               in_dev = __in_dev_get_rcu(strip_info->dev);
                if (in_dev == NULL) {
                        rcu_read_unlock();
                        return NULL;
@@ -1508,7 +1508,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb)
 
                brd = addr = 0;
                rcu_read_lock();
-               in_dev = __in_dev_get(strip_info->dev);
+               in_dev = __in_dev_get_rcu(strip_info->dev);
                if (in_dev) {
                        if (in_dev->ifa_list) {
                                brd = in_dev->ifa_list->ifa_broadcast;
index e90fb72a6962936012fabb496e8ee8868cb5492d..286902298e33615e75fdbb75de6c67921ff08e7d 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/proc_fs.h>
 #include <linux/ctype.h>
 #include <linux/blkdev.h>
+#include <linux/rcupdate.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/hardware.h>
@@ -358,9 +359,10 @@ static __inline__ int led_get_net_activity(void)
        /* we are running as tasklet, so locking dev_base 
         * for reading should be OK */
        read_lock(&dev_base_lock);
+       rcu_read_lock();
        for (dev = dev_base; dev; dev = dev->next) {
            struct net_device_stats *stats;
-           struct in_device *in_dev = __in_dev_get(dev);
+           struct in_device *in_dev = __in_dev_get_rcu(dev);
            if (!in_dev || !in_dev->ifa_list)
                continue;
            if (LOOPBACK(in_dev->ifa_list->ifa_local))
@@ -371,6 +373,7 @@ static __inline__ int led_get_net_activity(void)
            rx_total += stats->rx_packets;
            tx_total += stats->tx_packets;
        }
+       rcu_read_unlock();
        read_unlock(&dev_base_lock);
 
        retval = 0;
index 08d1c92882647a2e1801722236f3349973fdf55b..94be9e51654e39da4ac7ab5694eb7bc9b89723a3 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <asm/hardware.h>
 #include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/sizes.h>
 
 #include <asm/arch/mux.h>
index c42455d20eb683c6d2c99de733966ad403c5941d..f9a5c70284b5a8901a7afbd86d07f39b1330978b 100644 (file)
@@ -691,7 +691,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
        unsigned long size = end - start + 1;
        int ret = 0;
 
-       if (end <= start)
+       if (end < start)
                return -EINVAL;
 
        down(&rsrc_sem);
@@ -724,7 +724,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
        unsigned long size = end - start + 1;
        int ret = 0;
 
-       if (end <= start)
+       if (end < start)
                return -EINVAL;
 
        if (end > IO_SPACE_LIMIT)
@@ -817,7 +817,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
 
        /* if we got at least one of IO, and one of MEM, we can be glad and
         * activate the PCMCIA subsystem */
-       if (done & (IORESOURCE_MEM | IORESOURCE_IO))
+       if (done == (IORESOURCE_MEM | IORESOURCE_IO))
                s->resource_setup_done = 1;
 
        return 0;
@@ -925,7 +925,7 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size
                                return -EINVAL;
                }
        }
-       if (end_addr <= start_addr)
+       if (end_addr < start_addr)
                return -EINVAL;
 
        ret = adjust_io(s, add, start_addr, end_addr);
@@ -977,7 +977,7 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz
                                return -EINVAL;
                }
        }
-       if (end_addr <= start_addr)
+       if (end_addr < start_addr)
                return -EINVAL;
 
        ret = adjust_memory(s, add, start_addr, end_addr);
index da0b404561c92946cc4e7e9e6d632f6ec0655935..539b5cd1a5986153974eaa23b98c22bb7aed6310 100644 (file)
@@ -873,6 +873,7 @@ static int ti1250_override(struct yenta_socket *socket)
  * Some fixup code to make everybody happy (TM).
  */
 
+#ifdef CONFIG_CARDBUS
 /**
  * set/clear various test bits:
  * Defaults to clear the bit.
@@ -927,7 +928,6 @@ static void ene_tune_bridge(struct pcmcia_socket *sock, struct pci_bus *bus)
        config_writeb(socket, ENE_TEST_C9, test_c9);
 }
 
-
 static int ene_override(struct yenta_socket *socket)
 {
        /* install tune_bridge() function */
@@ -935,6 +935,9 @@ static int ene_override(struct yenta_socket *socket)
 
        return ti1250_override(socket);
 }
+#else
+#  define ene_override ti1250_override
+#endif
 
 #endif /* _LINUX_TI113X_H */
 
index 2ad4797ce024b058e460e1cca6334cf9d32d729e..9963479ba89f71df304cdb87ab552da5ea834eaf 100644 (file)
@@ -686,6 +686,7 @@ struct qeth_seqno {
        __u32 pdu_hdr;
        __u32 pdu_hdr_ack;
        __u16 ipa;
+       __u32 pkt_seqno;
 };
 
 struct qeth_reply {
@@ -848,6 +849,7 @@ qeth_realloc_headroom(struct qeth_card *card, struct sk_buff **skb, int size)
                                   "on interface %s", QETH_CARD_IFNAME(card));
                         return -ENOMEM;
                 }
+               kfree_skb(*skb);
                 *skb = new_skb;
        }
        return 0;
index 86582cf1e19e01026556effa5ef2b13162806a47..bd28e2438d7f5168272a1ee94a4e94e46295ac81 100644 (file)
@@ -511,7 +511,7 @@ static int
 __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
 {
        struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data;
-       int rc = 0;
+       int rc = 0, rc2 = 0, rc3 = 0;
        enum qeth_card_states recover_flag;
 
        QETH_DBF_TEXT(setup, 3, "setoffl");
@@ -523,11 +523,13 @@ __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
                           CARD_BUS_ID(card));
                return -ERESTARTSYS;
        }
-       if ((rc = ccw_device_set_offline(CARD_DDEV(card))) ||
-           (rc = ccw_device_set_offline(CARD_WDEV(card))) ||
-           (rc = ccw_device_set_offline(CARD_RDEV(card)))) {
+       rc  = ccw_device_set_offline(CARD_DDEV(card));
+       rc2 = ccw_device_set_offline(CARD_WDEV(card));
+       rc3 = ccw_device_set_offline(CARD_RDEV(card));
+       if (!rc)
+               rc = (rc2) ? rc2 : rc3;
+       if (rc)
                QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
-       }
        if (recover_flag == CARD_STATE_UP)
                card->state = CARD_STATE_RECOVER;
        qeth_notify_processes();
@@ -1046,6 +1048,7 @@ qeth_setup_card(struct qeth_card *card)
        spin_lock_init(&card->vlanlock);
        card->vlangrp = NULL;
 #endif
+       spin_lock_init(&card->lock);
        spin_lock_init(&card->ip_lock);
        spin_lock_init(&card->thread_mask_lock);
        card->thread_start_mask = 0;
@@ -1626,16 +1629,6 @@ qeth_cmd_timeout(unsigned long data)
        spin_unlock_irqrestore(&reply->card->lock, flags);
 }
 
-static void
-qeth_reset_ip_addresses(struct qeth_card *card)
-{
-       QETH_DBF_TEXT(trace, 2, "rstipadd");
-
-       qeth_clear_ip_list(card, 0, 1);
-       /* this function will also schedule the SET_IP_THREAD */
-       qeth_set_multicast_list(card->dev);
-}
-
 static struct qeth_ipa_cmd *
 qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
 {
@@ -1664,9 +1657,8 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
                                           "IP address reset.\n",
                                           QETH_CARD_IFNAME(card),
                                           card->info.chpid);
-                               card->lan_online = 1;
                                netif_carrier_on(card->dev);
-                               qeth_reset_ip_addresses(card);
+                               qeth_schedule_recovery(card);
                                return NULL;
                        case IPA_CMD_REGISTER_LOCAL_ADDR:
                                QETH_DBF_TEXT(trace,3, "irla");
@@ -2387,6 +2379,7 @@ qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb,
                skb_pull(skb, VLAN_HLEN);
        }
 #endif
+       *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno;
        return vlan_id;
 }
 
@@ -3014,7 +3007,7 @@ qeth_alloc_buffer_pool(struct qeth_card *card)
                        return -ENOMEM;
                }
                for(j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j){
-                       ptr = (void *) __get_free_page(GFP_KERNEL);
+                       ptr = (void *) __get_free_page(GFP_KERNEL|GFP_DMA);
                        if (!ptr) {
                                while (j > 0)
                                        free_page((unsigned long)
@@ -3058,7 +3051,8 @@ qeth_alloc_qdio_buffers(struct qeth_card *card)
        if (card->qdio.state == QETH_QDIO_ALLOCATED)
                return 0;
 
-       card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), GFP_KERNEL);
+       card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), 
+                                 GFP_KERNEL|GFP_DMA);
        if (!card->qdio.in_q)
                return - ENOMEM;
        QETH_DBF_TEXT(setup, 2, "inq");
@@ -3083,7 +3077,7 @@ qeth_alloc_qdio_buffers(struct qeth_card *card)
        }
        for (i = 0; i < card->qdio.no_out_queues; ++i){
                card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q),
-                                              GFP_KERNEL);
+                                              GFP_KERNEL|GFP_DMA);
                if (!card->qdio.out_qs[i]){
                        while (i > 0)
                                kfree(card->qdio.out_qs[--i]);
@@ -5200,7 +5194,7 @@ qeth_free_vlan_addresses4(struct qeth_card *card, unsigned short vid)
        if (!card->vlangrp)
                return;
        rcu_read_lock();
-       in_dev = __in_dev_get(card->vlangrp->vlan_devices[vid]);
+       in_dev = __in_dev_get_rcu(card->vlangrp->vlan_devices[vid]);
        if (!in_dev)
                goto out;
        for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
@@ -6470,6 +6464,9 @@ qeth_query_ipassists_cb(struct qeth_card *card, struct qeth_reply *reply,
        if (cmd->hdr.prot_version == QETH_PROT_IPV4) {
                card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported;
                card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
+               /* Disable IPV6 support hard coded for Hipersockets */
+               if(card->info.type == QETH_CARD_TYPE_IQD)
+                       card->options.ipa4.supported_funcs &= ~IPA_IPV6;
        } else {
 #ifdef CONFIG_QETH_IPV6
                card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported;
@@ -7725,7 +7722,7 @@ qeth_arp_constructor(struct neighbour *neigh)
                goto out;
 
        rcu_read_lock();
-       in_dev = rcu_dereference(__in_dev_get(dev));
+       in_dev = __in_dev_get_rcu(dev);
        if (in_dev == NULL) {
                rcu_read_unlock();
                return -EINVAL;
index a6ac61611f35296c2a1d4402940075d10e38dc0a..a748fbfb66927dc9c54903abcec1d7a585a5b240 100644 (file)
@@ -60,6 +60,7 @@
                  Remove un-needed eh_abort handler.
                  Add support for embedded firmware error strings.
    2.26.02.003 - Correctly handle single sgl's with use_sg=1.
+   2.26.02.004 - Add support for 9550SX controllers.
 */
 
 #include <linux/module.h>
@@ -82,7 +83,7 @@
 #include "3w-9xxx.h"
 
 /* Globals */
-#define TW_DRIVER_VERSION "2.26.02.003"
+#define TW_DRIVER_VERSION "2.26.02.004"
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -892,11 +893,6 @@ static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
                writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
        }
 
-       if (status_reg_value & TW_STATUS_SBUF_WRITE_ERROR) {
-               TW_PRINTK(tw_dev->host, TW_DRIVER, 0xf, "SBUF Write Error: clearing");
-               writel(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
-       }
-
        if (status_reg_value & TW_STATUS_MICROCONTROLLER_ERROR) {
                if (tw_dev->reset_print == 0) {
                        TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Microcontroller Error: clearing");
@@ -930,6 +926,36 @@ out:
        return retval;
 } /* End twa_empty_response_queue() */
 
+/* This function will clear the pchip/response queue on 9550SX */
+static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
+{
+       u32 status_reg_value, response_que_value;
+       int count = 0, retval = 1;
+
+       if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) {
+               status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
+
+               while (((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) && (count < TW_MAX_RESPONSE_DRAIN)) {
+                       response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
+                       if ((response_que_value & TW_9550SX_DRAIN_COMPLETED) == TW_9550SX_DRAIN_COMPLETED) {
+                               /* P-chip settle time */
+                               msleep(500);
+                               retval = 0;
+                               goto out;
+                       }
+                       status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
+                       count++;
+               }
+               if (count == TW_MAX_RESPONSE_DRAIN)
+                       goto out;
+               
+               retval = 0;
+       } else
+               retval = 0;
+out:
+       return retval;
+} /* End twa_empty_response_queue_large() */
+
 /* This function passes sense keys from firmware to scsi layer */
 static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host)
 {
@@ -1613,8 +1639,16 @@ static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset)
        int tries = 0, retval = 1, flashed = 0, do_soft_reset = soft_reset;
 
        while (tries < TW_MAX_RESET_TRIES) {
-               if (do_soft_reset)
+               if (do_soft_reset) {
                        TW_SOFT_RESET(tw_dev);
+                       /* Clear pchip/response queue on 9550SX */
+                       if (twa_empty_response_queue_large(tw_dev)) {
+                               TW_PRINTK(tw_dev->host, TW_DRIVER, 0x36, "Response queue (large) empty failed during reset sequence");
+                               do_soft_reset = 1;
+                               tries++;
+                               continue;
+                       }
+               }
 
                /* Make sure controller is in a good state */
                if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTENTION_INTERRUPT : 0), 60)) {
@@ -2034,7 +2068,10 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
                goto out_free_device_extension;
        }
 
-       mem_addr = pci_resource_start(pdev, 1);
+       if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
+               mem_addr = pci_resource_start(pdev, 1);
+       else
+               mem_addr = pci_resource_start(pdev, 2);
 
        /* Save base address */
        tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
@@ -2148,6 +2185,8 @@ static void twa_remove(struct pci_dev *pdev)
 static struct pci_device_id twa_pci_tbl[] __devinitdata = {
        { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9000,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
        { }
 };
 MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
index 8c8ecbed3b58708cf64583c86d478094aafa4522..46f22cdc82985d91bbad87fe3df4a0e8e090cc5d 100644 (file)
@@ -267,7 +267,6 @@ static twa_message_type twa_error_table[] = {
 #define TW_CONTROL_CLEAR_PARITY_ERROR          0x00800000
 #define TW_CONTROL_CLEAR_QUEUE_ERROR           0x00400000
 #define TW_CONTROL_CLEAR_PCI_ABORT             0x00100000
-#define TW_CONTROL_CLEAR_SBUF_WRITE_ERROR      0x00000008
 
 /* Status register bit definitions */
 #define TW_STATUS_MAJOR_VERSION_MASK          0xF0000000
@@ -285,9 +284,8 @@ static twa_message_type twa_error_table[] = {
 #define TW_STATUS_MICROCONTROLLER_READY               0x00002000
 #define TW_STATUS_COMMAND_QUEUE_EMPTY         0x00001000
 #define TW_STATUS_EXPECTED_BITS                       0x00002000
-#define TW_STATUS_UNEXPECTED_BITS             0x00F00008
-#define TW_STATUS_SBUF_WRITE_ERROR             0x00000008
-#define TW_STATUS_VALID_INTERRUPT              0x00DF0008
+#define TW_STATUS_UNEXPECTED_BITS             0x00F00000
+#define TW_STATUS_VALID_INTERRUPT              0x00DF0000
 
 /* RESPONSE QUEUE BIT DEFINITIONS */
 #define TW_RESPONSE_ID_MASK                   0x00000FF0
@@ -324,9 +322,9 @@ static twa_message_type twa_error_table[] = {
 
 /* Compatibility defines */
 #define TW_9000_ARCH_ID 0x5
-#define TW_CURRENT_DRIVER_SRL 28
-#define TW_CURRENT_DRIVER_BUILD 9
-#define TW_CURRENT_DRIVER_BRANCH 4
+#define TW_CURRENT_DRIVER_SRL 30
+#define TW_CURRENT_DRIVER_BUILD 80
+#define TW_CURRENT_DRIVER_BRANCH 0
 
 /* Phase defines */
 #define TW_PHASE_INITIAL 0
@@ -334,6 +332,7 @@ static twa_message_type twa_error_table[] = {
 #define TW_PHASE_SGLIST  2
 
 /* Misc defines */
+#define TW_9550SX_DRAIN_COMPLETED            0xFFFF
 #define TW_SECTOR_SIZE                        512
 #define TW_ALIGNMENT_9000                     4  /* 4 bytes */
 #define TW_ALIGNMENT_9000_SGL                 0x3
@@ -417,6 +416,9 @@ static twa_message_type twa_error_table[] = {
 #ifndef PCI_DEVICE_ID_3WARE_9000
 #define PCI_DEVICE_ID_3WARE_9000 0x1002
 #endif
+#ifndef PCI_DEVICE_ID_3WARE_9550SX
+#define PCI_DEVICE_ID_3WARE_9550SX 0x1003
+#endif
 
 /* Bitmask macros to eliminate bitfields */
 
@@ -443,6 +445,7 @@ static twa_message_type twa_error_table[] = {
 #define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4)
 #define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8))
 #define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC)
+#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30)
 #define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
 #define TW_CLEAR_ATTENTION_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
 #define TW_CLEAR_HOST_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
index 1e4edbdf27304bc80a28f8b05d08f21580936b63..48529d180ca8869397ce903d154ffe1f85bbdc4e 100644 (file)
@@ -99,6 +99,7 @@ obj-$(CONFIG_SCSI_DC395x)     += dc395x.o
 obj-$(CONFIG_SCSI_DC390T)      += tmscsim.o
 obj-$(CONFIG_MEGARAID_LEGACY)  += megaraid.o
 obj-$(CONFIG_MEGARAID_NEWGEN)  += megaraid/
+obj-$(CONFIG_MEGARAID_SAS)     += megaraid/
 obj-$(CONFIG_SCSI_ACARD)       += atp870u.o
 obj-$(CONFIG_SCSI_SUNESP)      += esp.o
 obj-$(CONFIG_SCSI_GDTH)                += gdth.o
index a8e3dfcd0dc758025a388a201f8eaddae5d23d58..93416f760e5a507c33b06bf3ca9d9b92955cbb2f 100644 (file)
@@ -313,18 +313,37 @@ int aac_get_containers(struct aac_dev *dev)
                }
                dresp = (struct aac_mount *)fib_data(fibptr);
 
+               if ((le32_to_cpu(dresp->status) == ST_OK) &&
+                   (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
+                       dinfo->command = cpu_to_le32(VM_NameServe64);
+                       dinfo->count = cpu_to_le32(index);
+                       dinfo->type = cpu_to_le32(FT_FILESYS);
+
+                       if (fib_send(ContainerCommand,
+                                   fibptr,
+                                   sizeof(struct aac_query_mount),
+                                   FsaNormal,
+                                   1, 1,
+                                   NULL, NULL) < 0)
+                               continue;
+               } else
+                       dresp->mnt[0].capacityhigh = 0;
+
                dprintk ((KERN_DEBUG
-                 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%u\n",
+                 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
                  (int)index, (int)le32_to_cpu(dresp->status),
                  (int)le32_to_cpu(dresp->mnt[0].vol),
                  (int)le32_to_cpu(dresp->mnt[0].state),
-                 (unsigned)le32_to_cpu(dresp->mnt[0].capacity)));
+                 ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
+                   (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32)));
                if ((le32_to_cpu(dresp->status) == ST_OK) &&
                    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
                    (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
                        fsa_dev_ptr[index].valid = 1;
                        fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
-                       fsa_dev_ptr[index].size = le32_to_cpu(dresp->mnt[0].capacity);
+                       fsa_dev_ptr[index].size
+                         = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
+                           (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
                        if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
                                    fsa_dev_ptr[index].ro = 1;
                }
@@ -460,7 +479,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
  *     is updated in the struct fsa_dev_info structure rather than returned.
  */
  
-static int probe_container(struct aac_dev *dev, int cid)
+int probe_container(struct aac_dev *dev, int cid)
 {
        struct fsa_dev_info *fsa_dev_ptr;
        int status;
@@ -496,12 +515,30 @@ static int probe_container(struct aac_dev *dev, int cid)
 
        dresp = (struct aac_mount *) fib_data(fibptr);
 
+       if ((le32_to_cpu(dresp->status) == ST_OK) &&
+           (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
+               dinfo->command = cpu_to_le32(VM_NameServe64);
+               dinfo->count = cpu_to_le32(cid);
+               dinfo->type = cpu_to_le32(FT_FILESYS);
+
+               if (fib_send(ContainerCommand,
+                           fibptr,
+                           sizeof(struct aac_query_mount),
+                           FsaNormal,
+                           1, 1,
+                           NULL, NULL) < 0)
+                       goto error;
+       } else
+               dresp->mnt[0].capacityhigh = 0;
+
        if ((le32_to_cpu(dresp->status) == ST_OK) &&
            (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
            (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
                fsa_dev_ptr[cid].valid = 1;
                fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol);
-               fsa_dev_ptr[cid].size = le32_to_cpu(dresp->mnt[0].capacity);
+               fsa_dev_ptr[cid].size
+                 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
+                   (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
                if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
                        fsa_dev_ptr[cid].ro = 1;
        }
@@ -655,7 +692,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
                         fibptr, 
                         sizeof(*info),
                         FsaNormal, 
-                        1, 1, 
+                        -1, 1, /* First `interrupt' command uses special wait */
                         NULL, 
                         NULL);
 
@@ -806,8 +843,8 @@ int aac_get_adapter_info(struct aac_dev* dev)
        if (!(dev->raw_io_interface)) {
                dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size -
                        sizeof(struct aac_fibhdr) -
-                       sizeof(struct aac_write) + sizeof(struct sgmap)) /
-                               sizeof(struct sgmap);
+                       sizeof(struct aac_write) + sizeof(struct sgentry)) /
+                               sizeof(struct sgentry);
                if (dev->dac_support) {
                        /* 
                         * 38 scatter gather elements 
@@ -816,8 +853,8 @@ int aac_get_adapter_info(struct aac_dev* dev)
                                (dev->max_fib_size -
                                sizeof(struct aac_fibhdr) -
                                sizeof(struct aac_write64) +
-                               sizeof(struct sgmap64)) /
-                                       sizeof(struct sgmap64);
+                               sizeof(struct sgentry64)) /
+                                       sizeof(struct sgentry64);
                }
                dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
                if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) {
@@ -854,7 +891,40 @@ static void io_callback(void *context, struct fib * fibptr)
        dev = (struct aac_dev *)scsicmd->device->host->hostdata;
        cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
 
-       dprintk((KERN_DEBUG "io_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3], jiffies));
+       if (nblank(dprintk(x))) {
+               u64 lba;
+               switch (scsicmd->cmnd[0]) {
+               case WRITE_6:
+               case READ_6:
+                       lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
+                           (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
+                       break;
+               case WRITE_16:
+               case READ_16:
+                       lba = ((u64)scsicmd->cmnd[2] << 56) |
+                             ((u64)scsicmd->cmnd[3] << 48) |
+                             ((u64)scsicmd->cmnd[4] << 40) |
+                             ((u64)scsicmd->cmnd[5] << 32) |
+                             ((u64)scsicmd->cmnd[6] << 24) |
+                             (scsicmd->cmnd[7] << 16) |
+                             (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
+                       break;
+               case WRITE_12:
+               case READ_12:
+                       lba = ((u64)scsicmd->cmnd[2] << 24) |
+                             (scsicmd->cmnd[3] << 16) |
+                             (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+                       break;
+               default:
+                       lba = ((u64)scsicmd->cmnd[2] << 24) |
+                              (scsicmd->cmnd[3] << 16) |
+                              (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+                       break;
+               }
+               printk(KERN_DEBUG
+                 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
+                 smp_processor_id(), (unsigned long long)lba, jiffies);
+       }
 
        if (fibptr == NULL)
                BUG();
@@ -895,7 +965,7 @@ static void io_callback(void *context, struct fib * fibptr)
 
 static int aac_read(struct scsi_cmnd * scsicmd, int cid)
 {
-       u32 lba;
+       u64 lba;
        u32 count;
        int status;
 
@@ -907,23 +977,69 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
        /*
         *      Get block address and transfer length
         */
-       if (scsicmd->cmnd[0] == READ_6) /* 6 byte command */
-       {
+       switch (scsicmd->cmnd[0]) {
+       case READ_6:
                dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid));
 
-               lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
+               lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | 
+                       (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
                count = scsicmd->cmnd[4];
 
                if (count == 0)
                        count = 256;
-       } else {
+               break;
+       case READ_16:
+               dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", cid));
+
+               lba =   ((u64)scsicmd->cmnd[2] << 56) |
+                       ((u64)scsicmd->cmnd[3] << 48) |
+                       ((u64)scsicmd->cmnd[4] << 40) |
+                       ((u64)scsicmd->cmnd[5] << 32) |
+                       ((u64)scsicmd->cmnd[6] << 24) | 
+                       (scsicmd->cmnd[7] << 16) |
+                       (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
+               count = (scsicmd->cmnd[10] << 24) | 
+                       (scsicmd->cmnd[11] << 16) |
+                       (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
+               break;
+       case READ_12:
+               dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", cid));
+
+               lba = ((u64)scsicmd->cmnd[2] << 24) | 
+                       (scsicmd->cmnd[3] << 16) |
+                       (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+               count = (scsicmd->cmnd[6] << 24) | 
+                       (scsicmd->cmnd[7] << 16) |
+                       (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
+               break;
+       default:
                dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid));
 
-               lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+               lba = ((u64)scsicmd->cmnd[2] << 24) | 
+                       (scsicmd->cmnd[3] << 16) | 
+                       (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
                count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
+               break;
        }
-       dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n",
+       dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n",
          smp_processor_id(), (unsigned long long)lba, jiffies));
+       if ((!(dev->raw_io_interface) || !(dev->raw_io_64)) &&
+               (lba & 0xffffffff00000000LL)) {
+               dprintk((KERN_DEBUG "aac_read: Illegal lba\n"));
+               scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 
+                       SAM_STAT_CHECK_CONDITION;
+               set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
+                           HARDWARE_ERROR,
+                           SENCODE_INTERNAL_TARGET_FAILURE,
+                           ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
+                           0, 0);
+               memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
+                 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
+                   ? sizeof(scsicmd->sense_buffer)
+                   : sizeof(dev->fsa_dev[cid].sense_data));
+               scsicmd->scsi_done(scsicmd);
+               return 0;
+       }
        /*
         *      Alocate and initialize a Fib
         */
@@ -936,8 +1052,8 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
        if (dev->raw_io_interface) {
                struct aac_raw_io *readcmd;
                readcmd = (struct aac_raw_io *) fib_data(cmd_fibcontext);
-               readcmd->block[0] = cpu_to_le32(lba);
-               readcmd->block[1] = 0;
+               readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff));
+               readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
                readcmd->count = cpu_to_le32(count<<9);
                readcmd->cid = cpu_to_le16(cid);
                readcmd->flags = cpu_to_le16(1);
@@ -964,7 +1080,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
                readcmd->command = cpu_to_le32(VM_CtHostRead64);
                readcmd->cid = cpu_to_le16(cid);
                readcmd->sector_count = cpu_to_le16(count);
-               readcmd->block = cpu_to_le32(lba);
+               readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                readcmd->pad   = 0;
                readcmd->flags = 0; 
 
@@ -989,7 +1105,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
                readcmd = (struct aac_read *) fib_data(cmd_fibcontext);
                readcmd->command = cpu_to_le32(VM_CtBlockRead);
                readcmd->cid = cpu_to_le32(cid);
-               readcmd->block = cpu_to_le32(lba);
+               readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                readcmd->count = cpu_to_le32(count * 512);
 
                aac_build_sg(scsicmd, &readcmd->sg);
@@ -1031,7 +1147,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
 
 static int aac_write(struct scsi_cmnd * scsicmd, int cid)
 {
-       u32 lba;
+       u64 lba;
        u32 count;
        int status;
        u16 fibsize;
@@ -1048,13 +1164,48 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
                count = scsicmd->cmnd[4];
                if (count == 0)
                        count = 256;
+       } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */
+               dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", cid));
+
+               lba =   ((u64)scsicmd->cmnd[2] << 56) |
+                       ((u64)scsicmd->cmnd[3] << 48) |
+                       ((u64)scsicmd->cmnd[4] << 40) |
+                       ((u64)scsicmd->cmnd[5] << 32) |
+                       ((u64)scsicmd->cmnd[6] << 24) | 
+                       (scsicmd->cmnd[7] << 16) |
+                       (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
+               count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |
+                       (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
+       } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */
+               dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", cid));
+
+               lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16)
+                   | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+               count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16)
+                     | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
        } else {
                dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid));
-               lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+               lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
                count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
        }
-       dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n",
+       dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n",
          smp_processor_id(), (unsigned long long)lba, jiffies));
+       if ((!(dev->raw_io_interface) || !(dev->raw_io_64))
+        && (lba & 0xffffffff00000000LL)) {
+               dprintk((KERN_DEBUG "aac_write: Illegal lba\n"));
+               scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
+               set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
+                           HARDWARE_ERROR,
+                           SENCODE_INTERNAL_TARGET_FAILURE,
+                           ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
+                           0, 0);
+               memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
+                 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
+                   ? sizeof(scsicmd->sense_buffer)
+                   : sizeof(dev->fsa_dev[cid].sense_data));
+               scsicmd->scsi_done(scsicmd);
+               return 0;
+       }
        /*
         *      Allocate and initialize a Fib then setup a BlockWrite command
         */
@@ -1068,8 +1219,8 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
        if (dev->raw_io_interface) {
                struct aac_raw_io *writecmd;
                writecmd = (struct aac_raw_io *) fib_data(cmd_fibcontext);
-               writecmd->block[0] = cpu_to_le32(lba);
-               writecmd->block[1] = 0;
+               writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff));
+               writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
                writecmd->count = cpu_to_le32(count<<9);
                writecmd->cid = cpu_to_le16(cid);
                writecmd->flags = 0; 
@@ -1096,7 +1247,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
                writecmd->command = cpu_to_le32(VM_CtHostWrite64);
                writecmd->cid = cpu_to_le16(cid);
                writecmd->sector_count = cpu_to_le16(count); 
-               writecmd->block = cpu_to_le32(lba);
+               writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                writecmd->pad   = 0;
                writecmd->flags = 0;
 
@@ -1121,7 +1272,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
                writecmd = (struct aac_write *) fib_data(cmd_fibcontext);
                writecmd->command = cpu_to_le32(VM_CtBlockWrite);
                writecmd->cid = cpu_to_le32(cid);
-               writecmd->block = cpu_to_le32(lba);
+               writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                writecmd->count = cpu_to_le32(count * 512);
                writecmd->sg.count = cpu_to_le32(1);
                /* ->stable is not used - it did mean which type of write */
@@ -1310,11 +1461,18 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                         */
                        if ((fsa_dev_ptr[cid].valid & 1) == 0) {
                                switch (scsicmd->cmnd[0]) {
+                               case SERVICE_ACTION_IN:
+                                       if (!(dev->raw_io_interface) ||
+                                           !(dev->raw_io_64) ||
+                                           ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
+                                               break;
                                case INQUIRY:
                                case READ_CAPACITY:
                                case TEST_UNIT_READY:
                                        spin_unlock_irq(host->host_lock);
                                        probe_container(dev, cid);
+                                       if ((fsa_dev_ptr[cid].valid & 1) == 0)
+                                               fsa_dev_ptr[cid].valid = 0;
                                        spin_lock_irq(host->host_lock);
                                        if (fsa_dev_ptr[cid].valid == 0) {
                                                scsicmd->result = DID_NO_CONNECT << 16;
@@ -1375,7 +1533,6 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                memset(&inq_data, 0, sizeof (struct inquiry_data));
 
                inq_data.inqd_ver = 2;  /* claim compliance to SCSI-2 */
-               inq_data.inqd_dtq = 0x80;       /* set RMB bit to one indicating that the medium is removable */
                inq_data.inqd_rdf = 2;  /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
                inq_data.inqd_len = 31;
                /*Format for "pad2" is  RelAdr | WBus32 | WBus16 |  Sync  | Linked |Reserved| CmdQue | SftRe */
@@ -1397,13 +1554,55 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
                return aac_get_container_name(scsicmd, cid);
        }
+       case SERVICE_ACTION_IN:
+               if (!(dev->raw_io_interface) ||
+                   !(dev->raw_io_64) ||
+                   ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
+                       break;
+       {
+               u64 capacity;
+               char cp[12];
+               unsigned int offset = 0;
+
+               dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n"));
+               capacity = fsa_dev_ptr[cid].size - 1;
+               if (scsicmd->cmnd[13] > 12) {
+                       offset = scsicmd->cmnd[13] - 12;
+                       if (offset > sizeof(cp))
+                               break;
+                       memset(cp, 0, offset);
+                       aac_internal_transfer(scsicmd, cp, 0, offset);
+               }
+               cp[0] = (capacity >> 56) & 0xff;
+               cp[1] = (capacity >> 48) & 0xff;
+               cp[2] = (capacity >> 40) & 0xff;
+               cp[3] = (capacity >> 32) & 0xff;
+               cp[4] = (capacity >> 24) & 0xff;
+               cp[5] = (capacity >> 16) & 0xff;
+               cp[6] = (capacity >> 8) & 0xff;
+               cp[7] = (capacity >> 0) & 0xff;
+               cp[8] = 0;
+               cp[9] = 0;
+               cp[10] = 2;
+               cp[11] = 0;
+               aac_internal_transfer(scsicmd, cp, offset, sizeof(cp));
+
+               /* Do not cache partition table for arrays */
+               scsicmd->device->removable = 1;
+
+               scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
+               scsicmd->scsi_done(scsicmd);
+
+               return 0;
+       }
+
        case READ_CAPACITY:
        {
                u32 capacity;
                char cp[8];
 
                dprintk((KERN_DEBUG "READ CAPACITY command.\n"));
-               if (fsa_dev_ptr[cid].size <= 0x100000000LL)
+               if (fsa_dev_ptr[cid].size <= 0x100000000ULL)
                        capacity = fsa_dev_ptr[cid].size - 1;
                else
                        capacity = (u32)-1;
@@ -1417,6 +1616,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                cp[6] = 2;
                cp[7] = 0;
                aac_internal_transfer(scsicmd, cp, 0, sizeof(cp));
+               /* Do not cache partition table for arrays */
+               scsicmd->device->removable = 1;
 
                scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
                scsicmd->scsi_done(scsicmd);
@@ -1497,6 +1698,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
        {
                case READ_6:
                case READ_10:
+               case READ_12:
+               case READ_16:
                        /*
                         *      Hack to keep track of ordinal number of the device that
                         *      corresponds to a container. Needed to convert
@@ -1504,17 +1707,19 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                         */
                         
                        spin_unlock_irq(host->host_lock);
-                       if  (scsicmd->request->rq_disk)
-                               memcpy(fsa_dev_ptr[cid].devname,
-                                       scsicmd->request->rq_disk->disk_name,
-                                       8);
-
+                       if (scsicmd->request->rq_disk)
+                               strlcpy(fsa_dev_ptr[cid].devname,
+                               scsicmd->request->rq_disk->disk_name,
+                               min(sizeof(fsa_dev_ptr[cid].devname),
+                               sizeof(scsicmd->request->rq_disk->disk_name) + 1));
                        ret = aac_read(scsicmd, cid);
                        spin_lock_irq(host->host_lock);
                        return ret;
 
                case WRITE_6:
                case WRITE_10:
+               case WRITE_12:
+               case WRITE_16:
                        spin_unlock_irq(host->host_lock);
                        ret = aac_write(scsicmd, cid);
                        spin_lock_irq(host->host_lock);
@@ -1745,6 +1950,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
                case  WRITE_10:
                case  READ_12:
                case  WRITE_12:
+               case  READ_16:
+               case  WRITE_16:
                        if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {
                                printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
                        } else {
@@ -1850,8 +2057,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
                                sizeof(scsicmd->sense_buffer) :
                                le32_to_cpu(srbreply->sense_data_size);
 #ifdef AAC_DETAILED_STATUS_INFO
-               dprintk((KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", 
-                                       le32_to_cpu(srbreply->status), len));
+               printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
+                                       le32_to_cpu(srbreply->status), len);
 #endif
                memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
                
index e40528185d48fab70a6d5011ed1a4f6773073cef..4a99d2f000f4a952a720ce0e7866b406c255ba09 100644 (file)
@@ -1,6 +1,10 @@
 #if (!defined(dprintk))
 # define dprintk(x)
 #endif
+/* eg: if (nblank(dprintk(x))) */
+#define _nblank(x) #x
+#define nblank(x) _nblank(x)[0]
+
 
 /*------------------------------------------------------------------------------
  *              D E F I N E S
@@ -302,7 +306,6 @@ enum aac_queue_types {
  */
 
 #define                FsaNormal       1
-#define                FsaHigh         2
 
 /*
  * Define the FIB. The FIB is the where all the requested data and
@@ -546,8 +549,6 @@ struct aac_queue {
                   /* This is only valid for adapter to host command queues. */ 
        spinlock_t              *lock;          /* Spinlock for this queue must take this lock before accessing the lock */
        spinlock_t              lockdata;       /* Actual lock (used only on one side of the lock) */
-       unsigned long           SavedIrql;      /* Previous IRQL when the spin lock is taken */
-       u32                     padding;        /* Padding - FIXME - can remove I believe */
        struct list_head        cmdq;           /* A queue of FIBs which need to be prcessed by the FS thread. This is */
                                                /* only valid for command queues which receive entries from the adapter. */
        struct list_head        pendingq;       /* A queue of outstanding fib's to the adapter. */
@@ -776,7 +777,9 @@ struct fsa_dev_info {
        u64             last;
        u64             size;
        u32             type;
+       u32             config_waiting_on;
        u16             queue_depth;
+       u8              config_needed;
        u8              valid;
        u8              ro;
        u8              locked;
@@ -1012,6 +1015,7 @@ struct aac_dev
        /* macro side-effects BEWARE */
 #      define                  raw_io_interface \
          init->InitStructRevision==cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4)
+       u8                      raw_io_64;
        u8                      printf_enabled;
 };
 
@@ -1362,8 +1366,10 @@ struct aac_srb_reply
 #define                VM_CtBlockVerify64      18
 #define                VM_CtHostRead64         19
 #define                VM_CtHostWrite64        20
+#define                VM_DrvErrTblLog         21
+#define                VM_NameServe64          22
 
-#define                MAX_VMCOMMAND_NUM       21      /* used for sizing stats array - leave last */
+#define                MAX_VMCOMMAND_NUM       23      /* used for sizing stats array - leave last */
 
 /*
  *     Descriptive information (eg, vital stats)
@@ -1472,6 +1478,7 @@ struct aac_mntent {
                                                   manager (eg, filesystem) */
        __le32                  altoid;         /* != oid <==> snapshot or 
                                                   broken mirror exists */
+       __le32                  capacityhigh;
 };
 
 #define FSCS_NOTCLEAN  0x0001  /* fsck is neccessary before mounting */
@@ -1707,6 +1714,7 @@ extern struct aac_common aac_config;
 #define                AifCmdJobProgress       2       /* Progress report */
 #define                        AifJobCtrZero   101     /* Array Zero progress */
 #define                        AifJobStsSuccess 1      /* Job completes */
+#define                        AifJobStsRunning 102    /* Job running */
 #define                AifCmdAPIReport         3       /* Report from other user of API */
 #define                AifCmdDriverNotify      4       /* Notify host driver of event */
 #define                        AifDenMorphComplete 200 /* A morph operation completed */
@@ -1777,6 +1785,7 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size);
 struct aac_driver_ident* aac_get_driver_ident(int devtype);
 int aac_get_adapter_info(struct aac_dev* dev);
 int aac_send_shutdown(struct aac_dev *dev);
+int probe_container(struct aac_dev *dev, int cid);
 extern int numacb;
 extern int acbsize;
 extern char aac_driver_version[];
index 75abd04532890de2c7855e39bb1551c7886a0468..59a341b2aedcc6ab233ddf295b7c756b618cd8c9 100644 (file)
@@ -195,7 +195,7 @@ int aac_send_shutdown(struct aac_dev * dev)
                          fibctx,
                          sizeof(struct aac_close),
                          FsaNormal,
-                         1, 1,
+                         -2 /* Timeout silently */, 1,
                          NULL, NULL);
 
        if (status == 0)
@@ -313,8 +313,15 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
        dev->max_fib_size = sizeof(struct hw_fib);
        dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size
                - sizeof(struct aac_fibhdr)
-               - sizeof(struct aac_write) + sizeof(struct sgmap))
-                       / sizeof(struct sgmap);
+               - sizeof(struct aac_write) + sizeof(struct sgentry))
+                       / sizeof(struct sgentry);
+       dev->raw_io_64 = 0;
+       if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
+               0, 0, 0, 0, 0, 0, status+0, status+1, status+2, NULL, NULL)) &&
+                       (status[0] == 0x00000001)) {
+               if (status[1] & AAC_OPT_NEW_COMM_64)
+                       dev->raw_io_64 = 1;
+       }
        if ((!aac_adapter_sync_cmd(dev, GET_COMM_PREFERRED_SETTINGS,
          0, 0, 0, 0, 0, 0,
          status+0, status+1, status+2, status+3, status+4))
@@ -342,8 +349,8 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
                        dev->max_fib_size = 512;
                        dev->sg_tablesize = host->sg_tablesize
                          = (512 - sizeof(struct aac_fibhdr)
-                           - sizeof(struct aac_write) + sizeof(struct sgmap))
-                            / sizeof(struct sgmap);
+                           - sizeof(struct aac_write) + sizeof(struct sgentry))
+                            / sizeof(struct sgentry);
                        host->can_queue = AAC_NUM_IO_FIB;
                } else if (acbsize == 2048) {
                        host->max_sectors = 512;
index a1d303f034808f3e31a2f44860355f1e240d7ee4..e4d543a474ae7182cde72d0b3472952414e9c829 100644 (file)
@@ -39,7 +39,9 @@
 #include <linux/completion.h>
 #include <linux/blkdev.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
 #include <asm/semaphore.h>
+#include <asm/delay.h>
 
 #include "aacraid.h"
 
@@ -269,40 +271,22 @@ static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entr
        /* Interrupt Moderation, only interrupt for first two entries */
        if (idx != le32_to_cpu(*(q->headers.consumer))) {
                if (--idx == 0) {
-                       if (qid == AdapHighCmdQueue)
-                               idx = ADAP_HIGH_CMD_ENTRIES;
-                       else if (qid == AdapNormCmdQueue)
+                       if (qid == AdapNormCmdQueue)
                                idx = ADAP_NORM_CMD_ENTRIES;
-                       else if (qid == AdapHighRespQueue) 
-                               idx = ADAP_HIGH_RESP_ENTRIES;
-                       else if (qid == AdapNormRespQueue) 
+                       else
                                idx = ADAP_NORM_RESP_ENTRIES;
                }
                if (idx != le32_to_cpu(*(q->headers.consumer)))
                        *nonotify = 1; 
        }
 
-       if (qid == AdapHighCmdQueue) {
-               if (*index >= ADAP_HIGH_CMD_ENTRIES)
-                       *index = 0;
-       } else if (qid == AdapNormCmdQueue) {
+       if (qid == AdapNormCmdQueue) {
                if (*index >= ADAP_NORM_CMD_ENTRIES) 
                        *index = 0; /* Wrap to front of the Producer Queue. */
-       }
-       else if (qid == AdapHighRespQueue) 
-       {
-               if (*index >= ADAP_HIGH_RESP_ENTRIES)
-                       *index = 0;
-       }
-       else if (qid == AdapNormRespQueue) 
-       {
+       } else {
                if (*index >= ADAP_NORM_RESP_ENTRIES) 
                        *index = 0; /* Wrap to front of the Producer Queue. */
        }
-       else {
-               printk("aacraid: invalid qid\n");
-               BUG();
-       }
 
         if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */
                printk(KERN_WARNING "Queue %d full, %u outstanding.\n",
@@ -334,12 +318,8 @@ static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_f
 {
        struct aac_entry * entry = NULL;
        int map = 0;
-       struct aac_queue * q = &dev->queues->queue[qid];
-               
-       spin_lock_irqsave(q->lock, q->SavedIrql);
            
-       if (qid == AdapHighCmdQueue || qid == AdapNormCmdQueue) 
-       {
+       if (qid == AdapNormCmdQueue) {
                /*  if no entries wait for some if caller wants to */
                while (!aac_get_entry(dev, qid, &entry, index, nonotify)) 
                {
@@ -350,9 +330,7 @@ static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_f
                 */
                entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
                map = 1;
-       }
-       else if (qid == AdapHighRespQueue || qid == AdapNormRespQueue)
-       {
+       } else {
                while(!aac_get_entry(dev, qid, &entry, index, nonotify)) 
                {
                        /* if no entries wait for some if caller wants to */
@@ -375,42 +353,6 @@ static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_f
        return 0;
 }
 
-
-/**
- *     aac_insert_entry        -       insert a queue entry
- *     @dev: Adapter
- *     @index: Index of entry to insert
- *     @qid: Queue number
- *     @nonotify: Suppress adapter notification
- *
- *     Gets the next free QE off the requested priorty adapter command
- *     queue and associates the Fib with the QE. The QE represented by
- *     index is ready to insert on the queue when this routine returns
- *     success.
- */
-static int aac_insert_entry(struct aac_dev * dev, u32 index, u32 qid, unsigned long nonotify) 
-{
-       struct aac_queue * q = &dev->queues->queue[qid];
-
-       if(q == NULL)
-               BUG();
-       *(q->headers.producer) = cpu_to_le32(index + 1);
-       spin_unlock_irqrestore(q->lock, q->SavedIrql);
-
-       if (qid == AdapHighCmdQueue ||
-           qid == AdapNormCmdQueue ||
-           qid == AdapHighRespQueue ||
-           qid == AdapNormRespQueue)
-       {
-               if (!nonotify)
-                       aac_adapter_notify(dev, qid);
-       }
-       else
-               printk("Suprise insert!\n");
-       return 0;
-}
-
 /*
  *     Define the highest level of host to adapter communication routines. 
  *     These routines will support host to adapter FS commuication. These 
@@ -439,12 +381,13 @@ static int aac_insert_entry(struct aac_dev * dev, u32 index, u32 qid, unsigned l
 int fib_send(u16 command, struct fib * fibptr, unsigned long size,  int priority, int wait, int reply, fib_callback callback, void * callback_data)
 {
        u32 index;
-       u32 qid;
        struct aac_dev * dev = fibptr->dev;
        unsigned long nointr = 0;
        struct hw_fib * hw_fib = fibptr->hw_fib;
        struct aac_queue * q;
        unsigned long flags = 0;
+       unsigned long qflags;
+
        if (!(hw_fib->header.XferState & cpu_to_le32(HostOwned)))
                return -EBUSY;
        /*
@@ -497,26 +440,8 @@ int fib_send(u16 command, struct fib * fibptr, unsigned long size,  int priority
         *      Get a queue entry connect the FIB to it and send an notify
         *      the adapter a command is ready.
         */
-       if (priority == FsaHigh) {
-               hw_fib->header.XferState |= cpu_to_le32(HighPriority);
-               qid = AdapHighCmdQueue;
-       } else {
-               hw_fib->header.XferState |= cpu_to_le32(NormalPriority);
-               qid = AdapNormCmdQueue;
-       }
-       q = &dev->queues->queue[qid];
+       hw_fib->header.XferState |= cpu_to_le32(NormalPriority);
 
-       if(wait)
-               spin_lock_irqsave(&fibptr->event_lock, flags);
-       if(aac_queue_get( dev, &index, qid, hw_fib, 1, fibptr, &nointr)<0)
-               return -EWOULDBLOCK;
-       dprintk((KERN_DEBUG "fib_send: inserting a queue entry at index %d.\n",index));
-       dprintk((KERN_DEBUG "Fib contents:.\n"));
-       dprintk((KERN_DEBUG "  Command =               %d.\n", hw_fib->header.Command));
-       dprintk((KERN_DEBUG "  XferState  =            %x.\n", hw_fib->header.XferState));
-       dprintk((KERN_DEBUG "  hw_fib va being sent=%p\n",fibptr->hw_fib));
-       dprintk((KERN_DEBUG "  hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa));
-       dprintk((KERN_DEBUG "  fib being sent=%p\n",fibptr));
        /*
         *      Fill in the Callback and CallbackContext if we are not
         *      going to wait.
@@ -525,22 +450,67 @@ int fib_send(u16 command, struct fib * fibptr, unsigned long size,  int priority
                fibptr->callback = callback;
                fibptr->callback_data = callback_data;
        }
-       FIB_COUNTER_INCREMENT(aac_config.FibsSent);
-       list_add_tail(&fibptr->queue, &q->pendingq);
-       q->numpending++;
 
        fibptr->done = 0;
        fibptr->flags = 0;
 
-       if(aac_insert_entry(dev, index, qid, (nointr & aac_config.irq_mod)) < 0)
-               return -EWOULDBLOCK;
+       FIB_COUNTER_INCREMENT(aac_config.FibsSent);
+
+       dprintk((KERN_DEBUG "fib_send: inserting a queue entry at index %d.\n",index));
+       dprintk((KERN_DEBUG "Fib contents:.\n"));
+       dprintk((KERN_DEBUG "  Command =               %d.\n", hw_fib->header.Command));
+       dprintk((KERN_DEBUG "  XferState  =            %x.\n", hw_fib->header.XferState));
+       dprintk((KERN_DEBUG "  hw_fib va being sent=%p\n",fibptr->hw_fib));
+       dprintk((KERN_DEBUG "  hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa));
+       dprintk((KERN_DEBUG "  fib being sent=%p\n",fibptr));
+
+       q = &dev->queues->queue[AdapNormCmdQueue];
+
+       if(wait)
+               spin_lock_irqsave(&fibptr->event_lock, flags);
+       spin_lock_irqsave(q->lock, qflags);
+       aac_queue_get( dev, &index, AdapNormCmdQueue, hw_fib, 1, fibptr, &nointr);
+
+       list_add_tail(&fibptr->queue, &q->pendingq);
+       q->numpending++;
+       *(q->headers.producer) = cpu_to_le32(index + 1);
+       spin_unlock_irqrestore(q->lock, qflags);
+       if (!(nointr & aac_config.irq_mod))
+               aac_adapter_notify(dev, AdapNormCmdQueue);
        /*
         *      If the caller wanted us to wait for response wait now. 
         */
     
        if (wait) {
                spin_unlock_irqrestore(&fibptr->event_lock, flags);
-               down(&fibptr->event_wait);
+               /* Only set for first known interruptable command */
+               if (wait < 0) {
+                       /*
+                        * *VERY* Dangerous to time out a command, the
+                        * assumption is made that we have no hope of
+                        * functioning because an interrupt routing or other
+                        * hardware failure has occurred.
+                        */
+                       unsigned long count = 36000000L; /* 3 minutes */
+                       unsigned long qflags;
+                       while (down_trylock(&fibptr->event_wait)) {
+                               if (--count == 0) {
+                                       spin_lock_irqsave(q->lock, qflags);
+                                       q->numpending--;
+                                       list_del(&fibptr->queue);
+                                       spin_unlock_irqrestore(q->lock, qflags);
+                                       if (wait == -1) {
+                                               printk(KERN_ERR "aacraid: fib_send: first asynchronous command timed out.\n"
+                                                 "Usually a result of a PCI interrupt routing problem;\n"
+                                                 "update mother board BIOS or consider utilizing one of\n"
+                                                 "the SAFE mode kernel options (acpi, apic etc)\n");
+                                       }
+                                       return -ETIMEDOUT;
+                               }
+                               udelay(5);
+                       }
+               } else
+                       down(&fibptr->event_wait);
                if(fibptr->done == 0)
                        BUG();
                        
@@ -622,15 +592,9 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid)
                case HostNormCmdQueue:
                        notify = HostNormCmdNotFull;
                        break;
-               case HostHighCmdQueue:
-                       notify = HostHighCmdNotFull;
-                       break;
                case HostNormRespQueue:
                        notify = HostNormRespNotFull;
                        break;
-               case HostHighRespQueue:
-                       notify = HostHighRespNotFull;
-                       break;
                default:
                        BUG();
                        return;
@@ -652,9 +616,13 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size)
 {
        struct hw_fib * hw_fib = fibptr->hw_fib;
        struct aac_dev * dev = fibptr->dev;
+       struct aac_queue * q;
        unsigned long nointr = 0;
-       if (hw_fib->header.XferState == 0)
+       unsigned long qflags;
+
+       if (hw_fib->header.XferState == 0) {
                return 0;
+       }
        /*
         *      If we plan to do anything check the structure type first.
         */ 
@@ -669,37 +637,21 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size)
         *      send the completed cdb to the adapter.
         */
        if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) {
+               u32 index;
                hw_fib->header.XferState |= cpu_to_le32(HostProcessed);
-               if (hw_fib->header.XferState & cpu_to_le32(HighPriority)) {
-                       u32 index;
-                               if (size) 
-                       {
-                               size += sizeof(struct aac_fibhdr);
-                               if (size > le16_to_cpu(hw_fib->header.SenderSize))
-                                       return -EMSGSIZE;
-                               hw_fib->header.Size = cpu_to_le16(size);
-                       }
-                       if(aac_queue_get(dev, &index, AdapHighRespQueue, hw_fib, 1, NULL, &nointr) < 0) {
-                               return -EWOULDBLOCK;
-                       }
-                       if (aac_insert_entry(dev, index, AdapHighRespQueue,  (nointr & (int)aac_config.irq_mod)) != 0) {
-                       }
-               } else if (hw_fib->header.XferState & 
-                               cpu_to_le32(NormalPriority)) {
-                       u32 index;
-
-                       if (size) {
-                               size += sizeof(struct aac_fibhdr);
-                               if (size > le16_to_cpu(hw_fib->header.SenderSize)) 
-                                       return -EMSGSIZE;
-                               hw_fib->header.Size = cpu_to_le16(size);
-                       }
-                       if (aac_queue_get(dev, &index, AdapNormRespQueue, hw_fib, 1, NULL, &nointr) < 0) 
-                               return -EWOULDBLOCK;
-                       if (aac_insert_entry(dev, index, AdapNormRespQueue, (nointr & (int)aac_config.irq_mod)) != 0) 
-                       {
-                       }
+               if (size) {
+                       size += sizeof(struct aac_fibhdr);
+                       if (size > le16_to_cpu(hw_fib->header.SenderSize)) 
+                               return -EMSGSIZE;
+                       hw_fib->header.Size = cpu_to_le16(size);
                }
+               q = &dev->queues->queue[AdapNormRespQueue];
+               spin_lock_irqsave(q->lock, qflags);
+               aac_queue_get(dev, &index, AdapNormRespQueue, hw_fib, 1, NULL, &nointr);
+               *(q->headers.producer) = cpu_to_le32(index + 1);
+               spin_unlock_irqrestore(q->lock, qflags);
+               if (!(nointr & (int)aac_config.irq_mod))
+                       aac_adapter_notify(dev, AdapNormRespQueue);
        }
        else 
        {
@@ -791,6 +743,268 @@ void aac_printf(struct aac_dev *dev, u32 val)
        memset(cp, 0,  256);
 }
 
+
+/**
+ *     aac_handle_aif          -       Handle a message from the firmware
+ *     @dev: Which adapter this fib is from
+ *     @fibptr: Pointer to fibptr from adapter
+ *
+ *     This routine handles a driver notify fib from the adapter and
+ *     dispatches it to the appropriate routine for handling.
+ */
+
+static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
+{
+       struct hw_fib * hw_fib = fibptr->hw_fib;
+       struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data;
+       int busy;
+       u32 container;
+       struct scsi_device *device;
+       enum {
+               NOTHING,
+               DELETE,
+               ADD,
+               CHANGE
+       } device_config_needed;
+
+       /* Sniff for container changes */
+
+       if (!dev)
+               return;
+       container = (u32)-1;
+
+       /*
+        *      We have set this up to try and minimize the number of
+        * re-configures that take place. As a result of this when
+        * certain AIF's come in we will set a flag waiting for another
+        * type of AIF before setting the re-config flag.
+        */
+       switch (le32_to_cpu(aifcmd->command)) {
+       case AifCmdDriverNotify:
+               switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {
+               /*
+                *      Morph or Expand complete
+                */
+               case AifDenMorphComplete:
+               case AifDenVolumeExtendComplete:
+                       container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
+                       if (container >= dev->maximum_num_containers)
+                               break;
+
+                       /*
+                        *      Find the Scsi_Device associated with the SCSI
+                        * address. Make sure we have the right array, and if
+                        * so set the flag to initiate a new re-config once we
+                        * see an AifEnConfigChange AIF come through.
+                        */
+
+                       if ((dev != NULL) && (dev->scsi_host_ptr != NULL)) {
+                               device = scsi_device_lookup(dev->scsi_host_ptr, 
+                                       CONTAINER_TO_CHANNEL(container), 
+                                       CONTAINER_TO_ID(container), 
+                                       CONTAINER_TO_LUN(container));
+                               if (device) {
+                                       dev->fsa_dev[container].config_needed = CHANGE;
+                                       dev->fsa_dev[container].config_waiting_on = AifEnConfigChange;
+                                       scsi_device_put(device);
+                               }
+                       }
+               }
+
+               /*
+                *      If we are waiting on something and this happens to be
+                * that thing then set the re-configure flag.
+                */
+               if (container != (u32)-1) {
+                       if (container >= dev->maximum_num_containers)
+                               break;
+                       if (dev->fsa_dev[container].config_waiting_on ==
+                           le32_to_cpu(*(u32 *)aifcmd->data))
+                               dev->fsa_dev[container].config_waiting_on = 0;
+               } else for (container = 0;
+                   container < dev->maximum_num_containers; ++container) {
+                       if (dev->fsa_dev[container].config_waiting_on ==
+                           le32_to_cpu(*(u32 *)aifcmd->data))
+                               dev->fsa_dev[container].config_waiting_on = 0;
+               }
+               break;
+
+       case AifCmdEventNotify:
+               switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {
+               /*
+                *      Add an Array.
+                */
+               case AifEnAddContainer:
+                       container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
+                       if (container >= dev->maximum_num_containers)
+                               break;
+                       dev->fsa_dev[container].config_needed = ADD;
+                       dev->fsa_dev[container].config_waiting_on =
+                               AifEnConfigChange;
+                       break;
+
+               /*
+                *      Delete an Array.
+                */
+               case AifEnDeleteContainer:
+                       container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
+                       if (container >= dev->maximum_num_containers)
+                               break;
+                       dev->fsa_dev[container].config_needed = DELETE;
+                       dev->fsa_dev[container].config_waiting_on =
+                               AifEnConfigChange;
+                       break;
+
+               /*
+                *      Container change detected. If we currently are not
+                * waiting on something else, setup to wait on a Config Change.
+                */
+               case AifEnContainerChange:
+                       container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
+                       if (container >= dev->maximum_num_containers)
+                               break;
+                       if (dev->fsa_dev[container].config_waiting_on)
+                               break;
+                       dev->fsa_dev[container].config_needed = CHANGE;
+                       dev->fsa_dev[container].config_waiting_on =
+                               AifEnConfigChange;
+                       break;
+
+               case AifEnConfigChange:
+                       break;
+
+               }
+
+               /*
+                *      If we are waiting on something and this happens to be
+                * that thing then set the re-configure flag.
+                */
+               if (container != (u32)-1) {
+                       if (container >= dev->maximum_num_containers)
+                               break;
+                       if (dev->fsa_dev[container].config_waiting_on ==
+                           le32_to_cpu(*(u32 *)aifcmd->data))
+                               dev->fsa_dev[container].config_waiting_on = 0;
+               } else for (container = 0;
+                   container < dev->maximum_num_containers; ++container) {
+                       if (dev->fsa_dev[container].config_waiting_on ==
+                           le32_to_cpu(*(u32 *)aifcmd->data))
+                               dev->fsa_dev[container].config_waiting_on = 0;
+               }
+               break;
+
+       case AifCmdJobProgress:
+               /*
+                *      These are job progress AIF's. When a Clear is being
+                * done on a container it is initially created then hidden from
+                * the OS. When the clear completes we don't get a config
+                * change so we monitor the job status complete on a clear then
+                * wait for a container change.
+                */
+
+               if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))
+                && ((((u32 *)aifcmd->data)[6] == ((u32 *)aifcmd->data)[5])
+                 || (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsSuccess)))) {
+                       for (container = 0;
+                           container < dev->maximum_num_containers;
+                           ++container) {
+                               /*
+                                * Stomp on all config sequencing for all
+                                * containers?
+                                */
+                               dev->fsa_dev[container].config_waiting_on =
+                                       AifEnContainerChange;
+                               dev->fsa_dev[container].config_needed = ADD;
+                       }
+               }
+               if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))
+                && (((u32 *)aifcmd->data)[6] == 0)
+                && (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsRunning))) {
+                       for (container = 0;
+                           container < dev->maximum_num_containers;
+                           ++container) {
+                               /*
+                                * Stomp on all config sequencing for all
+                                * containers?
+                                */
+                               dev->fsa_dev[container].config_waiting_on =
+                                       AifEnContainerChange;
+                               dev->fsa_dev[container].config_needed = DELETE;
+                       }
+               }
+               break;
+       }
+
+       device_config_needed = NOTHING;
+       for (container = 0; container < dev->maximum_num_containers;
+           ++container) {
+               if ((dev->fsa_dev[container].config_waiting_on == 0)
+                && (dev->fsa_dev[container].config_needed != NOTHING)) {
+                       device_config_needed =
+                               dev->fsa_dev[container].config_needed;
+                       dev->fsa_dev[container].config_needed = NOTHING;
+                       break;
+               }
+       }
+       if (device_config_needed == NOTHING)
+               return;
+
+       /*
+        *      If we decided that a re-configuration needs to be done,
+        * schedule it here on the way out the door, please close the door
+        * behind you.
+        */
+
+       busy = 0;
+
+
+       /*
+        *      Find the Scsi_Device associated with the SCSI address,
+        * and mark it as changed, invalidating the cache. This deals
+        * with changes to existing device IDs.
+        */
+
+       if (!dev || !dev->scsi_host_ptr)
+               return;
+       /*
+        * force reload of disk info via probe_container
+        */
+       if ((device_config_needed == CHANGE)
+        && (dev->fsa_dev[container].valid == 1))
+               dev->fsa_dev[container].valid = 2;
+       if ((device_config_needed == CHANGE) ||
+                       (device_config_needed == ADD))
+               probe_container(dev, container);
+       device = scsi_device_lookup(dev->scsi_host_ptr, 
+               CONTAINER_TO_CHANNEL(container), 
+               CONTAINER_TO_ID(container), 
+               CONTAINER_TO_LUN(container));
+       if (device) {
+               switch (device_config_needed) {
+               case DELETE:
+                       scsi_remove_device(device);
+                       break;
+               case CHANGE:
+                       if (!dev->fsa_dev[container].valid) {
+                               scsi_remove_device(device);
+                               break;
+                       }
+                       scsi_rescan_device(&device->sdev_gendev);
+
+               default:
+                       break;
+               }
+               scsi_device_put(device);
+       }
+       if (device_config_needed == ADD) {
+               scsi_add_device(dev->scsi_host_ptr,
+                 CONTAINER_TO_CHANNEL(container),
+                 CONTAINER_TO_ID(container),
+                 CONTAINER_TO_LUN(container));
+       }
+
+}
+
 /**
  *     aac_command_thread      -       command processing thread
  *     @dev: Adapter to monitor
@@ -805,7 +1019,6 @@ int aac_command_thread(struct aac_dev * dev)
 {
        struct hw_fib *hw_fib, *hw_newfib;
        struct fib *fib, *newfib;
-       struct aac_queue_block *queues = dev->queues;
        struct aac_fib_context *fibctx;
        unsigned long flags;
        DECLARE_WAITQUEUE(wait, current);
@@ -825,21 +1038,22 @@ int aac_command_thread(struct aac_dev * dev)
         *      Let the DPC know it has a place to send the AIF's to.
         */
        dev->aif_thread = 1;
-       add_wait_queue(&queues->queue[HostNormCmdQueue].cmdready, &wait);
+       add_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
        set_current_state(TASK_INTERRUPTIBLE);
+       dprintk ((KERN_INFO "aac_command_thread start\n"));
        while(1) 
        {
-               spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags);
-               while(!list_empty(&(queues->queue[HostNormCmdQueue].cmdq))) {
+               spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
+               while(!list_empty(&(dev->queues->queue[HostNormCmdQueue].cmdq))) {
                        struct list_head *entry;
                        struct aac_aifcmd * aifcmd;
 
                        set_current_state(TASK_RUNNING);
-               
-                       entry = queues->queue[HostNormCmdQueue].cmdq.next;
+       
+                       entry = dev->queues->queue[HostNormCmdQueue].cmdq.next;
                        list_del(entry);
-                       
-                       spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags);
+               
+                       spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
                        fib = list_entry(entry, struct fib, fiblink);
                        /*
                         *      We will process the FIB here or pass it to a 
@@ -860,6 +1074,7 @@ int aac_command_thread(struct aac_dev * dev)
                        aifcmd = (struct aac_aifcmd *) hw_fib->data;
                        if (aifcmd->command == cpu_to_le32(AifCmdDriverNotify)) {
                                /* Handle Driver Notify Events */
+                               aac_handle_aif(dev, fib);
                                *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
                                fib_adapter_complete(fib, (u16)sizeof(u32));
                        } else {
@@ -869,9 +1084,62 @@ int aac_command_thread(struct aac_dev * dev)
                                   
                                u32 time_now, time_last;
                                unsigned long flagv;
-                               
+                               unsigned num;
+                               struct hw_fib ** hw_fib_pool, ** hw_fib_p;
+                               struct fib ** fib_pool, ** fib_p;
+                       
+                               /* Sniff events */
+                               if ((aifcmd->command == 
+                                    cpu_to_le32(AifCmdEventNotify)) ||
+                                   (aifcmd->command == 
+                                    cpu_to_le32(AifCmdJobProgress))) {
+                                       aac_handle_aif(dev, fib);
+                               }
+                               
                                time_now = jiffies/HZ;
 
+                               /*
+                                * Warning: no sleep allowed while
+                                * holding spinlock. We take the estimate
+                                * and pre-allocate a set of fibs outside the
+                                * lock.
+                                */
+                               num = le32_to_cpu(dev->init->AdapterFibsSize)
+                                   / sizeof(struct hw_fib); /* some extra */
+                               spin_lock_irqsave(&dev->fib_lock, flagv);
+                               entry = dev->fib_list.next;
+                               while (entry != &dev->fib_list) {
+                                       entry = entry->next;
+                                       ++num;
+                               }
+                               spin_unlock_irqrestore(&dev->fib_lock, flagv);
+                               hw_fib_pool = NULL;
+                               fib_pool = NULL;
+                               if (num
+                                && ((hw_fib_pool = kmalloc(sizeof(struct hw_fib *) * num, GFP_KERNEL)))
+                                && ((fib_pool = kmalloc(sizeof(struct fib *) * num, GFP_KERNEL)))) {
+                                       hw_fib_p = hw_fib_pool;
+                                       fib_p = fib_pool;
+                                       while (hw_fib_p < &hw_fib_pool[num]) {
+                                               if (!(*(hw_fib_p++) = kmalloc(sizeof(struct hw_fib), GFP_KERNEL))) {
+                                                       --hw_fib_p;
+                                                       break;
+                                               }
+                                               if (!(*(fib_p++) = kmalloc(sizeof(struct fib), GFP_KERNEL))) {
+                                                       kfree(*(--hw_fib_p));
+                                                       break;
+                                               }
+                                       }
+                                       if ((num = hw_fib_p - hw_fib_pool) == 0) {
+                                               kfree(fib_pool);
+                                               fib_pool = NULL;
+                                               kfree(hw_fib_pool);
+                                               hw_fib_pool = NULL;
+                                       }
+                               } else if (hw_fib_pool) {
+                                       kfree(hw_fib_pool);
+                                       hw_fib_pool = NULL;
+                               }
                                spin_lock_irqsave(&dev->fib_lock, flagv);
                                entry = dev->fib_list.next;
                                /*
@@ -880,6 +1148,8 @@ int aac_command_thread(struct aac_dev * dev)
                                 * fib, and then set the event to wake up the
                                 * thread that is waiting for it.
                                 */
+                               hw_fib_p = hw_fib_pool;
+                               fib_p = fib_pool;
                                while (entry != &dev->fib_list) {
                                        /*
                                         * Extract the fibctx
@@ -912,9 +1182,11 @@ int aac_command_thread(struct aac_dev * dev)
                                         * Warning: no sleep allowed while
                                         * holding spinlock
                                         */
-                                       hw_newfib = kmalloc(sizeof(struct hw_fib), GFP_ATOMIC);
-                                       newfib = kmalloc(sizeof(struct fib), GFP_ATOMIC);
-                                       if (newfib && hw_newfib) {
+                                       if (hw_fib_p < &hw_fib_pool[num]) {
+                                               hw_newfib = *hw_fib_p;
+                                               *(hw_fib_p++) = NULL;
+                                               newfib = *fib_p;
+                                               *(fib_p++) = NULL;
                                                /*
                                                 * Make the copy of the FIB
                                                 */
@@ -929,15 +1201,11 @@ int aac_command_thread(struct aac_dev * dev)
                                                fibctx->count++;
                                                /* 
                                                 * Set the event to wake up the
-                                                * thread that will waiting.
+                                                * thread that is waiting.
                                                 */
                                                up(&fibctx->wait_sem);
                                        } else {
                                                printk(KERN_WARNING "aifd: didn't allocate NewFib.\n");
-                                               if(newfib)
-                                                       kfree(newfib);
-                                               if(hw_newfib)
-                                                       kfree(hw_newfib);
                                        }
                                        entry = entry->next;
                                }
@@ -947,21 +1215,38 @@ int aac_command_thread(struct aac_dev * dev)
                                *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
                                fib_adapter_complete(fib, sizeof(u32));
                                spin_unlock_irqrestore(&dev->fib_lock, flagv);
+                               /* Free up the remaining resources */
+                               hw_fib_p = hw_fib_pool;
+                               fib_p = fib_pool;
+                               while (hw_fib_p < &hw_fib_pool[num]) {
+                                       if (*hw_fib_p)
+                                               kfree(*hw_fib_p);
+                                       if (*fib_p)
+                                               kfree(*fib_p);
+                                       ++fib_p;
+                                       ++hw_fib_p;
+                               }
+                               if (hw_fib_pool)
+                                       kfree(hw_fib_pool);
+                               if (fib_pool)
+                                       kfree(fib_pool);
                        }
-                       spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags);
                        kfree(fib);
+                       spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
                }
                /*
                 *      There are no more AIF's
                 */
-               spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags);
+               spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
                schedule();
 
                if(signal_pending(current))
                        break;
                set_current_state(TASK_INTERRUPTIBLE);
        }
-       remove_wait_queue(&queues->queue[HostNormCmdQueue].cmdready, &wait);
+       if (dev->queues)
+               remove_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
        dev->aif_thread = 0;
        complete_and_exit(&dev->aif_completion, 0);
+       return 0;
 }
index 4ff29d7f58252cb6b5fabb309aa84ad25eea64be..de8490a92831b62cef00560a950c37c2e1dcd7e0 100644 (file)
@@ -748,7 +748,8 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
                unique_id++;
        }
 
-       if (pci_enable_device(pdev))
+       error = pci_enable_device(pdev);
+       if (error)
                goto out;
 
        if (pci_set_dma_mask(pdev, 0xFFFFFFFFULL) || 
@@ -772,6 +773,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
        shost->irq = pdev->irq;
        shost->base = pci_resource_start(pdev, 0);
        shost->unique_id = unique_id;
+       shost->max_cmd_len = 16;
 
        aac = (struct aac_dev *)shost->hostdata;
        aac->scsi_host_ptr = shost;     
@@ -799,7 +801,9 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
                        goto out_free_fibs;
 
        aac->maximum_num_channels = aac_drivers[index].channels;
-       aac_get_adapter_info(aac);
+       error = aac_get_adapter_info(aac);
+       if (error < 0)
+               goto out_deinit;
 
        /*
         * Lets override negotiations and drop the maximum SG limit to 34
@@ -927,8 +931,8 @@ static int __init aac_init(void)
        printk(KERN_INFO "Adaptec %s driver (%s)\n",
          AAC_DRIVERNAME, aac_driver_version);
 
-       error = pci_module_init(&aac_pci_driver);
-       if (error)
+       error = pci_register_driver(&aac_pci_driver);
+       if (error < 0)
                return error;
 
        aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops);
index 70c5fb59c9ea4c07c4ec6fa04eacaeb6028907a4..d754b32678631dd9984ff273d3ee32f1ce6d2c5e 100644 (file)
@@ -112,6 +112,9 @@ aic7770_remove(struct device *dev)
        struct ahc_softc *ahc = dev_get_drvdata(dev);
        u_long s;
 
+       if (ahc->platform_data && ahc->platform_data->host)
+                       scsi_remove_host(ahc->platform_data->host);
+
        ahc_lock(ahc, &s);
        ahc_intr_enable(ahc, FALSE);
        ahc_unlock(ahc, &s);
index 6b6d4e287793acd5b3c044e7f80e7cf4ab7bba5f..95c285cc83e469a4e20c11b9593597b985c03574 100644 (file)
@@ -1192,11 +1192,6 @@ ahd_platform_free(struct ahd_softc *ahd)
        int i, j;
 
        if (ahd->platform_data != NULL) {
-               if (ahd->platform_data->host != NULL) {
-                       scsi_remove_host(ahd->platform_data->host);
-                       scsi_host_put(ahd->platform_data->host);
-               }
-
                /* destroy all of the device and target objects */
                for (i = 0; i < AHD_NUM_TARGETS; i++) {
                        starget = ahd->platform_data->starget[i];
@@ -1226,6 +1221,9 @@ ahd_platform_free(struct ahd_softc *ahd)
                        release_mem_region(ahd->platform_data->mem_busaddr,
                                           0x1000);
                }
+               if (ahd->platform_data->host)
+                       scsi_host_put(ahd->platform_data->host);
+
                free(ahd->platform_data, M_DEVBUF);
        }
 }
index 390b53852d4b9cfdfd6644d57f6f3881d7528502..bf360ae021abb0582482d4702e903a9eda4ac7f8 100644 (file)
@@ -95,6 +95,9 @@ ahd_linux_pci_dev_remove(struct pci_dev *pdev)
        struct ahd_softc *ahd = pci_get_drvdata(pdev);
        u_long s;
 
+       if (ahd->platform_data && ahd->platform_data->host)
+                       scsi_remove_host(ahd->platform_data->host);
+
        ahd_lock(ahd, &s);
        ahd_intr_enable(ahd, FALSE);
        ahd_unlock(ahd, &s);
index 876d1de8480d1388f0b740e40271ca9d21c2e2e2..6ee1435d37fac9efbce4d3a3ecd763c4ed2cfe5e 100644 (file)
@@ -1209,11 +1209,6 @@ ahc_platform_free(struct ahc_softc *ahc)
        int i, j;
 
        if (ahc->platform_data != NULL) {
-               if (ahc->platform_data->host != NULL) {
-                       scsi_remove_host(ahc->platform_data->host);
-                       scsi_host_put(ahc->platform_data->host);
-               }
-
                /* destroy all of the device and target objects */
                for (i = 0; i < AHC_NUM_TARGETS; i++) {
                        starget = ahc->platform_data->starget[i];
@@ -1242,6 +1237,9 @@ ahc_platform_free(struct ahc_softc *ahc)
                                           0x1000);
                }
 
+               if (ahc->platform_data->host)
+                       scsi_host_put(ahc->platform_data->host);
+
                free(ahc->platform_data, M_DEVBUF);
        }
 }
index 3ce77ddc889e8a6a2cefe4f54092bbaf218b65d5..cb30d9c1153d5394c08db57f6b64486bfcd1592a 100644 (file)
@@ -143,6 +143,9 @@ ahc_linux_pci_dev_remove(struct pci_dev *pdev)
        struct ahc_softc *ahc = pci_get_drvdata(pdev);
        u_long s;
 
+       if (ahc->platform_data && ahc->platform_data->host)
+                       scsi_remove_host(ahc->platform_data->host);
+
        ahc_lock(ahc, &s);
        ahc_intr_enable(ahc, FALSE);
        ahc_unlock(ahc, &s);
index f2a72d33132c4e24e9e9b5f29fb4126276ea089d..02fe371b0ab87142b718e2d707bf365427f08ea9 100644 (file)
@@ -176,6 +176,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
        transport_unregister_device(&shost->shost_gendev);
        class_device_unregister(&shost->shost_classdev);
        device_del(&shost->shost_gendev);
+       scsi_proc_hostdir_rm(shost->hostt);
 }
 EXPORT_SYMBOL(scsi_remove_host);
 
@@ -262,7 +263,6 @@ static void scsi_host_dev_release(struct device *dev)
        if (shost->work_q)
                destroy_workqueue(shost->work_q);
 
-       scsi_proc_hostdir_rm(shost->hostt);
        scsi_destroy_command_freelist(shost);
        kfree(shost->shost_data);
 
index 86eaf6d408d5770aa77befca6da6b784bb8c4328..acae7c48ef7dabeead41c41976e2ca5adb5a7912 100644 (file)
@@ -973,10 +973,10 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost)
        if ((phba->fc_flag & FC_FABRIC) ||
            ((phba->fc_topology == TOPOLOGY_LOOP) &&
             (phba->fc_flag & FC_PUBLIC_LOOP)))
-               node_name = wwn_to_u64(phba->fc_fabparam.nodeName.wwn);
+               node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
        else
                /* fabric is local port if there is no F/FL_Port */
-               node_name = wwn_to_u64(phba->fc_nodename.wwn);
+               node_name = wwn_to_u64(phba->fc_nodename.u.wwn);
 
        spin_unlock_irq(shost->host_lock);
 
@@ -1110,7 +1110,7 @@ lpfc_get_starget_node_name(struct scsi_target *starget)
        /* Search the mapped list for this target ID */
        list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
                if (starget->id == ndlp->nlp_sid) {
-                       node_name = wwn_to_u64(ndlp->nlp_nodename.wwn);
+                       node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
                        break;
                }
        }
@@ -1131,7 +1131,7 @@ lpfc_get_starget_port_name(struct scsi_target *starget)
        /* Search the mapped list for this target ID */
        list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
                if (starget->id == ndlp->nlp_sid) {
-                       port_name = wwn_to_u64(ndlp->nlp_portname.wwn);
+                       port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
                        break;
                }
        }
index 4fb8eb0c84cfc0773c7f2115f95d350db2b22edd..56052f4510c3c6bf1a2280b66bf5f402405e31ad 100644 (file)
@@ -1019,8 +1019,8 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        struct fc_rport_identifiers rport_ids;
 
        /* Remote port has reappeared. Re-register w/ FC transport */
-       rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.wwn);
-       rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.wwn);
+       rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
+       rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
        rport_ids.port_id = ndlp->nlp_DID;
        rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
        if (ndlp->nlp_type & NLP_FCP_TARGET)
index 047a87c26cc0825e72235573325ac4dc2f60092e..86c41981188b33b5d3c7a204411d79a52d01dce1 100644 (file)
@@ -280,9 +280,9 @@ struct lpfc_name {
 #define NAME_CCITT_GR_TYPE  0xE
                        uint8_t IEEEextLsb;     /* FC Word 0, bit 16:23, IEEE extended Lsb */
                        uint8_t IEEE[6];        /* FC IEEE address */
-               };
+               } s;
                uint8_t wwn[8];
-       };
+       } u;
 };
 
 struct csp {
index 454058f655db6b056a1f1f123d13efc6448e7b5e..0856ff7d3b33d587b99e4bb72107cd34f90e2f47 100644 (file)
@@ -285,7 +285,7 @@ lpfc_config_port_post(struct lpfc_hba * phba)
        if (phba->SerialNumber[0] == 0) {
                uint8_t *outptr;
 
-               outptr = (uint8_t *) & phba->fc_nodename.IEEE[0];
+               outptr = &phba->fc_nodename.u.s.IEEE[0];
                for (i = 0; i < 12; i++) {
                        status = *outptr++;
                        j = ((status & 0xf0) >> 4);
@@ -1523,8 +1523,8 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
         * Must done after lpfc_sli_hba_setup()
         */
 
-       fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.wwn);
-       fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.wwn);
+       fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn);
+       fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn);
        fc_host_supported_classes(host) = FC_COS_CLASS3;
 
        memset(fc_host_supported_fc4s(host), 0,
index 6f308ebe3e797857d02baae2679c96db8fd8bfbd..61a6fd810bb4bedfb24a13b57265e7af87a56966 100644 (file)
@@ -621,8 +621,6 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
        if(islogical) {
                switch (cmd->cmnd[0]) {
                case TEST_UNIT_READY:
-                       memset(cmd->request_buffer, 0, cmd->request_bufflen);
-
 #if MEGA_HAVE_CLUSTERING
                        /*
                         * Do we support clustering and is the support enabled
@@ -652,11 +650,28 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
                        return NULL;
 #endif
 
-               case MODE_SENSE:
+               case MODE_SENSE: {
+                       char *buf;
+
+                       if (cmd->use_sg) {
+                               struct scatterlist *sg;
+
+                               sg = (struct scatterlist *)cmd->request_buffer;
+                               buf = kmap_atomic(sg->page, KM_IRQ0) +
+                                       sg->offset;
+                       } else
+                               buf = cmd->request_buffer;
                        memset(cmd->request_buffer, 0, cmd->cmnd[4]);
+                       if (cmd->use_sg) {
+                               struct scatterlist *sg;
+
+                               sg = (struct scatterlist *)cmd->request_buffer;
+                               kunmap_atomic(buf - sg->offset, KM_IRQ0);
+                       }
                        cmd->result = (DID_OK << 16);
                        cmd->scsi_done(cmd);
                        return NULL;
+               }
 
                case READ_CAPACITY:
                case INQUIRY:
@@ -1685,14 +1700,23 @@ mega_rundoneq (adapter_t *adapter)
 static void
 mega_free_scb(adapter_t *adapter, scb_t *scb)
 {
+       unsigned long length;
+
        switch( scb->dma_type ) {
 
        case MEGA_DMA_TYPE_NONE:
                break;
 
        case MEGA_BULK_DATA:
+               if (scb->cmd->use_sg == 0)
+                       length = scb->cmd->request_bufflen;
+               else {
+                       struct scatterlist *sgl =
+                               (struct scatterlist *)scb->cmd->request_buffer;
+                       length = sgl->length;
+               }
                pci_unmap_page(adapter->dev, scb->dma_h_bulkdata,
-                       scb->cmd->request_bufflen, scb->dma_direction);
+                              length, scb->dma_direction);
                break;
 
        case MEGA_SGLIST:
@@ -1741,6 +1765,7 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
        struct scatterlist      *sgl;
        struct page     *page;
        unsigned long   offset;
+       unsigned int    length;
        Scsi_Cmnd       *cmd;
        int     sgcnt;
        int     idx;
@@ -1748,14 +1773,23 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
        cmd = scb->cmd;
 
        /* Scatter-gather not used */
-       if( !cmd->use_sg ) {
-
-               page = virt_to_page(cmd->request_buffer);
-               offset = offset_in_page(cmd->request_buffer);
+       if( cmd->use_sg == 0 || (cmd->use_sg == 1 && 
+                                !adapter->has_64bit_addr)) {
+
+               if (cmd->use_sg == 0) {
+                       page = virt_to_page(cmd->request_buffer);
+                       offset = offset_in_page(cmd->request_buffer);
+                       length = cmd->request_bufflen;
+               } else {
+                       sgl = (struct scatterlist *)cmd->request_buffer;
+                       page = sgl->page;
+                       offset = sgl->offset;
+                       length = sgl->length;
+               }
 
                scb->dma_h_bulkdata = pci_map_page(adapter->dev,
                                                  page, offset,
-                                                 cmd->request_bufflen,
+                                                 length,
                                                  scb->dma_direction);
                scb->dma_type = MEGA_BULK_DATA;
 
@@ -1765,14 +1799,14 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
                 */
                if( adapter->has_64bit_addr ) {
                        scb->sgl64[0].address = scb->dma_h_bulkdata;
-                       scb->sgl64[0].length = cmd->request_bufflen;
+                       scb->sgl64[0].length = length;
                        *buf = (u32)scb->sgl_dma_addr;
-                       *len = (u32)cmd->request_bufflen;
+                       *len = (u32)length;
                        return 1;
                }
                else {
                        *buf = (u32)scb->dma_h_bulkdata;
-                       *len = (u32)cmd->request_bufflen;
+                       *len = (u32)length;
                }
                return 0;
        }
@@ -1791,27 +1825,23 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
 
        if( sgcnt > adapter->sglen ) BUG();
 
+       *len = 0;
+
        for( idx = 0; idx < sgcnt; idx++, sgl++ ) {
 
                if( adapter->has_64bit_addr ) {
                        scb->sgl64[idx].address = sg_dma_address(sgl);
-                       scb->sgl64[idx].length = sg_dma_len(sgl);
+                       *len += scb->sgl64[idx].length = sg_dma_len(sgl);
                }
                else {
                        scb->sgl[idx].address = sg_dma_address(sgl);
-                       scb->sgl[idx].length = sg_dma_len(sgl);
+                       *len += scb->sgl[idx].length = sg_dma_len(sgl);
                }
        }
 
        /* Reset pointer and length fields */
        *buf = scb->sgl_dma_addr;
 
-       /*
-        * For passthru command, dataxferlen must be set, even for commands
-        * with a sg list
-        */
-       *len = (u32)cmd->request_bufflen;
-
        /* Return count of SG requests */
        return sgcnt;
 }
index 917d591d90b2fcd404b42a4033e4e4a722b051f7..7363e12663acab0a92711ec59569b7014b0ba456 100644 (file)
@@ -76,3 +76,12 @@ config MEGARAID_LEGACY
        To compile this driver as a module, choose M here: the
        module will be called megaraid
 endif
+
+config MEGARAID_SAS
+       tristate "LSI Logic MegaRAID SAS RAID Module"
+       depends on PCI && SCSI
+       help
+       Module for LSI Logic's SAS based RAID controllers.
+       To compile this driver as a module, choose 'm' here.
+       Module will be called megaraid_sas
+
index 6dd99f275722da40d1265bccfbfccc93060eaf21..f469915b97c388833d5c0d5d2b844bf84fb5526a 100644 (file)
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MEGARAID_MM)      += megaraid_mm.o
 obj-$(CONFIG_MEGARAID_MAILBOX) += megaraid_mbox.o
+obj-$(CONFIG_MEGARAID_SAS)     += megaraid_sas.o
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
new file mode 100644 (file)
index 0000000..c3f6373
--- /dev/null
@@ -0,0 +1,2806 @@
+/*
+ *
+ *             Linux MegaRAID driver for SAS based RAID controllers
+ *
+ * Copyright (c) 2003-2005  LSI Logic Corporation.
+ *
+ *        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.
+ *
+ * FILE                : megaraid_sas.c
+ * Version     : v00.00.02.00-rc4
+ *
+ * Authors:
+ *     Sreenivas Bagalkote     <Sreenivas.Bagalkote@lsil.com>
+ *     Sumant Patro            <Sumant.Patro@lsil.com>
+ *
+ * List of supported controllers
+ *
+ * OEM Product Name                    VID     DID     SSVID   SSID
+ * --- ------------                    ---     ---     ----    ----
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/list.h>
+#include <linux/version.h>
+#include <linux/moduleparam.h>
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/uio.h>
+#include <asm/uaccess.h>
+#include <linux/fs.h>
+#include <linux/compat.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include "megaraid_sas.h"
+
+MODULE_LICENSE("GPL");
+MODULE_VERSION(MEGASAS_VERSION);
+MODULE_AUTHOR("sreenivas.bagalkote@lsil.com");
+MODULE_DESCRIPTION("LSI Logic MegaRAID SAS Driver");
+
+/*
+ * PCI ID table for all supported controllers
+ */
+static struct pci_device_id megasas_pci_table[] = {
+
+       {
+        PCI_VENDOR_ID_LSI_LOGIC,
+        PCI_DEVICE_ID_LSI_SAS1064R,
+        PCI_ANY_ID,
+        PCI_ANY_ID,
+        },
+       {
+        PCI_VENDOR_ID_DELL,
+        PCI_DEVICE_ID_DELL_PERC5,
+        PCI_ANY_ID,
+        PCI_ANY_ID,
+        },
+       {0}                     /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(pci, megasas_pci_table);
+
+static int megasas_mgmt_majorno;
+static struct megasas_mgmt_info megasas_mgmt_info;
+static struct fasync_struct *megasas_async_queue;
+static DECLARE_MUTEX(megasas_async_queue_mutex);
+
+/**
+ * megasas_get_cmd -   Get a command from the free pool
+ * @instance:          Adapter soft state
+ *
+ * Returns a free command from the pool
+ */
+static inline struct megasas_cmd *megasas_get_cmd(struct megasas_instance
+                                                 *instance)
+{
+       unsigned long flags;
+       struct megasas_cmd *cmd = NULL;
+
+       spin_lock_irqsave(&instance->cmd_pool_lock, flags);
+
+       if (!list_empty(&instance->cmd_pool)) {
+               cmd = list_entry((&instance->cmd_pool)->next,
+                                struct megasas_cmd, list);
+               list_del_init(&cmd->list);
+       } else {
+               printk(KERN_ERR "megasas: Command pool empty!\n");
+       }
+
+       spin_unlock_irqrestore(&instance->cmd_pool_lock, flags);
+       return cmd;
+}
+
+/**
+ * megasas_return_cmd -        Return a cmd to free command pool
+ * @instance:          Adapter soft state
+ * @cmd:               Command packet to be returned to free command pool
+ */
+static inline void
+megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&instance->cmd_pool_lock, flags);
+
+       cmd->scmd = NULL;
+       list_add_tail(&cmd->list, &instance->cmd_pool);
+
+       spin_unlock_irqrestore(&instance->cmd_pool_lock, flags);
+}
+
+/**
+ * megasas_enable_intr -       Enables interrupts
+ * @regs:                      MFI register set
+ */
+static inline void
+megasas_enable_intr(struct megasas_register_set __iomem * regs)
+{
+       writel(1, &(regs)->outbound_intr_mask);
+
+       /* Dummy readl to force pci flush */
+       readl(&regs->outbound_intr_mask);
+}
+
+/**
+ * megasas_disable_intr -      Disables interrupts
+ * @regs:                      MFI register set
+ */
+static inline void
+megasas_disable_intr(struct megasas_register_set __iomem * regs)
+{
+       u32 mask = readl(&regs->outbound_intr_mask) & (~0x00000001);
+       writel(mask, &regs->outbound_intr_mask);
+
+       /* Dummy readl to force pci flush */
+       readl(&regs->outbound_intr_mask);
+}
+
+/**
+ * megasas_issue_polled -      Issues a polling command
+ * @instance:                  Adapter soft state
+ * @cmd:                       Command packet to be issued 
+ *
+ * For polling, MFI requires the cmd_status to be set to 0xFF before posting.
+ */
+static int
+megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd)
+{
+       int i;
+       u32 msecs = MFI_POLL_TIMEOUT_SECS * 1000;
+
+       struct megasas_header *frame_hdr = &cmd->frame->hdr;
+
+       frame_hdr->cmd_status = 0xFF;
+       frame_hdr->flags |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
+
+       /*
+        * Issue the frame using inbound queue port
+        */
+       writel(cmd->frame_phys_addr >> 3,
+              &instance->reg_set->inbound_queue_port);
+
+       /*
+        * Wait for cmd_status to change
+        */
+       for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i++) {
+               rmb();
+               msleep(1);
+       }
+
+       if (frame_hdr->cmd_status == 0xff)
+               return -ETIME;
+
+       return 0;
+}
+
+/**
+ * megasas_issue_blocked_cmd - Synchronous wrapper around regular FW cmds
+ * @instance:                  Adapter soft state
+ * @cmd:                       Command to be issued
+ *
+ * This function waits on an event for the command to be returned from ISR.
+ * Used to issue ioctl commands.
+ */
+static int
+megasas_issue_blocked_cmd(struct megasas_instance *instance,
+                         struct megasas_cmd *cmd)
+{
+       cmd->cmd_status = ENODATA;
+
+       writel(cmd->frame_phys_addr >> 3,
+              &instance->reg_set->inbound_queue_port);
+
+       wait_event(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA));
+
+       return 0;
+}
+
+/**
+ * megasas_issue_blocked_abort_cmd -   Aborts previously issued cmd
+ * @instance:                          Adapter soft state
+ * @cmd_to_abort:                      Previously issued cmd to be aborted
+ *
+ * MFI firmware can abort previously issued AEN comamnd (automatic event
+ * notification). The megasas_issue_blocked_abort_cmd() issues such abort
+ * cmd and blocks till it is completed.
+ */
+static int
+megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
+                               struct megasas_cmd *cmd_to_abort)
+{
+       struct megasas_cmd *cmd;
+       struct megasas_abort_frame *abort_fr;
+
+       cmd = megasas_get_cmd(instance);
+
+       if (!cmd)
+               return -1;
+
+       abort_fr = &cmd->frame->abort;
+
+       /*
+        * Prepare and issue the abort frame
+        */
+       abort_fr->cmd = MFI_CMD_ABORT;
+       abort_fr->cmd_status = 0xFF;
+       abort_fr->flags = 0;
+       abort_fr->abort_context = cmd_to_abort->index;
+       abort_fr->abort_mfi_phys_addr_lo = cmd_to_abort->frame_phys_addr;
+       abort_fr->abort_mfi_phys_addr_hi = 0;
+
+       cmd->sync_cmd = 1;
+       cmd->cmd_status = 0xFF;
+
+       writel(cmd->frame_phys_addr >> 3,
+              &instance->reg_set->inbound_queue_port);
+
+       /*
+        * Wait for this cmd to complete
+        */
+       wait_event(instance->abort_cmd_wait_q, (cmd->cmd_status != 0xFF));
+
+       megasas_return_cmd(instance, cmd);
+       return 0;
+}
+
+/**
+ * megasas_make_sgl32 -        Prepares 32-bit SGL
+ * @instance:          Adapter soft state
+ * @scp:               SCSI command from the mid-layer
+ * @mfi_sgl:           SGL to be filled in
+ *
+ * If successful, this function returns the number of SG elements. Otherwise,
+ * it returnes -1.
+ */
+static inline int
+megasas_make_sgl32(struct megasas_instance *instance, struct scsi_cmnd *scp,
+                  union megasas_sgl *mfi_sgl)
+{
+       int i;
+       int sge_count;
+       struct scatterlist *os_sgl;
+
+       /*
+        * Return 0 if there is no data transfer
+        */
+       if (!scp->request_buffer || !scp->request_bufflen)
+               return 0;
+
+       if (!scp->use_sg) {
+               mfi_sgl->sge32[0].phys_addr = pci_map_single(instance->pdev,
+                                                            scp->
+                                                            request_buffer,
+                                                            scp->
+                                                            request_bufflen,
+                                                            scp->
+                                                            sc_data_direction);
+               mfi_sgl->sge32[0].length = scp->request_bufflen;
+
+               return 1;
+       }
+
+       os_sgl = (struct scatterlist *)scp->request_buffer;
+       sge_count = pci_map_sg(instance->pdev, os_sgl, scp->use_sg,
+                              scp->sc_data_direction);
+
+       for (i = 0; i < sge_count; i++, os_sgl++) {
+               mfi_sgl->sge32[i].length = sg_dma_len(os_sgl);
+               mfi_sgl->sge32[i].phys_addr = sg_dma_address(os_sgl);
+       }
+
+       return sge_count;
+}
+
+/**
+ * megasas_make_sgl64 -        Prepares 64-bit SGL
+ * @instance:          Adapter soft state
+ * @scp:               SCSI command from the mid-layer
+ * @mfi_sgl:           SGL to be filled in
+ *
+ * If successful, this function returns the number of SG elements. Otherwise,
+ * it returnes -1.
+ */
+static inline int
+megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp,
+                  union megasas_sgl *mfi_sgl)
+{
+       int i;
+       int sge_count;
+       struct scatterlist *os_sgl;
+
+       /*
+        * Return 0 if there is no data transfer
+        */
+       if (!scp->request_buffer || !scp->request_bufflen)
+               return 0;
+
+       if (!scp->use_sg) {
+               mfi_sgl->sge64[0].phys_addr = pci_map_single(instance->pdev,
+                                                            scp->
+                                                            request_buffer,
+                                                            scp->
+                                                            request_bufflen,
+                                                            scp->
+                                                            sc_data_direction);
+
+               mfi_sgl->sge64[0].length = scp->request_bufflen;
+
+               return 1;
+       }
+
+       os_sgl = (struct scatterlist *)scp->request_buffer;
+       sge_count = pci_map_sg(instance->pdev, os_sgl, scp->use_sg,
+                              scp->sc_data_direction);
+
+       for (i = 0; i < sge_count; i++, os_sgl++) {
+               mfi_sgl->sge64[i].length = sg_dma_len(os_sgl);
+               mfi_sgl->sge64[i].phys_addr = sg_dma_address(os_sgl);
+       }
+
+       return sge_count;
+}
+
+/**
+ * megasas_build_dcdb -        Prepares a direct cdb (DCDB) command
+ * @instance:          Adapter soft state
+ * @scp:               SCSI command
+ * @cmd:               Command to be prepared in
+ *
+ * This function prepares CDB commands. These are typcially pass-through
+ * commands to the devices.
+ */
+static inline int
+megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
+                  struct megasas_cmd *cmd)
+{
+       u32 sge_sz;
+       int sge_bytes;
+       u32 is_logical;
+       u32 device_id;
+       u16 flags = 0;
+       struct megasas_pthru_frame *pthru;
+
+       is_logical = MEGASAS_IS_LOGICAL(scp);
+       device_id = MEGASAS_DEV_INDEX(instance, scp);
+       pthru = (struct megasas_pthru_frame *)cmd->frame;
+
+       if (scp->sc_data_direction == PCI_DMA_TODEVICE)
+               flags = MFI_FRAME_DIR_WRITE;
+       else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
+               flags = MFI_FRAME_DIR_READ;
+       else if (scp->sc_data_direction == PCI_DMA_NONE)
+               flags = MFI_FRAME_DIR_NONE;
+
+       /*
+        * Prepare the DCDB frame
+        */
+       pthru->cmd = (is_logical) ? MFI_CMD_LD_SCSI_IO : MFI_CMD_PD_SCSI_IO;
+       pthru->cmd_status = 0x0;
+       pthru->scsi_status = 0x0;
+       pthru->target_id = device_id;
+       pthru->lun = scp->device->lun;
+       pthru->cdb_len = scp->cmd_len;
+       pthru->timeout = 0;
+       pthru->flags = flags;
+       pthru->data_xfer_len = scp->request_bufflen;
+
+       memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);
+
+       /*
+        * Construct SGL
+        */
+       sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
+           sizeof(struct megasas_sge32);
+
+       if (IS_DMA64) {
+               pthru->flags |= MFI_FRAME_SGL64;
+               pthru->sge_count = megasas_make_sgl64(instance, scp,
+                                                     &pthru->sgl);
+       } else
+               pthru->sge_count = megasas_make_sgl32(instance, scp,
+                                                     &pthru->sgl);
+
+       /*
+        * Sense info specific
+        */
+       pthru->sense_len = SCSI_SENSE_BUFFERSIZE;
+       pthru->sense_buf_phys_addr_hi = 0;
+       pthru->sense_buf_phys_addr_lo = cmd->sense_phys_addr;
+
+       sge_bytes = sge_sz * pthru->sge_count;
+
+       /*
+        * Compute the total number of frames this command consumes. FW uses
+        * this number to pull sufficient number of frames from host memory.
+        */
+       cmd->frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
+           ((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) + 1;
+
+       if (cmd->frame_count > 7)
+               cmd->frame_count = 8;
+
+       return cmd->frame_count;
+}
+
+/**
+ * megasas_build_ldio -        Prepares IOs to logical devices
+ * @instance:          Adapter soft state
+ * @scp:               SCSI command
+ * @cmd:               Command to to be prepared
+ *
+ * Frames (and accompanying SGLs) for regular SCSI IOs use this function.
+ */
+static inline int
+megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
+                  struct megasas_cmd *cmd)
+{
+       u32 sge_sz;
+       int sge_bytes;
+       u32 device_id;
+       u8 sc = scp->cmnd[0];
+       u16 flags = 0;
+       struct megasas_io_frame *ldio;
+
+       device_id = MEGASAS_DEV_INDEX(instance, scp);
+       ldio = (struct megasas_io_frame *)cmd->frame;
+
+       if (scp->sc_data_direction == PCI_DMA_TODEVICE)
+               flags = MFI_FRAME_DIR_WRITE;
+       else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
+               flags = MFI_FRAME_DIR_READ;
+
+       /*
+        * Preare the Logical IO frame: 2nd bit is zero for all read cmds
+        */
+       ldio->cmd = (sc & 0x02) ? MFI_CMD_LD_WRITE : MFI_CMD_LD_READ;
+       ldio->cmd_status = 0x0;
+       ldio->scsi_status = 0x0;
+       ldio->target_id = device_id;
+       ldio->timeout = 0;
+       ldio->reserved_0 = 0;
+       ldio->pad_0 = 0;
+       ldio->flags = flags;
+       ldio->start_lba_hi = 0;
+       ldio->access_byte = (scp->cmd_len != 6) ? scp->cmnd[1] : 0;
+
+       /*
+        * 6-byte READ(0x08) or WRITE(0x0A) cdb
+        */
+       if (scp->cmd_len == 6) {
+               ldio->lba_count = (u32) scp->cmnd[4];
+               ldio->start_lba_lo = ((u32) scp->cmnd[1] << 16) |
+                   ((u32) scp->cmnd[2] << 8) | (u32) scp->cmnd[3];
+
+               ldio->start_lba_lo &= 0x1FFFFF;
+       }
+
+       /*
+        * 10-byte READ(0x28) or WRITE(0x2A) cdb
+        */
+       else if (scp->cmd_len == 10) {
+               ldio->lba_count = (u32) scp->cmnd[8] |
+                   ((u32) scp->cmnd[7] << 8);
+               ldio->start_lba_lo = ((u32) scp->cmnd[2] << 24) |
+                   ((u32) scp->cmnd[3] << 16) |
+                   ((u32) scp->cmnd[4] << 8) | (u32) scp->cmnd[5];
+       }
+
+       /*
+        * 12-byte READ(0xA8) or WRITE(0xAA) cdb
+        */
+       else if (scp->cmd_len == 12) {
+               ldio->lba_count = ((u32) scp->cmnd[6] << 24) |
+                   ((u32) scp->cmnd[7] << 16) |
+                   ((u32) scp->cmnd[8] << 8) | (u32) scp->cmnd[9];
+
+               ldio->start_lba_lo = ((u32) scp->cmnd[2] << 24) |
+                   ((u32) scp->cmnd[3] << 16) |
+                   ((u32) scp->cmnd[4] << 8) | (u32) scp->cmnd[5];
+       }
+
+       /*
+        * 16-byte READ(0x88) or WRITE(0x8A) cdb
+        */
+       else if (scp->cmd_len == 16) {
+               ldio->lba_count = ((u32) scp->cmnd[10] << 24) |
+                   ((u32) scp->cmnd[11] << 16) |
+                   ((u32) scp->cmnd[12] << 8) | (u32) scp->cmnd[13];
+
+               ldio->start_lba_lo = ((u32) scp->cmnd[6] << 24) |
+                   ((u32) scp->cmnd[7] << 16) |
+                   ((u32) scp->cmnd[8] << 8) | (u32) scp->cmnd[9];
+
+               ldio->start_lba_hi = ((u32) scp->cmnd[2] << 24) |
+                   ((u32) scp->cmnd[3] << 16) |
+                   ((u32) scp->cmnd[4] << 8) | (u32) scp->cmnd[5];
+
+       }
+
+       /*
+        * Construct SGL
+        */
+       sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
+           sizeof(struct megasas_sge32);
+
+       if (IS_DMA64) {
+               ldio->flags |= MFI_FRAME_SGL64;
+               ldio->sge_count = megasas_make_sgl64(instance, scp, &ldio->sgl);
+       } else
+               ldio->sge_count = megasas_make_sgl32(instance, scp, &ldio->sgl);
+
+       /*
+        * Sense info specific
+        */
+       ldio->sense_len = SCSI_SENSE_BUFFERSIZE;
+       ldio->sense_buf_phys_addr_hi = 0;
+       ldio->sense_buf_phys_addr_lo = cmd->sense_phys_addr;
+
+       sge_bytes = sge_sz * ldio->sge_count;
+
+       cmd->frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
+           ((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) + 1;
+
+       if (cmd->frame_count > 7)
+               cmd->frame_count = 8;
+
+       return cmd->frame_count;
+}
+
+/**
+ * megasas_build_cmd - Prepares a command packet
+ * @instance:          Adapter soft state
+ * @scp:               SCSI command
+ * @frame_count:       [OUT] Number of frames used to prepare this command
+ */
+static inline struct megasas_cmd *megasas_build_cmd(struct megasas_instance
+                                                   *instance,
+                                                   struct scsi_cmnd *scp,
+                                                   int *frame_count)
+{
+       u32 logical_cmd;
+       struct megasas_cmd *cmd;
+
+       /*
+        * Find out if this is logical or physical drive command.
+        */
+       logical_cmd = MEGASAS_IS_LOGICAL(scp);
+
+       /*
+        * Logical drive command
+        */
+       if (logical_cmd) {
+
+               if (scp->device->id >= MEGASAS_MAX_LD) {
+                       scp->result = DID_BAD_TARGET << 16;
+                       return NULL;
+               }
+
+               switch (scp->cmnd[0]) {
+
+               case READ_10:
+               case WRITE_10:
+               case READ_12:
+               case WRITE_12:
+               case READ_6:
+               case WRITE_6:
+               case READ_16:
+               case WRITE_16:
+                       /*
+                        * Fail for LUN > 0
+                        */
+                       if (scp->device->lun) {
+                               scp->result = DID_BAD_TARGET << 16;
+                               return NULL;
+                       }
+
+                       cmd = megasas_get_cmd(instance);
+
+                       if (!cmd) {
+                               scp->result = DID_IMM_RETRY << 16;
+                               return NULL;
+                       }
+
+                       *frame_count = megasas_build_ldio(instance, scp, cmd);
+
+                       if (!(*frame_count)) {
+                               megasas_return_cmd(instance, cmd);
+                               return NULL;
+                       }
+
+                       return cmd;
+
+               default:
+                       /*
+                        * Fail for LUN > 0
+                        */
+                       if (scp->device->lun) {
+                               scp->result = DID_BAD_TARGET << 16;
+                               return NULL;
+                       }
+
+                       cmd = megasas_get_cmd(instance);
+
+                       if (!cmd) {
+                               scp->result = DID_IMM_RETRY << 16;
+                               return NULL;
+                       }
+
+                       *frame_count = megasas_build_dcdb(instance, scp, cmd);
+
+                       if (!(*frame_count)) {
+                               megasas_return_cmd(instance, cmd);
+                               return NULL;
+                       }
+
+                       return cmd;
+               }
+       } else {
+               cmd = megasas_get_cmd(instance);
+
+               if (!cmd) {
+                       scp->result = DID_IMM_RETRY << 16;
+                       return NULL;
+               }
+
+               *frame_count = megasas_build_dcdb(instance, scp, cmd);
+
+               if (!(*frame_count)) {
+                       megasas_return_cmd(instance, cmd);
+                       return NULL;
+               }
+
+               return cmd;
+       }
+
+       return NULL;
+}
+
+/**
+ * megasas_queue_command -     Queue entry point
+ * @scmd:                      SCSI command to be queued
+ * @done:                      Callback entry point
+ */
+static int
+megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
+{
+       u32 frame_count;
+       unsigned long flags;
+       struct megasas_cmd *cmd;
+       struct megasas_instance *instance;
+
+       instance = (struct megasas_instance *)
+           scmd->device->host->hostdata;
+       scmd->scsi_done = done;
+       scmd->result = 0;
+
+       cmd = megasas_build_cmd(instance, scmd, &frame_count);
+
+       if (!cmd) {
+               done(scmd);
+               return 0;
+       }
+
+       cmd->scmd = scmd;
+       scmd->SCp.ptr = (char *)cmd;
+       scmd->SCp.sent_command = jiffies;
+
+       /*
+        * Issue the command to the FW
+        */
+       spin_lock_irqsave(&instance->instance_lock, flags);
+       instance->fw_outstanding++;
+       spin_unlock_irqrestore(&instance->instance_lock, flags);
+
+       writel(((cmd->frame_phys_addr >> 3) | (cmd->frame_count - 1)),
+              &instance->reg_set->inbound_queue_port);
+
+       return 0;
+}
+
+/**
+ * megasas_wait_for_outstanding -      Wait for all outstanding cmds
+ * @instance:                          Adapter soft state
+ *
+ * This function waits for upto MEGASAS_RESET_WAIT_TIME seconds for FW to
+ * complete all its outstanding commands. Returns error if one or more IOs
+ * are pending after this time period. It also marks the controller dead.
+ */
+static int megasas_wait_for_outstanding(struct megasas_instance *instance)
+{
+       int i;
+       u32 wait_time = MEGASAS_RESET_WAIT_TIME;
+
+       for (i = 0; i < wait_time; i++) {
+
+               if (!instance->fw_outstanding)
+                       break;
+
+               if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
+                       printk(KERN_NOTICE "megasas: [%2d]waiting for %d "
+                              "commands to complete\n", i,
+                              instance->fw_outstanding);
+               }
+
+               msleep(1000);
+       }
+
+       if (instance->fw_outstanding) {
+               instance->hw_crit_error = 1;
+               return FAILED;
+       }
+
+       return SUCCESS;
+}
+
+/**
+ * megasas_generic_reset -     Generic reset routine
+ * @scmd:                      Mid-layer SCSI command
+ *
+ * This routine implements a generic reset handler for device, bus and host
+ * reset requests. Device, bus and host specific reset handlers can use this
+ * function after they do their specific tasks.
+ */
+static int megasas_generic_reset(struct scsi_cmnd *scmd)
+{
+       int ret_val;
+       struct megasas_instance *instance;
+
+       instance = (struct megasas_instance *)scmd->device->host->hostdata;
+
+       printk(KERN_NOTICE "megasas: RESET -%ld cmd=%x <c=%d t=%d l=%d>\n",
+              scmd->serial_number, scmd->cmnd[0], scmd->device->channel,
+              scmd->device->id, scmd->device->lun);
+
+       if (instance->hw_crit_error) {
+               printk(KERN_ERR "megasas: cannot recover from previous reset "
+                      "failures\n");
+               return FAILED;
+       }
+
+       spin_unlock(scmd->device->host->host_lock);
+
+       ret_val = megasas_wait_for_outstanding(instance);
+
+       if (ret_val == SUCCESS)
+               printk(KERN_NOTICE "megasas: reset successful \n");
+       else
+               printk(KERN_ERR "megasas: failed to do reset\n");
+
+       spin_lock(scmd->device->host->host_lock);
+
+       return ret_val;
+}
+
+static enum scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
+{
+       unsigned long seconds;
+
+       if (scmd->SCp.ptr) {
+               seconds = (jiffies - scmd->SCp.sent_command) / HZ;
+
+               if (seconds < 90) {
+                       return EH_RESET_TIMER;
+               } else {
+                       return EH_NOT_HANDLED;
+               }
+       }
+
+       return EH_HANDLED;
+}
+
+/**
+ * megasas_reset_device -      Device reset handler entry point
+ */
+static int megasas_reset_device(struct scsi_cmnd *scmd)
+{
+       int ret;
+
+       /*
+        * First wait for all commands to complete
+        */
+       ret = megasas_generic_reset(scmd);
+
+       return ret;
+}
+
+/**
+ * megasas_reset_bus_host -    Bus & host reset handler entry point
+ */
+static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
+{
+       int ret;
+
+       /*
+        * Frist wait for all commands to complete
+        */
+       ret = megasas_generic_reset(scmd);
+
+       return ret;
+}
+
+/**
+ * megasas_service_aen -       Processes an event notification
+ * @instance:                  Adapter soft state
+ * @cmd:                       AEN command completed by the ISR
+ *
+ * For AEN, driver sends a command down to FW that is held by the FW till an
+ * event occurs. When an event of interest occurs, FW completes the command
+ * that it was previously holding.
+ *
+ * This routines sends SIGIO signal to processes that have registered with the
+ * driver for AEN.
+ */
+static void
+megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
+{
+       /*
+        * Don't signal app if it is just an aborted previously registered aen
+        */
+       if (!cmd->abort_aen)
+               kill_fasync(&megasas_async_queue, SIGIO, POLL_IN);
+       else
+               cmd->abort_aen = 0;
+
+       instance->aen_cmd = NULL;
+       megasas_return_cmd(instance, cmd);
+}
+
+/*
+ * Scsi host template for megaraid_sas driver
+ */
+static struct scsi_host_template megasas_template = {
+
+       .module = THIS_MODULE,
+       .name = "LSI Logic SAS based MegaRAID driver",
+       .proc_name = "megaraid_sas",
+       .queuecommand = megasas_queue_command,
+       .eh_device_reset_handler = megasas_reset_device,
+       .eh_bus_reset_handler = megasas_reset_bus_host,
+       .eh_host_reset_handler = megasas_reset_bus_host,
+       .eh_timed_out = megasas_reset_timer,
+       .use_clustering = ENABLE_CLUSTERING,
+};
+
+/**
+ * megasas_complete_int_cmd -  Completes an internal command
+ * @instance:                  Adapter soft state
+ * @cmd:                       Command to be completed
+ *
+ * The megasas_issue_blocked_cmd() function waits for a command to complete
+ * after it issues a command. This function wakes up that waiting routine by
+ * calling wake_up() on the wait queue.
+ */
+static void
+megasas_complete_int_cmd(struct megasas_instance *instance,
+                        struct megasas_cmd *cmd)
+{
+       cmd->cmd_status = cmd->frame->io.cmd_status;
+
+       if (cmd->cmd_status == ENODATA) {
+               cmd->cmd_status = 0;
+       }
+       wake_up(&instance->int_cmd_wait_q);
+}
+
+/**
+ * megasas_complete_abort -    Completes aborting a command
+ * @instance:                  Adapter soft state
+ * @cmd:                       Cmd that was issued to abort another cmd
+ *
+ * The megasas_issue_blocked_abort_cmd() function waits on abort_cmd_wait_q 
+ * after it issues an abort on a previously issued command. This function 
+ * wakes up all functions waiting on the same wait queue.
+ */
+static void
+megasas_complete_abort(struct megasas_instance *instance,
+                      struct megasas_cmd *cmd)
+{
+       if (cmd->sync_cmd) {
+               cmd->sync_cmd = 0;
+               cmd->cmd_status = 0;
+               wake_up(&instance->abort_cmd_wait_q);
+       }
+
+       return;
+}
+
+/**
+ * megasas_unmap_sgbuf -       Unmap SG buffers
+ * @instance:                  Adapter soft state
+ * @cmd:                       Completed command
+ */
+static inline void
+megasas_unmap_sgbuf(struct megasas_instance *instance, struct megasas_cmd *cmd)
+{
+       dma_addr_t buf_h;
+       u8 opcode;
+
+       if (cmd->scmd->use_sg) {
+               pci_unmap_sg(instance->pdev, cmd->scmd->request_buffer,
+                            cmd->scmd->use_sg, cmd->scmd->sc_data_direction);
+               return;
+       }
+
+       if (!cmd->scmd->request_bufflen)
+               return;
+
+       opcode = cmd->frame->hdr.cmd;
+
+       if ((opcode == MFI_CMD_LD_READ) || (opcode == MFI_CMD_LD_WRITE)) {
+               if (IS_DMA64)
+                       buf_h = cmd->frame->io.sgl.sge64[0].phys_addr;
+               else
+                       buf_h = cmd->frame->io.sgl.sge32[0].phys_addr;
+       } else {
+               if (IS_DMA64)
+                       buf_h = cmd->frame->pthru.sgl.sge64[0].phys_addr;
+               else
+                       buf_h = cmd->frame->pthru.sgl.sge32[0].phys_addr;
+       }
+
+       pci_unmap_single(instance->pdev, buf_h, cmd->scmd->request_bufflen,
+                        cmd->scmd->sc_data_direction);
+       return;
+}
+
+/**
+ * megasas_complete_cmd -      Completes a command
+ * @instance:                  Adapter soft state
+ * @cmd:                       Command to be completed
+ * @alt_status:                        If non-zero, use this value as status to 
+ *                             SCSI mid-layer instead of the value returned
+ *                             by the FW. This should be used if caller wants
+ *                             an alternate status (as in the case of aborted
+ *                             commands)
+ */
+static inline void
+megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
+                    u8 alt_status)
+{
+       int exception = 0;
+       struct megasas_header *hdr = &cmd->frame->hdr;
+       unsigned long flags;
+
+       if (cmd->scmd) {
+               cmd->scmd->SCp.ptr = (char *)0;
+       }
+
+       switch (hdr->cmd) {
+
+       case MFI_CMD_PD_SCSI_IO:
+       case MFI_CMD_LD_SCSI_IO:
+
+               /*
+                * MFI_CMD_PD_SCSI_IO and MFI_CMD_LD_SCSI_IO could have been
+                * issued either through an IO path or an IOCTL path. If it
+                * was via IOCTL, we will send it to internal completion.
+                */
+               if (cmd->sync_cmd) {
+                       cmd->sync_cmd = 0;
+                       megasas_complete_int_cmd(instance, cmd);
+                       break;
+               }
+
+               /*
+                * Don't export physical disk devices to mid-layer.
+                */
+               if (!MEGASAS_IS_LOGICAL(cmd->scmd) &&
+                   (hdr->cmd_status == MFI_STAT_OK) &&
+                   (cmd->scmd->cmnd[0] == INQUIRY)) {
+
+                       if (((*(u8 *) cmd->scmd->request_buffer) & 0x1F) ==
+                           TYPE_DISK) {
+                               cmd->scmd->result = DID_BAD_TARGET << 16;
+                               exception = 1;
+                       }
+               }
+
+       case MFI_CMD_LD_READ:
+       case MFI_CMD_LD_WRITE:
+
+               if (alt_status) {
+                       cmd->scmd->result = alt_status << 16;
+                       exception = 1;
+               }
+
+               if (exception) {
+
+                       spin_lock_irqsave(&instance->instance_lock, flags);
+                       instance->fw_outstanding--;
+                       spin_unlock_irqrestore(&instance->instance_lock, flags);
+
+                       megasas_unmap_sgbuf(instance, cmd);
+                       cmd->scmd->scsi_done(cmd->scmd);
+                       megasas_return_cmd(instance, cmd);
+
+                       break;
+               }
+
+               switch (hdr->cmd_status) {
+
+               case MFI_STAT_OK:
+                       cmd->scmd->result = DID_OK << 16;
+                       break;
+
+               case MFI_STAT_SCSI_IO_FAILED:
+               case MFI_STAT_LD_INIT_IN_PROGRESS:
+                       cmd->scmd->result =
+                           (DID_ERROR << 16) | hdr->scsi_status;
+                       break;
+
+               case MFI_STAT_SCSI_DONE_WITH_ERROR:
+
+                       cmd->scmd->result = (DID_OK << 16) | hdr->scsi_status;
+
+                       if (hdr->scsi_status == SAM_STAT_CHECK_CONDITION) {
+                               memset(cmd->scmd->sense_buffer, 0,
+                                      SCSI_SENSE_BUFFERSIZE);
+                               memcpy(cmd->scmd->sense_buffer, cmd->sense,
+                                      hdr->sense_len);
+
+                               cmd->scmd->result |= DRIVER_SENSE << 24;
+                       }
+
+                       break;
+
+               case MFI_STAT_LD_OFFLINE:
+               case MFI_STAT_DEVICE_NOT_FOUND:
+                       cmd->scmd->result = DID_BAD_TARGET << 16;
+                       break;
+
+               default:
+                       printk(KERN_DEBUG "megasas: MFI FW status %#x\n",
+                              hdr->cmd_status);
+                       cmd->scmd->result = DID_ERROR << 16;
+                       break;
+               }
+
+               spin_lock_irqsave(&instance->instance_lock, flags);
+               instance->fw_outstanding--;
+               spin_unlock_irqrestore(&instance->instance_lock, flags);
+
+               megasas_unmap_sgbuf(instance, cmd);
+               cmd->scmd->scsi_done(cmd->scmd);
+               megasas_return_cmd(instance, cmd);
+
+               break;
+
+       case MFI_CMD_SMP:
+       case MFI_CMD_STP:
+       case MFI_CMD_DCMD:
+
+               /*
+                * See if got an event notification
+                */
+               if (cmd->frame->dcmd.opcode == MR_DCMD_CTRL_EVENT_WAIT)
+                       megasas_service_aen(instance, cmd);
+               else
+                       megasas_complete_int_cmd(instance, cmd);
+
+               break;
+
+       case MFI_CMD_ABORT:
+               /*
+                * Cmd issued to abort another cmd returned
+                */
+               megasas_complete_abort(instance, cmd);
+               break;
+
+       default:
+               printk("megasas: Unknown command completed! [0x%X]\n",
+                      hdr->cmd);
+               break;
+       }
+}
+
+/**
+ * megasas_deplete_reply_queue -       Processes all completed commands
+ * @instance:                          Adapter soft state
+ * @alt_status:                                Alternate status to be returned to
+ *                                     SCSI mid-layer instead of the status
+ *                                     returned by the FW
+ */
+static inline int
+megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status)
+{
+       u32 status;
+       u32 producer;
+       u32 consumer;
+       u32 context;
+       struct megasas_cmd *cmd;
+
+       /*
+        * Check if it is our interrupt
+        */
+       status = readl(&instance->reg_set->outbound_intr_status);
+
+       if (!(status & MFI_OB_INTR_STATUS_MASK)) {
+               return IRQ_NONE;
+       }
+
+       /*
+        * Clear the interrupt by writing back the same value
+        */
+       writel(status, &instance->reg_set->outbound_intr_status);
+
+       producer = *instance->producer;
+       consumer = *instance->consumer;
+
+       while (consumer != producer) {
+               context = instance->reply_queue[consumer];
+
+               cmd = instance->cmd_list[context];
+
+               megasas_complete_cmd(instance, cmd, alt_status);
+
+               consumer++;
+               if (consumer == (instance->max_fw_cmds + 1)) {
+                       consumer = 0;
+               }
+       }
+
+       *instance->consumer = producer;
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * megasas_isr - isr entry point
+ */
+static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs)
+{
+       return megasas_deplete_reply_queue((struct megasas_instance *)devp,
+                                          DID_OK);
+}
+
+/**
+ * megasas_transition_to_ready -       Move the FW to READY state
+ * @reg_set:                           MFI register set
+ *
+ * During the initialization, FW passes can potentially be in any one of
+ * several possible states. If the FW in operational, waiting-for-handshake
+ * states, driver must take steps to bring it to ready state. Otherwise, it
+ * has to wait for the ready state.
+ */
+static int
+megasas_transition_to_ready(struct megasas_register_set __iomem * reg_set)
+{
+       int i;
+       u8 max_wait;
+       u32 fw_state;
+       u32 cur_state;
+
+       fw_state = readl(&reg_set->outbound_msg_0) & MFI_STATE_MASK;
+
+       while (fw_state != MFI_STATE_READY) {
+
+               printk(KERN_INFO "megasas: Waiting for FW to come to ready"
+                      " state\n");
+               switch (fw_state) {
+
+               case MFI_STATE_FAULT:
+
+                       printk(KERN_DEBUG "megasas: FW in FAULT state!!\n");
+                       return -ENODEV;
+
+               case MFI_STATE_WAIT_HANDSHAKE:
+                       /*
+                        * Set the CLR bit in inbound doorbell
+                        */
+                       writel(MFI_INIT_CLEAR_HANDSHAKE,
+                              &reg_set->inbound_doorbell);
+
+                       max_wait = 2;
+                       cur_state = MFI_STATE_WAIT_HANDSHAKE;
+                       break;
+
+               case MFI_STATE_OPERATIONAL:
+                       /*
+                        * Bring it to READY state; assuming max wait 2 secs
+                        */
+                       megasas_disable_intr(reg_set);
+                       writel(MFI_INIT_READY, &reg_set->inbound_doorbell);
+
+                       max_wait = 10;
+                       cur_state = MFI_STATE_OPERATIONAL;
+                       break;
+
+               case MFI_STATE_UNDEFINED:
+                       /*
+                        * This state should not last for more than 2 seconds
+                        */
+                       max_wait = 2;
+                       cur_state = MFI_STATE_UNDEFINED;
+                       break;
+
+               case MFI_STATE_BB_INIT:
+                       max_wait = 2;
+                       cur_state = MFI_STATE_BB_INIT;
+                       break;
+
+               case MFI_STATE_FW_INIT:
+                       max_wait = 20;
+                       cur_state = MFI_STATE_FW_INIT;
+                       break;
+
+               case MFI_STATE_FW_INIT_2:
+                       max_wait = 20;
+                       cur_state = MFI_STATE_FW_INIT_2;
+                       break;
+
+               case MFI_STATE_DEVICE_SCAN:
+                       max_wait = 20;
+                       cur_state = MFI_STATE_DEVICE_SCAN;
+                       break;
+
+               case MFI_STATE_FLUSH_CACHE:
+                       max_wait = 20;
+                       cur_state = MFI_STATE_FLUSH_CACHE;
+                       break;
+
+               default:
+                       printk(KERN_DEBUG "megasas: Unknown state 0x%x\n",
+                              fw_state);
+                       return -ENODEV;
+               }
+
+               /*
+                * The cur_state should not last for more than max_wait secs
+                */
+               for (i = 0; i < (max_wait * 1000); i++) {
+                       fw_state = MFI_STATE_MASK &
+                           readl(&reg_set->outbound_msg_0);
+
+                       if (fw_state == cur_state) {
+                               msleep(1);
+                       } else
+                               break;
+               }
+
+               /*
+                * Return error if fw_state hasn't changed after max_wait
+                */
+               if (fw_state == cur_state) {
+                       printk(KERN_DEBUG "FW state [%d] hasn't changed "
+                              "in %d secs\n", fw_state, max_wait);
+                       return -ENODEV;
+               }
+       };
+
+       return 0;
+}
+
+/**
+ * megasas_teardown_frame_pool -       Destroy the cmd frame DMA pool
+ * @instance:                          Adapter soft state
+ */
+static void megasas_teardown_frame_pool(struct megasas_instance *instance)
+{
+       int i;
+       u32 max_cmd = instance->max_fw_cmds;
+       struct megasas_cmd *cmd;
+
+       if (!instance->frame_dma_pool)
+               return;
+
+       /*
+        * Return all frames to pool
+        */
+       for (i = 0; i < max_cmd; i++) {
+
+               cmd = instance->cmd_list[i];
+
+               if (cmd->frame)
+                       pci_pool_free(instance->frame_dma_pool, cmd->frame,
+                                     cmd->frame_phys_addr);
+
+               if (cmd->sense)
+                       pci_pool_free(instance->sense_dma_pool, cmd->frame,
+                                     cmd->sense_phys_addr);
+       }
+
+       /*
+        * Now destroy the pool itself
+        */
+       pci_pool_destroy(instance->frame_dma_pool);
+       pci_pool_destroy(instance->sense_dma_pool);
+
+       instance->frame_dma_pool = NULL;
+       instance->sense_dma_pool = NULL;
+}
+
+/**
+ * megasas_create_frame_pool - Creates DMA pool for cmd frames
+ * @instance:                  Adapter soft state
+ *
+ * Each command packet has an embedded DMA memory buffer that is used for
+ * filling MFI frame and the SG list that immediately follows the frame. This
+ * function creates those DMA memory buffers for each command packet by using
+ * PCI pool facility.
+ */
+static int megasas_create_frame_pool(struct megasas_instance *instance)
+{
+       int i;
+       u32 max_cmd;
+       u32 sge_sz;
+       u32 sgl_sz;
+       u32 total_sz;
+       u32 frame_count;
+       struct megasas_cmd *cmd;
+
+       max_cmd = instance->max_fw_cmds;
+
+       /*
+        * Size of our frame is 64 bytes for MFI frame, followed by max SG
+        * elements and finally SCSI_SENSE_BUFFERSIZE bytes for sense buffer
+        */
+       sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
+           sizeof(struct megasas_sge32);
+
+       /*
+        * Calculated the number of 64byte frames required for SGL
+        */
+       sgl_sz = sge_sz * instance->max_num_sge;
+       frame_count = (sgl_sz + MEGAMFI_FRAME_SIZE - 1) / MEGAMFI_FRAME_SIZE;
+
+       /*
+        * We need one extra frame for the MFI command
+        */
+       frame_count++;
+
+       total_sz = MEGAMFI_FRAME_SIZE * frame_count;
+       /*
+        * Use DMA pool facility provided by PCI layer
+        */
+       instance->frame_dma_pool = pci_pool_create("megasas frame pool",
+                                                  instance->pdev, total_sz, 64,
+                                                  0);
+
+       if (!instance->frame_dma_pool) {
+               printk(KERN_DEBUG "megasas: failed to setup frame pool\n");
+               return -ENOMEM;
+       }
+
+       instance->sense_dma_pool = pci_pool_create("megasas sense pool",
+                                                  instance->pdev, 128, 4, 0);
+
+       if (!instance->sense_dma_pool) {
+               printk(KERN_DEBUG "megasas: failed to setup sense pool\n");
+
+               pci_pool_destroy(instance->frame_dma_pool);
+               instance->frame_dma_pool = NULL;
+
+               return -ENOMEM;
+       }
+
+       /*
+        * Allocate and attach a frame to each of the commands in cmd_list.
+        * By making cmd->index as the context instead of the &cmd, we can
+        * always use 32bit context regardless of the architecture
+        */
+       for (i = 0; i < max_cmd; i++) {
+
+               cmd = instance->cmd_list[i];
+
+               cmd->frame = pci_pool_alloc(instance->frame_dma_pool,
+                                           GFP_KERNEL, &cmd->frame_phys_addr);
+
+               cmd->sense = pci_pool_alloc(instance->sense_dma_pool,
+                                           GFP_KERNEL, &cmd->sense_phys_addr);
+
+               /*
+                * megasas_teardown_frame_pool() takes care of freeing
+                * whatever has been allocated
+                */
+               if (!cmd->frame || !cmd->sense) {
+                       printk(KERN_DEBUG "megasas: pci_pool_alloc failed \n");
+                       megasas_teardown_frame_pool(instance);
+                       return -ENOMEM;
+               }
+
+               cmd->frame->io.context = cmd->index;
+       }
+
+       return 0;
+}
+
+/**
+ * megasas_free_cmds - Free all the cmds in the free cmd pool
+ * @instance:          Adapter soft state
+ */
+static void megasas_free_cmds(struct megasas_instance *instance)
+{
+       int i;
+       /* First free the MFI frame pool */
+       megasas_teardown_frame_pool(instance);
+
+       /* Free all the commands in the cmd_list */
+       for (i = 0; i < instance->max_fw_cmds; i++)
+               kfree(instance->cmd_list[i]);
+
+       /* Free the cmd_list buffer itself */
+       kfree(instance->cmd_list);
+       instance->cmd_list = NULL;
+
+       INIT_LIST_HEAD(&instance->cmd_pool);
+}
+
+/**
+ * megasas_alloc_cmds -        Allocates the command packets
+ * @instance:          Adapter soft state
+ *
+ * Each command that is issued to the FW, whether IO commands from the OS or
+ * internal commands like IOCTLs, are wrapped in local data structure called
+ * megasas_cmd. The frame embedded in this megasas_cmd is actually issued to
+ * the FW.
+ *
+ * Each frame has a 32-bit field called context (tag). This context is used
+ * to get back the megasas_cmd from the frame when a frame gets completed in
+ * the ISR. Typically the address of the megasas_cmd itself would be used as
+ * the context. But we wanted to keep the differences between 32 and 64 bit
+ * systems to the mininum. We always use 32 bit integers for the context. In
+ * this driver, the 32 bit values are the indices into an array cmd_list.
+ * This array is used only to look up the megasas_cmd given the context. The
+ * free commands themselves are maintained in a linked list called cmd_pool.
+ */
+static int megasas_alloc_cmds(struct megasas_instance *instance)
+{
+       int i;
+       int j;
+       u32 max_cmd;
+       struct megasas_cmd *cmd;
+
+       max_cmd = instance->max_fw_cmds;
+
+       /*
+        * instance->cmd_list is an array of struct megasas_cmd pointers.
+        * Allocate the dynamic array first and then allocate individual
+        * commands.
+        */
+       instance->cmd_list = kmalloc(sizeof(struct megasas_cmd *) * max_cmd,
+                                    GFP_KERNEL);
+
+       if (!instance->cmd_list) {
+               printk(KERN_DEBUG "megasas: out of memory\n");
+               return -ENOMEM;
+       }
+
+       memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) * max_cmd);
+
+       for (i = 0; i < max_cmd; i++) {
+               instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
+                                               GFP_KERNEL);
+
+               if (!instance->cmd_list[i]) {
+
+                       for (j = 0; j < i; j++)
+                               kfree(instance->cmd_list[j]);
+
+                       kfree(instance->cmd_list);
+                       instance->cmd_list = NULL;
+
+                       return -ENOMEM;
+               }
+       }
+
+       /*
+        * Add all the commands to command pool (instance->cmd_pool)
+        */
+       for (i = 0; i < max_cmd; i++) {
+               cmd = instance->cmd_list[i];
+               memset(cmd, 0, sizeof(struct megasas_cmd));
+               cmd->index = i;
+               cmd->instance = instance;
+
+               list_add_tail(&cmd->list, &instance->cmd_pool);
+       }
+
+       /*
+        * Create a frame pool and assign one frame to each cmd
+        */
+       if (megasas_create_frame_pool(instance)) {
+               printk(KERN_DEBUG "megasas: Error creating frame DMA pool\n");
+               megasas_free_cmds(instance);
+       }
+
+       return 0;
+}
+
+/**
+ * megasas_get_controller_info -       Returns FW's controller structure
+ * @instance:                          Adapter soft state
+ * @ctrl_info:                         Controller information structure
+ *
+ * Issues an internal command (DCMD) to get the FW's controller structure.
+ * This information is mainly used to find out the maximum IO transfer per
+ * command supported by the FW.
+ */
+static int
+megasas_get_ctrl_info(struct megasas_instance *instance,
+                     struct megasas_ctrl_info *ctrl_info)
+{
+       int ret = 0;
+       struct megasas_cmd *cmd;
+       struct megasas_dcmd_frame *dcmd;
+       struct megasas_ctrl_info *ci;
+       dma_addr_t ci_h = 0;
+
+       cmd = megasas_get_cmd(instance);
+
+       if (!cmd) {
+               printk(KERN_DEBUG "megasas: Failed to get a free cmd\n");
+               return -ENOMEM;
+       }
+
+       dcmd = &cmd->frame->dcmd;
+
+       ci = pci_alloc_consistent(instance->pdev,
+                                 sizeof(struct megasas_ctrl_info), &ci_h);
+
+       if (!ci) {
+               printk(KERN_DEBUG "Failed to alloc mem for ctrl info\n");
+               megasas_return_cmd(instance, cmd);
+               return -ENOMEM;
+       }
+
+       memset(ci, 0, sizeof(*ci));
+       memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+
+       dcmd->cmd = MFI_CMD_DCMD;
+       dcmd->cmd_status = 0xFF;
+       dcmd->sge_count = 1;
+       dcmd->flags = MFI_FRAME_DIR_READ;
+       dcmd->timeout = 0;
+       dcmd->data_xfer_len = sizeof(struct megasas_ctrl_info);
+       dcmd->opcode = MR_DCMD_CTRL_GET_INFO;
+       dcmd->sgl.sge32[0].phys_addr = ci_h;
+       dcmd->sgl.sge32[0].length = sizeof(struct megasas_ctrl_info);
+
+       if (!megasas_issue_polled(instance, cmd)) {
+               ret = 0;
+               memcpy(ctrl_info, ci, sizeof(struct megasas_ctrl_info));
+       } else {
+               ret = -1;
+       }
+
+       pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info),
+                           ci, ci_h);
+
+       megasas_return_cmd(instance, cmd);
+       return ret;
+}
+
+/**
+ * megasas_init_mfi -  Initializes the FW
+ * @instance:          Adapter soft state
+ *
+ * This is the main function for initializing MFI firmware.
+ */
+static int megasas_init_mfi(struct megasas_instance *instance)
+{
+       u32 context_sz;
+       u32 reply_q_sz;
+       u32 max_sectors_1;
+       u32 max_sectors_2;
+       struct megasas_register_set __iomem *reg_set;
+
+       struct megasas_cmd *cmd;
+       struct megasas_ctrl_info *ctrl_info;
+
+       struct megasas_init_frame *init_frame;
+       struct megasas_init_queue_info *initq_info;
+       dma_addr_t init_frame_h;
+       dma_addr_t initq_info_h;
+
+       /*
+        * Map the message registers
+        */
+       instance->base_addr = pci_resource_start(instance->pdev, 0);
+
+       if (pci_request_regions(instance->pdev, "megasas: LSI Logic")) {
+               printk(KERN_DEBUG "megasas: IO memory region busy!\n");
+               return -EBUSY;
+       }
+
+       instance->reg_set = ioremap_nocache(instance->base_addr, 8192);
+
+       if (!instance->reg_set) {
+               printk(KERN_DEBUG "megasas: Failed to map IO mem\n");
+               goto fail_ioremap;
+       }
+
+       reg_set = instance->reg_set;
+
+       /*
+        * We expect the FW state to be READY
+        */
+       if (megasas_transition_to_ready(instance->reg_set))
+               goto fail_ready_state;
+
+       /*
+        * Get various operational parameters from status register
+        */
+       instance->max_fw_cmds = readl(&reg_set->outbound_msg_0) & 0x00FFFF;
+       instance->max_num_sge = (readl(&reg_set->outbound_msg_0) & 0xFF0000) >>
+           0x10;
+       /*
+        * Create a pool of commands
+        */
+       if (megasas_alloc_cmds(instance))
+               goto fail_alloc_cmds;
+
+       /*
+        * Allocate memory for reply queue. Length of reply queue should
+        * be _one_ more than the maximum commands handled by the firmware.
+        *
+        * Note: When FW completes commands, it places corresponding contex
+        * values in this circular reply queue. This circular queue is a fairly
+        * typical producer-consumer queue. FW is the producer (of completed
+        * commands) and the driver is the consumer.
+        */
+       context_sz = sizeof(u32);
+       reply_q_sz = context_sz * (instance->max_fw_cmds + 1);
+
+       instance->reply_queue = pci_alloc_consistent(instance->pdev,
+                                                    reply_q_sz,
+                                                    &instance->reply_queue_h);
+
+       if (!instance->reply_queue) {
+               printk(KERN_DEBUG "megasas: Out of DMA mem for reply queue\n");
+               goto fail_reply_queue;
+       }
+
+       /*
+        * Prepare a init frame. Note the init frame points to queue info
+        * structure. Each frame has SGL allocated after first 64 bytes. For
+        * this frame - since we don't need any SGL - we use SGL's space as
+        * queue info structure
+        *
+        * We will not get a NULL command below. We just created the pool.
+        */
+       cmd = megasas_get_cmd(instance);
+
+       init_frame = (struct megasas_init_frame *)cmd->frame;
+       initq_info = (struct megasas_init_queue_info *)
+           ((unsigned long)init_frame + 64);
+
+       init_frame_h = cmd->frame_phys_addr;
+       initq_info_h = init_frame_h + 64;
+
+       memset(init_frame, 0, MEGAMFI_FRAME_SIZE);
+       memset(initq_info, 0, sizeof(struct megasas_init_queue_info));
+
+       initq_info->reply_queue_entries = instance->max_fw_cmds + 1;
+       initq_info->reply_queue_start_phys_addr_lo = instance->reply_queue_h;
+
+       initq_info->producer_index_phys_addr_lo = instance->producer_h;
+       initq_info->consumer_index_phys_addr_lo = instance->consumer_h;
+
+       init_frame->cmd = MFI_CMD_INIT;
+       init_frame->cmd_status = 0xFF;
+       init_frame->queue_info_new_phys_addr_lo = initq_info_h;
+
+       init_frame->data_xfer_len = sizeof(struct megasas_init_queue_info);
+
+       /*
+        * Issue the init frame in polled mode
+        */
+       if (megasas_issue_polled(instance, cmd)) {
+               printk(KERN_DEBUG "megasas: Failed to init firmware\n");
+               goto fail_fw_init;
+       }
+
+       megasas_return_cmd(instance, cmd);
+
+       ctrl_info = kmalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL);
+
+       /*
+        * Compute the max allowed sectors per IO: The controller info has two
+        * limits on max sectors. Driver should use the minimum of these two.
+        *
+        * 1 << stripe_sz_ops.min = max sectors per strip
+        *
+        * Note that older firmwares ( < FW ver 30) didn't report information
+        * to calculate max_sectors_1. So the number ended up as zero always.
+        */
+       if (ctrl_info && !megasas_get_ctrl_info(instance, ctrl_info)) {
+
+               max_sectors_1 = (1 << ctrl_info->stripe_sz_ops.min) *
+                   ctrl_info->max_strips_per_io;
+               max_sectors_2 = ctrl_info->max_request_size;
+
+               instance->max_sectors_per_req = (max_sectors_1 < max_sectors_2)
+                   ? max_sectors_1 : max_sectors_2;
+       } else
+               instance->max_sectors_per_req = instance->max_num_sge *
+                   PAGE_SIZE / 512;
+
+       kfree(ctrl_info);
+
+       return 0;
+
+      fail_fw_init:
+       megasas_return_cmd(instance, cmd);
+
+       pci_free_consistent(instance->pdev, reply_q_sz,
+                           instance->reply_queue, instance->reply_queue_h);
+      fail_reply_queue:
+       megasas_free_cmds(instance);
+
+      fail_alloc_cmds:
+      fail_ready_state:
+       iounmap(instance->reg_set);
+
+      fail_ioremap:
+       pci_release_regions(instance->pdev);
+
+       return -EINVAL;
+}
+
+/**
+ * megasas_release_mfi -       Reverses the FW initialization
+ * @intance:                   Adapter soft state
+ */
+static void megasas_release_mfi(struct megasas_instance *instance)
+{
+       u32 reply_q_sz = sizeof(u32) * (instance->max_fw_cmds + 1);
+
+       pci_free_consistent(instance->pdev, reply_q_sz,
+                           instance->reply_queue, instance->reply_queue_h);
+
+       megasas_free_cmds(instance);
+
+       iounmap(instance->reg_set);
+
+       pci_release_regions(instance->pdev);
+}
+
+/**
+ * megasas_get_seq_num -       Gets latest event sequence numbers
+ * @instance:                  Adapter soft state
+ * @eli:                       FW event log sequence numbers information
+ *
+ * FW maintains a log of all events in a non-volatile area. Upper layers would
+ * usually find out the latest sequence number of the events, the seq number at
+ * the boot etc. They would "read" all the events below the latest seq number
+ * by issuing a direct fw cmd (DCMD). For the future events (beyond latest seq
+ * number), they would subsribe to AEN (asynchronous event notification) and
+ * wait for the events to happen.
+ */
+static int
+megasas_get_seq_num(struct megasas_instance *instance,
+                   struct megasas_evt_log_info *eli)
+{
+       struct megasas_cmd *cmd;
+       struct megasas_dcmd_frame *dcmd;
+       struct megasas_evt_log_info *el_info;
+       dma_addr_t el_info_h = 0;
+
+       cmd = megasas_get_cmd(instance);
+
+       if (!cmd) {
+               return -ENOMEM;
+       }
+
+       dcmd = &cmd->frame->dcmd;
+       el_info = pci_alloc_consistent(instance->pdev,
+                                      sizeof(struct megasas_evt_log_info),
+                                      &el_info_h);
+
+       if (!el_info) {
+               megasas_return_cmd(instance, cmd);
+               return -ENOMEM;
+       }
+
+       memset(el_info, 0, sizeof(*el_info));
+       memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+
+       dcmd->cmd = MFI_CMD_DCMD;
+       dcmd->cmd_status = 0x0;
+       dcmd->sge_count = 1;
+       dcmd->flags = MFI_FRAME_DIR_READ;
+       dcmd->timeout = 0;
+       dcmd->data_xfer_len = sizeof(struct megasas_evt_log_info);
+       dcmd->opcode = MR_DCMD_CTRL_EVENT_GET_INFO;
+       dcmd->sgl.sge32[0].phys_addr = el_info_h;
+       dcmd->sgl.sge32[0].length = sizeof(struct megasas_evt_log_info);
+
+       megasas_issue_blocked_cmd(instance, cmd);
+
+       /*
+        * Copy the data back into callers buffer
+        */
+       memcpy(eli, el_info, sizeof(struct megasas_evt_log_info));
+
+       pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info),
+                           el_info, el_info_h);
+
+       megasas_return_cmd(instance, cmd);
+
+       return 0;
+}
+
+/**
+ * megasas_register_aen -      Registers for asynchronous event notification
+ * @instance:                  Adapter soft state
+ * @seq_num:                   The starting sequence number
+ * @class_locale:              Class of the event
+ *
+ * This function subscribes for AEN for events beyond the @seq_num. It requests
+ * to be notified if and only if the event is of type @class_locale
+ */
+static int
+megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
+                    u32 class_locale_word)
+{
+       int ret_val;
+       struct megasas_cmd *cmd;
+       struct megasas_dcmd_frame *dcmd;
+       union megasas_evt_class_locale curr_aen;
+       union megasas_evt_class_locale prev_aen;
+
+       /*
+        * If there an AEN pending already (aen_cmd), check if the
+        * class_locale of that pending AEN is inclusive of the new
+        * AEN request we currently have. If it is, then we don't have
+        * to do anything. In other words, whichever events the current
+        * AEN request is subscribing to, have already been subscribed
+        * to.
+        *
+        * If the old_cmd is _not_ inclusive, then we have to abort
+        * that command, form a class_locale that is superset of both
+        * old and current and re-issue to the FW
+        */
+
+       curr_aen.word = class_locale_word;
+
+       if (instance->aen_cmd) {
+
+               prev_aen.word = instance->aen_cmd->frame->dcmd.mbox.w[1];
+
+               /*
+                * A class whose enum value is smaller is inclusive of all
+                * higher values. If a PROGRESS (= -1) was previously
+                * registered, then a new registration requests for higher
+                * classes need not be sent to FW. They are automatically
+                * included.
+                *
+                * Locale numbers don't have such hierarchy. They are bitmap
+                * values
+                */
+               if ((prev_aen.members.class <= curr_aen.members.class) &&
+                   !((prev_aen.members.locale & curr_aen.members.locale) ^
+                     curr_aen.members.locale)) {
+                       /*
+                        * Previously issued event registration includes
+                        * current request. Nothing to do.
+                        */
+                       return 0;
+               } else {
+                       curr_aen.members.locale |= prev_aen.members.locale;
+
+                       if (prev_aen.members.class < curr_aen.members.class)
+                               curr_aen.members.class = prev_aen.members.class;
+
+                       instance->aen_cmd->abort_aen = 1;
+                       ret_val = megasas_issue_blocked_abort_cmd(instance,
+                                                                 instance->
+                                                                 aen_cmd);
+
+                       if (ret_val) {
+                               printk(KERN_DEBUG "megasas: Failed to abort "
+                                      "previous AEN command\n");
+                               return ret_val;
+                       }
+               }
+       }
+
+       cmd = megasas_get_cmd(instance);
+
+       if (!cmd)
+               return -ENOMEM;
+
+       dcmd = &cmd->frame->dcmd;
+
+       memset(instance->evt_detail, 0, sizeof(struct megasas_evt_detail));
+
+       /*
+        * Prepare DCMD for aen registration
+        */
+       memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+
+       dcmd->cmd = MFI_CMD_DCMD;
+       dcmd->cmd_status = 0x0;
+       dcmd->sge_count = 1;
+       dcmd->flags = MFI_FRAME_DIR_READ;
+       dcmd->timeout = 0;
+       dcmd->data_xfer_len = sizeof(struct megasas_evt_detail);
+       dcmd->opcode = MR_DCMD_CTRL_EVENT_WAIT;
+       dcmd->mbox.w[0] = seq_num;
+       dcmd->mbox.w[1] = curr_aen.word;
+       dcmd->sgl.sge32[0].phys_addr = (u32) instance->evt_detail_h;
+       dcmd->sgl.sge32[0].length = sizeof(struct megasas_evt_detail);
+
+       /*
+        * Store reference to the cmd used to register for AEN. When an
+        * application wants us to register for AEN, we have to abort this
+        * cmd and re-register with a new EVENT LOCALE supplied by that app
+        */
+       instance->aen_cmd = cmd;
+
+       /*
+        * Issue the aen registration frame
+        */
+       writel(cmd->frame_phys_addr >> 3,
+              &instance->reg_set->inbound_queue_port);
+
+       return 0;
+}
+
+/**
+ * megasas_start_aen - Subscribes to AEN during driver load time
+ * @instance:          Adapter soft state
+ */
+static int megasas_start_aen(struct megasas_instance *instance)
+{
+       struct megasas_evt_log_info eli;
+       union megasas_evt_class_locale class_locale;
+
+       /*
+        * Get the latest sequence number from FW
+        */
+       memset(&eli, 0, sizeof(eli));
+
+       if (megasas_get_seq_num(instance, &eli))
+               return -1;
+
+       /*
+        * Register AEN with FW for latest sequence number plus 1
+        */
+       class_locale.members.reserved = 0;
+       class_locale.members.locale = MR_EVT_LOCALE_ALL;
+       class_locale.members.class = MR_EVT_CLASS_DEBUG;
+
+       return megasas_register_aen(instance, eli.newest_seq_num + 1,
+                                   class_locale.word);
+}
+
+/**
+ * megasas_io_attach - Attaches this driver to SCSI mid-layer
+ * @instance:          Adapter soft state
+ */
+static int megasas_io_attach(struct megasas_instance *instance)
+{
+       struct Scsi_Host *host = instance->host;
+
+       /*
+        * Export parameters required by SCSI mid-layer
+        */
+       host->irq = instance->pdev->irq;
+       host->unique_id = instance->unique_id;
+       host->can_queue = instance->max_fw_cmds - MEGASAS_INT_CMDS;
+       host->this_id = instance->init_id;
+       host->sg_tablesize = instance->max_num_sge;
+       host->max_sectors = instance->max_sectors_per_req;
+       host->cmd_per_lun = 128;
+       host->max_channel = MEGASAS_MAX_CHANNELS - 1;
+       host->max_id = MEGASAS_MAX_DEV_PER_CHANNEL;
+       host->max_lun = MEGASAS_MAX_LUN;
+
+       /*
+        * Notify the mid-layer about the new controller
+        */
+       if (scsi_add_host(host, &instance->pdev->dev)) {
+               printk(KERN_DEBUG "megasas: scsi_add_host failed\n");
+               return -ENODEV;
+       }
+
+       /*
+        * Trigger SCSI to scan our drives
+        */
+       scsi_scan_host(host);
+       return 0;
+}
+
+/**
+ * megasas_probe_one - PCI hotplug entry point
+ * @pdev:              PCI device structure
+ * @id:                        PCI ids of supported hotplugged adapter 
+ */
+static int __devinit
+megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+       int rval;
+       struct Scsi_Host *host;
+       struct megasas_instance *instance;
+
+       /*
+        * Announce PCI information
+        */
+       printk(KERN_INFO "megasas: %#4.04x:%#4.04x:%#4.04x:%#4.04x: ",
+              pdev->vendor, pdev->device, pdev->subsystem_vendor,
+              pdev->subsystem_device);
+
+       printk("bus %d:slot %d:func %d\n",
+              pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+
+       /*
+        * PCI prepping: enable device set bus mastering and dma mask
+        */
+       rval = pci_enable_device(pdev);
+
+       if (rval) {
+               return rval;
+       }
+
+       pci_set_master(pdev);
+
+       /*
+        * All our contollers are capable of performing 64-bit DMA
+        */
+       if (IS_DMA64) {
+               if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
+
+                       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)
+                               goto fail_set_dma_mask;
+               }
+       } else {
+               if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)
+                       goto fail_set_dma_mask;
+       }
+
+       host = scsi_host_alloc(&megasas_template,
+                              sizeof(struct megasas_instance));
+
+       if (!host) {
+               printk(KERN_DEBUG "megasas: scsi_host_alloc failed\n");
+               goto fail_alloc_instance;
+       }
+
+       instance = (struct megasas_instance *)host->hostdata;
+       memset(instance, 0, sizeof(*instance));
+
+       instance->producer = pci_alloc_consistent(pdev, sizeof(u32),
+                                                 &instance->producer_h);
+       instance->consumer = pci_alloc_consistent(pdev, sizeof(u32),
+                                                 &instance->consumer_h);
+
+       if (!instance->producer || !instance->consumer) {
+               printk(KERN_DEBUG "megasas: Failed to allocate memory for "
+                      "producer, consumer\n");
+               goto fail_alloc_dma_buf;
+       }
+
+       *instance->producer = 0;
+       *instance->consumer = 0;
+
+       instance->evt_detail = pci_alloc_consistent(pdev,
+                                                   sizeof(struct
+                                                          megasas_evt_detail),
+                                                   &instance->evt_detail_h);
+
+       if (!instance->evt_detail) {
+               printk(KERN_DEBUG "megasas: Failed to allocate memory for "
+                      "event detail structure\n");
+               goto fail_alloc_dma_buf;
+       }
+
+       /*
+        * Initialize locks and queues
+        */
+       INIT_LIST_HEAD(&instance->cmd_pool);
+
+       init_waitqueue_head(&instance->int_cmd_wait_q);
+       init_waitqueue_head(&instance->abort_cmd_wait_q);
+
+       spin_lock_init(&instance->cmd_pool_lock);
+       spin_lock_init(&instance->instance_lock);
+
+       sema_init(&instance->aen_mutex, 1);
+       sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS);
+
+       /*
+        * Initialize PCI related and misc parameters
+        */
+       instance->pdev = pdev;
+       instance->host = host;
+       instance->unique_id = pdev->bus->number << 8 | pdev->devfn;
+       instance->init_id = MEGASAS_DEFAULT_INIT_ID;
+
+       /*
+        * Initialize MFI Firmware
+        */
+       if (megasas_init_mfi(instance))
+               goto fail_init_mfi;
+
+       /*
+        * Register IRQ
+        */
+       if (request_irq(pdev->irq, megasas_isr, SA_SHIRQ, "megasas", instance)) {
+               printk(KERN_DEBUG "megasas: Failed to register IRQ\n");
+               goto fail_irq;
+       }
+
+       megasas_enable_intr(instance->reg_set);
+
+       /*
+        * Store instance in PCI softstate
+        */
+       pci_set_drvdata(pdev, instance);
+
+       /*
+        * Add this controller to megasas_mgmt_info structure so that it
+        * can be exported to management applications
+        */
+       megasas_mgmt_info.count++;
+       megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = instance;
+       megasas_mgmt_info.max_index++;
+
+       /*
+        * Initiate AEN (Asynchronous Event Notification)
+        */
+       if (megasas_start_aen(instance)) {
+               printk(KERN_DEBUG "megasas: start aen failed\n");
+               goto fail_start_aen;
+       }
+
+       /*
+        * Register with SCSI mid-layer
+        */
+       if (megasas_io_attach(instance))
+               goto fail_io_attach;
+
+       return 0;
+
+      fail_start_aen:
+      fail_io_attach:
+       megasas_mgmt_info.count--;
+       megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
+       megasas_mgmt_info.max_index--;
+
+       pci_set_drvdata(pdev, NULL);
+       megasas_disable_intr(instance->reg_set);
+       free_irq(instance->pdev->irq, instance);
+
+       megasas_release_mfi(instance);
+
+      fail_irq:
+      fail_init_mfi:
+      fail_alloc_dma_buf:
+       if (instance->evt_detail)
+               pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),
+                                   instance->evt_detail,
+                                   instance->evt_detail_h);
+
+       if (instance->producer)
+               pci_free_consistent(pdev, sizeof(u32), instance->producer,
+                                   instance->producer_h);
+       if (instance->consumer)
+               pci_free_consistent(pdev, sizeof(u32), instance->consumer,
+                                   instance->consumer_h);
+       scsi_host_put(host);
+
+      fail_alloc_instance:
+      fail_set_dma_mask:
+       pci_disable_device(pdev);
+
+       return -ENODEV;
+}
+
+/**
+ * megasas_flush_cache -       Requests FW to flush all its caches
+ * @instance:                  Adapter soft state
+ */
+static void megasas_flush_cache(struct megasas_instance *instance)
+{
+       struct megasas_cmd *cmd;
+       struct megasas_dcmd_frame *dcmd;
+
+       cmd = megasas_get_cmd(instance);
+
+       if (!cmd)
+               return;
+
+       dcmd = &cmd->frame->dcmd;
+
+       memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+
+       dcmd->cmd = MFI_CMD_DCMD;
+       dcmd->cmd_status = 0x0;
+       dcmd->sge_count = 0;
+       dcmd->flags = MFI_FRAME_DIR_NONE;
+       dcmd->timeout = 0;
+       dcmd->data_xfer_len = 0;
+       dcmd->opcode = MR_DCMD_CTRL_CACHE_FLUSH;
+       dcmd->mbox.b[0] = MR_FLUSH_CTRL_CACHE | MR_FLUSH_DISK_CACHE;
+
+       megasas_issue_blocked_cmd(instance, cmd);
+
+       megasas_return_cmd(instance, cmd);
+
+       return;
+}
+
+/**
+ * megasas_shutdown_controller -       Instructs FW to shutdown the controller
+ * @instance:                          Adapter soft state
+ */
+static void megasas_shutdown_controller(struct megasas_instance *instance)
+{
+       struct megasas_cmd *cmd;
+       struct megasas_dcmd_frame *dcmd;
+
+       cmd = megasas_get_cmd(instance);
+
+       if (!cmd)
+               return;
+
+       if (instance->aen_cmd)
+               megasas_issue_blocked_abort_cmd(instance, instance->aen_cmd);
+
+       dcmd = &cmd->frame->dcmd;
+
+       memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+
+       dcmd->cmd = MFI_CMD_DCMD;
+       dcmd->cmd_status = 0x0;
+       dcmd->sge_count = 0;
+       dcmd->flags = MFI_FRAME_DIR_NONE;
+       dcmd->timeout = 0;
+       dcmd->data_xfer_len = 0;
+       dcmd->opcode = MR_DCMD_CTRL_SHUTDOWN;
+
+       megasas_issue_blocked_cmd(instance, cmd);
+
+       megasas_return_cmd(instance, cmd);
+
+       return;
+}
+
+/**
+ * megasas_detach_one -        PCI hot"un"plug entry point
+ * @pdev:              PCI device structure
+ */
+static void megasas_detach_one(struct pci_dev *pdev)
+{
+       int i;
+       struct Scsi_Host *host;
+       struct megasas_instance *instance;
+
+       instance = pci_get_drvdata(pdev);
+       host = instance->host;
+
+       scsi_remove_host(instance->host);
+       megasas_flush_cache(instance);
+       megasas_shutdown_controller(instance);
+
+       /*
+        * Take the instance off the instance array. Note that we will not
+        * decrement the max_index. We let this array be sparse array
+        */
+       for (i = 0; i < megasas_mgmt_info.max_index; i++) {
+               if (megasas_mgmt_info.instance[i] == instance) {
+                       megasas_mgmt_info.count--;
+                       megasas_mgmt_info.instance[i] = NULL;
+
+                       break;
+               }
+       }
+
+       pci_set_drvdata(instance->pdev, NULL);
+
+       megasas_disable_intr(instance->reg_set);
+
+       free_irq(instance->pdev->irq, instance);
+
+       megasas_release_mfi(instance);
+
+       pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),
+                           instance->evt_detail, instance->evt_detail_h);
+
+       pci_free_consistent(pdev, sizeof(u32), instance->producer,
+                           instance->producer_h);
+
+       pci_free_consistent(pdev, sizeof(u32), instance->consumer,
+                           instance->consumer_h);
+
+       scsi_host_put(host);
+
+       pci_set_drvdata(pdev, NULL);
+
+       pci_disable_device(pdev);
+
+       return;
+}
+
+/**
+ * megasas_shutdown -  Shutdown entry point
+ * @device:            Generic device structure
+ */
+static void megasas_shutdown(struct pci_dev *pdev)
+{
+       struct megasas_instance *instance = pci_get_drvdata(pdev);
+       megasas_flush_cache(instance);
+}
+
+/**
+ * megasas_mgmt_open - char node "open" entry point
+ */
+static int megasas_mgmt_open(struct inode *inode, struct file *filep)
+{
+       /*
+        * Allow only those users with admin rights
+        */
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
+
+       return 0;
+}
+
+/**
+ * megasas_mgmt_release - char node "release" entry point
+ */
+static int megasas_mgmt_release(struct inode *inode, struct file *filep)
+{
+       filep->private_data = NULL;
+       fasync_helper(-1, filep, 0, &megasas_async_queue);
+
+       return 0;
+}
+
+/**
+ * megasas_mgmt_fasync -       Async notifier registration from applications
+ *
+ * This function adds the calling process to a driver global queue. When an
+ * event occurs, SIGIO will be sent to all processes in this queue.
+ */
+static int megasas_mgmt_fasync(int fd, struct file *filep, int mode)
+{
+       int rc;
+
+       down(&megasas_async_queue_mutex);
+
+       rc = fasync_helper(fd, filep, mode, &megasas_async_queue);
+
+       up(&megasas_async_queue_mutex);
+
+       if (rc >= 0) {
+               /* For sanity check when we get ioctl */
+               filep->private_data = filep;
+               return 0;
+       }
+
+       printk(KERN_DEBUG "megasas: fasync_helper failed [%d]\n", rc);
+
+       return rc;
+}
+
+/**
+ * megasas_mgmt_fw_ioctl -     Issues management ioctls to FW
+ * @instance:                  Adapter soft state
+ * @argp:                      User's ioctl packet
+ */
+static int
+megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
+                     struct megasas_iocpacket __user * user_ioc,
+                     struct megasas_iocpacket *ioc)
+{
+       struct megasas_sge32 *kern_sge32;
+       struct megasas_cmd *cmd;
+       void *kbuff_arr[MAX_IOCTL_SGE];
+       dma_addr_t buf_handle = 0;
+       int error = 0, i;
+       void *sense = NULL;
+       dma_addr_t sense_handle;
+       u32 *sense_ptr;
+
+       memset(kbuff_arr, 0, sizeof(kbuff_arr));
+
+       if (ioc->sge_count > MAX_IOCTL_SGE) {
+               printk(KERN_DEBUG "megasas: SGE count [%d] >  max limit [%d]\n",
+                      ioc->sge_count, MAX_IOCTL_SGE);
+               return -EINVAL;
+       }
+
+       cmd = megasas_get_cmd(instance);
+       if (!cmd) {
+               printk(KERN_DEBUG "megasas: Failed to get a cmd packet\n");
+               return -ENOMEM;
+       }
+
+       /*
+        * User's IOCTL packet has 2 frames (maximum). Copy those two
+        * frames into our cmd's frames. cmd->frame's context will get
+        * overwritten when we copy from user's frames. So set that value
+        * alone separately
+        */
+       memcpy(cmd->frame, ioc->frame.raw, 2 * MEGAMFI_FRAME_SIZE);
+       cmd->frame->hdr.context = cmd->index;
+
+       /*
+        * The management interface between applications and the fw uses
+        * MFI frames. E.g, RAID configuration changes, LD property changes
+        * etc are accomplishes through different kinds of MFI frames. The
+        * driver needs to care only about substituting user buffers with
+        * kernel buffers in SGLs. The location of SGL is embedded in the
+        * struct iocpacket itself.
+        */
+       kern_sge32 = (struct megasas_sge32 *)
+           ((unsigned long)cmd->frame + ioc->sgl_off);
+
+       /*
+        * For each user buffer, create a mirror buffer and copy in
+        */
+       for (i = 0; i < ioc->sge_count; i++) {
+               kbuff_arr[i] = pci_alloc_consistent(instance->pdev,
+                                                   ioc->sgl[i].iov_len,
+                                                   &buf_handle);
+               if (!kbuff_arr[i]) {
+                       printk(KERN_DEBUG "megasas: Failed to alloc "
+                              "kernel SGL buffer for IOCTL \n");
+                       error = -ENOMEM;
+                       goto out;
+               }
+
+               /*
+                * We don't change the dma_coherent_mask, so
+                * pci_alloc_consistent only returns 32bit addresses
+                */
+               kern_sge32[i].phys_addr = (u32) buf_handle;
+               kern_sge32[i].length = ioc->sgl[i].iov_len;
+
+               /*
+                * We created a kernel buffer corresponding to the
+                * user buffer. Now copy in from the user buffer
+                */
+               if (copy_from_user(kbuff_arr[i], ioc->sgl[i].iov_base,
+                                  (u32) (ioc->sgl[i].iov_len))) {
+                       error = -EFAULT;
+                       goto out;
+               }
+       }
+
+       if (ioc->sense_len) {
+               sense = pci_alloc_consistent(instance->pdev, ioc->sense_len,
+                                            &sense_handle);
+               if (!sense) {
+                       error = -ENOMEM;
+                       goto out;
+               }
+
+               sense_ptr =
+                   (u32 *) ((unsigned long)cmd->frame + ioc->sense_off);
+               *sense_ptr = sense_handle;
+       }
+
+       /*
+        * Set the sync_cmd flag so that the ISR knows not to complete this
+        * cmd to the SCSI mid-layer
+        */
+       cmd->sync_cmd = 1;
+       megasas_issue_blocked_cmd(instance, cmd);
+       cmd->sync_cmd = 0;
+
+       /*
+        * copy out the kernel buffers to user buffers
+        */
+       for (i = 0; i < ioc->sge_count; i++) {
+               if (copy_to_user(ioc->sgl[i].iov_base, kbuff_arr[i],
+                                ioc->sgl[i].iov_len)) {
+                       error = -EFAULT;
+                       goto out;
+               }
+       }
+
+       /*
+        * copy out the sense
+        */
+       if (ioc->sense_len) {
+               /*
+                * sense_ptr points to the location that has the user
+                * sense buffer address
+                */
+               sense_ptr = (u32 *) ((unsigned long)ioc->frame.raw +
+                                    ioc->sense_off);
+
+               if (copy_to_user((void __user *)((unsigned long)(*sense_ptr)),
+                                sense, ioc->sense_len)) {
+                       error = -EFAULT;
+                       goto out;
+               }
+       }
+
+       /*
+        * copy the status codes returned by the fw
+        */
+       if (copy_to_user(&user_ioc->frame.hdr.cmd_status,
+                        &cmd->frame->hdr.cmd_status, sizeof(u8))) {
+               printk(KERN_DEBUG "megasas: Error copying out cmd_status\n");
+               error = -EFAULT;
+       }
+
+      out:
+       if (sense) {
+               pci_free_consistent(instance->pdev, ioc->sense_len,
+                                   sense, sense_handle);
+       }
+
+       for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) {
+               pci_free_consistent(instance->pdev,
+                                   kern_sge32[i].length,
+                                   kbuff_arr[i], kern_sge32[i].phys_addr);
+       }
+
+       megasas_return_cmd(instance, cmd);
+       return error;
+}
+
+static struct megasas_instance *megasas_lookup_instance(u16 host_no)
+{
+       int i;
+
+       for (i = 0; i < megasas_mgmt_info.max_index; i++) {
+
+               if ((megasas_mgmt_info.instance[i]) &&
+                   (megasas_mgmt_info.instance[i]->host->host_no == host_no))
+                       return megasas_mgmt_info.instance[i];
+       }
+
+       return NULL;
+}
+
+static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
+{
+       struct megasas_iocpacket __user *user_ioc =
+           (struct megasas_iocpacket __user *)arg;
+       struct megasas_iocpacket *ioc;
+       struct megasas_instance *instance;
+       int error;
+
+       ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
+       if (!ioc)
+               return -ENOMEM;
+
+       if (copy_from_user(ioc, user_ioc, sizeof(*ioc))) {
+               error = -EFAULT;
+               goto out_kfree_ioc;
+       }
+
+       instance = megasas_lookup_instance(ioc->host_no);
+       if (!instance) {
+               error = -ENODEV;
+               goto out_kfree_ioc;
+       }
+
+       /*
+        * We will allow only MEGASAS_INT_CMDS number of parallel ioctl cmds
+        */
+       if (down_interruptible(&instance->ioctl_sem)) {
+               error = -ERESTARTSYS;
+               goto out_kfree_ioc;
+       }
+       error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
+       up(&instance->ioctl_sem);
+
+      out_kfree_ioc:
+       kfree(ioc);
+       return error;
+}
+
+static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
+{
+       struct megasas_instance *instance;
+       struct megasas_aen aen;
+       int error;
+
+       if (file->private_data != file) {
+               printk(KERN_DEBUG "megasas: fasync_helper was not "
+                      "called first\n");
+               return -EINVAL;
+       }
+
+       if (copy_from_user(&aen, (void __user *)arg, sizeof(aen)))
+               return -EFAULT;
+
+       instance = megasas_lookup_instance(aen.host_no);
+
+       if (!instance)
+               return -ENODEV;
+
+       down(&instance->aen_mutex);
+       error = megasas_register_aen(instance, aen.seq_num,
+                                    aen.class_locale_word);
+       up(&instance->aen_mutex);
+       return error;
+}
+
+/**
+ * megasas_mgmt_ioctl -        char node ioctl entry point
+ */
+static long
+megasas_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case MEGASAS_IOC_FIRMWARE:
+               return megasas_mgmt_ioctl_fw(file, arg);
+
+       case MEGASAS_IOC_GET_AEN:
+               return megasas_mgmt_ioctl_aen(file, arg);
+       }
+
+       return -ENOTTY;
+}
+
+#ifdef CONFIG_COMPAT
+static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
+{
+       struct compat_megasas_iocpacket __user *cioc =
+           (struct compat_megasas_iocpacket __user *)arg;
+       struct megasas_iocpacket __user *ioc =
+           compat_alloc_user_space(sizeof(struct megasas_iocpacket));
+       int i;
+       int error = 0;
+
+       clear_user(ioc, sizeof(*ioc));
+
+       if (copy_in_user(&ioc->host_no, &cioc->host_no, sizeof(u16)) ||
+           copy_in_user(&ioc->sgl_off, &cioc->sgl_off, sizeof(u32)) ||
+           copy_in_user(&ioc->sense_off, &cioc->sense_off, sizeof(u32)) ||
+           copy_in_user(&ioc->sense_len, &cioc->sense_len, sizeof(u32)) ||
+           copy_in_user(ioc->frame.raw, cioc->frame.raw, 128) ||
+           copy_in_user(&ioc->sge_count, &cioc->sge_count, sizeof(u32)))
+               return -EFAULT;
+
+       for (i = 0; i < MAX_IOCTL_SGE; i++) {
+               compat_uptr_t ptr;
+
+               if (get_user(ptr, &cioc->sgl[i].iov_base) ||
+                   put_user(compat_ptr(ptr), &ioc->sgl[i].iov_base) ||
+                   copy_in_user(&ioc->sgl[i].iov_len,
+                                &cioc->sgl[i].iov_len, sizeof(compat_size_t)))
+                       return -EFAULT;
+       }
+
+       error = megasas_mgmt_ioctl_fw(file, (unsigned long)ioc);
+
+       if (copy_in_user(&cioc->frame.hdr.cmd_status,
+                        &ioc->frame.hdr.cmd_status, sizeof(u8))) {
+               printk(KERN_DEBUG "megasas: error copy_in_user cmd_status\n");
+               return -EFAULT;
+       }
+       return error;
+}
+
+static long
+megasas_mgmt_compat_ioctl(struct file *file, unsigned int cmd,
+                         unsigned long arg)
+{
+       switch (cmd) {
+       case MEGASAS_IOC_FIRMWARE:{
+                       return megasas_mgmt_compat_ioctl_fw(file, arg);
+               }
+       case MEGASAS_IOC_GET_AEN:
+               return megasas_mgmt_ioctl_aen(file, arg);
+       }
+
+       return -ENOTTY;
+}
+#endif
+
+/*
+ * File operations structure for management interface
+ */
+static struct file_operations megasas_mgmt_fops = {
+       .owner = THIS_MODULE,
+       .open = megasas_mgmt_open,
+       .release = megasas_mgmt_release,
+       .fasync = megasas_mgmt_fasync,
+       .unlocked_ioctl = megasas_mgmt_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = megasas_mgmt_compat_ioctl,
+#endif
+};
+
+/*
+ * PCI hotplug support registration structure
+ */
+static struct pci_driver megasas_pci_driver = {
+
+       .name = "megaraid_sas",
+       .id_table = megasas_pci_table,
+       .probe = megasas_probe_one,
+       .remove = __devexit_p(megasas_detach_one),
+       .shutdown = megasas_shutdown,
+};
+
+/*
+ * Sysfs driver attributes
+ */
+static ssize_t megasas_sysfs_show_version(struct device_driver *dd, char *buf)
+{
+       return snprintf(buf, strlen(MEGASAS_VERSION) + 2, "%s\n",
+                       MEGASAS_VERSION);
+}
+
+static DRIVER_ATTR(version, S_IRUGO, megasas_sysfs_show_version, NULL);
+
+static ssize_t
+megasas_sysfs_show_release_date(struct device_driver *dd, char *buf)
+{
+       return snprintf(buf, strlen(MEGASAS_RELDATE) + 2, "%s\n",
+                       MEGASAS_RELDATE);
+}
+
+static DRIVER_ATTR(release_date, S_IRUGO, megasas_sysfs_show_release_date,
+                  NULL);
+
+/**
+ * megasas_init - Driver load entry point
+ */
+static int __init megasas_init(void)
+{
+       int rval;
+
+       /*
+        * Announce driver version and other information
+        */
+       printk(KERN_INFO "megasas: %s %s\n", MEGASAS_VERSION,
+              MEGASAS_EXT_VERSION);
+
+       memset(&megasas_mgmt_info, 0, sizeof(megasas_mgmt_info));
+
+       /*
+        * Register character device node
+        */
+       rval = register_chrdev(0, "megaraid_sas_ioctl", &megasas_mgmt_fops);
+
+       if (rval < 0) {
+               printk(KERN_DEBUG "megasas: failed to open device node\n");
+               return rval;
+       }
+
+       megasas_mgmt_majorno = rval;
+
+       /*
+        * Register ourselves as PCI hotplug module
+        */
+       rval = pci_module_init(&megasas_pci_driver);
+
+       if (rval) {
+               printk(KERN_DEBUG "megasas: PCI hotplug regisration failed \n");
+               unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
+       }
+
+       driver_create_file(&megasas_pci_driver.driver, &driver_attr_version);
+       driver_create_file(&megasas_pci_driver.driver,
+                          &driver_attr_release_date);
+
+       return rval;
+}
+
+/**
+ * megasas_exit - Driver unload entry point
+ */
+static void __exit megasas_exit(void)
+{
+       driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);
+       driver_remove_file(&megasas_pci_driver.driver,
+                          &driver_attr_release_date);
+
+       pci_unregister_driver(&megasas_pci_driver);
+       unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
+}
+
+module_init(megasas_init);
+module_exit(megasas_exit);
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
new file mode 100644 (file)
index 0000000..eaec9d5
--- /dev/null
@@ -0,0 +1,1142 @@
+/*
+ *
+ *             Linux MegaRAID driver for SAS based RAID controllers
+ *
+ * Copyright (c) 2003-2005  LSI Logic Corporation.
+ *
+ *             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.
+ *
+ * FILE                : megaraid_sas.h
+ */
+
+#ifndef LSI_MEGARAID_SAS_H
+#define LSI_MEGARAID_SAS_H
+
+/**
+ * MegaRAID SAS Driver meta data
+ */
+#define MEGASAS_VERSION                                "00.00.02.00-rc4"
+#define MEGASAS_RELDATE                                "Sep 16, 2005"
+#define MEGASAS_EXT_VERSION                    "Fri Sep 16 12:37:08 EDT 2005"
+
+/*
+ * =====================================
+ * MegaRAID SAS MFI firmware definitions
+ * =====================================
+ */
+
+/*
+ * MFI stands for  MegaRAID SAS FW Interface. This is just a moniker for 
+ * protocol between the software and firmware. Commands are issued using
+ * "message frames"
+ */
+
+/**
+ * FW posts its state in upper 4 bits of outbound_msg_0 register
+ */
+#define MFI_STATE_MASK                         0xF0000000
+#define MFI_STATE_UNDEFINED                    0x00000000
+#define MFI_STATE_BB_INIT                      0x10000000
+#define MFI_STATE_FW_INIT                      0x40000000
+#define MFI_STATE_WAIT_HANDSHAKE               0x60000000
+#define MFI_STATE_FW_INIT_2                    0x70000000
+#define MFI_STATE_DEVICE_SCAN                  0x80000000
+#define MFI_STATE_FLUSH_CACHE                  0xA0000000
+#define MFI_STATE_READY                                0xB0000000
+#define MFI_STATE_OPERATIONAL                  0xC0000000
+#define MFI_STATE_FAULT                                0xF0000000
+
+#define MEGAMFI_FRAME_SIZE                     64
+
+/**
+ * During FW init, clear pending cmds & reset state using inbound_msg_0
+ *
+ * ABORT       : Abort all pending cmds
+ * READY       : Move from OPERATIONAL to READY state; discard queue info
+ * MFIMODE     : Discard (possible) low MFA posted in 64-bit mode (??)
+ * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
+ */
+#define MFI_INIT_ABORT                         0x00000000
+#define MFI_INIT_READY                         0x00000002
+#define MFI_INIT_MFIMODE                       0x00000004
+#define MFI_INIT_CLEAR_HANDSHAKE               0x00000008
+#define MFI_RESET_FLAGS                                MFI_INIT_READY|MFI_INIT_MFIMODE
+
+/**
+ * MFI frame flags
+ */
+#define MFI_FRAME_POST_IN_REPLY_QUEUE          0x0000
+#define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE     0x0001
+#define MFI_FRAME_SGL32                                0x0000
+#define MFI_FRAME_SGL64                                0x0002
+#define MFI_FRAME_SENSE32                      0x0000
+#define MFI_FRAME_SENSE64                      0x0004
+#define MFI_FRAME_DIR_NONE                     0x0000
+#define MFI_FRAME_DIR_WRITE                    0x0008
+#define MFI_FRAME_DIR_READ                     0x0010
+#define MFI_FRAME_DIR_BOTH                     0x0018
+
+/**
+ * Definition for cmd_status
+ */
+#define MFI_CMD_STATUS_POLL_MODE               0xFF
+
+/**
+ * MFI command opcodes
+ */
+#define MFI_CMD_INIT                           0x00
+#define MFI_CMD_LD_READ                                0x01
+#define MFI_CMD_LD_WRITE                       0x02
+#define MFI_CMD_LD_SCSI_IO                     0x03
+#define MFI_CMD_PD_SCSI_IO                     0x04
+#define MFI_CMD_DCMD                           0x05
+#define MFI_CMD_ABORT                          0x06
+#define MFI_CMD_SMP                            0x07
+#define MFI_CMD_STP                            0x08
+
+#define MR_DCMD_CTRL_GET_INFO                  0x01010000
+
+#define MR_DCMD_CTRL_CACHE_FLUSH               0x01101000
+#define MR_FLUSH_CTRL_CACHE                    0x01
+#define MR_FLUSH_DISK_CACHE                    0x02
+
+#define MR_DCMD_CTRL_SHUTDOWN                  0x01050000
+#define MR_ENABLE_DRIVE_SPINDOWN               0x01
+
+#define MR_DCMD_CTRL_EVENT_GET_INFO            0x01040100
+#define MR_DCMD_CTRL_EVENT_GET                 0x01040300
+#define MR_DCMD_CTRL_EVENT_WAIT                        0x01040500
+#define MR_DCMD_LD_GET_PROPERTIES              0x03030000
+
+#define MR_DCMD_CLUSTER                                0x08000000
+#define MR_DCMD_CLUSTER_RESET_ALL              0x08010100
+#define MR_DCMD_CLUSTER_RESET_LD               0x08010200
+
+/**
+ * MFI command completion codes
+ */
+enum MFI_STAT {
+       MFI_STAT_OK = 0x00,
+       MFI_STAT_INVALID_CMD = 0x01,
+       MFI_STAT_INVALID_DCMD = 0x02,
+       MFI_STAT_INVALID_PARAMETER = 0x03,
+       MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
+       MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
+       MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
+       MFI_STAT_APP_IN_USE = 0x07,
+       MFI_STAT_APP_NOT_INITIALIZED = 0x08,
+       MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
+       MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
+       MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
+       MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
+       MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
+       MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
+       MFI_STAT_FLASH_BUSY = 0x0f,
+       MFI_STAT_FLASH_ERROR = 0x10,
+       MFI_STAT_FLASH_IMAGE_BAD = 0x11,
+       MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
+       MFI_STAT_FLASH_NOT_OPEN = 0x13,
+       MFI_STAT_FLASH_NOT_STARTED = 0x14,
+       MFI_STAT_FLUSH_FAILED = 0x15,
+       MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
+       MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
+       MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
+       MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
+       MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
+       MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
+       MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
+       MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
+       MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
+       MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
+       MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
+       MFI_STAT_MFC_HW_ERROR = 0x21,
+       MFI_STAT_NO_HW_PRESENT = 0x22,
+       MFI_STAT_NOT_FOUND = 0x23,
+       MFI_STAT_NOT_IN_ENCL = 0x24,
+       MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
+       MFI_STAT_PD_TYPE_WRONG = 0x26,
+       MFI_STAT_PR_DISABLED = 0x27,
+       MFI_STAT_ROW_INDEX_INVALID = 0x28,
+       MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
+       MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
+       MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
+       MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
+       MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
+       MFI_STAT_SCSI_IO_FAILED = 0x2e,
+       MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
+       MFI_STAT_SHUTDOWN_FAILED = 0x30,
+       MFI_STAT_TIME_NOT_SET = 0x31,
+       MFI_STAT_WRONG_STATE = 0x32,
+       MFI_STAT_LD_OFFLINE = 0x33,
+       MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
+       MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
+       MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
+       MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
+       MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
+
+       MFI_STAT_INVALID_STATUS = 0xFF
+};
+
+/*
+ * Number of mailbox bytes in DCMD message frame
+ */
+#define MFI_MBOX_SIZE                          12
+
+enum MR_EVT_CLASS {
+
+       MR_EVT_CLASS_DEBUG = -2,
+       MR_EVT_CLASS_PROGRESS = -1,
+       MR_EVT_CLASS_INFO = 0,
+       MR_EVT_CLASS_WARNING = 1,
+       MR_EVT_CLASS_CRITICAL = 2,
+       MR_EVT_CLASS_FATAL = 3,
+       MR_EVT_CLASS_DEAD = 4,
+
+};
+
+enum MR_EVT_LOCALE {
+
+       MR_EVT_LOCALE_LD = 0x0001,
+       MR_EVT_LOCALE_PD = 0x0002,
+       MR_EVT_LOCALE_ENCL = 0x0004,
+       MR_EVT_LOCALE_BBU = 0x0008,
+       MR_EVT_LOCALE_SAS = 0x0010,
+       MR_EVT_LOCALE_CTRL = 0x0020,
+       MR_EVT_LOCALE_CONFIG = 0x0040,
+       MR_EVT_LOCALE_CLUSTER = 0x0080,
+       MR_EVT_LOCALE_ALL = 0xffff,
+
+};
+
+enum MR_EVT_ARGS {
+
+       MR_EVT_ARGS_NONE,
+       MR_EVT_ARGS_CDB_SENSE,
+       MR_EVT_ARGS_LD,
+       MR_EVT_ARGS_LD_COUNT,
+       MR_EVT_ARGS_LD_LBA,
+       MR_EVT_ARGS_LD_OWNER,
+       MR_EVT_ARGS_LD_LBA_PD_LBA,
+       MR_EVT_ARGS_LD_PROG,
+       MR_EVT_ARGS_LD_STATE,
+       MR_EVT_ARGS_LD_STRIP,
+       MR_EVT_ARGS_PD,
+       MR_EVT_ARGS_PD_ERR,
+       MR_EVT_ARGS_PD_LBA,
+       MR_EVT_ARGS_PD_LBA_LD,
+       MR_EVT_ARGS_PD_PROG,
+       MR_EVT_ARGS_PD_STATE,
+       MR_EVT_ARGS_PCI,
+       MR_EVT_ARGS_RATE,
+       MR_EVT_ARGS_STR,
+       MR_EVT_ARGS_TIME,
+       MR_EVT_ARGS_ECC,
+
+};
+
+/*
+ * SAS controller properties
+ */
+struct megasas_ctrl_prop {
+
+       u16 seq_num;
+       u16 pred_fail_poll_interval;
+       u16 intr_throttle_count;
+       u16 intr_throttle_timeouts;
+       u8 rebuild_rate;
+       u8 patrol_read_rate;
+       u8 bgi_rate;
+       u8 cc_rate;
+       u8 recon_rate;
+       u8 cache_flush_interval;
+       u8 spinup_drv_count;
+       u8 spinup_delay;
+       u8 cluster_enable;
+       u8 coercion_mode;
+       u8 alarm_enable;
+       u8 disable_auto_rebuild;
+       u8 disable_battery_warn;
+       u8 ecc_bucket_size;
+       u16 ecc_bucket_leak_rate;
+       u8 restore_hotspare_on_insertion;
+       u8 expose_encl_devices;
+       u8 reserved[38];
+
+} __attribute__ ((packed));
+
+/*
+ * SAS controller information
+ */
+struct megasas_ctrl_info {
+
+       /*
+        * PCI device information
+        */
+       struct {
+
+               u16 vendor_id;
+               u16 device_id;
+               u16 sub_vendor_id;
+               u16 sub_device_id;
+               u8 reserved[24];
+
+       } __attribute__ ((packed)) pci;
+
+       /*
+        * Host interface information
+        */
+       struct {
+
+               u8 PCIX:1;
+               u8 PCIE:1;
+               u8 iSCSI:1;
+               u8 SAS_3G:1;
+               u8 reserved_0:4;
+               u8 reserved_1[6];
+               u8 port_count;
+               u64 port_addr[8];
+
+       } __attribute__ ((packed)) host_interface;
+
+       /*
+        * Device (backend) interface information
+        */
+       struct {
+
+               u8 SPI:1;
+               u8 SAS_3G:1;
+               u8 SATA_1_5G:1;
+               u8 SATA_3G:1;
+               u8 reserved_0:4;
+               u8 reserved_1[6];
+               u8 port_count;
+               u64 port_addr[8];
+
+       } __attribute__ ((packed)) device_interface;
+
+       /*
+        * List of components residing in flash. All str are null terminated
+        */
+       u32 image_check_word;
+       u32 image_component_count;
+
+       struct {
+
+               char name[8];
+               char version[32];
+               char build_date[16];
+               char built_time[16];
+
+       } __attribute__ ((packed)) image_component[8];
+
+       /*
+        * List of flash components that have been flashed on the card, but
+        * are not in use, pending reset of the adapter. This list will be
+        * empty if a flash operation has not occurred. All stings are null
+        * terminated
+        */
+       u32 pending_image_component_count;
+
+       struct {
+
+               char name[8];
+               char version[32];
+               char build_date[16];
+               char build_time[16];
+
+       } __attribute__ ((packed)) pending_image_component[8];
+
+       u8 max_arms;
+       u8 max_spans;
+       u8 max_arrays;
+       u8 max_lds;
+
+       char product_name[80];
+       char serial_no[32];
+
+       /*
+        * Other physical/controller/operation information. Indicates the
+        * presence of the hardware
+        */
+       struct {
+
+               u32 bbu:1;
+               u32 alarm:1;
+               u32 nvram:1;
+               u32 uart:1;
+               u32 reserved:28;
+
+       } __attribute__ ((packed)) hw_present;
+
+       u32 current_fw_time;
+
+       /*
+        * Maximum data transfer sizes
+        */
+       u16 max_concurrent_cmds;
+       u16 max_sge_count;
+       u32 max_request_size;
+
+       /*
+        * Logical and physical device counts
+        */
+       u16 ld_present_count;
+       u16 ld_degraded_count;
+       u16 ld_offline_count;
+
+       u16 pd_present_count;
+       u16 pd_disk_present_count;
+       u16 pd_disk_pred_failure_count;
+       u16 pd_disk_failed_count;
+
+       /*
+        * Memory size information
+        */
+       u16 nvram_size;
+       u16 memory_size;
+       u16 flash_size;
+
+       /*
+        * Error counters
+        */
+       u16 mem_correctable_error_count;
+       u16 mem_uncorrectable_error_count;
+
+       /*
+        * Cluster information
+        */
+       u8 cluster_permitted;
+       u8 cluster_active;
+
+       /*
+        * Additional max data transfer sizes
+        */
+       u16 max_strips_per_io;
+
+       /*
+        * Controller capabilities structures
+        */
+       struct {
+
+               u32 raid_level_0:1;
+               u32 raid_level_1:1;
+               u32 raid_level_5:1;
+               u32 raid_level_1E:1;
+               u32 raid_level_6:1;
+               u32 reserved:27;
+
+       } __attribute__ ((packed)) raid_levels;
+
+       struct {
+
+               u32 rbld_rate:1;
+               u32 cc_rate:1;
+               u32 bgi_rate:1;
+               u32 recon_rate:1;
+               u32 patrol_rate:1;
+               u32 alarm_control:1;
+               u32 cluster_supported:1;
+               u32 bbu:1;
+               u32 spanning_allowed:1;
+               u32 dedicated_hotspares:1;
+               u32 revertible_hotspares:1;
+               u32 foreign_config_import:1;
+               u32 self_diagnostic:1;
+               u32 mixed_redundancy_arr:1;
+               u32 global_hot_spares:1;
+               u32 reserved:17;
+
+       } __attribute__ ((packed)) adapter_operations;
+
+       struct {
+
+               u32 read_policy:1;
+               u32 write_policy:1;
+               u32 io_policy:1;
+               u32 access_policy:1;
+               u32 disk_cache_policy:1;
+               u32 reserved:27;
+
+       } __attribute__ ((packed)) ld_operations;
+
+       struct {
+
+               u8 min;
+               u8 max;
+               u8 reserved[2];
+
+       } __attribute__ ((packed)) stripe_sz_ops;
+
+       struct {
+
+               u32 force_online:1;
+               u32 force_offline:1;
+               u32 force_rebuild:1;
+               u32 reserved:29;
+
+       } __attribute__ ((packed)) pd_operations;
+
+       struct {
+
+               u32 ctrl_supports_sas:1;
+               u32 ctrl_supports_sata:1;
+               u32 allow_mix_in_encl:1;
+               u32 allow_mix_in_ld:1;
+               u32 allow_sata_in_cluster:1;
+               u32 reserved:27;
+
+       } __attribute__ ((packed)) pd_mix_support;
+
+       /*
+        * Define ECC single-bit-error bucket information
+        */
+       u8 ecc_bucket_count;
+       u8 reserved_2[11];
+
+       /*
+        * Include the controller properties (changeable items)
+        */
+       struct megasas_ctrl_prop properties;
+
+       /*
+        * Define FW pkg version (set in envt v'bles on OEM basis)
+        */
+       char package_version[0x60];
+
+       u8 pad[0x800 - 0x6a0];
+
+} __attribute__ ((packed));
+
+/*
+ * ===============================
+ * MegaRAID SAS driver definitions
+ * ===============================
+ */
+#define MEGASAS_MAX_PD_CHANNELS                        2
+#define MEGASAS_MAX_LD_CHANNELS                        2
+#define MEGASAS_MAX_CHANNELS                   (MEGASAS_MAX_PD_CHANNELS + \
+                                               MEGASAS_MAX_LD_CHANNELS)
+#define MEGASAS_MAX_DEV_PER_CHANNEL            128
+#define MEGASAS_DEFAULT_INIT_ID                        -1
+#define MEGASAS_MAX_LUN                                8
+#define MEGASAS_MAX_LD                         64
+
+/*
+ * When SCSI mid-layer calls driver's reset routine, driver waits for
+ * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
+ * that the driver cannot _actually_ abort or reset pending commands. While
+ * it is waiting for the commands to complete, it prints a diagnostic message
+ * every MEGASAS_RESET_NOTICE_INTERVAL seconds
+ */
+#define MEGASAS_RESET_WAIT_TIME                        180
+#define        MEGASAS_RESET_NOTICE_INTERVAL           5
+
+#define MEGASAS_IOCTL_CMD                      0
+
+/*
+ * FW reports the maximum of number of commands that it can accept (maximum
+ * commands that can be outstanding) at any time. The driver must report a
+ * lower number to the mid layer because it can issue a few internal commands
+ * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
+ * is shown below
+ */
+#define MEGASAS_INT_CMDS                       32
+
+/*
+ * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
+ * SGLs based on the size of dma_addr_t
+ */
+#define IS_DMA64                               (sizeof(dma_addr_t) == 8)
+
+#define MFI_OB_INTR_STATUS_MASK                        0x00000002
+#define MFI_POLL_TIMEOUT_SECS                  10
+
+struct megasas_register_set {
+
+       u32 reserved_0[4];      /*0000h */
+
+       u32 inbound_msg_0;      /*0010h */
+       u32 inbound_msg_1;      /*0014h */
+       u32 outbound_msg_0;     /*0018h */
+       u32 outbound_msg_1;     /*001Ch */
+
+       u32 inbound_doorbell;   /*0020h */
+       u32 inbound_intr_status;        /*0024h */
+       u32 inbound_intr_mask;  /*0028h */
+
+       u32 outbound_doorbell;  /*002Ch */
+       u32 outbound_intr_status;       /*0030h */
+       u32 outbound_intr_mask; /*0034h */
+
+       u32 reserved_1[2];      /*0038h */
+
+       u32 inbound_queue_port; /*0040h */
+       u32 outbound_queue_port;        /*0044h */
+
+       u32 reserved_2;         /*004Ch */
+
+       u32 index_registers[1004];      /*0050h */
+
+} __attribute__ ((packed));
+
+struct megasas_sge32 {
+
+       u32 phys_addr;
+       u32 length;
+
+} __attribute__ ((packed));
+
+struct megasas_sge64 {
+
+       u64 phys_addr;
+       u32 length;
+
+} __attribute__ ((packed));
+
+union megasas_sgl {
+
+       struct megasas_sge32 sge32[1];
+       struct megasas_sge64 sge64[1];
+
+} __attribute__ ((packed));
+
+struct megasas_header {
+
+       u8 cmd;                 /*00h */
+       u8 sense_len;           /*01h */
+       u8 cmd_status;          /*02h */
+       u8 scsi_status;         /*03h */
+
+       u8 target_id;           /*04h */
+       u8 lun;                 /*05h */
+       u8 cdb_len;             /*06h */
+       u8 sge_count;           /*07h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 timeout;            /*12h */
+       u32 data_xferlen;       /*14h */
+
+} __attribute__ ((packed));
+
+union megasas_sgl_frame {
+
+       struct megasas_sge32 sge32[8];
+       struct megasas_sge64 sge64[5];
+
+} __attribute__ ((packed));
+
+struct megasas_init_frame {
+
+       u8 cmd;                 /*00h */
+       u8 reserved_0;          /*01h */
+       u8 cmd_status;          /*02h */
+
+       u8 reserved_1;          /*03h */
+       u32 reserved_2;         /*04h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 reserved_3;         /*12h */
+       u32 data_xfer_len;      /*14h */
+
+       u32 queue_info_new_phys_addr_lo;        /*18h */
+       u32 queue_info_new_phys_addr_hi;        /*1Ch */
+       u32 queue_info_old_phys_addr_lo;        /*20h */
+       u32 queue_info_old_phys_addr_hi;        /*24h */
+
+       u32 reserved_4[6];      /*28h */
+
+} __attribute__ ((packed));
+
+struct megasas_init_queue_info {
+
+       u32 init_flags;         /*00h */
+       u32 reply_queue_entries;        /*04h */
+
+       u32 reply_queue_start_phys_addr_lo;     /*08h */
+       u32 reply_queue_start_phys_addr_hi;     /*0Ch */
+       u32 producer_index_phys_addr_lo;        /*10h */
+       u32 producer_index_phys_addr_hi;        /*14h */
+       u32 consumer_index_phys_addr_lo;        /*18h */
+       u32 consumer_index_phys_addr_hi;        /*1Ch */
+
+} __attribute__ ((packed));
+
+struct megasas_io_frame {
+
+       u8 cmd;                 /*00h */
+       u8 sense_len;           /*01h */
+       u8 cmd_status;          /*02h */
+       u8 scsi_status;         /*03h */
+
+       u8 target_id;           /*04h */
+       u8 access_byte;         /*05h */
+       u8 reserved_0;          /*06h */
+       u8 sge_count;           /*07h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 timeout;            /*12h */
+       u32 lba_count;          /*14h */
+
+       u32 sense_buf_phys_addr_lo;     /*18h */
+       u32 sense_buf_phys_addr_hi;     /*1Ch */
+
+       u32 start_lba_lo;       /*20h */
+       u32 start_lba_hi;       /*24h */
+
+       union megasas_sgl sgl;  /*28h */
+
+} __attribute__ ((packed));
+
+struct megasas_pthru_frame {
+
+       u8 cmd;                 /*00h */
+       u8 sense_len;           /*01h */
+       u8 cmd_status;          /*02h */
+       u8 scsi_status;         /*03h */
+
+       u8 target_id;           /*04h */
+       u8 lun;                 /*05h */
+       u8 cdb_len;             /*06h */
+       u8 sge_count;           /*07h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 timeout;            /*12h */
+       u32 data_xfer_len;      /*14h */
+
+       u32 sense_buf_phys_addr_lo;     /*18h */
+       u32 sense_buf_phys_addr_hi;     /*1Ch */
+
+       u8 cdb[16];             /*20h */
+       union megasas_sgl sgl;  /*30h */
+
+} __attribute__ ((packed));
+
+struct megasas_dcmd_frame {
+
+       u8 cmd;                 /*00h */
+       u8 reserved_0;          /*01h */
+       u8 cmd_status;          /*02h */
+       u8 reserved_1[4];       /*03h */
+       u8 sge_count;           /*07h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 timeout;            /*12h */
+
+       u32 data_xfer_len;      /*14h */
+       u32 opcode;             /*18h */
+
+       union {                 /*1Ch */
+               u8 b[12];
+               u16 s[6];
+               u32 w[3];
+       } mbox;
+
+       union megasas_sgl sgl;  /*28h */
+
+} __attribute__ ((packed));
+
+struct megasas_abort_frame {
+
+       u8 cmd;                 /*00h */
+       u8 reserved_0;          /*01h */
+       u8 cmd_status;          /*02h */
+
+       u8 reserved_1;          /*03h */
+       u32 reserved_2;         /*04h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 reserved_3;         /*12h */
+       u32 reserved_4;         /*14h */
+
+       u32 abort_context;      /*18h */
+       u32 pad_1;              /*1Ch */
+
+       u32 abort_mfi_phys_addr_lo;     /*20h */
+       u32 abort_mfi_phys_addr_hi;     /*24h */
+
+       u32 reserved_5[6];      /*28h */
+
+} __attribute__ ((packed));
+
+struct megasas_smp_frame {
+
+       u8 cmd;                 /*00h */
+       u8 reserved_1;          /*01h */
+       u8 cmd_status;          /*02h */
+       u8 connection_status;   /*03h */
+
+       u8 reserved_2[3];       /*04h */
+       u8 sge_count;           /*07h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 timeout;            /*12h */
+
+       u32 data_xfer_len;      /*14h */
+       u64 sas_addr;           /*18h */
+
+       union {
+               struct megasas_sge32 sge32[2];  /* [0]: resp [1]: req */
+               struct megasas_sge64 sge64[2];  /* [0]: resp [1]: req */
+       } sgl;
+
+} __attribute__ ((packed));
+
+struct megasas_stp_frame {
+
+       u8 cmd;                 /*00h */
+       u8 reserved_1;          /*01h */
+       u8 cmd_status;          /*02h */
+       u8 reserved_2;          /*03h */
+
+       u8 target_id;           /*04h */
+       u8 reserved_3[2];       /*05h */
+       u8 sge_count;           /*07h */
+
+       u32 context;            /*08h */
+       u32 pad_0;              /*0Ch */
+
+       u16 flags;              /*10h */
+       u16 timeout;            /*12h */
+
+       u32 data_xfer_len;      /*14h */
+
+       u16 fis[10];            /*18h */
+       u32 stp_flags;
+
+       union {
+               struct megasas_sge32 sge32[2];  /* [0]: resp [1]: data */
+               struct megasas_sge64 sge64[2];  /* [0]: resp [1]: data */
+       } sgl;
+
+} __attribute__ ((packed));
+
+union megasas_frame {
+
+       struct megasas_header hdr;
+       struct megasas_init_frame init;
+       struct megasas_io_frame io;
+       struct megasas_pthru_frame pthru;
+       struct megasas_dcmd_frame dcmd;
+       struct megasas_abort_frame abort;
+       struct megasas_smp_frame smp;
+       struct megasas_stp_frame stp;
+
+       u8 raw_bytes[64];
+};
+
+struct megasas_cmd;
+
+union megasas_evt_class_locale {
+
+       struct {
+               u16 locale;
+               u8 reserved;
+               s8 class;
+       } __attribute__ ((packed)) members;
+
+       u32 word;
+
+} __attribute__ ((packed));
+
+struct megasas_evt_log_info {
+       u32 newest_seq_num;
+       u32 oldest_seq_num;
+       u32 clear_seq_num;
+       u32 shutdown_seq_num;
+       u32 boot_seq_num;
+
+} __attribute__ ((packed));
+
+struct megasas_progress {
+
+       u16 progress;
+       u16 elapsed_seconds;
+
+} __attribute__ ((packed));
+
+struct megasas_evtarg_ld {
+
+       u16 target_id;
+       u8 ld_index;
+       u8 reserved;
+
+} __attribute__ ((packed));
+
+struct megasas_evtarg_pd {
+       u16 device_id;
+       u8 encl_index;
+       u8 slot_number;
+
+} __attribute__ ((packed));
+
+struct megasas_evt_detail {
+
+       u32 seq_num;
+       u32 time_stamp;
+       u32 code;
+       union megasas_evt_class_locale cl;
+       u8 arg_type;
+       u8 reserved1[15];
+
+       union {
+               struct {
+                       struct megasas_evtarg_pd pd;
+                       u8 cdb_length;
+                       u8 sense_length;
+                       u8 reserved[2];
+                       u8 cdb[16];
+                       u8 sense[64];
+               } __attribute__ ((packed)) cdbSense;
+
+               struct megasas_evtarg_ld ld;
+
+               struct {
+                       struct megasas_evtarg_ld ld;
+                       u64 count;
+               } __attribute__ ((packed)) ld_count;
+
+               struct {
+                       u64 lba;
+                       struct megasas_evtarg_ld ld;
+               } __attribute__ ((packed)) ld_lba;
+
+               struct {
+                       struct megasas_evtarg_ld ld;
+                       u32 prevOwner;
+                       u32 newOwner;
+               } __attribute__ ((packed)) ld_owner;
+
+               struct {
+                       u64 ld_lba;
+                       u64 pd_lba;
+                       struct megasas_evtarg_ld ld;
+                       struct megasas_evtarg_pd pd;
+               } __attribute__ ((packed)) ld_lba_pd_lba;
+
+               struct {
+                       struct megasas_evtarg_ld ld;
+                       struct megasas_progress prog;
+               } __attribute__ ((packed)) ld_prog;
+
+               struct {
+                       struct megasas_evtarg_ld ld;
+                       u32 prev_state;
+                       u32 new_state;
+               } __attribute__ ((packed)) ld_state;
+
+               struct {
+                       u64 strip;
+                       struct megasas_evtarg_ld ld;
+               } __attribute__ ((packed)) ld_strip;
+
+               struct megasas_evtarg_pd pd;
+
+               struct {
+                       struct megasas_evtarg_pd pd;
+                       u32 err;
+               } __attribute__ ((packed)) pd_err;
+
+               struct {
+                       u64 lba;
+                       struct megasas_evtarg_pd pd;
+               } __attribute__ ((packed)) pd_lba;
+
+               struct {
+                       u64 lba;
+                       struct megasas_evtarg_pd pd;
+                       struct megasas_evtarg_ld ld;
+               } __attribute__ ((packed)) pd_lba_ld;
+
+               struct {
+                       struct megasas_evtarg_pd pd;
+                       struct megasas_progress prog;
+               } __attribute__ ((packed)) pd_prog;
+
+               struct {
+                       struct megasas_evtarg_pd pd;
+                       u32 prevState;
+                       u32 newState;
+               } __attribute__ ((packed)) pd_state;
+
+               struct {
+                       u16 vendorId;
+                       u16 deviceId;
+                       u16 subVendorId;
+                       u16 subDeviceId;
+               } __attribute__ ((packed)) pci;
+
+               u32 rate;
+               char str[96];
+
+               struct {
+                       u32 rtc;
+                       u32 elapsedSeconds;
+               } __attribute__ ((packed)) time;
+
+               struct {
+                       u32 ecar;
+                       u32 elog;
+                       char str[64];
+               } __attribute__ ((packed)) ecc;
+
+               u8 b[96];
+               u16 s[48];
+               u32 w[24];
+               u64 d[12];
+       } args;
+
+       char description[128];
+
+} __attribute__ ((packed));
+
+struct megasas_instance {
+
+       u32 *producer;
+       dma_addr_t producer_h;
+       u32 *consumer;
+       dma_addr_t consumer_h;
+
+       u32 *reply_queue;
+       dma_addr_t reply_queue_h;
+
+       unsigned long base_addr;
+       struct megasas_register_set __iomem *reg_set;
+
+       s8 init_id;
+       u8 reserved[3];
+
+       u16 max_num_sge;
+       u16 max_fw_cmds;
+       u32 max_sectors_per_req;
+
+       struct megasas_cmd **cmd_list;
+       struct list_head cmd_pool;
+       spinlock_t cmd_pool_lock;
+       struct dma_pool *frame_dma_pool;
+       struct dma_pool *sense_dma_pool;
+
+       struct megasas_evt_detail *evt_detail;
+       dma_addr_t evt_detail_h;
+       struct megasas_cmd *aen_cmd;
+       struct semaphore aen_mutex;
+       struct semaphore ioctl_sem;
+
+       struct Scsi_Host *host;
+
+       wait_queue_head_t int_cmd_wait_q;
+       wait_queue_head_t abort_cmd_wait_q;
+
+       struct pci_dev *pdev;
+       u32 unique_id;
+
+       u32 fw_outstanding;
+       u32 hw_crit_error;
+       spinlock_t instance_lock;
+};
+
+#define MEGASAS_IS_LOGICAL(scp)                                                \
+       (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
+
+#define MEGASAS_DEV_INDEX(inst, scp)                                   \
+       ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) +    \
+       scp->device->id
+
+struct megasas_cmd {
+
+       union megasas_frame *frame;
+       dma_addr_t frame_phys_addr;
+       u8 *sense;
+       dma_addr_t sense_phys_addr;
+
+       u32 index;
+       u8 sync_cmd;
+       u8 cmd_status;
+       u16 abort_aen;
+
+       struct list_head list;
+       struct scsi_cmnd *scmd;
+       struct megasas_instance *instance;
+       u32 frame_count;
+};
+
+#define MAX_MGMT_ADAPTERS              1024
+#define MAX_IOCTL_SGE                  16
+
+struct megasas_iocpacket {
+
+       u16 host_no;
+       u16 __pad1;
+       u32 sgl_off;
+       u32 sge_count;
+       u32 sense_off;
+       u32 sense_len;
+       union {
+               u8 raw[128];
+               struct megasas_header hdr;
+       } frame;
+
+       struct iovec sgl[MAX_IOCTL_SGE];
+
+} __attribute__ ((packed));
+
+struct megasas_aen {
+       u16 host_no;
+       u16 __pad1;
+       u32 seq_num;
+       u32 class_locale_word;
+} __attribute__ ((packed));
+
+#ifdef CONFIG_COMPAT
+struct compat_megasas_iocpacket {
+       u16 host_no;
+       u16 __pad1;
+       u32 sgl_off;
+       u32 sge_count;
+       u32 sense_off;
+       u32 sense_len;
+       union {
+               u8 raw[128];
+               struct megasas_header hdr;
+       } frame;
+       struct compat_iovec sgl[MAX_IOCTL_SGE];
+} __attribute__ ((packed));
+
+#define MEGASAS_IOC_FIRMWARE   _IOWR('M', 1, struct compat_megasas_iocpacket)
+#else
+#define MEGASAS_IOC_FIRMWARE   _IOWR('M', 1, struct megasas_iocpacket)
+#endif
+
+#define MEGASAS_IOC_GET_AEN    _IOW('M', 3, struct megasas_aen)
+
+struct megasas_mgmt_info {
+
+       u16 count;
+       struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
+       int max_index;
+};
+
+#endif                         /*LSI_MEGARAID_SAS_H */
index bdc3bc74bbe14ebfc7d090f328a6d6ed0484d325..1eba988286360efd49a696eb80613e5310953663 100644 (file)
@@ -330,6 +330,8 @@ qla2x00_update_login_fcport(scsi_qla_host_t *ha, struct mbx_entry *mbxstat,
        fcport->flags &= ~FCF_FAILOVER_NEEDED;
        fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
        atomic_set(&fcport->state, FCS_ONLINE);
+       if (fcport->rport)
+               fc_remote_port_unblock(fcport->rport);
 }
 
 
index fcf9f6cbb142d3675b295a2ffc04f3d4ada94c41..327c5d7e5bd2896af1fd6b5f37a0d3376a5d685a 100644 (file)
@@ -587,6 +587,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result,
        if (sdev->scsi_level >= 2 ||
            (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1))
                sdev->scsi_level++;
+       sdev->sdev_target->scsi_level = sdev->scsi_level;
 
        return 0;
 }
@@ -771,6 +772,15 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
        return SCSI_SCAN_LUN_PRESENT;
 }
 
+static inline void scsi_destroy_sdev(struct scsi_device *sdev)
+{
+       if (sdev->host->hostt->slave_destroy)
+               sdev->host->hostt->slave_destroy(sdev);
+       transport_destroy_device(&sdev->sdev_gendev);
+       put_device(&sdev->sdev_gendev);
+}
+
+
 /**
  * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it
  * @starget:   pointer to target device structure
@@ -803,9 +813,9 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
         * The rescan flag is used as an optimization, the first scan of a
         * host adapter calls into here with rescan == 0.
         */
-       if (rescan) {
-               sdev = scsi_device_lookup_by_target(starget, lun);
-               if (sdev) {
+       sdev = scsi_device_lookup_by_target(starget, lun);
+       if (sdev) {
+               if (rescan || sdev->sdev_state != SDEV_CREATED) {
                        SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
                                "scsi scan: device exists on %s\n",
                                sdev->sdev_gendev.bus_id));
@@ -820,9 +830,9 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
                                                                 sdev->model);
                        return SCSI_SCAN_LUN_PRESENT;
                }
-       }
-
-       sdev = scsi_alloc_sdev(starget, lun, hostdata);
+               scsi_device_put(sdev);
+       } else
+               sdev = scsi_alloc_sdev(starget, lun, hostdata);
        if (!sdev)
                goto out;
 
@@ -877,12 +887,8 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
                                res = SCSI_SCAN_NO_RESPONSE;
                        }
                }
-       } else {
-               if (sdev->host->hostt->slave_destroy)
-                       sdev->host->hostt->slave_destroy(sdev);
-               transport_destroy_device(&sdev->sdev_gendev);
-               put_device(&sdev->sdev_gendev);
-       }
+       } else
+               scsi_destroy_sdev(sdev);
  out:
        return res;
 }
@@ -1054,7 +1060,7 @@ EXPORT_SYMBOL(int_to_scsilun);
  *     0: scan completed (or no memory, so further scanning is futile)
  *     1: no report lun scan, or not configured
  **/
-static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
+static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
                                int rescan)
 {
        char devname[64];
@@ -1067,7 +1073,8 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
        struct scsi_lun *lunp, *lun_data;
        u8 *data;
        struct scsi_sense_hdr sshdr;
-       struct scsi_target *starget = scsi_target(sdev);
+       struct scsi_device *sdev;
+       struct Scsi_Host *shost = dev_to_shost(&starget->dev);
 
        /*
         * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set.
@@ -1075,15 +1082,23 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
         * support more than 8 LUNs.
         */
        if ((bflags & BLIST_NOREPORTLUN) || 
-            sdev->scsi_level < SCSI_2 ||
-           (sdev->scsi_level < SCSI_3 && 
-            (!(bflags & BLIST_REPORTLUN2) || sdev->host->max_lun <= 8)) )
+            starget->scsi_level < SCSI_2 ||
+           (starget->scsi_level < SCSI_3 && 
+            (!(bflags & BLIST_REPORTLUN2) || shost->max_lun <= 8)) )
                return 1;
        if (bflags & BLIST_NOLUN)
                return 0;
 
+       if (!(sdev = scsi_device_lookup_by_target(starget, 0))) {
+               sdev = scsi_alloc_sdev(starget, 0, NULL);
+               if (!sdev)
+                       return 0;
+               if (scsi_device_get(sdev))
+                       return 0;
+       }
+
        sprintf(devname, "host %d channel %d id %d",
-               sdev->host->host_no, sdev->channel, sdev->id);
+               shost->host_no, sdev->channel, sdev->id);
 
        /*
         * Allocate enough to hold the header (the same size as one scsi_lun)
@@ -1098,8 +1113,10 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
        length = (max_scsi_report_luns + 1) * sizeof(struct scsi_lun);
        lun_data = kmalloc(length, GFP_ATOMIC |
                           (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
-       if (!lun_data)
+       if (!lun_data) {
+               printk(ALLOC_FAILURE_MSG, __FUNCTION__);
                goto out;
+       }
 
        scsi_cmd[0] = REPORT_LUNS;
 
@@ -1201,10 +1218,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
                        for (i = 0; i < sizeof(struct scsi_lun); i++)
                                printk("%02x", data[i]);
                        printk(" has a LUN larger than currently supported.\n");
-               } else if (lun == 0) {
-                       /*
-                        * LUN 0 has already been scanned.
-                        */
                } else if (lun > sdev->host->max_lun) {
                        printk(KERN_WARNING "scsi: %s lun%d has a LUN larger"
                               " than allowed by the host adapter\n",
@@ -1227,13 +1240,13 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
        }
 
        kfree(lun_data);
-       return 0;
-
  out:
-       /*
-        * We are out of memory, don't try scanning any further.
-        */
-       printk(ALLOC_FAILURE_MSG, __FUNCTION__);
+       scsi_device_put(sdev);
+       if (sdev->sdev_state == SDEV_CREATED)
+               /*
+                * the sdev we used didn't appear in the report luns scan
+                */
+               scsi_destroy_sdev(sdev);
        return 0;
 }
 
@@ -1299,7 +1312,6 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
        struct Scsi_Host *shost = dev_to_shost(parent);
        int bflags = 0;
        int res;
-       struct scsi_device *sdev = NULL;
        struct scsi_target *starget;
 
        if (shost->this_id == id)
@@ -1325,27 +1337,16 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
         * Scan LUN 0, if there is some response, scan further. Ideally, we
         * would not configure LUN 0 until all LUNs are scanned.
         */
-       res = scsi_probe_and_add_lun(starget, 0, &bflags, &sdev, rescan, NULL);
-       if (res == SCSI_SCAN_LUN_PRESENT) {
-               if (scsi_report_lun_scan(sdev, bflags, rescan) != 0)
+       res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL);
+       if (res == SCSI_SCAN_LUN_PRESENT || res == SCSI_SCAN_TARGET_PRESENT) {
+               if (scsi_report_lun_scan(starget, bflags, rescan) != 0)
                        /*
                         * The REPORT LUN did not scan the target,
                         * do a sequential scan.
                         */
                        scsi_sequential_lun_scan(starget, bflags,
-                                       res, sdev->scsi_level, rescan);
-       } else if (res == SCSI_SCAN_TARGET_PRESENT) {
-               /*
-                * There's a target here, but lun 0 is offline so we
-                * can't use the report_lun scan.  Fall back to a
-                * sequential lun scan with a bflags of SPARSELUN and
-                * a default scsi level of SCSI_2
-                */
-               scsi_sequential_lun_scan(starget, BLIST_SPARSELUN,
-                               SCSI_SCAN_TARGET_PRESENT, SCSI_2, rescan);
+                                       res, starget->scsi_level, rescan);
        }
-       if (sdev)
-               scsi_device_put(sdev);
 
  out_reap:
        /* now determine if the target has any children at all
@@ -1542,10 +1543,7 @@ void scsi_free_host_dev(struct scsi_device *sdev)
 {
        BUG_ON(sdev->id != sdev->host->this_id);
 
-       if (sdev->host->hostt->slave_destroy)
-               sdev->host->hostt->slave_destroy(sdev);
-       transport_destroy_device(&sdev->sdev_gendev);
-       put_device(&sdev->sdev_gendev);
+       scsi_destroy_sdev(sdev);
 }
 EXPORT_SYMBOL(scsi_free_host_dev);
 
index ff724bbe661101efdce6766bdd1ecb606934006a..1d145d2f9a38b37ed6a3b0b281f60e78aa1ee7c5 100644 (file)
@@ -628,17 +628,16 @@ sas_rphy_delete(struct sas_rphy *rphy)
        struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
        struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
 
-       transport_destroy_device(&rphy->dev);
+       scsi_remove_target(dev);
 
-       scsi_remove_target(&rphy->dev);
+       transport_remove_device(dev);
+       device_del(dev);
+       transport_destroy_device(dev);
 
        spin_lock(&sas_host->lock);
        list_del(&rphy->list);
        spin_unlock(&sas_host->lock);
 
-       transport_remove_device(dev);
-       device_del(dev);
-       transport_destroy_device(dev);
        put_device(&parent->dev);
 }
 EXPORT_SYMBOL(sas_rphy_delete);
index 4d09a6e4dd2ea7143cbeece3813cbc869a211a7d..ad94367df430a8d8df9d9b62109fc2bf545b7af9 100644 (file)
@@ -2849,8 +2849,7 @@ sg_proc_init(void)
        struct proc_dir_entry *pdep;
        struct sg_proc_leaf * leaf;
 
-       sg_proc_sgp = create_proc_entry(sg_proc_sg_dirname,
-                                       S_IFDIR | S_IRUGO | S_IXUGO, NULL);
+       sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL);
        if (!sg_proc_sgp)
                return 1;
        for (k = 0; k < num_leaves; ++k) {
index 4c985e6b3784b0b611413c74deba61a98c086997..4e1e80adaf11f4baae5d24e42dcfaaf1be2e26b7 100644 (file)
@@ -860,7 +860,7 @@ imx_console_setup(struct console *co, char *options)
        return uart_set_options(&sport->port, co, baud, parity, bits, flow);
 }
 
-extern struct uart_driver imx_reg;
+static struct uart_driver imx_reg;
 static struct console imx_console = {
        .name           = "ttySMX",
        .write          = imx_console_write,
index 0c5c96a582b340cec9ea60f12c71262e2ddea2cc..f88fdd48068584bae364d291d6eb0f399ce47948 100644 (file)
@@ -973,18 +973,6 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
                                this_ir &= ~this_mir;
                        }
                }
-               if (this_ir) {
-                       printk(KERN_ERR
-                              "unknown IOC4 %s interrupt 0x%x, sio_ir = 0x%x,"
-                               " sio_ies = 0x%x, other_ir = 0x%x :"
-                               "other_ies = 0x%x\n",
-                              (intr_type == IOC4_SIO_INTR_TYPE) ? "sio" :
-                              "other", this_ir,
-                              readl(&soft->is_ioc4_misc_addr->sio_ir.raw),
-                              readl(&soft->is_ioc4_misc_addr->sio_ies.raw),
-                              readl(&soft->is_ioc4_misc_addr->other_ir.raw),
-                              readl(&soft->is_ioc4_misc_addr->other_ies.raw));
-               }
        }
 #ifdef DEBUG_INTERRUPTS
        {
index c361c6fb08092135171a7165876bb52c27313f19..50d7870d92bb469dd2d13ee00a38d0e874d53dcc 100644 (file)
@@ -82,8 +82,6 @@
 #include <asm/arch/regs-serial.h>
 #include <asm/arch/regs-gpio.h>
 
-#include <asm/mach-types.h>
-
 /* structures */
 
 struct s3c24xx_uart_info {
@@ -753,8 +751,8 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
 {
        struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
        struct s3c24xx_uart_port *ourport = to_ourport(port);
-       struct s3c24xx_uart_clksrc *clksrc;
-       struct clk *clk;
+       struct s3c24xx_uart_clksrc *clksrc = NULL;
+       struct clk *clk = NULL;
        unsigned long flags;
        unsigned int baud, quot;
        unsigned int ulcon;
index 5959e6755a8149d4fd440592b2d6ae57fe25b929..656c0e8d160eac0dc9ee73fa5eea7bb903df050c 100644 (file)
@@ -518,11 +518,7 @@ static void sunsu_change_mouse_baud(struct uart_sunsu_port *up)
 
        quot = up->port.uartclk / (16 * new_baud);
 
-       spin_unlock(&up->port.lock);
-
        sunsu_change_speed(&up->port, up->cflag, 0, quot);
-
-       spin_lock(&up->port.lock);
 }
 
 static void receive_kbd_ms_chars(struct uart_sunsu_port *up, struct pt_regs *regs, int is_break)
index cbb451d227d215a372110204ab89950f93f66aed..6385d1a99b60588e97d8d6fd80fc837e0267d02c 100644 (file)
@@ -242,7 +242,6 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
        case HC_STATE_SUSPENDED:
                /* no DMA or IRQs except when HC is active */
                if (dev->current_state == PCI_D0) {
-                       free_irq (hcd->irq, hcd);
                        pci_save_state (dev);
                        pci_disable_device (dev);
                }
@@ -374,14 +373,6 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
 
        hcd->state = HC_STATE_RESUMING;
        hcd->saw_irq = 0;
-       retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ,
-                               hcd->irq_descr, hcd);
-       if (retval < 0) {
-               dev_err (hcd->self.controller,
-                       "can't restore IRQ after resume!\n");
-               usb_hc_died (hcd);
-               return retval;
-       }
 
        retval = hcd->driver->resume (hcd);
        if (!HC_IS_RUNNING (hcd->state)) {
index 817620d738414cdafd5caaa1bb6d5dd582754eee..859aca7be753bf6dfbc209e0bf19497834262e7a 100644 (file)
@@ -17,8 +17,6 @@
  */
 
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/arch/hardware.h>
 
 
 extern int usb_disabled(void);
index 5cde76faab935bb4376815e6652a423170539245..d8f3ba7ad52e2d9309da74ff0fb8badcdf0f239d 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/io.h>
 #include <asm/mach-types.h>
 
-#include <asm/arch/hardware.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/irqs.h>
 #include <asm/arch/gpio.h>
index 3d9bcf78a9a4f6ed0b9084ac220779342f009c40..da7d5478f74d716a43fce47553a602d747b0afce 100644 (file)
@@ -20,7 +20,6 @@
 */
 
 #include <asm/hardware.h>
-#include <asm/mach-types.h>
 #include <asm/hardware/clock.h>
 #include <asm/arch/usb-control.h>
 
index 4a5857c53f112dc53eed4e0794f8f2fd8a62994d..0bc0b1247a6bc69f4a6ce2fdf5c86a04b0509014 100644 (file)
@@ -1148,7 +1148,7 @@ vicam_write_proc_gain(struct file *file, const char *buffer,
 static void
 vicam_create_proc_root(void)
 {
-       vicam_proc_root = create_proc_entry("video/vicam", S_IFDIR, 0);
+       vicam_proc_root = proc_mkdir("video/vicam", NULL);
 
        if (vicam_proc_root)
                vicam_proc_root->owner = THIS_MODULE;
@@ -1181,7 +1181,7 @@ vicam_create_proc_entry(struct vicam_camera *cam)
 
        sprintf(name, "video%d", cam->vdev.minor);
 
-       cam->proc_dir = create_proc_entry(name, S_IFDIR, vicam_proc_root);
+       cam->proc_dir = proc_mkdir(name, vicam_proc_root);
 
        if ( !cam->proc_dir )
                return; // FIXME: We should probably return an error here
index 773ae11b4a19edfddf92b0333462d6ef19c000d3..1cd942abb58078c94080d093ead2d771e760b02a 100644 (file)
@@ -768,6 +768,7 @@ config FB_INTEL
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
+       select FB_SOFT_CURSOR
        help
          This driver supports the on-board graphics built in to the Intel
           830M/845G/852GM/855GM/865G chipsets.
index 046b47860266daa0ec4c45124d124e90c77a941a..8a24a66d9ba8f6e7033ce0a4667c613ba8e7a183 100644 (file)
@@ -475,7 +475,7 @@ static int __devinit radeon_probe_pll_params(struct radeonfb_info *rinfo)
         */
 
        /* Flush PCI buffers ? */
-       tmp = INREG(DEVICE_ID);
+       tmp = INREG16(DEVICE_ID);
 
        local_irq_disable();
 
index 59a1b6f85067863a87749913911b2386827ff898..097d668c4fe5932df13b40b2fcf08d8939321b8b 100644 (file)
@@ -62,9 +62,9 @@ static void radeon_pm_disable_dynamic_mode(struct radeonfb_info *rinfo)
                 OUTPLL(pllSCLK_CNTL, tmp);
                return;
        }
-       /* RV350 (M10) */
+       /* RV350 (M10/M11) */
        if (rinfo->family == CHIP_FAMILY_RV350) {
-                /* for RV350/M10, no delays are required. */
+                /* for RV350/M10/M11, no delays are required. */
                 tmp = INPLL(pllSCLK_CNTL2);
                 tmp |= (SCLK_CNTL2__R300_FORCE_TCL |
                         SCLK_CNTL2__R300_FORCE_GA  |
@@ -248,7 +248,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
                return;
        }
 
-       /* M10 */
+       /* M10/M11 */
        if (rinfo->family == CHIP_FAMILY_RV350) {
                tmp = INPLL(pllSCLK_CNTL2);
                tmp &= ~(SCLK_CNTL2__R300_FORCE_TCL |
@@ -1155,7 +1155,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
        OUTREG( CRTC_GEN_CNTL,  (crtcGenCntl | CRTC_GEN_CNTL__CRTC_DISP_REQ_EN_B) );
        OUTREG( CRTC2_GEN_CNTL, (crtcGenCntl2 | CRTC2_GEN_CNTL__CRTC2_DISP_REQ_EN_B) );
   
-       /* This is the code for the Aluminium PowerBooks M10 */
+       /* This is the code for the Aluminium PowerBooks M10 / iBooks M11 */
        if (rinfo->family == CHIP_FAMILY_RV350) {
                u32 sdram_mode_reg = rinfo->save_regs[35];
                static u32 default_mrtable[] =
@@ -2741,9 +2741,11 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk)
                        rinfo->pm_mode |= radeon_pm_d2;
 
                /* We can restart Jasper (M10 chip in albooks), BlueStone (7500 chip
-                * in some desktop G4s), and Via (M9+ chip on iBook G4)
+                * in some desktop G4s), Via (M9+ chip on iBook G4) and
+                * Snowy (M11 chip on iBook G4 manufactured after July 2005)
                 */
-               if (!strcmp(rinfo->of_node->name, "ATY,JasperParent")) {
+               if (!strcmp(rinfo->of_node->name, "ATY,JasperParent") ||
+                   !strcmp(rinfo->of_node->name, "ATY,SnowyParent")) {
                        rinfo->reinit_func = radeon_reinitialize_M10;
                        rinfo->pm_mode |= radeon_pm_off;
                }
index 659bc9f62244aa316190dddcfa8a0aa22c78ea71..01b8b2f785140677d249fb2d72e12cf6a4396472 100644 (file)
@@ -395,6 +395,8 @@ static inline void _radeon_msleep(struct radeonfb_info *rinfo, unsigned long ms)
 
 #define INREG8(addr)           readb((rinfo->mmio_base)+addr)
 #define OUTREG8(addr,val)      writeb(val, (rinfo->mmio_base)+addr)
+#define INREG16(addr)          readw((rinfo->mmio_base)+addr)
+#define OUTREG16(addr,val)     writew(val, (rinfo->mmio_base)+addr)
 #define INREG(addr)            readl((rinfo->mmio_base)+addr)
 #define OUTREG(addr,val)       writel(val, (rinfo->mmio_base)+addr)
 
index 630f2dfa9699efe8c3c6685d6956d5ba809c8098..3c72c627e65e99249ceadfbbcc5c8c4d02c8cca4 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/fb.h>
 #include <linux/backlight.h>
 
-#include <asm/mach-types.h>
 #include <asm/arch/sharpsl.h>
 
 #define CORGI_DEFAULT_INTENSITY                0x1f
index ae2762cb560828ab4f6ad8b654fa663c8ffb4fc8..6992100a508c09175cd527bcb9d10d977f3a769e 100644 (file)
@@ -410,20 +410,21 @@ static void cyblafb_imageblit(struct fb_info *info,
        out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1));
 
        while(index < index_end) {
+               const char *p = image->data + index;
                for(i=0;i<width_dds;i++) {
-                       out32(GE9C,*((u32*) ((u32)image->data + index)));
+                       out32(GE9C,*(u32*)p);
+                       p+=4;
                        index+=4;
                }
                switch(width_dbs) {
                case 0: break;
-               case 8: out32(GE9C,*((u8*)((u32)image->data+index)));
+               case 8: out32(GE9C,*(u8*)p);
                        index+=1;
                        break;
-               case 16: out32(GE9C,*((u16*)((u32)image->data+index)));
+               case 16: out32(GE9C,*(u16*)p);
                        index+=2;
                        break;
-               case 24: out32(GE9C,(u32)(*((u16*)((u32)image->data+index))) |
-                              (u32)(*((u8*)((u32)image->data+index+2)))<<16);
+               case 24: out32(GE9C,*(u16*)p | *(u8*)(p+2)<<16);
                        index+=3;
                        break;
                }
index fda53aac1fc100c07b4d1e69d7a0c1a9388090fc..689d2586366d7ffafbdb7c55741580f6f858f277 100644 (file)
@@ -44,7 +44,7 @@ static void i810i2c_setscl(void *data, int state)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                        *mmio = par->mmio_start_virtual;
+       u8                        __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR |
                    SCL_DIR_MASK | SCL_VAL_MASK);
@@ -55,7 +55,7 @@ static void i810i2c_setsda(void *data, int state)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                        *mmio = par->mmio_start_virtual;
+       u8                        __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR |
                    SDA_DIR_MASK | SDA_VAL_MASK);
@@ -66,7 +66,7 @@ static int i810i2c_getscl(void *data)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                        *mmio = par->mmio_start_virtual;
+       u8                        __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOB, SCL_DIR_MASK);
        i810_writel(mmio, GPIOB, 0);
@@ -77,7 +77,7 @@ static int i810i2c_getsda(void *data)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                        *mmio = par->mmio_start_virtual;
+       u8                        __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOB, SDA_DIR_MASK);
        i810_writel(mmio, GPIOB, 0);
@@ -88,7 +88,7 @@ static void i810ddc_setscl(void *data, int state)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par       *par = chan->par;
-       u8                      *mmio = par->mmio_start_virtual;
+       u8                      __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR |
                    SCL_DIR_MASK | SCL_VAL_MASK);
@@ -99,7 +99,7 @@ static void i810ddc_setsda(void *data, int state)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                      *mmio = par->mmio_start_virtual;
+       u8                      __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR |
                    SDA_DIR_MASK | SDA_VAL_MASK);
@@ -110,7 +110,7 @@ static int i810ddc_getscl(void *data)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                      *mmio = par->mmio_start_virtual;
+       u8                      __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOA, SCL_DIR_MASK);
        i810_writel(mmio, GPIOA, 0);
@@ -121,7 +121,7 @@ static int i810ddc_getsda(void *data)
 {
         struct i810fb_i2c_chan    *chan = (struct i810fb_i2c_chan *)data;
         struct i810fb_par         *par = chan->par;
-       u8                      *mmio = par->mmio_start_virtual;
+       u8                      __iomem *mmio = par->mmio_start_virtual;
 
        i810_writel(mmio, GPIOA, SDA_DIR_MASK);
        i810_writel(mmio, GPIOA, 0);
index 6c2244cf0e746156df2d4b574ef26703de16808e..1d54d3d6960b6f09be29a340794050a520d7f772 100644 (file)
@@ -36,7 +36,6 @@
 
 #include <asm/hardware.h>
 #include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/uaccess.h>
 #include <asm/arch/imxfb.h>
 
index bf62e6ed0382c9a0cabe0ba632288ff85d26f44a..80a09344f1aaedffd1e6e665dd26186fe70e84b4 100644 (file)
@@ -226,7 +226,7 @@ MODULE_DEVICE_TABLE(pci, intelfb_pci_table);
 
 static int accel        = 1;
 static int vram         = 4;
-static int hwcursor     = 1;
+static int hwcursor     = 0;
 static int mtrr         = 1;
 static int fixed        = 0;
 static int noinit       = 0;
@@ -609,15 +609,9 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
                dinfo->accel = 0;
        }
 
-       if (MB(voffset) < stolen_size)
-               offset = (stolen_size >> 12);
-       else
-               offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
-
        /* Framebuffer parameters - Use all the stolen memory if >= vram */
-       if (ROUND_UP_TO_PAGE(stolen_size) >= ((offset << 12) +  MB(vram))) {
+       if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) {
                dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size);
-               dinfo->fb.offset = 0;
                dinfo->fbmem_gart = 0;
        } else {
                dinfo->fb.size =  MB(vram);
@@ -648,6 +642,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
                return -ENODEV;
        }
 
+       if (MB(voffset) < stolen_size)
+               offset = (stolen_size >> 12);
+       else
+               offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
+
        /* set the mem offsets - set them after the already used pages */
        if (dinfo->accel) {
                dinfo->ring.offset = offset + gtt_info.current_memory;
@@ -662,10 +661,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
                        + (dinfo->cursor.size >> 12);
        }
 
+       /* Allocate memories (which aren't stolen) */
        /* Map the fb and MMIO regions */
        /* ioremap only up to the end of used aperture */
        dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache
-               (dinfo->aperture.physical, (dinfo->fb.offset << 12)
+               (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12)
                 + dinfo->fb.size);
        if (!dinfo->aperture.virtual) {
                ERR_MSG("Cannot remap FB region.\n");
@@ -682,7 +682,6 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
                return -ENODEV;
        }
 
-       /* Allocate memories (which aren't stolen) */
        if (dinfo->accel) {
                if (!(dinfo->gtt_ring_mem =
                      agp_allocate_memory(bridge, dinfo->ring.size >> 12,
@@ -1484,7 +1483,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 #endif
 
        if (!dinfo->hwcursor)
-               return -ENXIO;
+               return soft_cursor(info, cursor);
 
        intelfbhw_cursor_hide(dinfo);
 
index 7808a01493ad605b3344c64b51c0697fb356ed9d..b76a5a9a125be4dde6d77959e780aed6fa664391 100644 (file)
@@ -288,6 +288,9 @@ static void p9100_init_one(struct sbus_dev *sdev)
        all->par.physbase = sdev->reg_addrs[2].phys_addr;
 
        sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
+       all->info.var.red.length = 8;
+       all->info.var.green.length = 8;
+       all->info.var.blue.length = 8;
 
        linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
                                       all->info.var.xres);
@@ -323,6 +326,7 @@ static void p9100_init_one(struct sbus_dev *sdev)
                kfree(all);
                return;
        }
+       fb_set_cmap(&all->info.cmap, &all->info);
 
        list_add(&all->list, &p9100_list);
 
index 34d4dcc0320ac9774e2c480e0d9c43e140ead5fe..194eed0a238c9a355dd030d1051de9cf37d7a2bc 100644 (file)
@@ -260,9 +260,9 @@ static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        }
 
 #ifdef CONFIG_CPU_FREQ
-       DPRINTK("dma period = %d ps, clock = %d kHz\n",
-               pxafb_display_dma_period(var),
-               get_clk_frequency_khz(0));
+       pr_debug("pxafb: dma period = %d ps, clock = %d kHz\n",
+                pxafb_display_dma_period(var),
+                get_clk_frequency_khz(0));
 #endif
 
        return 0;
@@ -270,7 +270,7 @@ static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 
 static inline void pxafb_set_truecolor(u_int is_true_color)
 {
-       DPRINTK("true_color = %d\n", is_true_color);
+       pr_debug("pxafb: true_color = %d\n", is_true_color);
        // do your machine-specific setup if needed
 }
 
@@ -284,7 +284,7 @@ static int pxafb_set_par(struct fb_info *info)
        struct fb_var_screeninfo *var = &info->var;
        unsigned long palette_mem_size;
 
-       DPRINTK("set_par\n");
+       pr_debug("pxafb: set_par\n");
 
        if (var->bits_per_pixel == 16)
                fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR;
@@ -308,7 +308,7 @@ static int pxafb_set_par(struct fb_info *info)
 
        palette_mem_size = fbi->palette_size * sizeof(u16);
 
-       DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
+       pr_debug("pxafb: palette_mem_size = 0x%08lx\n", palette_mem_size);
 
        fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);
        fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
@@ -369,7 +369,7 @@ static int pxafb_blank(int blank, struct fb_info *info)
        struct pxafb_info *fbi = (struct pxafb_info *)info;
        int i;
 
-       DPRINTK("pxafb_blank: blank=%d\n", blank);
+       pr_debug("pxafb: blank=%d\n", blank);
 
        switch (blank) {
        case FB_BLANK_POWERDOWN:
@@ -508,15 +508,15 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
        u_long flags;
        u_int lines_per_panel, pcd = get_pcd(var->pixclock);
 
-       DPRINTK("Configuring PXA LCD\n");
+       pr_debug("pxafb: Configuring PXA LCD\n");
 
-       DPRINTK("var: xres=%d hslen=%d lm=%d rm=%d\n",
-               var->xres, var->hsync_len,
-               var->left_margin, var->right_margin);
-       DPRINTK("var: yres=%d vslen=%d um=%d bm=%d\n",
-               var->yres, var->vsync_len,
-               var->upper_margin, var->lower_margin);
-       DPRINTK("var: pixclock=%d pcd=%d\n", var->pixclock, pcd);
+       pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n",
+                var->xres, var->hsync_len,
+                var->left_margin, var->right_margin);
+       pr_debug("var: yres=%d vslen=%d um=%d bm=%d\n",
+                var->yres, var->vsync_len,
+                var->upper_margin, var->lower_margin);
+       pr_debug("var: pixclock=%d pcd=%d\n", var->pixclock, pcd);
 
 #if DEBUG_VAR
        if (var->xres < 16        || var->xres > 1024)
@@ -589,10 +589,10 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
        if (pcd)
                new_regs.lccr3 |= LCCR3_PixClkDiv(pcd);
 
-       DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0);
-       DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1);
-       DPRINTK("nlccr2 = 0x%08x\n", new_regs.lccr2);
-       DPRINTK("nlccr3 = 0x%08x\n", new_regs.lccr3);
+       pr_debug("nlccr0 = 0x%08x\n", new_regs.lccr0);
+       pr_debug("nlccr1 = 0x%08x\n", new_regs.lccr1);
+       pr_debug("nlccr2 = 0x%08x\n", new_regs.lccr2);
+       pr_debug("nlccr3 = 0x%08x\n", new_regs.lccr3);
 
        /* Update shadow copy atomically */
        local_irq_save(flags);
@@ -637,24 +637,24 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
        }
 
 #if 0
-       DPRINTK("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu);
-       DPRINTK("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu);
-       DPRINTK("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma);
-       DPRINTK("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma);
-       DPRINTK("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma);
-
-       DPRINTK("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr);
-       DPRINTK("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr);
-
-       DPRINTK("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr);
-       DPRINTK("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr);
-
-       DPRINTK("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd);
-       DPRINTK("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd);
-       DPRINTK("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd);
+       pr_debug("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu);
+       pr_debug("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu);
+       pr_debug("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu);
+       pr_debug("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma);
+       pr_debug("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma);
+       pr_debug("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma);
+
+       pr_debug("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr);
+       pr_debug("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr);
+       pr_debug("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr);
+
+       pr_debug("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr);
+       pr_debug("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr);
+       pr_debug("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr);
+
+       pr_debug("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd);
+       pr_debug("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd);
+       pr_debug("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd);
 #endif
 
        fbi->reg_lccr0 = new_regs.lccr0;
@@ -684,7 +684,7 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
  */
 static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
 {
-       DPRINTK("backlight o%s\n", on ? "n" : "ff");
+       pr_debug("pxafb: backlight o%s\n", on ? "n" : "ff");
 
        if (pxafb_backlight_power)
                pxafb_backlight_power(on);
@@ -692,7 +692,7 @@ static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
 
 static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
 {
-       DPRINTK("LCD power o%s\n", on ? "n" : "ff");
+       pr_debug("pxafb: LCD power o%s\n", on ? "n" : "ff");
 
        if (pxafb_lcd_power)
                pxafb_lcd_power(on);
@@ -740,13 +740,13 @@ static void pxafb_setup_gpio(struct pxafb_info *fbi)
 
 static void pxafb_enable_controller(struct pxafb_info *fbi)
 {
-       DPRINTK("Enabling LCD controller\n");
-       DPRINTK("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0);
-       DPRINTK("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1);
-       DPRINTK("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0);
-       DPRINTK("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1);
-       DPRINTK("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2);
-       DPRINTK("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3);
+       pr_debug("pxafb: Enabling LCD controller\n");
+       pr_debug("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0);
+       pr_debug("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1);
+       pr_debug("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0);
+       pr_debug("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1);
+       pr_debug("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2);
+       pr_debug("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3);
 
        /* enable LCD controller clock */
        pxa_set_cken(CKEN16_LCD, 1);
@@ -761,19 +761,19 @@ static void pxafb_enable_controller(struct pxafb_info *fbi)
        FDADR1 = fbi->fdadr1;
        LCCR0 |= LCCR0_ENB;
 
-       DPRINTK("FDADR0 0x%08x\n", (unsigned int) FDADR0);
-       DPRINTK("FDADR1 0x%08x\n", (unsigned int) FDADR1);
-       DPRINTK("LCCR0 0x%08x\n", (unsigned int) LCCR0);
-       DPRINTK("LCCR1 0x%08x\n", (unsigned int) LCCR1);
-       DPRINTK("LCCR2 0x%08x\n", (unsigned int) LCCR2);
-       DPRINTK("LCCR3 0x%08x\n", (unsigned int) LCCR3);
+       pr_debug("FDADR0 0x%08x\n", (unsigned int) FDADR0);
+       pr_debug("FDADR1 0x%08x\n", (unsigned int) FDADR1);
+       pr_debug("LCCR0 0x%08x\n", (unsigned int) LCCR0);
+       pr_debug("LCCR1 0x%08x\n", (unsigned int) LCCR1);
+       pr_debug("LCCR2 0x%08x\n", (unsigned int) LCCR2);
+       pr_debug("LCCR3 0x%08x\n", (unsigned int) LCCR3);
 }
 
 static void pxafb_disable_controller(struct pxafb_info *fbi)
 {
        DECLARE_WAITQUEUE(wait, current);
 
-       DPRINTK("Disabling LCD controller\n");
+       pr_debug("pxafb: disabling LCD controller\n");
 
        set_current_state(TASK_UNINTERRUPTIBLE);
        add_wait_queue(&fbi->ctrlr_wait, &wait);
@@ -1039,7 +1039,7 @@ static int __init pxafb_map_video_memory(struct pxafb_info *fbi)
                fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16;
 
                palette_mem_size = fbi->palette_size * sizeof(u16);
-               DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
+               pr_debug("pxafb: palette_mem_size = 0x%08lx\n", palette_mem_size);
 
                fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);
                fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
index 22c00be786a8e28e12327051ae6473bb81eb4c47..47f41f70db7a042c821ddc65832529487364f26b 100644 (file)
@@ -113,15 +113,6 @@ struct pxafb_info {
 
 #define PXA_NAME       "PXA"
 
-/*
- *  Debug macros
- */
-#if DEBUG
-#  define DPRINTK(fmt, args...)        printk("%s: " fmt, __FUNCTION__ , ## args)
-#else
-#  define DPRINTK(fmt, args...)
-#endif
-
 /*
  * Minimum X and Y resolutions
  */
index 00c0223a352ea861b7318d9a81af2f3a0c09f406..5ab79afb53b78bdce439488c1fa53ce457290471 100644 (file)
@@ -228,8 +228,8 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
  * information
 */
 
-static int s3c2410fb_activate_var(struct s3c2410fb_info *fbi,
-                                 struct fb_var_screeninfo *var)
+static void s3c2410fb_activate_var(struct s3c2410fb_info *fbi,
+                                  struct fb_var_screeninfo *var)
 {
        fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
 
index 0957f4da91d46ffbe19e3c1687263e6d2fe75127..82c5b00840796d5f82bd6810a92f783b11e953d1 100644 (file)
@@ -129,7 +129,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type
 
        if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) {
                dprintk(DEBUG_ERROR, "problem initiating session\n");
-               return newfid;
+               return ERR_PTR(newfid);
        }
 
        sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
index 0e11e31dbb77147078b79eaad3fc97c70b79321d..d6b1551342b7206bff66323d60c6a8126bcaf813 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -741,19 +741,9 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
        ret = retry(iocb);
        current->io_wait = NULL;
 
-       if (-EIOCBRETRY != ret) {
-               if (-EIOCBQUEUED != ret) {
-                       BUG_ON(!list_empty(&iocb->ki_wait.task_list));
-                       aio_complete(iocb, ret, 0);
-                       /* must not access the iocb after this */
-               }
-       } else {
-               /*
-                * Issue an additional retry to avoid waiting forever if
-                * no waits were queued (e.g. in case of a short read).
-                */
-               if (list_empty(&iocb->ki_wait.task_list))
-                       kiocbSetKicked(iocb);
+       if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) {
+               BUG_ON(!list_empty(&iocb->ki_wait.task_list));
+               aio_complete(iocb, ret, 0);
        }
 out:
        spin_lock_irq(&ctx->ctx_lock);
@@ -899,16 +889,24 @@ static void aio_kick_handler(void *data)
  * and if required activate the aio work queue to process
  * it
  */
-static void queue_kicked_iocb(struct kiocb *iocb)
+static void try_queue_kicked_iocb(struct kiocb *iocb)
 {
        struct kioctx   *ctx = iocb->ki_ctx;
        unsigned long flags;
        int run = 0;
 
-       WARN_ON((!list_empty(&iocb->ki_wait.task_list)));
+       /* We're supposed to be the only path putting the iocb back on the run
+        * list.  If we find that the iocb is *back* on a wait queue already
+        * than retry has happened before we could queue the iocb.  This also
+        * means that the retry could have completed and freed our iocb, no
+        * good. */
+       BUG_ON((!list_empty(&iocb->ki_wait.task_list)));
 
        spin_lock_irqsave(&ctx->ctx_lock, flags);
-       run = __queue_kicked_iocb(iocb);
+       /* set this inside the lock so that we can't race with aio_run_iocb()
+        * testing it and putting the iocb on the run list under the lock */
+       if (!kiocbTryKick(iocb))
+               run = __queue_kicked_iocb(iocb);
        spin_unlock_irqrestore(&ctx->ctx_lock, flags);
        if (run)
                aio_queue_work(ctx);
@@ -931,10 +929,7 @@ void fastcall kick_iocb(struct kiocb *iocb)
                return;
        }
 
-       /* If its already kicked we shouldn't queue it again */
-       if (!kiocbTryKick(iocb)) {
-               queue_kicked_iocb(iocb);
-       }
+       try_queue_kicked_iocb(iocb);
 }
 EXPORT_SYMBOL(kick_iocb);
 
@@ -1322,8 +1317,11 @@ asmlinkage long sys_io_destroy(aio_context_t ctx)
 }
 
 /*
- * Default retry method for aio_read (also used for first time submit)
- * Responsible for updating iocb state as retries progress
+ * aio_p{read,write} are the default  ki_retry methods for
+ * IO_CMD_P{READ,WRITE}.  They maintains kiocb retry state around potentially
+ * multiple calls to f_op->aio_read().  They loop around partial progress
+ * instead of returning -EIOCBRETRY because they don't have the means to call
+ * kick_iocb().
  */
 static ssize_t aio_pread(struct kiocb *iocb)
 {
@@ -1332,25 +1330,25 @@ static ssize_t aio_pread(struct kiocb *iocb)
        struct inode *inode = mapping->host;
        ssize_t ret = 0;
 
-       ret = file->f_op->aio_read(iocb, iocb->ki_buf,
-               iocb->ki_left, iocb->ki_pos);
+       do {
+               ret = file->f_op->aio_read(iocb, iocb->ki_buf,
+                       iocb->ki_left, iocb->ki_pos);
+               /*
+                * Can't just depend on iocb->ki_left to determine
+                * whether we are done. This may have been a short read.
+                */
+               if (ret > 0) {
+                       iocb->ki_buf += ret;
+                       iocb->ki_left -= ret;
+               }
 
-       /*
-        * Can't just depend on iocb->ki_left to determine
-        * whether we are done. This may have been a short read.
-        */
-       if (ret > 0) {
-               iocb->ki_buf += ret;
-               iocb->ki_left -= ret;
                /*
-                * For pipes and sockets we return once we have
-                * some data; for regular files we retry till we
-                * complete the entire read or find that we can't
-                * read any more data (e.g short reads).
+                * For pipes and sockets we return once we have some data; for
+                * regular files we retry till we complete the entire read or
+                * find that we can't read any more data (e.g short reads).
                 */
-               if (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode))
-                       ret = -EIOCBRETRY;
-       }
+       } while (ret > 0 && iocb->ki_left > 0 &&
+                !S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode));
 
        /* This means we must have transferred all that we could */
        /* No need to retry anymore */
@@ -1360,27 +1358,21 @@ static ssize_t aio_pread(struct kiocb *iocb)
        return ret;
 }
 
-/*
- * Default retry method for aio_write (also used for first time submit)
- * Responsible for updating iocb state as retries progress
- */
+/* see aio_pread() */
 static ssize_t aio_pwrite(struct kiocb *iocb)
 {
        struct file *file = iocb->ki_filp;
        ssize_t ret = 0;
 
-       ret = file->f_op->aio_write(iocb, iocb->ki_buf,
-               iocb->ki_left, iocb->ki_pos);
-
-       if (ret > 0) {
-               iocb->ki_buf += ret;
-               iocb->ki_left -= ret;
-
-               ret = -EIOCBRETRY;
-       }
+       do {
+               ret = file->f_op->aio_write(iocb, iocb->ki_buf,
+                       iocb->ki_left, iocb->ki_pos);
+               if (ret > 0) {
+                       iocb->ki_buf += ret;
+                       iocb->ki_left -= ret;
+               }
+       } while (ret > 0 && iocb->ki_left > 0);
 
-       /* This means we must have transferred all that we could */
-       /* No need to retry anymore */
        if ((ret == 0) || (iocb->ki_left == 0))
                ret = iocb->ki_nbytes - iocb->ki_left;
 
index e240c335eb231eebea5ecb9aeb73d378e22084bb..5af928fa044909a63d0f82297ee4a70ffec6b71c 100644 (file)
@@ -108,7 +108,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode,
        inode->i_mapping->a_ops = &bfs_aops;
        inode->i_mode = mode;
        inode->i_ino = ino;
-       BFS_I(inode)->i_dsk_ino = cpu_to_le16(ino);
+       BFS_I(inode)->i_dsk_ino = ino;
        BFS_I(inode)->i_sblock = 0;
        BFS_I(inode)->i_eblock = 0;
        insert_inode_hash(inode);
index c7b39aa279d71098804570c0283d4195d54cf10a..3af6c73c5b5a69fe3831e6e8d6b588715f0dfb69 100644 (file)
@@ -357,28 +357,46 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
        }
 
        info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */
-       info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 -  cpu_to_le32(bfs_sb->s_start))>>BFS_BSIZE_BITS;
+       info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 -  le32_to_cpu(bfs_sb->s_start))>>BFS_BSIZE_BITS;
        info->si_freei = 0;
        info->si_lf_eblk = 0;
        info->si_lf_sblk = 0;
        info->si_lf_ioff = 0;
+       bh = NULL;
        for (i=BFS_ROOT_INO; i<=info->si_lasti; i++) {
-               inode = iget(s,i);
-               if (BFS_I(inode)->i_dsk_ino == 0)
+               struct bfs_inode *di;
+               int block = (i - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1;
+               int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
+               unsigned long sblock, eblock;
+
+               if (!off) {
+                       brelse(bh);
+                       bh = sb_bread(s, block);
+               }
+
+               if (!bh)
+                       continue;
+
+               di = (struct bfs_inode *)bh->b_data + off;
+
+               if (!di->i_ino) {
                        info->si_freei++;
-               else {
-                       set_bit(i, info->si_imap);
-                       info->si_freeb -= inode->i_blocks;
-                       if (BFS_I(inode)->i_eblock > info->si_lf_eblk) {
-                               info->si_lf_eblk = BFS_I(inode)->i_eblock;
-                               info->si_lf_sblk = BFS_I(inode)->i_sblock;
-                               info->si_lf_ioff = BFS_INO2OFF(i);
-                       }
+                       continue;
+               }
+               set_bit(i, info->si_imap);
+               info->si_freeb -= BFS_FILEBLOCKS(di);
+
+               sblock =  le32_to_cpu(di->i_sblock);
+               eblock =  le32_to_cpu(di->i_eblock);
+               if (eblock > info->si_lf_eblk) {
+                       info->si_lf_eblk = eblock;
+                       info->si_lf_sblk = sblock;
+                       info->si_lf_ioff = BFS_INO2OFF(i);
                }
-               iput(inode);
        }
+       brelse(bh);
        if (!(s->s_flags & MS_RDONLY)) {
-               mark_buffer_dirty(bh);
+               mark_buffer_dirty(info->si_sbh);
                s->s_dirt = 1;
        } 
        dump_imap("read_super", s);
index 6454022b05367c3818fa24e3d7dab7dd5a45bfae..657ab11c173b38a05678f49c05accc7313b02ede 100644 (file)
@@ -23,6 +23,10 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir)
        struct fuse_file *ff;
        int err;
 
+       /* VFS checks this, but only _after_ ->open() */
+       if (file->f_flags & O_DIRECT)
+               return -EINVAL;
+
        err = generic_file_open(inode, file);
        if (err)
                return err;
index 59c5062cd63f3bcc8af85edbdabda742a0c88325..dd7113106269992822e97e4bbf07ad2bc5ab5eca 100644 (file)
@@ -793,11 +793,6 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
        return(err);
 }
 
-void hostfs_truncate(struct inode *ino)
-{
-       not_implemented();
-}
-
 int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
 {
        char *name;
@@ -894,7 +889,6 @@ static struct inode_operations hostfs_iops = {
        .rmdir          = hostfs_rmdir,
        .mknod          = hostfs_mknod,
        .rename         = hostfs_rename,
-       .truncate       = hostfs_truncate,
        .permission     = hostfs_permission,
        .setattr        = hostfs_setattr,
        .getattr        = hostfs_getattr,
@@ -910,7 +904,6 @@ static struct inode_operations hostfs_dir_iops = {
        .rmdir          = hostfs_rmdir,
        .mknod          = hostfs_mknod,
        .rename         = hostfs_rename,
-       .truncate       = hostfs_truncate,
        .permission     = hostfs_permission,
        .setattr        = hostfs_setattr,
        .getattr        = hostfs_getattr,
index 043d587216b5a3f3354a75878827df61956facc4..aa62dbda93ac01234670658a315c5472552238aa 100644 (file)
@@ -1551,19 +1551,19 @@ do_link:
        if (nd->last_type != LAST_NORM)
                goto exit;
        if (nd->last.name[nd->last.len]) {
-               putname(nd->last.name);
+               __putname(nd->last.name);
                goto exit;
        }
        error = -ELOOP;
        if (count++==32) {
-               putname(nd->last.name);
+               __putname(nd->last.name);
                goto exit;
        }
        dir = nd->dentry;
        down(&dir->d_inode->i_sem);
        path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
        path.mnt = nd->mnt;
-       putname(nd->last.name);
+       __putname(nd->last.name);
        goto do_last;
 }
 
index 83f3322765cd1d47f08398f797550d26b0db5835..de58579a1d0e77a84e4f7d5fcc63c8eadcbb494d 100644 (file)
@@ -102,6 +102,9 @@ ToDo/Notes:
          inode instead of a vfs inode as parameter.
        - Fix the definition of the CHKD ntfs record magic.  It had an off by
          two error causing it to be CHKB instead of CHKD.
+       - Fix a stupid bug in __ntfs_bitmap_set_bits_in_run() which caused the
+         count to become negative and hence we had a wild memset() scribbling
+         all over the system's ram.
 
 2.1.23 - Implement extension of resident files and make writing safe as well as
         many bug fixes, cleanups, and enhancements...
index 12cf2e30c7dda9a2a8234af1c3b5a710f85aab72..7a190cdc60e2f4d403d157e2b5c912f182e4bf46 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * bitmap.c - NTFS kernel bitmap handling.  Part of the Linux-NTFS project.
  *
- * Copyright (c) 2004 Anton Altaparmakov
+ * Copyright (c) 2004-2005 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -90,7 +90,8 @@ int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
        /* If the first byte is partial, modify the appropriate bits in it. */
        if (bit) {
                u8 *byte = kaddr + pos;
-               while ((bit & 7) && cnt--) {
+               while ((bit & 7) && cnt) {
+                       cnt--;
                        if (value)
                                *byte |= 1 << bit++;
                        else
index 01f2dfa39cecaf29f3af0964247c1abd9a008670..5c248d404f05432277be8b0d9fb147ff549578b3 100644 (file)
@@ -309,7 +309,7 @@ typedef le16 MFT_RECORD_FLAGS;
  * Note: The _LE versions will return a CPU endian formatted value!
  */
 #define MFT_REF_MASK_CPU 0x0000ffffffffffffULL
-#define MFT_REF_MASK_LE const_cpu_to_le64(0x0000ffffffffffffULL)
+#define MFT_REF_MASK_LE const_cpu_to_le64(MFT_REF_MASK_CPU)
 
 typedef u64 MFT_REF;
 typedef le64 leMFT_REF;
index 247586d1d5dc52787c36233c60f10f32105f0bc3..b011369b59561139687e627f211207dc4edff72e 100644 (file)
@@ -58,7 +58,8 @@ static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni)
         * overflowing the unsigned long, but I don't think we would ever get
         * here if the volume was that big...
         */
-       index = ni->mft_no << vol->mft_record_size_bits >> PAGE_CACHE_SHIFT;
+       index = (u64)ni->mft_no << vol->mft_record_size_bits >>
+                       PAGE_CACHE_SHIFT;
        ofs = (ni->mft_no << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK;
 
        i_size = i_size_read(mft_vi);
index a389a5a16c84af96be71d6c399b3d7f9b1e52d17..0ea887fc859cc358dca5276f65ea1bcc9bb04e2f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * unistr.c - NTFS Unicode string handling. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001-2004 Anton Altaparmakov
+ * Copyright (c) 2001-2005 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
index b60324aaa2b6731d9ddedd67badaa7b5c9790a60..a091ee4f430df6cc83317b59c4a2fc363c005080 100644 (file)
@@ -497,6 +497,9 @@ static ssize_t do_readv_writev(int type, struct file *file,
        }
 
        ret = rw_verify_area(type, file, pos, tot_len);
+       if (ret)
+               goto out;
+       ret = security_file_permission(file, type == READ ? MAY_READ : MAY_WRITE);
        if (ret)
                goto out;
 
index 0b025e227ec20a8d168414ca9824b12e695446f0..09eda84592ffc03a0cb2f967d44d3f3d0f669197 100644 (file)
 static void arch_idle(void)
 {
        CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_IDLE;
-       __asm__ __volatile__(
-       "mov    r0, r0\n\t"
-       "mov    r0, r0");
+       nop();
+       nop();
+       CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_RUN;
+       nop();
+       nop();
 }
 
 
index 93b840e8fa603d32d5b9e6fcfbbb33e7fa0e0b37..229f7008d74f2ff0a393a162ee3bde19850bcbcf 100644 (file)
@@ -76,6 +76,7 @@
 #define GPIO_PIN_MASK 0x1f
 #define GPIO_PORT_MASK (0x3 << 5)
 
+#define GPIO_PORT_SHIFT 5
 #define GPIO_PORTA (0<<5)
 #define GPIO_PORTB (1<<5)
 #define GPIO_PORTC (2<<5)
 #define GPIO_PF    (0<<9)
 #define GPIO_AF    (1<<9)
 
+#define GPIO_OCR_SHIFT 10
 #define GPIO_OCR_MASK (3<<10)
 #define GPIO_AIN   (0<<10)
 #define GPIO_BIN   (1<<10)
 #define GPIO_CIN   (2<<10)
-#define GPIO_GPIO  (3<<10)
+#define GPIO_DR    (3<<10)
 
-#define GPIO_AOUT  (1<<12)
-#define GPIO_BOUT  (1<<13)
+#define GPIO_AOUT_SHIFT 12
+#define GPIO_AOUT_MASK (3<<12)
+#define GPIO_AOUT     (0<<12)
+#define GPIO_AOUT_ISR (1<<12)
+#define GPIO_AOUT_0   (2<<12)
+#define GPIO_AOUT_1   (3<<12)
+
+#define GPIO_BOUT_SHIFT 14
+#define GPIO_BOUT_MASK (3<<14)
+#define GPIO_BOUT      (0<<14)
+#define GPIO_BOUT_ISR  (1<<14)
+#define GPIO_BOUT_0    (2<<14)
+#define GPIO_BOUT_1    (3<<14)
+
+#define GPIO_GIUS      (1<<16)
 
 /* assignements for GPIO alternate/primary functions */
 
 /* FIXME: This list is not completed. The correct directions are
  * missing on some (many) pins
  */
-#define PA0_PF_A24           ( GPIO_PORTA | GPIO_PF | 0 )
-#define PA0_AIN_SPI2_CLK     ( GPIO_PORTA | GPIO_OUT | GPIO_AIN | 0 )
+#define PA0_AIN_SPI2_CLK     ( GPIO_GIUS | GPIO_PORTA | GPIO_OUT | 0 )
 #define PA0_AF_ETMTRACESYNC  ( GPIO_PORTA | GPIO_AF | 0 )
-#define PA1_AOUT_SPI2_RXD    ( GPIO_PORTA | GPIO_IN | GPIO_AOUT | 1 )
+#define PA1_AOUT_SPI2_RXD    ( GPIO_GIUS | GPIO_PORTA | GPIO_IN | 1 )
 #define PA1_PF_TIN           ( GPIO_PORTA | GPIO_PF | 1 )
 #define PA2_PF_PWM0          ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 2 )
 #define PA3_PF_CSI_MCLK      ( GPIO_PORTA | GPIO_PF | 3 )
 #define PA15_PF_I2C_SDA      ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 15 )
 #define PA16_PF_I2C_SCL      ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 16 )
 #define PA17_AF_ETMTRACEPKT4 ( GPIO_PORTA | GPIO_AF | 17 )
-#define PA17_AIN_SPI2_SS     ( GPIO_PORTA | GPIO_AIN | 17 )
+#define PA17_AIN_SPI2_SS     ( GPIO_GIUS | GPIO_PORTA | GPIO_OUT | 17 )
 #define PA18_AF_ETMTRACEPKT5 ( GPIO_PORTA | GPIO_AF | 18 )
 #define PA19_AF_ETMTRACEPKT6 ( GPIO_PORTA | GPIO_AF | 19 )
 #define PA20_AF_ETMTRACEPKT7 ( GPIO_PORTA | GPIO_AF | 20 )
 #define PC15_PF_SPI1_SS      ( GPIO_PORTC | GPIO_PF | 15 )
 #define PC16_PF_SPI1_MISO    ( GPIO_PORTC | GPIO_PF | 16 )
 #define PC17_PF_SPI1_MOSI    ( GPIO_PORTC | GPIO_PF | 17 )
+#define PC24_BIN_UART3_RI    ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 24 )
+#define PC25_BIN_UART3_DSR   ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 25 )
+#define PC26_AOUT_UART3_DTR  ( GPIO_GIUS | GPIO_PORTC | GPIO_IN | 26 )
+#define PC27_BIN_UART3_DCD   ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 27 )
+#define PC28_BIN_UART3_CTS   ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 28 )
+#define PC29_AOUT_UART3_RTS  ( GPIO_GIUS | GPIO_PORTC | GPIO_IN | 29 )
+#define PC30_BIN_UART3_TX    ( GPIO_GIUS | GPIO_PORTC | GPIO_BIN | 30 )
+#define PC31_AOUT_UART3_RX   ( GPIO_GIUS | GPIO_PORTC | GPIO_IN | 31)
 #define PD6_PF_LSCLK         ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 6 )
 #define PD7_PF_REV           ( GPIO_PORTD | GPIO_PF | 7 )
 #define PD7_AF_UART2_DTR     ( GPIO_PORTD | GPIO_IN | GPIO_AF | 7 )
-#define PD7_AIN_SPI2_SCLK    ( GPIO_PORTD | GPIO_AIN | 7 )
+#define PD7_AIN_SPI2_SCLK    ( GPIO_GIUS | GPIO_PORTD | GPIO_AIN | 7 )
 #define PD8_PF_CLS           ( GPIO_PORTD | GPIO_PF | 8 )
 #define PD8_AF_UART2_DCD     ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 8 )
-#define PD8_AIN_SPI2_SS      ( GPIO_PORTD | GPIO_AIN | 8 )
+#define PD8_AIN_SPI2_SS      ( GPIO_GIUS | GPIO_PORTD | GPIO_AIN | 8 )
 #define PD9_PF_PS            ( GPIO_PORTD | GPIO_PF | 9 )
 #define PD9_AF_UART2_RI      ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 9 )
-#define PD9_AOUT_SPI2_RXD    ( GPIO_PORTD | GPIO_IN | GPIO_AOUT | 9 )
+#define PD9_AOUT_SPI2_RXD    ( GPIO_GIUS | GPIO_PORTD | GPIO_IN | 9 )
 #define PD10_PF_SPL_SPR      ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 10 )
 #define PD10_AF_UART2_DSR    ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 10 )
-#define PD10_AIN_SPI2_TXD    ( GPIO_PORTD | GPIO_OUT | GPIO_AIN | 10 )
+#define PD10_AIN_SPI2_TXD    ( GPIO_GIUS | GPIO_PORTD | GPIO_OUT | 10 )
 #define PD11_PF_CONTRAST     ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 11 )
 #define PD12_PF_ACD_OE       ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 12 )
 #define PD13_PF_LP_HSYNC     ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 13 )
 #define PD29_PF_LD14         ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 29 )
 #define PD30_PF_LD15         ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 30 )
 #define PD31_PF_TMR2OUT      ( GPIO_PORTD | GPIO_PF | 31 )
-#define PD31_BIN_SPI2_TXD    ( GPIO_PORTD | GPIO_BIN | 31 )
+#define PD31_BIN_SPI2_TXD    ( GPIO_GIUS | GPIO_PORTD | GPIO_BIN | 31 )
 
 /*
  * PWM controller
index d13ee7f78c70a93b6528b06874971fdf4961cb49..f14ed63590c36cd80980fab6c9cf8eaeb08e1cf1 100644 (file)
@@ -93,7 +93,7 @@ extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
 
 static inline void gpio_line_config(u8 line, u32 direction)
 {
-       if (direction == IXP4XX_GPIO_OUT)
+       if (direction == IXP4XX_GPIO_IN)
                *IXP4XX_GPIO_GPOER |= (1 << line);
        else
                *IXP4XX_GPIO_GPOER &= ~(1 << line);
index be9754a05c19faa9b8fa1833d00cae4eb2fe11df..9d7f87375aa774b477485aa79eb422d00c9536ac 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/arch/memory.h>
 
 #ifndef __ASSEMBLY__
-#define IOMEM(x) ((void __iomem *)(x))
+#define IOMEM(x) ((void __iomem *)(unsigned long)(x))
 #else
 #define IOMEM(x) x
 #endif /* __ASSEMBLY__ */
@@ -52,7 +52,7 @@
 /*
  * IO Addresses
  */
-#define VIDC_BASE              (void __iomem *)0xe0400000
+#define VIDC_BASE              IOMEM(0xe0400000)
 #define EXPMASK_BASE           0xe0360000
 #define IOMD_BASE              IOMEM(0xe0200000)
 #define IOC_BASE               IOMEM(0xe0200000)
index 9f895bf61494308a2c2add721009c3699125781d..47e904cf25c748b6f19fca6e7b9ab70c9aa3ded3 100644 (file)
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define __io(a)                        ((void __iomem *)(a))
+static inline void __iomem *__io(unsigned long addr)
+{
+       return (void __iomem *)addr;
+}
+#define __io(a)        __io(a)
 #define __mem_pci(a)           (a)
 #define __mem_isa(a)           (a)
 
index a1696ba238d3aad1c891f194ac93d8c0b73c1362..7da97a937548afd05a977ceb0d2148821dc05cfb 100644 (file)
@@ -124,6 +124,8 @@ do { \
        if (((ex).e_flags & EF_ARM_EABI_MASK) || \
            ((ex).e_flags & EF_ARM_SOFT_FLOAT)) \
                set_thread_flag(TIF_USING_IWMMXT); \
+       else \
+               clear_thread_flag(TIF_USING_IWMMXT); \
 } while (0)
 
 #endif
index 4ac84cc6f01ac8c81fd16c9734a216a5cb4543f2..622815bf3243e00306774bbea1ab01e2bc2a2f3e 100644 (file)
@@ -18,6 +18,8 @@
 #include <asm/irq.h>
 #include <asm/sections.h>
 
+struct hw_interrupt_type;
+
 /*
  * Various low-level irq details needed by irq.c, process.c,
  * time.c, io_apic.c and smp.c
index 3a7829bb5954030cfb3a2eee73620de5a3f37403..9adb51211c2270d7500dfb00d8ed3a59264651e6 100644 (file)
@@ -187,8 +187,8 @@ extern void __get_user_unknown (void);
 ({                                                                                     \
        const __typeof__(*(ptr)) __user *__gu_ptr = (ptr);                              \
        __typeof__ (size) __gu_size = (size);                                           \
-       long __gu_err = -EFAULT, __gu_val = 0;                                          \
-                                                                                       \
+       long __gu_err = -EFAULT;                                                        \
+       unsigned long __gu_val = 0;                                                     \
        if (!check || __access_ok(__gu_ptr, size, segment))                             \
                switch (__gu_size) {                                                    \
                      case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break;  \
@@ -240,13 +240,13 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
 static inline unsigned long
 __copy_to_user (void __user *to, const void *from, unsigned long count)
 {
-       return __copy_user(to, (void __user *) from, count);
+       return __copy_user(to, (__force void __user *) from, count);
 }
 
 static inline unsigned long
 __copy_from_user (void *to, const void __user *from, unsigned long count)
 {
-       return __copy_user((void __user *) to, from, count);
+       return __copy_user((__force void __user *) to, from, count);
 }
 
 #define __copy_to_user_inatomic                __copy_to_user
@@ -258,7 +258,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
        long __cu_len = (n);                                                            \
                                                                                        \
        if (__access_ok(__cu_to, __cu_len, get_fs()))                                   \
-               __cu_len = __copy_user(__cu_to, (void __user *) __cu_from, __cu_len);   \
+               __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len);   \
        __cu_len;                                                                       \
 })
 
@@ -270,7 +270,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
                                                                                        \
        __chk_user_ptr(__cu_from);                                                      \
        if (__access_ok(__cu_from, __cu_len, get_fs()))                                 \
-               __cu_len = __copy_user((void __user *) __cu_to, __cu_from, __cu_len);   \
+               __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len);   \
        __cu_len;                                                                       \
 })
 
index 7eb7cf6360bd1e76d5909faf11959b6cea49f6b5..94d83998a75912851f4a3ff4095d2b09f4408f67 100644 (file)
@@ -56,7 +56,7 @@ extern unsigned long pci_dram_offset;
  * is actually performed (i.e. the data has come back) before we start
  * executing any following instructions.
  */
-extern inline int in_8(volatile unsigned char __iomem *addr)
+extern inline int in_8(const volatile unsigned char __iomem *addr)
 {
        int ret;
 
@@ -72,7 +72,7 @@ extern inline void out_8(volatile unsigned char __iomem *addr, int val)
        __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
 }
 
-extern inline int in_le16(volatile unsigned short __iomem *addr)
+extern inline int in_le16(const volatile unsigned short __iomem *addr)
 {
        int ret;
 
@@ -83,7 +83,7 @@ extern inline int in_le16(volatile unsigned short __iomem *addr)
        return ret;
 }
 
-extern inline int in_be16(volatile unsigned short __iomem *addr)
+extern inline int in_be16(const volatile unsigned short __iomem *addr)
 {
        int ret;
 
@@ -104,7 +104,7 @@ extern inline void out_be16(volatile unsigned short __iomem *addr, int val)
        __asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
 }
 
-extern inline unsigned in_le32(volatile unsigned __iomem *addr)
+extern inline unsigned in_le32(const volatile unsigned __iomem *addr)
 {
        unsigned ret;
 
@@ -115,7 +115,7 @@ extern inline unsigned in_le32(volatile unsigned __iomem *addr)
        return ret;
 }
 
-extern inline unsigned in_be32(volatile unsigned __iomem *addr)
+extern inline unsigned in_be32(const volatile unsigned __iomem *addr)
 {
        unsigned ret;
 
@@ -139,7 +139,7 @@ extern inline void out_be32(volatile unsigned __iomem *addr, int val)
 #define readb(addr) in_8((volatile u8 *)(addr))
 #define writeb(b,addr) out_8((volatile u8 *)(addr), (b))
 #else
-static inline __u8 readb(volatile void __iomem *addr)
+static inline __u8 readb(const volatile void __iomem *addr)
 {
        return in_8(addr);
 }
@@ -150,11 +150,11 @@ static inline void writeb(__u8 b, volatile void __iomem *addr)
 #endif
 
 #if defined(CONFIG_APUS)
-static inline __u16 readw(volatile void __iomem *addr)
+static inline __u16 readw(const volatile void __iomem *addr)
 {
        return *(__force volatile __u16 *)(addr);
 }
-static inline __u32 readl(volatile void __iomem *addr)
+static inline __u32 readl(const volatile void __iomem *addr)
 {
        return *(__force volatile __u32 *)(addr);
 }
@@ -173,11 +173,11 @@ static inline void writel(__u32 b, volatile void __iomem *addr)
 #define writew(b,addr) out_le16((volatile u16 *)(addr),(b))
 #define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
 #else
-static inline __u16 readw(volatile void __iomem *addr)
+static inline __u16 readw(const volatile void __iomem *addr)
 {
        return in_le16(addr);
 }
-static inline __u32 readl(volatile void __iomem *addr)
+static inline __u32 readl(const volatile void __iomem *addr)
 {
        return in_le32(addr);
 }
index 75c2ffa26b26d5b22a1dffcc78a1731361001b7a..ee2f9188cc64c0af24aea5d053d96952f1f6659b 100644 (file)
@@ -233,7 +233,7 @@ struct mv64x60_chip_info {
 struct mv64x60_handle {
        u32             type;           /* type of bridge */
        u32             rev;            /* revision of bridge */
-       void            *v_base;        /* virtual base addr of bridge regs */
+       void            __iomem *v_base;/* virtual base addr of bridge regs */
        phys_addr_t     p_base;         /* physical base addr of bridge regs */
 
        u32             pci_mode_a;     /* pci 0 mode: conventional pci, pci-x*/
@@ -303,7 +303,7 @@ void mv64x60_alloc_hose(struct mv64x60_handle *bh, u32 cfg_addr,
        u32 cfg_data, struct pci_controller **hose);
 int mv64x60_get_type(struct mv64x60_handle *bh);
 int mv64x60_setup_for_chip(struct mv64x60_handle *bh);
-void *mv64x60_get_bridge_vbase(void);
+void __iomem *mv64x60_get_bridge_vbase(void);
 u32 mv64x60_get_bridge_type(void);
 u32 mv64x60_get_bridge_rev(void);
 void mv64x60_get_mem_windows(struct mv64x60_handle *bh,
index c181a60d868c7ee82e79db9ce1d57f9817a8d8d4..132c1276547b9300475560b00a889867dab7fd12 100644 (file)
@@ -164,7 +164,8 @@ do {                                                                        \
 
 #define __get_user_nocheck(x,ptr,size)                         \
 ({                                                             \
-       long __gu_err, __gu_val;                                \
+       long __gu_err;                                          \
+       unsigned long __gu_val;                                 \
        might_sleep();                                          \
        __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
        (x) = (__typeof__(*(ptr)))__gu_val;                     \
@@ -173,7 +174,8 @@ do {                                                                        \
 
 #define __get_user_check(x,ptr,size)                                   \
 ({                                                                     \
-       long __gu_err = -EFAULT, __gu_val = 0;                          \
+       long __gu_err = -EFAULT;                                        \
+       unsigned long __gu_val = 0;                                     \
        const __typeof__(*(ptr)) __user *__gu_addr = (ptr);             \
        might_sleep();                                                  \
        if (access_ok(VERIFY_READ,__gu_addr,size))                      \
index d57bc0cebdcec86509ac09b57dc9e322cbccaf6c..803545351dd8d399c41469b32ed82298da36adf7 100644 (file)
@@ -61,7 +61,7 @@ typedef struct
 struct sigcontext
 {
        unsigned long   oldmask[_SIGCONTEXT_NSIG_WORDS];
-       _sigregs        *sregs;
+       _sigregs        __user *sregs;
 };
 
 
index 3d6e11c6c1fdd94a4568e1bd230bbdfb25733f3b..7084626de215750590bf4dfac15f88257ce187bb 100644 (file)
@@ -165,7 +165,7 @@ struct sigaction {
 #endif /* __KERNEL__ */
 
 typedef struct sigaltstack {
-        void *ss_sp;
+        void __user *ss_sp;
         int ss_flags;
         size_t ss_size;
 } stack_t;
index b84c96c895816008a9413d1069d577ad464ddda3..c2868d0f60b62889a89cd8013ee4cfcfbbba2d25 100644 (file)
@@ -49,17 +49,17 @@ extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
 /* Put bottom 13bits into some register variable */
 
 #define BTFIXUPDEF_SIMM13(__name)                                                      \
-       extern unsigned int ___sf_##__name(void) __attribute_const__;           \
+       static inline unsigned int ___sf_##__name(void) __attribute_const__;            \
        extern unsigned ___ss_##__name[2];                                              \
-       extern __inline__ unsigned int ___sf_##__name(void) {                           \
+       static inline unsigned int ___sf_##__name(void) {                               \
                unsigned int ret;                                                       \
                __asm__ ("or %%g0, ___s_" #__name ", %0" : "=r"(ret));                  \
                return ret;                                                             \
        }
 #define BTFIXUPDEF_SIMM13_INIT(__name,__val)                                           \
-       extern unsigned int ___sf_##__name(void) __attribute_const__;           \
+       static inline unsigned int ___sf_##__name(void) __attribute_const__;            \
        extern unsigned ___ss_##__name[2];                                              \
-       extern __inline__ unsigned int ___sf_##__name(void) {                           \
+       static inline unsigned int ___sf_##__name(void) {                               \
                unsigned int ret;                                                       \
                __asm__ ("or %%g0, ___s_" #__name "__btset_" #__val ", %0" : "=r"(ret));\
                return ret;                                                             \
@@ -71,17 +71,17 @@ extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
  */
 
 #define BTFIXUPDEF_HALF(__name)                                                                \
-       extern unsigned int ___af_##__name(void) __attribute_const__;           \
+       static inline unsigned int ___af_##__name(void) __attribute_const__;            \
        extern unsigned ___as_##__name[2];                                              \
-       extern __inline__ unsigned int ___af_##__name(void) {                           \
+       static inline unsigned int ___af_##__name(void) {                               \
                unsigned int ret;                                                       \
                __asm__ ("or %%g0, ___a_" #__name ", %0" : "=r"(ret));                  \
                return ret;                                                             \
        }
 #define BTFIXUPDEF_HALF_INIT(__name,__val)                                             \
-       extern unsigned int ___af_##__name(void) __attribute_const__;           \
+       static inline unsigned int ___af_##__name(void) __attribute_const__;            \
        extern unsigned ___as_##__name[2];                                              \
-       extern __inline__ unsigned int ___af_##__name(void) {                           \
+       static inline unsigned int ___af_##__name(void) {                               \
                unsigned int ret;                                                       \
                __asm__ ("or %%g0, ___a_" #__name "__btset_" #__val ", %0" : "=r"(ret));\
                return ret;                                                             \
@@ -90,17 +90,17 @@ extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
 /* Put upper 22 bits into some register variable */
 
 #define BTFIXUPDEF_SETHI(__name)                                                       \
-       extern unsigned int ___hf_##__name(void) __attribute_const__;           \
+       static inline unsigned int ___hf_##__name(void) __attribute_const__;            \
        extern unsigned ___hs_##__name[2];                                              \
-       extern __inline__ unsigned int ___hf_##__name(void) {                           \
+       static inline unsigned int ___hf_##__name(void) {                               \
                unsigned int ret;                                                       \
                __asm__ ("sethi %%hi(___h_" #__name "), %0" : "=r"(ret));               \
                return ret;                                                             \
        }
 #define BTFIXUPDEF_SETHI_INIT(__name,__val)                                            \
-       extern unsigned int ___hf_##__name(void) __attribute_const__;           \
+       static inline unsigned int ___hf_##__name(void) __attribute_const__;            \
        extern unsigned ___hs_##__name[2];                                              \
-       extern __inline__ unsigned int ___hf_##__name(void) {                           \
+       static inline unsigned int ___hf_##__name(void) {                               \
                unsigned int ret;                                                       \
                __asm__ ("sethi %%hi(___h_" #__name "__btset_" #__val "), %0" :         \
                         "=r"(ret));                                                    \
index e6316fd7e1a4085880796216fc45e9368b90c391..a10522cb21b7d311b698f48b7a751b216a10dad6 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 /* First, cache-tag access. */
-extern __inline__ unsigned int get_icache_tag(int setnum, int tagnum)
+static inline unsigned int get_icache_tag(int setnum, int tagnum)
 {
        unsigned int vaddr, retval;
 
@@ -38,7 +38,7 @@ extern __inline__ unsigned int get_icache_tag(int setnum, int tagnum)
        return retval;
 }
 
-extern __inline__ void put_icache_tag(int setnum, int tagnum, unsigned int entry)
+static inline void put_icache_tag(int setnum, int tagnum, unsigned int entry)
 {
        unsigned int vaddr;
 
@@ -51,7 +51,7 @@ extern __inline__ void put_icache_tag(int setnum, int tagnum, unsigned int entry
 /* Second cache-data access.  The data is returned two-32bit quantities
  * at a time.
  */
-extern __inline__ void get_icache_data(int setnum, int tagnum, int subblock,
+static inline void get_icache_data(int setnum, int tagnum, int subblock,
                                       unsigned int *data)
 {
        unsigned int value1, value2, vaddr;
@@ -67,7 +67,7 @@ extern __inline__ void get_icache_data(int setnum, int tagnum, int subblock,
        data[0] = value1; data[1] = value2;
 }
 
-extern __inline__ void put_icache_data(int setnum, int tagnum, int subblock,
+static inline void put_icache_data(int setnum, int tagnum, int subblock,
                                       unsigned int *data)
 {
        unsigned int value1, value2, vaddr;
@@ -92,35 +92,35 @@ extern __inline__ void put_icache_data(int setnum, int tagnum, int subblock,
  */
 
 /* Flushes which clear out both the on-chip and external caches */
-extern __inline__ void flush_ei_page(unsigned int addr)
+static inline void flush_ei_page(unsigned int addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_PAGE) :
                             "memory");
 }
 
-extern __inline__ void flush_ei_seg(unsigned int addr)
+static inline void flush_ei_seg(unsigned int addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_SEG) :
                             "memory");
 }
 
-extern __inline__ void flush_ei_region(unsigned int addr)
+static inline void flush_ei_region(unsigned int addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_REGION) :
                             "memory");
 }
 
-extern __inline__ void flush_ei_ctx(unsigned int addr)
+static inline void flush_ei_ctx(unsigned int addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_CTX) :
                             "memory");
 }
 
-extern __inline__ void flush_ei_user(unsigned int addr)
+static inline void flush_ei_user(unsigned int addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_USER) :
index fc92fc839c3f4e458ca6edd6d2883f83a59af300..99599533efbc4e940011fdc31156d776de7effec 100644 (file)
 #define CYPRESS_NFAULT    0x00000002
 #define CYPRESS_MENABLE   0x00000001
 
-extern __inline__ void cypress_flush_page(unsigned long page)
+static inline void cypress_flush_page(unsigned long page)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (page), "i" (ASI_M_FLUSH_PAGE));
 }
 
-extern __inline__ void cypress_flush_segment(unsigned long addr)
+static inline void cypress_flush_segment(unsigned long addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_SEG));
 }
 
-extern __inline__ void cypress_flush_region(unsigned long addr)
+static inline void cypress_flush_region(unsigned long addr)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
                             "r" (addr), "i" (ASI_M_FLUSH_REGION));
 }
 
-extern __inline__ void cypress_flush_context(void)
+static inline void cypress_flush_context(void)
 {
        __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t" : :
                             "i" (ASI_M_FLUSH_CTX));
index 6edf2cbb246b062a26ff04fa321db7b11dc04be9..7ec8e9f7ad4fa66aa259625f2687b094c53c2a08 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/config.h>
 #include <asm/cpudata.h>
 
-extern __inline__ void __delay(unsigned long loops)
+static inline void __delay(unsigned long loops)
 {
        __asm__ __volatile__("cmp %0, 0\n\t"
                             "1: bne 1b\n\t"
index 07e6368a2521bdd3536551cb55533bc64a571a6f..8ec206aa5f2ecac2191556a6344953398495210b 100644 (file)
@@ -198,7 +198,7 @@ extern void dvma_init(struct sbus_bus *);
 /* Pause until counter runs out or BIT isn't set in the DMA condition
  * register.
  */
-extern __inline__ void sparc_dma_pause(struct sparc_dma_registers *regs,
+static inline void sparc_dma_pause(struct sparc_dma_registers *regs,
                                       unsigned long bit)
 {
        int ctr = 50000;   /* Let's find some bugs ;) */
index 8171362d56b9f9e15b78b50576e5d7486605315c..70c589c05a109627e9c70adf1b50e104513f436c 100644 (file)
@@ -108,12 +108,12 @@ struct iommu_struct {
        struct bit_map usemap;
 };
 
-extern __inline__ void iommu_invalidate(struct iommu_regs *regs)
+static inline void iommu_invalidate(struct iommu_regs *regs)
 {
        regs->tlbflush = 0;
 }
 
-extern __inline__ void iommu_invalidate_page(struct iommu_regs *regs, unsigned long ba)
+static inline void iommu_invalidate_page(struct iommu_regs *regs, unsigned long ba)
 {
        regs->pageflush = (ba & PAGE_MASK);
 }
index 3ea4916635ee6283359d670b0d2e2287f0b0b842..fba92485fdba5fe1ebbaff2569498a4a69eb4b41 100644 (file)
@@ -46,7 +46,7 @@ struct kernel_debug {
 extern struct kernel_debug *linux_dbvec;
 
 /* Use this macro in C-code to enter the debugger. */
-extern __inline__ void sp_enter_debugger(void)
+static inline void sp_enter_debugger(void)
 {
        __asm__ __volatile__("jmpl %0, %%o7\n\t"
                             "nop\n\t" : :
index 5f27490153421ed8b7f5f535351196517b703d8d..ecacdf4075d76f7e80e78a7b60c00815a0d32307 100644 (file)
@@ -83,7 +83,7 @@ extern unsigned int hwbug_bitmask;
  */
 #define TBR_ID_SHIFT            20
 
-extern __inline__ int get_cpuid(void)
+static inline int get_cpuid(void)
 {
        register int retval;
        __asm__ __volatile__("rd %%tbr, %0\n\t"
@@ -93,7 +93,7 @@ extern __inline__ int get_cpuid(void)
        return (retval & 3);
 }
 
-extern __inline__ int get_modid(void)
+static inline int get_modid(void)
 {
        return (get_cpuid() | 0x8);
 }
index b69543dd3b46069127b44d5b3d5d5b3ca1b4eb4f..ff72cbd946a4462df51ddf4e19b22b468f7f8bc4 100644 (file)
@@ -19,7 +19,7 @@
 #define MSI_ASYNC_MODE  0x80000000     /* Operate the MSI asynchronously */
 
 
-extern __inline__ void msi_set_sync(void)
+static inline void msi_set_sync(void)
 {
        __asm__ __volatile__ ("lda [%0] %1, %%g3\n\t"
                              "andn %%g3, %2, %%g3\n\t"
index 60ef9d6fe7bca424d3b8a5e2cb846fb324ef7802..128fe9708135c5262a5f701584e59c0d599b9665 100644 (file)
@@ -85,7 +85,7 @@
 
 #ifndef __ASSEMBLY__
 
-extern __inline__ void mxcc_set_stream_src(unsigned long *paddr)
+static inline void mxcc_set_stream_src(unsigned long *paddr)
 {
        unsigned long data0 = paddr[0];
        unsigned long data1 = paddr[1];
@@ -98,7 +98,7 @@ extern __inline__ void mxcc_set_stream_src(unsigned long *paddr)
                              "i" (ASI_M_MXCC) : "g2", "g3");
 }
 
-extern __inline__ void mxcc_set_stream_dst(unsigned long *paddr)
+static inline void mxcc_set_stream_dst(unsigned long *paddr)
 {
        unsigned long data0 = paddr[0];
        unsigned long data1 = paddr[1];
@@ -111,7 +111,7 @@ extern __inline__ void mxcc_set_stream_dst(unsigned long *paddr)
                              "i" (ASI_M_MXCC) : "g2", "g3");
 }
 
-extern __inline__ unsigned long mxcc_get_creg(void)
+static inline unsigned long mxcc_get_creg(void)
 {
        unsigned long mxcc_control;
 
@@ -125,7 +125,7 @@ extern __inline__ unsigned long mxcc_get_creg(void)
        return mxcc_control;
 }
 
-extern __inline__ void mxcc_set_creg(unsigned long mxcc_control)
+static inline void mxcc_set_creg(unsigned long mxcc_control)
 {
        __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
                             "r" (mxcc_control), "r" (MXCC_CREG),
index 62e1d77965f3fd9a13011ce9dc151dca2b47a7fa..47854a2a12cf09a45fcd0b5958456874f82d855c 100644 (file)
@@ -98,7 +98,7 @@
 
 #ifndef __ASSEMBLY__
 
-extern __inline__ int bw_get_intr_mask(int sbus_level)
+static inline int bw_get_intr_mask(int sbus_level)
 {
        int mask;
        
@@ -109,7 +109,7 @@ extern __inline__ int bw_get_intr_mask(int sbus_level)
        return mask;
 }
 
-extern __inline__ void bw_clear_intr_mask(int sbus_level, int mask)
+static inline void bw_clear_intr_mask(int sbus_level, int mask)
 {
        __asm__ __volatile__ ("stha %0, [%1] %2" : :
                              "r" (mask),
@@ -117,7 +117,7 @@ extern __inline__ void bw_clear_intr_mask(int sbus_level, int mask)
                              "i" (ASI_M_CTL));
 }
 
-extern __inline__ unsigned bw_get_prof_limit(int cpu)
+static inline unsigned bw_get_prof_limit(int cpu)
 {
        unsigned limit;
        
@@ -128,7 +128,7 @@ extern __inline__ unsigned bw_get_prof_limit(int cpu)
        return limit;
 }
 
-extern __inline__ void bw_set_prof_limit(int cpu, unsigned limit)
+static inline void bw_set_prof_limit(int cpu, unsigned limit)
 {
        __asm__ __volatile__ ("sta %0, [%1] %2" : :
                              "r" (limit),
@@ -136,7 +136,7 @@ extern __inline__ void bw_set_prof_limit(int cpu, unsigned limit)
                              "i" (ASI_M_CTL));
 }
 
-extern __inline__ unsigned bw_get_ctrl(int cpu)
+static inline unsigned bw_get_ctrl(int cpu)
 {
        unsigned ctrl;
        
@@ -147,7 +147,7 @@ extern __inline__ unsigned bw_get_ctrl(int cpu)
        return ctrl;
 }
 
-extern __inline__ void bw_set_ctrl(int cpu, unsigned ctrl)
+static inline void bw_set_ctrl(int cpu, unsigned ctrl)
 {
        __asm__ __volatile__ ("sta %0, [%1] %2" : :
                              "r" (ctrl),
@@ -157,7 +157,7 @@ extern __inline__ void bw_set_ctrl(int cpu, unsigned ctrl)
 
 extern unsigned char cpu_leds[32];
 
-extern __inline__ void show_leds(int cpuid)
+static inline void show_leds(int cpuid)
 {
        cpuid &= 0x1e;
        __asm__ __volatile__ ("stba %0, [%1] %2" : :
@@ -166,7 +166,7 @@ extern __inline__ void show_leds(int cpuid)
                              "i" (ASI_M_CTL));
 }
 
-extern __inline__ unsigned cc_get_ipen(void)
+static inline unsigned cc_get_ipen(void)
 {
        unsigned pending;
        
@@ -177,7 +177,7 @@ extern __inline__ unsigned cc_get_ipen(void)
        return pending;
 }
 
-extern __inline__ void cc_set_iclr(unsigned clear)
+static inline void cc_set_iclr(unsigned clear)
 {
        __asm__ __volatile__ ("stha %0, [%1] %2" : :
                              "r" (clear),
@@ -185,7 +185,7 @@ extern __inline__ void cc_set_iclr(unsigned clear)
                              "i" (ASI_M_MXCC));
 }
 
-extern __inline__ unsigned cc_get_imsk(void)
+static inline unsigned cc_get_imsk(void)
 {
        unsigned mask;
        
@@ -196,7 +196,7 @@ extern __inline__ unsigned cc_get_imsk(void)
        return mask;
 }
 
-extern __inline__ void cc_set_imsk(unsigned mask)
+static inline void cc_set_imsk(unsigned mask)
 {
        __asm__ __volatile__ ("stha %0, [%1] %2" : :
                              "r" (mask),
@@ -204,7 +204,7 @@ extern __inline__ void cc_set_imsk(unsigned mask)
                              "i" (ASI_M_MXCC));
 }
 
-extern __inline__ unsigned cc_get_imsk_other(int cpuid)
+static inline unsigned cc_get_imsk_other(int cpuid)
 {
        unsigned mask;
        
@@ -215,7 +215,7 @@ extern __inline__ unsigned cc_get_imsk_other(int cpuid)
        return mask;
 }
 
-extern __inline__ void cc_set_imsk_other(int cpuid, unsigned mask)
+static inline void cc_set_imsk_other(int cpuid, unsigned mask)
 {
        __asm__ __volatile__ ("stha %0, [%1] %2" : :
                              "r" (mask),
@@ -223,7 +223,7 @@ extern __inline__ void cc_set_imsk_other(int cpuid, unsigned mask)
                              "i" (ASI_M_CTL));
 }
 
-extern __inline__ void cc_set_igen(unsigned gen)
+static inline void cc_set_igen(unsigned gen)
 {
        __asm__ __volatile__ ("sta %0, [%1] %2" : :
                              "r" (gen),
@@ -239,7 +239,7 @@ extern __inline__ void cc_set_igen(unsigned gen)
 #define IGEN_MESSAGE(bcast, devid, sid, levels) \
        (((bcast) << 31) | ((devid) << 23) | ((sid) << 15) | (levels))
             
-extern __inline__ void sun4d_send_ipi(int cpu, int level)
+static inline void sun4d_send_ipi(int cpu, int level)
 {
        cc_set_igen(IGEN_MESSAGE(0, cpu << 3, 6 + ((level >> 1) & 7), 1 << (level - 1)));
 }
index 97052baf90c130f3757415bff91f6d732e151e4a..38644742f01192012d565fb9f78fba88539db479 100644 (file)
 
 #define PCI_IRQ_NONE           0xffffffff
 
-extern inline void pcibios_set_master(struct pci_dev *dev)
+static inline void pcibios_set_master(struct pci_dev *dev)
 {
        /* No special bus mastering setup handling */
 }
 
-extern inline void pcibios_penalize_isa_irq(int irq, int active)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
 {
        /* We don't do dynamic PCI IRQ allocation */
 }
@@ -137,7 +137,7 @@ extern void pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist
  * only drive the low 24-bits during PCI bus mastering, then
  * you would pass 0x00ffffff as the mask to this function.
  */
-extern inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
+static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
 {
        return 1;
 }
index 8f4f6a95965130820e03f46e22cfe795721bbfcb..a14e9867750047ded9a76449f5a21c7f0b0e5d1d 100644 (file)
@@ -82,6 +82,8 @@ extern unsigned long page_kernel;
 /* Top-level page directory */
 extern pgd_t swapper_pg_dir[1024];
 
+extern void paging_init(void);
+
 /* Page table for 0-4MB for everybody, on the Sparc this
  * holds the same as on the i386.
  */
@@ -152,7 +154,7 @@ BTFIXUPDEF_CALL_CONST(int, pte_present, pte_t)
 BTFIXUPDEF_CALL(void, pte_clear, pte_t *)
 BTFIXUPDEF_CALL(int, pte_read, pte_t)
 
-extern __inline__ int pte_none(pte_t pte)
+static inline int pte_none(pte_t pte)
 {
        return !(pte_val(pte) & ~BTFIXUP_SETHI(none_mask));
 }
@@ -165,7 +167,7 @@ BTFIXUPDEF_CALL_CONST(int, pmd_bad, pmd_t)
 BTFIXUPDEF_CALL_CONST(int, pmd_present, pmd_t)
 BTFIXUPDEF_CALL(void, pmd_clear, pmd_t *)
 
-extern __inline__ int pmd_none(pmd_t pmd)
+static inline int pmd_none(pmd_t pmd)
 {
        return !(pmd_val(pmd) & ~BTFIXUP_SETHI(none_mask));
 }
@@ -192,20 +194,20 @@ BTFIXUPDEF_HALF(pte_writei)
 BTFIXUPDEF_HALF(pte_dirtyi)
 BTFIXUPDEF_HALF(pte_youngi)
 
-extern int pte_write(pte_t pte) __attribute_const__;
-extern __inline__ int pte_write(pte_t pte)
+static int pte_write(pte_t pte) __attribute_const__;
+static inline int pte_write(pte_t pte)
 {
        return pte_val(pte) & BTFIXUP_HALF(pte_writei);
 }
 
-extern int pte_dirty(pte_t pte) __attribute_const__;
-extern __inline__ int pte_dirty(pte_t pte)
+static int pte_dirty(pte_t pte) __attribute_const__;
+static inline int pte_dirty(pte_t pte)
 {
        return pte_val(pte) & BTFIXUP_HALF(pte_dirtyi);
 }
 
-extern int pte_young(pte_t pte) __attribute_const__;
-extern __inline__ int pte_young(pte_t pte)
+static int pte_young(pte_t pte) __attribute_const__;
+static inline int pte_young(pte_t pte)
 {
        return pte_val(pte) & BTFIXUP_HALF(pte_youngi);
 }
@@ -215,8 +217,8 @@ extern __inline__ int pte_young(pte_t pte)
  */
 BTFIXUPDEF_HALF(pte_filei)
 
-extern int pte_file(pte_t pte) __attribute_const__;
-extern __inline__ int pte_file(pte_t pte)
+static int pte_file(pte_t pte) __attribute_const__;
+static inline int pte_file(pte_t pte)
 {
        return pte_val(pte) & BTFIXUP_HALF(pte_filei);
 }
@@ -227,20 +229,20 @@ BTFIXUPDEF_HALF(pte_wrprotecti)
 BTFIXUPDEF_HALF(pte_mkcleani)
 BTFIXUPDEF_HALF(pte_mkoldi)
 
-extern pte_t pte_wrprotect(pte_t pte) __attribute_const__;
-extern __inline__ pte_t pte_wrprotect(pte_t pte)
+static pte_t pte_wrprotect(pte_t pte) __attribute_const__;
+static inline pte_t pte_wrprotect(pte_t pte)
 {
        return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_wrprotecti));
 }
 
-extern pte_t pte_mkclean(pte_t pte) __attribute_const__;
-extern __inline__ pte_t pte_mkclean(pte_t pte)
+static pte_t pte_mkclean(pte_t pte) __attribute_const__;
+static inline pte_t pte_mkclean(pte_t pte)
 {
        return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkcleani));
 }
 
-extern pte_t pte_mkold(pte_t pte) __attribute_const__;
-extern __inline__ pte_t pte_mkold(pte_t pte)
+static pte_t pte_mkold(pte_t pte) __attribute_const__;
+static inline pte_t pte_mkold(pte_t pte)
 {
        return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkoldi));
 }
@@ -276,8 +278,8 @@ BTFIXUPDEF_CALL_CONST(pte_t, mk_pte_io, unsigned long, pgprot_t, int)
 
 BTFIXUPDEF_INT(pte_modify_mask)
 
-extern pte_t pte_modify(pte_t pte, pgprot_t newprot) __attribute_const__;
-extern __inline__ pte_t pte_modify(pte_t pte, pgprot_t newprot)
+static pte_t pte_modify(pte_t pte, pgprot_t newprot) __attribute_const__;
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
        return __pte((pte_val(pte) & BTFIXUP_INT(pte_modify_mask)) |
                pgprot_val(newprot));
@@ -384,13 +386,13 @@ extern struct ctx_list ctx_used;        /* Head of used contexts list */
 
 #define NO_CONTEXT     -1
 
-extern __inline__ void remove_from_ctx_list(struct ctx_list *entry)
+static inline void remove_from_ctx_list(struct ctx_list *entry)
 {
        entry->next->prev = entry->prev;
        entry->prev->next = entry->next;
 }
 
-extern __inline__ void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
+static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
 {
        entry->next = head;
        (entry->prev = head->prev)->next = entry;
@@ -399,7 +401,7 @@ extern __inline__ void add_to_ctx_list(struct ctx_list *head, struct ctx_list *e
 #define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
 #define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
 
-extern __inline__ unsigned long
+static inline unsigned long
 __get_phys (unsigned long addr)
 {
        switch (sparc_cpu_model){
@@ -414,7 +416,7 @@ __get_phys (unsigned long addr)
        }
 }
 
-extern __inline__ int
+static inline int
 __get_iospace (unsigned long addr)
 {
        switch (sparc_cpu_model){
index ee3b9d93187ce5959b95d709e41048e0218cf823..edeb9811e7285fd35da7fa0d68246b5021725bd5 100644 (file)
@@ -148,7 +148,7 @@ extern void *srmmu_nocache_pool;
 #define __nocache_fix(VADDR) __va(__nocache_pa(VADDR))
 
 /* Accessing the MMU control register. */
-extern __inline__ unsigned int srmmu_get_mmureg(void)
+static inline unsigned int srmmu_get_mmureg(void)
 {
         unsigned int retval;
        __asm__ __volatile__("lda [%%g0] %1, %0\n\t" :
@@ -157,14 +157,14 @@ extern __inline__ unsigned int srmmu_get_mmureg(void)
        return retval;
 }
 
-extern __inline__ void srmmu_set_mmureg(unsigned long regval)
+static inline void srmmu_set_mmureg(unsigned long regval)
 {
        __asm__ __volatile__("sta %0, [%%g0] %1\n\t" : :
                             "r" (regval), "i" (ASI_M_MMUREGS) : "memory");
 
 }
 
-extern __inline__ void srmmu_set_ctable_ptr(unsigned long paddr)
+static inline void srmmu_set_ctable_ptr(unsigned long paddr)
 {
        paddr = ((paddr >> 4) & SRMMU_CTX_PMASK);
        __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
@@ -173,7 +173,7 @@ extern __inline__ void srmmu_set_ctable_ptr(unsigned long paddr)
                             "memory");
 }
 
-extern __inline__ unsigned long srmmu_get_ctable_ptr(void)
+static inline unsigned long srmmu_get_ctable_ptr(void)
 {
        unsigned int retval;
 
@@ -184,14 +184,14 @@ extern __inline__ unsigned long srmmu_get_ctable_ptr(void)
        return (retval & SRMMU_CTX_PMASK) << 4;
 }
 
-extern __inline__ void srmmu_set_context(int context)
+static inline void srmmu_set_context(int context)
 {
        __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
                             "r" (context), "r" (SRMMU_CTX_REG),
                             "i" (ASI_M_MMUREGS) : "memory");
 }
 
-extern __inline__ int srmmu_get_context(void)
+static inline int srmmu_get_context(void)
 {
        register int retval;
        __asm__ __volatile__("lda [%1] %2, %0\n\t" :
@@ -201,7 +201,7 @@ extern __inline__ int srmmu_get_context(void)
        return retval;
 }
 
-extern __inline__ unsigned int srmmu_get_fstatus(void)
+static inline unsigned int srmmu_get_fstatus(void)
 {
        unsigned int retval;
 
@@ -211,7 +211,7 @@ extern __inline__ unsigned int srmmu_get_fstatus(void)
        return retval;
 }
 
-extern __inline__ unsigned int srmmu_get_faddr(void)
+static inline unsigned int srmmu_get_faddr(void)
 {
        unsigned int retval;
 
@@ -222,7 +222,7 @@ extern __inline__ unsigned int srmmu_get_faddr(void)
 }
 
 /* This is guaranteed on all SRMMU's. */
-extern __inline__ void srmmu_flush_whole_tlb(void)
+static inline void srmmu_flush_whole_tlb(void)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
                             "r" (0x400),        /* Flush entire TLB!! */
@@ -231,7 +231,7 @@ extern __inline__ void srmmu_flush_whole_tlb(void)
 }
 
 /* These flush types are not available on all chips... */
-extern __inline__ void srmmu_flush_tlb_ctx(void)
+static inline void srmmu_flush_tlb_ctx(void)
 {
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
                             "r" (0x300),        /* Flush TLB ctx.. */
@@ -239,7 +239,7 @@ extern __inline__ void srmmu_flush_tlb_ctx(void)
 
 }
 
-extern __inline__ void srmmu_flush_tlb_region(unsigned long addr)
+static inline void srmmu_flush_tlb_region(unsigned long addr)
 {
        addr &= SRMMU_PGDIR_MASK;
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
@@ -249,7 +249,7 @@ extern __inline__ void srmmu_flush_tlb_region(unsigned long addr)
 }
 
 
-extern __inline__ void srmmu_flush_tlb_segment(unsigned long addr)
+static inline void srmmu_flush_tlb_segment(unsigned long addr)
 {
        addr &= SRMMU_REAL_PMD_MASK;
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
@@ -258,7 +258,7 @@ extern __inline__ void srmmu_flush_tlb_segment(unsigned long addr)
 
 }
 
-extern __inline__ void srmmu_flush_tlb_page(unsigned long page)
+static inline void srmmu_flush_tlb_page(unsigned long page)
 {
        page &= PAGE_MASK;
        __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
@@ -267,7 +267,7 @@ extern __inline__ void srmmu_flush_tlb_page(unsigned long page)
 
 }
 
-extern __inline__ unsigned long srmmu_hwprobe(unsigned long vaddr)
+static inline unsigned long srmmu_hwprobe(unsigned long vaddr)
 {
        unsigned long retval;
 
@@ -279,7 +279,7 @@ extern __inline__ unsigned long srmmu_hwprobe(unsigned long vaddr)
        return retval;
 }
 
-extern __inline__ int
+static inline int
 srmmu_get_pte (unsigned long addr)
 {
        register unsigned long entry;
index 5a7a1a8d29ac9ccbf09ea9fc5df220c4744432cb..6fbb3f0af8d891a6b7e1fdc8b80c58970a0a5a4e 100644 (file)
@@ -79,7 +79,7 @@ struct thread_struct {
 extern unsigned long thread_saved_pc(struct task_struct *t);
 
 /* Do necessary setup to start up a newly executed thread. */
-extern __inline__ void start_thread(struct pt_regs * regs, unsigned long pc,
+static inline void start_thread(struct pt_regs * regs, unsigned long pc,
                                    unsigned long sp)
 {
        register unsigned long zero asm("g1");
index 9778b8c8b15bce2e24f863f86f9aab9bdb19c485..19c9780511180f2b24378bf26dfdeff9ecb535c8 100644 (file)
@@ -38,7 +38,7 @@
 
 #ifndef __ASSEMBLY__
 /* Get the %psr register. */
-extern __inline__ unsigned int get_psr(void)
+static inline unsigned int get_psr(void)
 {
        unsigned int psr;
        __asm__ __volatile__(
@@ -53,7 +53,7 @@ extern __inline__ unsigned int get_psr(void)
        return psr;
 }
 
-extern __inline__ void put_psr(unsigned int new_psr)
+static inline void put_psr(unsigned int new_psr)
 {
        __asm__ __volatile__(
                "wr     %0, 0x0, %%psr\n\t"
@@ -72,7 +72,7 @@ extern __inline__ void put_psr(unsigned int new_psr)
 
 extern unsigned int fsr_storage;
 
-extern __inline__ unsigned int get_fsr(void)
+static inline unsigned int get_fsr(void)
 {
        unsigned int fsr = 0;
 
index 739ccac5dcf284290cc74fd5990dba8bddc3b60b..86a603ac7b20d3f910d53cf363cfcd4f392f080d 100644 (file)
@@ -65,7 +65,7 @@ struct sbi_regs {
 
 #ifndef __ASSEMBLY__
 
-extern __inline__ int acquire_sbi(int devid, int mask)
+static inline int acquire_sbi(int devid, int mask)
 {
        __asm__ __volatile__ ("swapa [%2] %3, %0" :
                              "=r" (mask) :
@@ -75,7 +75,7 @@ extern __inline__ int acquire_sbi(int devid, int mask)
        return mask;
 }
 
-extern __inline__ void release_sbi(int devid, int mask)
+static inline void release_sbi(int devid, int mask)
 {
        __asm__ __volatile__ ("sta %0, [%1] %2" : :
                              "r" (mask),
@@ -83,7 +83,7 @@ extern __inline__ void release_sbi(int devid, int mask)
                              "i" (ASI_M_CTL));
 }
 
-extern __inline__ void set_sbi_tid(int devid, int targetid)
+static inline void set_sbi_tid(int devid, int targetid)
 {
        __asm__ __volatile__ ("sta %0, [%1] %2" : :
                              "r" (targetid),
@@ -91,7 +91,7 @@ extern __inline__ void set_sbi_tid(int devid, int targetid)
                              "i" (ASI_M_CTL));
 }
 
-extern __inline__ int get_sbi_ctl(int devid, int cfgno)
+static inline int get_sbi_ctl(int devid, int cfgno)
 {
        int cfg;
        
@@ -102,7 +102,7 @@ extern __inline__ int get_sbi_ctl(int devid, int cfgno)
        return cfg;
 }
 
-extern __inline__ void set_sbi_ctl(int devid, int cfgno, int cfg)
+static inline void set_sbi_ctl(int devid, int cfgno, int cfg)
 {
        __asm__ __volatile__ ("sta %0, [%1] %2" : :
                              "r" (cfg),
index 3a8b3908728ac40105335bb6d51273ec803cadd2..a13cddcecec5df15ac6be4a2d074a6637652b91e 100644 (file)
  * numbers + offsets, and vice versa.
  */
 
-extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
+static inline unsigned long sbus_devaddr(int slotnum, unsigned long offset)
 {
   return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
 }
 
-extern __inline__ int sbus_dev_slot(unsigned long dev_addr)
+static inline int sbus_dev_slot(unsigned long dev_addr)
 {
   return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
 }
@@ -80,7 +80,7 @@ struct sbus_bus {
 
 extern struct sbus_bus *sbus_root;
 
-extern __inline__ int
+static inline int
 sbus_is_slave(struct sbus_dev *dev)
 {
        /* XXX Have to write this for sun4c's */
index 4f96d8333a12ad362a70b3c86d95937564cd43c5..580c51d011dfd56d6bf33ddcaf5e5355ea5b2b26 100644 (file)
@@ -60,22 +60,22 @@ BTFIXUPDEF_BLACKBOX(load_current)
 #define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
 #define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
 
-extern __inline__ void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
-extern __inline__ void xc1(smpfunc_t func, unsigned long arg1)
+static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
+static inline void xc1(smpfunc_t func, unsigned long arg1)
 { smp_cross_call(func, arg1, 0, 0, 0, 0); }
-extern __inline__ void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
+static inline void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
 { smp_cross_call(func, arg1, arg2, 0, 0, 0); }
-extern __inline__ void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
+static inline void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
                           unsigned long arg3)
 { smp_cross_call(func, arg1, arg2, arg3, 0, 0); }
-extern __inline__ void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
+static inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
                           unsigned long arg3, unsigned long arg4)
 { smp_cross_call(func, arg1, arg2, arg3, arg4, 0); }
-extern __inline__ void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
+static inline void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
                           unsigned long arg3, unsigned long arg4, unsigned long arg5)
 { smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); }
 
-extern __inline__ int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait)
+static inline int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait)
 {
        xc1((smpfunc_t)func, (unsigned long)info);
        return 0;
@@ -84,16 +84,16 @@ extern __inline__ int smp_call_function(void (*func)(void *info), void *info, in
 extern __volatile__ int __cpu_number_map[NR_CPUS];
 extern __volatile__ int __cpu_logical_map[NR_CPUS];
 
-extern __inline__ int cpu_logical_map(int cpu)
+static inline int cpu_logical_map(int cpu)
 {
        return __cpu_logical_map[cpu];
 }
-extern __inline__ int cpu_number_map(int cpu)
+static inline int cpu_number_map(int cpu)
 {
        return __cpu_number_map[cpu];
 }
 
-extern __inline__ int hard_smp4m_processor_id(void)
+static inline int hard_smp4m_processor_id(void)
 {
        int cpuid;
 
@@ -104,7 +104,7 @@ extern __inline__ int hard_smp4m_processor_id(void)
        return cpuid;
 }
 
-extern __inline__ int hard_smp4d_processor_id(void)
+static inline int hard_smp4d_processor_id(void)
 {
        int cpuid;
 
@@ -114,7 +114,7 @@ extern __inline__ int hard_smp4d_processor_id(void)
 }
 
 #ifndef MODULE
-extern __inline__ int hard_smp_processor_id(void)
+static inline int hard_smp_processor_id(void)
 {
        int cpuid;
 
@@ -136,7 +136,7 @@ extern __inline__ int hard_smp_processor_id(void)
        return cpuid;
 }
 #else
-extern __inline__ int hard_smp_processor_id(void)
+static inline int hard_smp_processor_id(void)
 {
        int cpuid;
        
index 9b9c28ed748e1d9f7426925f20c19d85358381e7..e7b6d346ae1098f832ae63a05ed126a8957373be 100644 (file)
@@ -15,7 +15,7 @@
  * atomic.
  */
 
-extern __inline__ __volatile__ char test_and_set(void *addr)
+static inline __volatile__ char test_and_set(void *addr)
 {
        char state = 0;
 
@@ -27,7 +27,7 @@ extern __inline__ __volatile__ char test_and_set(void *addr)
 }
 
 /* Initialize a spin-lock. */
-extern __inline__ __volatile__ smp_initlock(void *spinlock)
+static inline __volatile__ smp_initlock(void *spinlock)
 {
        /* Unset the lock. */
        *((unsigned char *) spinlock) = 0;
@@ -36,7 +36,7 @@ extern __inline__ __volatile__ smp_initlock(void *spinlock)
 }
 
 /* This routine spins until it acquires the lock at ADDR. */
-extern __inline__ __volatile__ smp_lock(void *addr)
+static inline __volatile__ smp_lock(void *addr)
 {
        while(test_and_set(addr) == 0xff)
                ;
@@ -46,7 +46,7 @@ extern __inline__ __volatile__ smp_lock(void *addr)
 }
 
 /* This routine releases the lock at ADDR. */
-extern __inline__ __volatile__ smp_unlock(void *addr)
+static inline __volatile__ smp_unlock(void *addr)
 {
        *((unsigned char *) addr) = 0;
 }
index 111727a2bb4e4f173b89434ddba3f4f00f191c91..e344c98a6f5f98145cf4d73fc97c89f02fc59255 100644 (file)
@@ -17,7 +17,7 @@
 #define __raw_spin_unlock_wait(lock) \
        do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0)
 
-extern __inline__ void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void __raw_spin_lock(raw_spinlock_t *lock)
 {
        __asm__ __volatile__(
        "\n1:\n\t"
@@ -37,7 +37,7 @@ extern __inline__ void __raw_spin_lock(raw_spinlock_t *lock)
        : "g2", "memory", "cc");
 }
 
-extern __inline__ int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int __raw_spin_trylock(raw_spinlock_t *lock)
 {
        unsigned int result;
        __asm__ __volatile__("ldstub [%1], %0"
@@ -47,7 +47,7 @@ extern __inline__ int __raw_spin_trylock(raw_spinlock_t *lock)
        return (result == 0);
 }
 
-extern __inline__ void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void __raw_spin_unlock(raw_spinlock_t *lock)
 {
        __asm__ __volatile__("stb %%g0, [%0]" : : "r" (lock) : "memory");
 }
@@ -78,7 +78,7 @@ extern __inline__ void __raw_spin_unlock(raw_spinlock_t *lock)
  *
  * Unfortunately this scheme limits us to ~16,000,000 cpus.
  */
-extern __inline__ void __read_lock(raw_rwlock_t *rw)
+static inline void __read_lock(raw_rwlock_t *rw)
 {
        register raw_rwlock_t *lp asm("g1");
        lp = rw;
@@ -98,7 +98,7 @@ do {  unsigned long flags; \
        local_irq_restore(flags); \
 } while(0)
 
-extern __inline__ void __read_unlock(raw_rwlock_t *rw)
+static inline void __read_unlock(raw_rwlock_t *rw)
 {
        register raw_rwlock_t *lp asm("g1");
        lp = rw;
index 3557781a4bfd7082bb8bbe8dd1e3a5c8d2bc1f1d..1f6b71f9e1b637f9c773e26db22dbc26e690402d 100644 (file)
@@ -204,7 +204,7 @@ static inline unsigned long getipl(void)
 BTFIXUPDEF_CALL(void, ___xchg32, void)
 #endif
 
-extern __inline__ unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned long val)
+static inline unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned long val)
 {
 #ifdef CONFIG_SMP
        __asm__ __volatile__("swap [%2], %0"
index 6690ab956ea6ada3997c68be08997e675284d3bb..f62c7f878ee1d043fb0afbf8b6d0f45c7ca2b655 100644 (file)
@@ -22,7 +22,7 @@ struct tt_entry {
 /* We set this to _start in system setup. */
 extern struct tt_entry *sparc_ttable;
 
-extern __inline__ unsigned long get_tbr(void)
+static inline unsigned long get_tbr(void)
 {
        unsigned long tbr;
 
index b63a33cf497181342351eeb629559a807bf5b161..0abd3a674e8f1abcd178f5f3fe9260efcc2a04ce 100644 (file)
 #define __JALAPENO_ID  0x003e0016
 
 #define CHEETAH_MANUF          0x003e
-#define CHEETAH_IMPL           0x0014
-#define CHEETAH_PLUS_IMPL      0x0015
-#define JALAPENO_IMPL          0x0016
+#define CHEETAH_IMPL           0x0014 /* Ultra-III   */
+#define CHEETAH_PLUS_IMPL      0x0015 /* Ultra-III+  */
+#define JALAPENO_IMPL          0x0016 /* Ultra-IIIi  */
+#define JAGUAR_IMPL            0x0018 /* Ultra-IV    */
+#define PANTHER_IMPL           0x0019 /* Ultra-IV+   */
+#define SERRANO_IMPL           0x0022 /* Ultra-IIIi+ */
 
 #define BRANCH_IF_CHEETAH_BASE(tmp1,tmp2,label)        \
        rdpr    %ver, %tmp1;                    \
index 0a336901d58576eb30a921df2b429b458447c2e6..b4959d2b0d991712cc4114644804d17a9152061f 100644 (file)
@@ -186,8 +186,8 @@ struct linux_prom_registers {
 };
 
 struct linux_prom64_registers {
-       long phys_addr;
-       long reg_size;
+       unsigned long phys_addr;
+       unsigned long reg_size;
 };
 
 struct linux_prom_irqs {
index c628189b6c89d6dbc70d59668ac8b2a87dd0f6ba..d02f1e8ae1a6cd9bbbe8c46a47be25ae9aa2ccaa 100644 (file)
@@ -95,20 +95,6 @@ extern int prom_devclose(int device_handle);
 extern void prom_seek(int device_handle, unsigned int seek_hival,
                      unsigned int seek_lowval);
 
-/* Machine memory configuration routine. */
-
-/* This function returns a V0 format memory descriptor table, it has three
- * entries.  One for the total amount of physical ram on the machine, one
- * for the amount of physical ram available, and one describing the virtual
- * areas which are allocated by the prom.  So, in a sense the physical
- * available is a calculation of the total physical minus the physical mapped
- * by the prom with virtual mappings.
- *
- * These lists are returned pre-sorted, this should make your life easier
- * since the prom itself is way too lazy to do such nice things.
- */
-extern struct linux_mem_p1275 *prom_meminfo(void);
-
 /* Miscellaneous routines, don't really fit in any category per se. */
 
 /* Reboot the machine with the command line passed. */
index 7f8d764abc47df424b469c8809855fb67fb2deb6..5426bb28a9931956a46585268a4b86e2703a50f2 100644 (file)
@@ -140,23 +140,6 @@ extern unsigned long page_to_pfn(struct page *);
 #define virt_to_phys __pa
 #define phys_to_virt __va
 
-/* The following structure is used to hold the physical
- * memory configuration of the machine.  This is filled in
- * probe_memory() and is later used by mem_init() to set up
- * mem_map[].  We statically allocate SPARC_PHYS_BANKS of
- * these structs, this is arbitrary.  The entry after the
- * last valid one has num_bytes==0.
- */
-
-struct sparc_phys_banks {
-       unsigned long base_addr;
-       unsigned long num_bytes;
-};
-
-#define SPARC_PHYS_BANKS 32
-
-extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
-
 #endif /* !(__ASSEMBLY__) */
 
 #define VM_DATA_DEFAULT_FLAGS  (VM_READ | VM_WRITE | VM_EXEC | \
index 43cbb089cde2dfc08e500086b5c251b2d766eea2..8c6dfc6c7af6e6d67ab3e1893cd66421208adbd8 100644 (file)
@@ -98,7 +98,9 @@
 #define _PAGE_NFO      _AC(0x1000000000000000,UL) /* No Fault Only          */
 #define _PAGE_IE       _AC(0x0800000000000000,UL) /* Invert Endianness      */
 #define _PAGE_SOFT2    _AC(0x07FC000000000000,UL) /* Software bits, set 2   */
-#define _PAGE_RES1     _AC(0x0003000000000000,UL) /* Reserved               */
+#define _PAGE_RES1     _AC(0x0002000000000000,UL) /* Reserved               */
+#define _PAGE_SZ32MB   _AC(0x0001000000000000,UL) /* (Panther) 32MB page    */
+#define _PAGE_SZ256MB  _AC(0x2001000000000000,UL) /* (Panther) 256MB page   */
 #define _PAGE_SN       _AC(0x0000800000000000,UL) /* (Cheetah) Snoop        */
 #define _PAGE_RES2     _AC(0x0000780000000000,UL) /* Reserved               */
 #define _PAGE_PADDR_SF _AC(0x000001FFFFFFE000,UL) /* (Spitfire) paddr[40:13]*/
@@ -339,6 +341,9 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *p
 extern pgd_t swapper_pg_dir[2048];
 extern pmd_t swapper_low_pmd_dir[2048];
 
+extern void paging_init(void);
+extern unsigned long find_ecache_flush_span(unsigned long size);
+
 /* These do nothing with the way I have things setup. */
 #define mmu_lockarea(vaddr, len)               (vaddr)
 #define mmu_unlockarea(vaddr, len)             do { } while(0)
index 80a65d7e3dbff92308d2b4e1bf5e394e45c97551..203e8eee63515db1fa9a7dd5ed998aacfe99b460 100644 (file)
@@ -70,26 +70,14 @@ static inline int access_ok(int type, const void __user * addr, unsigned long si
  * with the main instruction path.  This means when everything is well,
  * we don't even have to jump over them.  Further, they do not intrude
  * on our cache or tlb entries.
- *
- * There is a special way how to put a range of potentially faulting
- * insns (like twenty ldd/std's with now intervening other instructions)
- * You specify address of first in insn and 0 in fixup and in the next
- * exception_table_entry you specify last potentially faulting insn + 1
- * and in fixup the routine which should handle the fault.
- * That fixup code will get
- * (faulting_insn_address - first_insn_in_the_range_address)/4
- * in %g2 (ie. index of the faulting instruction in the range).
  */
 
-struct exception_table_entry
-{
-        unsigned insn, fixup;
+struct exception_table_entry {
+        unsigned int insn, fixup;
 };
 
-/* Special exable search, which handles ranges.  Returns fixup */
-unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
-
 extern void __ret_efault(void);
+extern void __retl_efault(void);
 
 /* Uh, these should become the main single-value transfer routines..
  * They automatically use the right size if we just have the right
@@ -263,7 +251,7 @@ copy_from_user(void *to, const void __user *from, unsigned long size)
 {
        unsigned long ret = ___copy_from_user(to, from, size);
 
-       if (ret)
+       if (unlikely(ret))
                ret = copy_from_user_fixup(to, from, size);
        return ret;
 }
@@ -279,7 +267,7 @@ copy_to_user(void __user *to, const void *from, unsigned long size)
 {
        unsigned long ret = ___copy_to_user(to, from, size);
 
-       if (ret)
+       if (unlikely(ret))
                ret = copy_to_user_fixup(to, from, size);
        return ret;
 }
@@ -295,7 +283,7 @@ copy_in_user(void __user *to, void __user *from, unsigned long size)
 {
        unsigned long ret = ___copy_in_user(to, from, size);
 
-       if (ret)
+       if (unlikely(ret))
                ret = copy_in_user_fixup(to, from, size);
        return ret;
 }
index 2d242360c3d655b12e0494528901af2dfa945fc0..075771c371f6a40be8b1e1dc5e6a0731711d11ec 100644 (file)
@@ -13,6 +13,7 @@ struct task_struct;
 #include "linux/config.h"
 #include "asm/ptrace.h"
 #include "choose-mode.h"
+#include "registers.h"
 
 struct mm_struct;
 
@@ -136,19 +137,15 @@ extern struct cpuinfo_um cpu_data[];
 #define current_cpu_data boot_cpu_data
 #endif
 
-#define KSTK_EIP(tsk) (PT_REGS_IP(&tsk->thread.regs))
-#define KSTK_ESP(tsk) (PT_REGS_SP(&tsk->thread.regs))
-#define get_wchan(p) (0)
 
+#ifdef CONFIG_MODE_SKAS
+#define KSTK_REG(tsk, reg) \
+       ({ union uml_pt_regs regs; \
+          get_thread_regs(&regs, tsk->thread.mode.skas.switch_buf); \
+          UPT_REG(&regs, reg); })
+#else
+#define KSTK_REG(tsk, reg) (0xbadbabe)
 #endif
+#define get_wchan(p) (0)
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+#endif
index 431bad3ae9d7cf33f72ec43cdd779e58cec12bb2..4108a579eb92a531f1010a1f0dd3f7e321dbd15c 100644 (file)
@@ -43,17 +43,10 @@ static inline void rep_nop(void)
 #define ARCH_IS_STACKGROW(address) \
        (address + 32 >= UPT_SP(&current->thread.regs.regs))
 
+#define KSTK_EIP(tsk) KSTK_REG(tsk, EIP)
+#define KSTK_ESP(tsk) KSTK_REG(tsk, UESP)
+#define KSTK_EBP(tsk) KSTK_REG(tsk, EBP)
+
 #include "asm/processor-generic.h"
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 0beb9a42ae05b5cf1afe8fd45d3e914837b6ad0f..e1e1255a1d3655c18bc2aa2206eead6187170a2b 100644 (file)
@@ -36,17 +36,9 @@ extern inline void rep_nop(void)
 #define ARCH_IS_STACKGROW(address) \
         (address + 128 >= UPT_SP(&current->thread.regs.regs))
 
+#define KSTK_EIP(tsk) KSTK_REG(tsk, RIP)
+#define KSTK_ESP(tsk) KSTK_REG(tsk, RSP)
+
 #include "asm/processor-generic.h"
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 801710d00a404ec6dd175714a9e074789ffe158e..2ee028b8de9df8f74edeb1c67b1f4375c3ae82b1 100644 (file)
@@ -44,7 +44,7 @@
         const __typeof__(ptr) __private_ptr = ptr; \
         __typeof__(*(__private_ptr)) __private_val; \
         int __private_ret = -EFAULT; \
-        (x) = 0; \
+        (x) = (__typeof__(*(__private_ptr)))0; \
        if (__copy_from_user(&__private_val, (__private_ptr), \
            sizeof(*(__private_ptr))) == 0) {\
                (x) = (__typeof__(*(__private_ptr))) __private_val; \
index 4d727f3f5550bb2eadba0a20829bbf96ff970050..5a7fe3c6c3d8427c51e3bbf8daf54c81a4ec05dc 100644 (file)
@@ -234,6 +234,7 @@ static inline unsigned int cpuid_edx(unsigned int op)
 #define MSR_K8_TOP_MEM1                   0xC001001A
 #define MSR_K8_TOP_MEM2                   0xC001001D
 #define MSR_K8_SYSCFG             0xC0010010
+#define MSR_K8_HWCR               0xC0010015
 
 /* K6 MSRs */
 #define MSR_K6_EFER                    0xC0000080
index 2cb483516459dd3efb48fa48269b66c3beb8d072..dd8711ecaf2ff71cf1bf0c6fd14d3ba690849465 100644 (file)
@@ -384,7 +384,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 }
 
 #define pte_index(address) \
-               ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+               (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_kernel(*(dir)) + \
                        pte_index(address))
 
index a4d5af907f900da1183e40fa0d9c452c1dbf85d6..60def658b2462f3282c9802a6241b67c3b441b65 100644 (file)
@@ -43,6 +43,40 @@ struct kioctx;
 #define kiocbIsKicked(iocb)    test_bit(KIF_KICKED, &(iocb)->ki_flags)
 #define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags)
 
+/* is there a better place to document function pointer methods? */
+/**
+ * ki_retry    -       iocb forward progress callback
+ * @kiocb:     The kiocb struct to advance by performing an operation.
+ *
+ * This callback is called when the AIO core wants a given AIO operation
+ * to make forward progress.  The kiocb argument describes the operation
+ * that is to be performed.  As the operation proceeds, perhaps partially,
+ * ki_retry is expected to update the kiocb with progress made.  Typically
+ * ki_retry is set in the AIO core and it itself calls file_operations
+ * helpers.
+ *
+ * ki_retry's return value determines when the AIO operation is completed
+ * and an event is generated in the AIO event ring.  Except the special
+ * return values described below, the value that is returned from ki_retry
+ * is transferred directly into the completion ring as the operation's
+ * resulting status.  Once this has happened ki_retry *MUST NOT* reference
+ * the kiocb pointer again.
+ *
+ * If ki_retry returns -EIOCBQUEUED it has made a promise that aio_complete()
+ * will be called on the kiocb pointer in the future.  The AIO core will
+ * not ask the method again -- ki_retry must ensure forward progress.
+ * aio_complete() must be called once and only once in the future, multiple
+ * calls may result in undefined behaviour.
+ *
+ * If ki_retry returns -EIOCBRETRY it has made a promise that kick_iocb()
+ * will be called on the kiocb pointer in the future.  This may happen
+ * through generic helpers that associate kiocb->ki_wait with a wait
+ * queue head that ki_retry uses via current->io_wait.  It can also happen
+ * with custom tracking and manual calls to kick_iocb(), though that is
+ * discouraged.  In either case, kick_iocb() must be called once and only
+ * once.  ki_retry must ensure forward progress, the AIO core will wait
+ * indefinitely for kick_iocb() to be called.
+ */
 struct kiocb {
        struct list_head        ki_run_list;
        long                    ki_flags;
index 9f374cfa1b05ac7afe0495f87939dd4511341e80..aca9b344bd356d5fa62cda22811d902957bb7edb 100644 (file)
@@ -76,6 +76,13 @@ struct atm_dev_stats {
                                        /* set interface ESI */
 #define ATM_SETESIF    _IOW('a',ATMIOC_ITF+13,struct atmif_sioc)
                                        /* force interface ESI */
+#define ATM_ADDLECSADDR        _IOW('a', ATMIOC_ITF+14, struct atmif_sioc)
+                                       /* register a LECS address */
+#define ATM_DELLECSADDR        _IOW('a', ATMIOC_ITF+15, struct atmif_sioc)
+                                       /* unregister a LECS address */
+#define ATM_GETLECSADDR        _IOW('a', ATMIOC_ITF+16, struct atmif_sioc)
+                                       /* retrieve LECS address(es) */
+
 #define ATM_GETSTAT    _IOW('a',ATMIOC_SARCOM+0,struct atmif_sioc)
                                        /* get AAL layer statistics */
 #define ATM_GETSTATZ   _IOW('a',ATMIOC_SARCOM+1,struct atmif_sioc)
@@ -328,6 +335,8 @@ struct atm_dev_addr {
        struct list_head entry;         /* next address */
 };
 
+enum atm_addr_type_t { ATM_ADDR_LOCAL, ATM_ADDR_LECS };
+
 struct atm_dev {
        const struct atmdev_ops *ops;   /* device operations; NULL if unused */
        const struct atmphy_ops *phy;   /* PHY operations, may be undefined */
@@ -338,6 +347,7 @@ struct atm_dev {
        void            *phy_data;      /* private PHY date */
        unsigned long   flags;          /* device flags (ATM_DF_*) */
        struct list_head local;         /* local ATM addresses */
+       struct list_head lecs;          /* LECS ATM addresses learned via ILMI */
        unsigned char   esi[ESI_LEN];   /* ESI ("MAC" addr) */
        struct atm_cirange ci_range;    /* VPI/VCI range */
        struct k_atm_dev_stats stats;   /* statistics */
@@ -457,7 +467,7 @@ static inline void atm_dev_put(struct atm_dev *dev)
 
 int atm_charge(struct atm_vcc *vcc,int truesize);
 struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
-    int gfp_flags);
+    unsigned int __nocast gfp_flags);
 int atm_pcr_goal(struct atm_trafprm *tp);
 
 void vcc_release_async(struct atm_vcc *vcc, int reply);
index c1237aa92e38439649d1a9740985936f0e5a3c72..8ed6dfdcd78337f3a5b36066223c3cd2bc2ade80 100644 (file)
 
 /* BFS inode layout on disk */
 struct bfs_inode {
-       __u16 i_ino;
+       __le16 i_ino;
        __u16 i_unused;
-       __u32 i_sblock;
-       __u32 i_eblock;
-       __u32 i_eoffset;
-       __u32 i_vtype;
-       __u32 i_mode;
-       __s32 i_uid;
-       __s32 i_gid;
-       __u32 i_nlink;
-       __u32 i_atime;
-       __u32 i_mtime;
-       __u32 i_ctime;
+       __le32 i_sblock;
+       __le32 i_eblock;
+       __le32 i_eoffset;
+       __le32 i_vtype;
+       __le32 i_mode;
+       __le32 i_uid;
+       __le32 i_gid;
+       __le32 i_nlink;
+       __le32 i_atime;
+       __le32 i_mtime;
+       __le32 i_ctime;
        __u32 i_padding[4];
 };
 
@@ -41,17 +41,17 @@ struct bfs_inode {
 #define BFS_DIRS_PER_BLOCK     32
 
 struct bfs_dirent {
-       __u16 ino;
+       __le16 ino;
        char name[BFS_NAMELEN];
 };
 
 /* BFS superblock layout on disk */
 struct bfs_super_block {
-       __u32 s_magic;
-       __u32 s_start;
-       __u32 s_end;
-       __s32 s_from;
-       __s32 s_to;
+       __le32 s_magic;
+       __le32 s_start;
+       __le32 s_end;
+       __le32 s_from;
+       __le32 s_to;
        __s32 s_bfrom;
        __s32 s_bto;
        char  s_fsname[6];
@@ -66,15 +66,15 @@ struct bfs_super_block {
 #define BFS_INO2OFF(ino) \
        ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE)
 #define BFS_NZFILESIZE(ip) \
-        ((cpu_to_le32((ip)->i_eoffset) + 1) -  cpu_to_le32((ip)->i_sblock) * BFS_BSIZE)
+        ((le32_to_cpu((ip)->i_eoffset) + 1) -  le32_to_cpu((ip)->i_sblock) * BFS_BSIZE)
 
 #define BFS_FILESIZE(ip) \
         ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip))
 
 #define BFS_FILEBLOCKS(ip) \
-        ((ip)->i_sblock == 0 ? 0 : (cpu_to_le32((ip)->i_eblock) + 1) -  cpu_to_le32((ip)->i_sblock))
+        ((ip)->i_sblock == 0 ? 0 : (le32_to_cpu((ip)->i_eblock) + 1) -  le32_to_cpu((ip)->i_sblock))
 #define BFS_UNCLEAN(bfs_sb, sb)        \
-       ((cpu_to_le32(bfs_sb->s_from) != -1) && (cpu_to_le32(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY))
+       ((le32_to_cpu(bfs_sb->s_from) != -1) && (le32_to_cpu(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY))
 
 
 #endif /* _LINUX_BFS_FS_H */
index 86d4b0a81713733bb1cbb137d6dd2861ddd58623..96582c9911ac225e8523aba9dc9cc4e205c4f1b7 100644 (file)
@@ -149,7 +149,7 @@ struct cn_dev {
 
 int cn_add_callback(struct cb_id *, char *, void (*callback) (void *));
 void cn_del_callback(struct cb_id *);
-int cn_netlink_send(struct cn_msg *, u32, int);
+int cn_netlink_send(struct cn_msg *, u32, unsigned int __nocast);
 
 int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(void *));
 void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
index fc2d4c8225aa80d0429572594d26c87a8a5f9425..d21c305c6c64cec22a264fd6cb8f6ae6fb22e784 100644 (file)
@@ -111,7 +111,9 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
        return (struct ethhdr *)skb->mac.raw;
 }
 
+#ifdef CONFIG_SYSCTL
 extern struct ctl_table ether_table[];
 #endif
+#endif
 
 #endif /* _LINUX_IF_ETHER_H */
index 7e1e15f934f340851c503c789e701724d81bcb0c..fd7af86151b1ed06879f12cd5fa3323cb1533f46 100644 (file)
@@ -142,13 +142,21 @@ static __inline__ int bad_mask(u32 mask, u32 addr)
 
 #define endfor_ifa(in_dev) }
 
+static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
+{
+       struct in_device *in_dev = dev->ip_ptr;
+       if (in_dev)
+               in_dev = rcu_dereference(in_dev);
+       return in_dev;
+}
+
 static __inline__ struct in_device *
 in_dev_get(const struct net_device *dev)
 {
        struct in_device *in_dev;
 
        rcu_read_lock();
-       in_dev = dev->ip_ptr;
+       in_dev = __in_dev_get_rcu(dev);
        if (in_dev)
                atomic_inc(&in_dev->refcnt);
        rcu_read_unlock();
@@ -156,7 +164,7 @@ in_dev_get(const struct net_device *dev)
 }
 
 static __inline__ struct in_device *
-__in_dev_get(const struct net_device *dev)
+__in_dev_get_rtnl(const struct net_device *dev)
 {
        return (struct in_device*)dev->ip_ptr;
 }
index bb6f88e14061ed6d3543a632aebb7b616fca0a1e..e0b922785d985e5c2a03598303ad011cb0dbc9d4 100644 (file)
@@ -372,8 +372,9 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
 #define inet_v6_ipv6only(__sk)         0
 #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
 
-#define INET6_MATCH(__sk, __saddr, __daddr, __ports, __dif)       \
-       (((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports))   && \
+#define INET6_MATCH(__sk, __hash, __saddr, __daddr, __ports, __dif)\
+       (((__sk)->sk_hash == (__hash))                          && \
+        ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports))   && \
         ((__sk)->sk_family             == AF_INET6)            && \
         ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr))     && \
         ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
index 918c34a8347e6eb2b33624026f28d0a36bf77476..7a2e332067c33cdd39e33ad9d83bd7e6cd676f2e 100644 (file)
@@ -38,97 +38,16 @@ struct keyring_list {
        struct key      *keys[0];
 };
 
-
 /*
  * check to see whether permission is granted to use a key in the desired way
  */
-static inline int key_permission(const key_ref_t key_ref, key_perm_t perm)
-{
-       struct key *key = key_ref_to_ptr(key_ref);
-       key_perm_t kperm;
-
-       if (is_key_possessed(key_ref))
-               kperm = key->perm >> 24;
-       else if (key->uid == current->fsuid)
-               kperm = key->perm >> 16;
-       else if (key->gid != -1 &&
-                key->perm & KEY_GRP_ALL &&
-                in_group_p(key->gid)
-                )
-               kperm = key->perm >> 8;
-       else
-               kperm = key->perm;
-
-       kperm = kperm & perm & KEY_ALL;
-
-       return kperm == perm;
-}
-
-/*
- * check to see whether permission is granted to use a key in at least one of
- * the desired ways
- */
-static inline int key_any_permission(const key_ref_t key_ref, key_perm_t perm)
-{
-       struct key *key = key_ref_to_ptr(key_ref);
-       key_perm_t kperm;
-
-       if (is_key_possessed(key_ref))
-               kperm = key->perm >> 24;
-       else if (key->uid == current->fsuid)
-               kperm = key->perm >> 16;
-       else if (key->gid != -1 &&
-                key->perm & KEY_GRP_ALL &&
-                in_group_p(key->gid)
-                )
-               kperm = key->perm >> 8;
-       else
-               kperm = key->perm;
+extern int key_task_permission(const key_ref_t key_ref,
+                              struct task_struct *context,
+                              key_perm_t perm);
 
-       kperm = kperm & perm & KEY_ALL;
-
-       return kperm != 0;
-}
-
-static inline int key_task_groups_search(struct task_struct *tsk, gid_t gid)
-{
-       int ret;
-
-       task_lock(tsk);
-       ret = groups_search(tsk->group_info, gid);
-       task_unlock(tsk);
-       return ret;
-}
-
-static inline int key_task_permission(const key_ref_t key_ref,
-                                     struct task_struct *context,
-                                     key_perm_t perm)
+static inline int key_permission(const key_ref_t key_ref, key_perm_t perm)
 {
-       struct key *key = key_ref_to_ptr(key_ref);
-       key_perm_t kperm;
-
-       if (is_key_possessed(key_ref)) {
-               kperm = key->perm >> 24;
-       }
-       else if (key->uid == context->fsuid) {
-               kperm = key->perm >> 16;
-       }
-       else if (key->gid != -1 &&
-                key->perm & KEY_GRP_ALL && (
-                        key->gid == context->fsgid ||
-                        key_task_groups_search(context, key->gid)
-                        )
-                ) {
-               kperm = key->perm >> 8;
-       }
-       else {
-               kperm = key->perm;
-       }
-
-       kperm = kperm & perm & KEY_ALL;
-
-       return kperm == perm;
-
+       return key_task_permission(key_ref, current, perm);
 }
 
 extern key_ref_t lookup_user_key(struct task_struct *context,
index 4ed2107bc020f68e257e46d318e402b4bfecf4de..2f0299a448f68687e0bf430c3f531f07fbe029d2 100644 (file)
@@ -183,7 +183,7 @@ struct of_device_id
        char    name[32];
        char    type[32];
        char    compatible[128];
-#if __KERNEL__
+#ifdef __KERNEL__
        void    *data;
 #else
        kernel_ulong_t data;
index 7c717907896d1d5de04ac4028f70a0ff83b8bb13..368e4c825ff1b5006adfe8a962083500a6776e0c 100644 (file)
@@ -265,6 +265,8 @@ struct net_device
         * the interface.
         */
        char                    name[IFNAMSIZ];
+       /* device name hash chain */
+       struct hlist_node       name_hlist;
 
        /*
         *      I/O specific fields
@@ -292,6 +294,21 @@ struct net_device
 
        /* ------- Fields preinitialized in Space.c finish here ------- */
 
+       /* Net device features */
+       unsigned long           features;
+#define NETIF_F_SG             1       /* Scatter/gather IO. */
+#define NETIF_F_IP_CSUM                2       /* Can checksum only TCP/UDP over IPv4. */
+#define NETIF_F_NO_CSUM                4       /* Does not require checksum. F.e. loopack. */
+#define NETIF_F_HW_CSUM                8       /* Can checksum all the packets. */
+#define NETIF_F_HIGHDMA                32      /* Can DMA to high memory. */
+#define NETIF_F_FRAGLIST       64      /* Scatter/gather IO. */
+#define NETIF_F_HW_VLAN_TX     128     /* Transmit VLAN hw acceleration */
+#define NETIF_F_HW_VLAN_RX     256     /* Receive VLAN hw acceleration */
+#define NETIF_F_HW_VLAN_FILTER 512     /* Receive filtering on VLAN */
+#define NETIF_F_VLAN_CHALLENGED        1024    /* Device cannot handle VLAN packets */
+#define NETIF_F_TSO            2048    /* Can offload TCP/IP segmentation */
+#define NETIF_F_LLTX           4096    /* LockLess TX */
+
        struct net_device       *next_sched;
 
        /* Interface index. Unique device identifier    */
@@ -316,9 +333,6 @@ struct net_device
         * will (read: may be cleaned up at will).
         */
 
-       /* These may be needed for future network-power-down code. */
-       unsigned long           trans_start;    /* Time (in jiffies) of last Tx */
-       unsigned long           last_rx;        /* Time of last Rx      */
 
        unsigned short          flags;  /* interface flags (a la BSD)   */
        unsigned short          gflags;
@@ -328,15 +342,12 @@ struct net_device
        unsigned                mtu;    /* interface MTU value          */
        unsigned short          type;   /* interface hardware type      */
        unsigned short          hard_header_len;        /* hardware hdr length  */
-       void                    *priv;  /* pointer to private data      */
 
        struct net_device       *master; /* Pointer to master device of a group,
                                          * which this device is member of.
                                          */
 
        /* Interface address info. */
-       unsigned char           broadcast[MAX_ADDR_LEN];        /* hw bcast add */
-       unsigned char           dev_addr[MAX_ADDR_LEN]; /* hw address   */
        unsigned char           perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
        unsigned char           addr_len;       /* hardware address length      */
        unsigned short          dev_id;         /* for shared network cards */
@@ -346,8 +357,6 @@ struct net_device
        int                     promiscuity;
        int                     allmulti;
 
-       int                     watchdog_timeo;
-       struct timer_list       watchdog_timer;
 
        /* Protocol specific pointers */
        
@@ -358,32 +367,62 @@ struct net_device
        void                    *ec_ptr;        /* Econet specific data */
        void                    *ax25_ptr;      /* AX.25 specific data */
 
-       struct list_head        poll_list;      /* Link to poll list    */
+/*
+ * Cache line mostly used on receive path (including eth_type_trans())
+ */
+       struct list_head        poll_list ____cacheline_aligned_in_smp;
+                                       /* Link to poll list    */
+
+       int                     (*poll) (struct net_device *dev, int *quota);
        int                     quota;
        int                     weight;
+       unsigned long           last_rx;        /* Time of last Rx      */
+       /* Interface address info used in eth_type_trans() */
+       unsigned char           dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast 
+                                                       because most packets are unicast) */
+
+       unsigned char           broadcast[MAX_ADDR_LEN];        /* hw bcast add */
 
+/*
+ * Cache line mostly used on queue transmit path (qdisc)
+ */
+       /* device queue lock */
+       spinlock_t              queue_lock ____cacheline_aligned_in_smp;
        struct Qdisc            *qdisc;
        struct Qdisc            *qdisc_sleeping;
-       struct Qdisc            *qdisc_ingress;
        struct list_head        qdisc_list;
        unsigned long           tx_queue_len;   /* Max frames per queue allowed */
 
        /* ingress path synchronizer */
        spinlock_t              ingress_lock;
+       struct Qdisc            *qdisc_ingress;
+
+/*
+ * One part is mostly used on xmit path (device)
+ */
        /* hard_start_xmit synchronizer */
-       spinlock_t              xmit_lock;
+       spinlock_t              xmit_lock ____cacheline_aligned_in_smp;
        /* cpu id of processor entered to hard_start_xmit or -1,
           if nobody entered there.
         */
        int                     xmit_lock_owner;
-       /* device queue lock */
-       spinlock_t              queue_lock;
+       void                    *priv;  /* pointer to private data      */
+       int                     (*hard_start_xmit) (struct sk_buff *skb,
+                                                   struct net_device *dev);
+       /* These may be needed for future network-power-down code. */
+       unsigned long           trans_start;    /* Time (in jiffies) of last Tx */
+
+       int                     watchdog_timeo; /* used by dev_watchdog() */
+       struct timer_list       watchdog_timer;
+
+/*
+ * refcnt is a very hot point, so align it on SMP
+ */
        /* Number of references to this device */
-       atomic_t                refcnt;
+       atomic_t                refcnt ____cacheline_aligned_in_smp;
+
        /* delayed register/unregister */
        struct list_head        todo_list;
-       /* device name hash chain */
-       struct hlist_node       name_hlist;
        /* device index hash chain */
        struct hlist_node       index_hlist;
 
@@ -396,21 +435,6 @@ struct net_device
               NETREG_RELEASED,         /* called free_netdev */
        } reg_state;
 
-       /* Net device features */
-       unsigned long           features;
-#define NETIF_F_SG             1       /* Scatter/gather IO. */
-#define NETIF_F_IP_CSUM                2       /* Can checksum only TCP/UDP over IPv4. */
-#define NETIF_F_NO_CSUM                4       /* Does not require checksum. F.e. loopack. */
-#define NETIF_F_HW_CSUM                8       /* Can checksum all the packets. */
-#define NETIF_F_HIGHDMA                32      /* Can DMA to high memory. */
-#define NETIF_F_FRAGLIST       64      /* Scatter/gather IO. */
-#define NETIF_F_HW_VLAN_TX     128     /* Transmit VLAN hw acceleration */
-#define NETIF_F_HW_VLAN_RX     256     /* Receive VLAN hw acceleration */
-#define NETIF_F_HW_VLAN_FILTER 512     /* Receive filtering on VLAN */
-#define NETIF_F_VLAN_CHALLENGED        1024    /* Device cannot handle VLAN packets */
-#define NETIF_F_TSO            2048    /* Can offload TCP/IP segmentation */
-#define NETIF_F_LLTX           4096    /* LockLess TX */
-
        /* Called after device is detached from network. */
        void                    (*uninit)(struct net_device *dev);
        /* Called after last user reference disappears. */
@@ -419,10 +443,7 @@ struct net_device
        /* Pointers to interface service routines.      */
        int                     (*open)(struct net_device *dev);
        int                     (*stop)(struct net_device *dev);
-       int                     (*hard_start_xmit) (struct sk_buff *skb,
-                                                   struct net_device *dev);
 #define HAVE_NETDEV_POLL
-       int                     (*poll) (struct net_device *dev, int *quota);
        int                     (*hard_header) (struct sk_buff *skb,
                                                struct net_device *dev,
                                                unsigned short type,
index 68f11ac1a3147f5c56d244c81909e0ebb8ab1bbb..f74ed94624755003a3e628069fcb4364cf2780e2 100644 (file)
 #define PCI_DEVICE_ID_LSI_61C102       0x0901
 #define PCI_DEVICE_ID_LSI_63C815       0x1000
 #define PCI_DEVICE_ID_LSI_SAS1064      0x0050
+#define PCI_DEVICE_ID_LSI_SAS1064R     0x0411
 #define PCI_DEVICE_ID_LSI_SAS1066      0x005E
 #define PCI_DEVICE_ID_LSI_SAS1068      0x0054
 #define PCI_DEVICE_ID_LSI_SAS1064A     0x005C
 #define PCI_DEVICE_ID_NS_87560_USB     0x0012
 #define PCI_DEVICE_ID_NS_83815         0x0020
 #define PCI_DEVICE_ID_NS_83820         0x0022
+#define PCI_DEVICE_ID_NS_SATURN                0x0035
 #define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
 #define PCI_DEVICE_ID_NS_SCx200_SMI    0x0501
 #define PCI_DEVICE_ID_NS_SCx200_IDE    0x0502
 #define PCI_VENDOR_ID_DELL             0x1028
 #define PCI_DEVICE_ID_DELL_RACIII      0x0008
 #define PCI_DEVICE_ID_DELL_RAC4                0x0012
+#define PCI_DEVICE_ID_DELL_PERC5       0x0015
 
 #define PCI_VENDOR_ID_MATROX           0x102B
 #define PCI_DEVICE_ID_MATROX_MGA_2     0x0518
 #define PCI_DEVICE_ID_SUN_SABRE                0xa000
 #define PCI_DEVICE_ID_SUN_HUMMINGBIRD  0xa001
 #define PCI_DEVICE_ID_SUN_TOMATILLO    0xa801
+#define PCI_DEVICE_ID_SUN_CASSINI      0xabba
 
 #define PCI_VENDOR_ID_CMD              0x1095
 #define PCI_DEVICE_ID_CMD_640          0x0640
index 49e617fa0f662a10a04980ed0f2b3997a1adc0d0..c3ba31f210a963a466d22d50d3fd5a42b03e15d4 100644 (file)
@@ -107,13 +107,25 @@ extern unsigned long nr_iowait(void);
 
 #include <asm/processor.h>
 
+/*
+ * Task state bitmask. NOTE! These bits are also
+ * encoded in fs/proc/array.c: get_task_state().
+ *
+ * We have two separate sets of flags: task->state
+ * is about runnability, while task->exit_state are
+ * about the task exiting. Confusing, but this way
+ * modifying one set can't modify the other one by
+ * mistake.
+ */
 #define TASK_RUNNING           0
 #define TASK_INTERRUPTIBLE     1
 #define TASK_UNINTERRUPTIBLE   2
 #define TASK_STOPPED           4
 #define TASK_TRACED            8
+/* in tsk->exit_state */
 #define EXIT_ZOMBIE            16
 #define EXIT_DEAD              32
+/* in tsk->state again */
 #define TASK_NONINTERACTIVE    64
 
 #define __set_task_state(tsk, state_value)             \
index 2741c0c55e83e1f486a7effc3772a63da8f4e3ed..466c879f82b8fb36a2657878d3c85d08e5a6c89e 100644 (file)
@@ -155,8 +155,6 @@ struct skb_shared_info {
 #define SKB_DATAREF_SHIFT 16
 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
 
-extern struct timeval skb_tv_base;
-
 struct skb_timeval {
        u32     off_sec;
        u32     off_usec;
@@ -175,7 +173,7 @@ enum {
  *     @prev: Previous buffer in list
  *     @list: List we are on
  *     @sk: Socket we are owned by
- *     @tstamp: Time we arrived stored as offset to skb_tv_base
+ *     @tstamp: Time we arrived
  *     @dev: Device we arrived on/are leaving by
  *     @input_dev: Device we arrived on
  *     @h: Transport layer header
@@ -1255,10 +1253,6 @@ static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *
 {
        stamp->tv_sec  = skb->tstamp.off_sec;
        stamp->tv_usec = skb->tstamp.off_usec;
-       if (skb->tstamp.off_sec) {
-               stamp->tv_sec  += skb_tv_base.tv_sec;
-               stamp->tv_usec += skb_tv_base.tv_usec;
-       }
 }
 
 /**
@@ -1272,8 +1266,8 @@ static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *
  */
 static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp)
 {
-       skb->tstamp.off_sec  = stamp->tv_sec - skb_tv_base.tv_sec;
-       skb->tstamp.off_usec = stamp->tv_usec - skb_tv_base.tv_usec;
+       skb->tstamp.off_sec  = stamp->tv_sec;
+       skb->tstamp.off_usec = stamp->tv_usec;
 }
 
 extern void __net_timestamp(struct sk_buff *skb);
index 081b1ee8516edde81c7583d9248ef760c87b0f3f..e21937cf91d0e4510659566215260b13a9c9b6b8 100644 (file)
@@ -71,7 +71,7 @@ enum
        TCF_META_ID_SK_SNDBUF,
        TCF_META_ID_SK_ALLOCS,
        TCF_META_ID_SK_ROUTE_CAPS,
-       TCF_META_ID_SK_HASHENT,
+       TCF_META_ID_SK_HASH,
        TCF_META_ID_SK_LINGERTIME,
        TCF_META_ID_SK_ACK_BACKLOG,
        TCF_META_ID_SK_MAX_ACK_BACKLOG,
index 941f45ac117a41363fb0758243950d382d16a919..1a4990e448e9074a7c8a030b56c52271eff1221a 100644 (file)
@@ -158,7 +158,8 @@ extern unsigned int textsearch_find_continuous(struct ts_config *,
 #define TS_PRIV_ALIGNTO        8
 #define TS_PRIV_ALIGN(len) (((len) + TS_PRIV_ALIGNTO-1) & ~(TS_PRIV_ALIGNTO-1))
 
-static inline struct ts_config *alloc_ts_config(size_t payload, int gfp_mask)
+static inline struct ts_config *alloc_ts_config(size_t payload,
+                                               unsigned int __nocast gfp_mask)
 {
        struct ts_config *conf;
 
index 6bbeafa73e8bfb3384d53382c1bd8c1fdb9ac49d..8a0891e2e888bb83e267186961ab9c684b11ac78 100644 (file)
@@ -19,9 +19,9 @@ extern void dn_nsp_send_data_ack(struct sock *sk);
 extern void dn_nsp_send_oth_ack(struct sock *sk);
 extern void dn_nsp_delayed_ack(struct sock *sk);
 extern void dn_send_conn_ack(struct sock *sk);
-extern void dn_send_conn_conf(struct sock *sk, int gfp);
+extern void dn_send_conn_conf(struct sock *sk, unsigned int __nocast gfp);
 extern void dn_nsp_send_disc(struct sock *sk, unsigned char type, 
-                               unsigned short reason, int gfp);
+                       unsigned short reason, unsigned int __nocast gfp);
 extern void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type,
                                unsigned short reason);
 extern void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval);
@@ -29,14 +29,14 @@ extern void dn_nsp_send_conninit(struct sock *sk, unsigned char flags);
 
 extern void dn_nsp_output(struct sock *sk);
 extern int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum);
-extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, int gfp, int oob);
+extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, unsigned int __nocast gfp, int oob);
 extern unsigned long dn_nsp_persist(struct sock *sk);
 extern int dn_nsp_xmit_timeout(struct sock *sk);
 
 extern int dn_nsp_rx(struct sk_buff *);
 extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
 
-extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri);
+extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, unsigned int __nocast pri);
 extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err);
 
 #define NSP_REASON_OK 0                /* No error */
index d084721db198d6fb5176b3f2cc12bad0b3df301c..11fe973cf383519cebec11056fbe567d9be1fbe0 100644 (file)
@@ -15,7 +15,7 @@
     GNU General Public License for more details.
 *******************************************************************************/
 
-extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri);
+extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, unsigned int __nocast pri);
 extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags);
 extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
 extern int dn_cache_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
index 03df3b157960cb711bccf0d44fab11127dde1b3b..5a2beed5a7701e0c69d7793a6eb3b60667abd84e 100644 (file)
 struct inet_hashinfo;
 
 /* I have no idea if this is a good hash for v6 or not. -DaveM */
-static inline int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport,
-                               const struct in6_addr *faddr, const u16 fport,
-                               const int ehash_size)
+static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport,
+                               const struct in6_addr *faddr, const u16 fport)
 {
-       int hashent = (lport ^ fport);
+       unsigned int hashent = (lport ^ fport);
 
        hashent ^= (laddr->s6_addr32[3] ^ faddr->s6_addr32[3]);
        hashent ^= hashent >> 16;
        hashent ^= hashent >> 8;
-       return (hashent & (ehash_size - 1));
+       return hashent;
 }
 
-static inline int inet6_sk_ehashfn(const struct sock *sk, const int ehash_size)
+static inline int inet6_sk_ehashfn(const struct sock *sk)
 {
        const struct inet_sock *inet = inet_sk(sk);
        const struct ipv6_pinfo *np = inet6_sk(sk);
@@ -46,7 +45,7 @@ static inline int inet6_sk_ehashfn(const struct sock *sk, const int ehash_size)
        const struct in6_addr *faddr = &np->daddr;
        const __u16 lport = inet->num;
        const __u16 fport = inet->dport;
-       return inet6_ehashfn(laddr, lport, faddr, fport, ehash_size);
+       return inet6_ehashfn(laddr, lport, faddr, fport);
 }
 
 /*
@@ -69,14 +68,14 @@ static inline struct sock *
        /* Optimize here for direct hit, only listening connections can
         * have wildcards anyways.
         */
-       const int hash = inet6_ehashfn(daddr, hnum, saddr, sport,
-                                      hashinfo->ehash_size);
-       struct inet_ehash_bucket *head = &hashinfo->ehash[hash];
+       unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport);
+       struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
 
+       prefetch(head->chain.first);
        read_lock(&head->lock);
        sk_for_each(sk, node, &head->chain) {
                /* For IPV6 do the cheaper port and family tests first. */
-               if (INET6_MATCH(sk, saddr, daddr, ports, dif))
+               if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif))
                        goto hit; /* You sunk my battleship! */
        }
        /* Must check for a TIME_WAIT'er before going to listener hash. */
index 646b6ea7fe26f71f703cae6816e2d6a70f092bca..f50f959683400b78df241e061f64138c0f7a9ff9 100644 (file)
@@ -40,7 +40,7 @@
 struct inet_ehash_bucket {
        rwlock_t          lock;
        struct hlist_head chain;
-} __attribute__((__aligned__(8)));
+};
 
 /* There are a few simple rules, which allow for local port reuse by
  * an application.  In essence:
@@ -108,7 +108,7 @@ struct inet_hashinfo {
        struct inet_bind_hashbucket     *bhash;
 
        int                             bhash_size;
-       int                             ehash_size;
+       unsigned int                    ehash_size;
 
        /* All sockets in TCP_LISTEN state will be in here.  This is the only
         * table where wildcard'd TCP sockets can exist.  Hash function here
@@ -130,17 +130,16 @@ struct inet_hashinfo {
        int                             port_rover;
 };
 
-static inline int inet_ehashfn(const __u32 laddr, const __u16 lport,
-                              const __u32 faddr, const __u16 fport,
-                              const int ehash_size)
+static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport,
+                              const __u32 faddr, const __u16 fport)
 {
-       int h = (laddr ^ lport) ^ (faddr ^ fport);
+       unsigned int h = (laddr ^ lport) ^ (faddr ^ fport);
        h ^= h >> 16;
        h ^= h >> 8;
-       return h & (ehash_size - 1);
+       return h;
 }
 
-static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size)
+static inline int inet_sk_ehashfn(const struct sock *sk)
 {
        const struct inet_sock *inet = inet_sk(sk);
        const __u32 laddr = inet->rcv_saddr;
@@ -148,7 +147,14 @@ static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size)
        const __u32 faddr = inet->daddr;
        const __u16 fport = inet->dport;
 
-       return inet_ehashfn(laddr, lport, faddr, fport, ehash_size);
+       return inet_ehashfn(laddr, lport, faddr, fport);
+}
+
+static inline struct inet_ehash_bucket *inet_ehash_bucket(
+       struct inet_hashinfo *hashinfo,
+       unsigned int hash)
+{
+       return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)];
 }
 
 extern struct inet_bind_bucket *
@@ -235,9 +241,11 @@ static inline void __inet_hash(struct inet_hashinfo *hashinfo,
                lock = &hashinfo->lhash_lock;
                inet_listen_wlock(hashinfo);
        } else {
-               sk->sk_hashent = inet_sk_ehashfn(sk, hashinfo->ehash_size);
-               list = &hashinfo->ehash[sk->sk_hashent].chain;
-               lock = &hashinfo->ehash[sk->sk_hashent].lock;
+               struct inet_ehash_bucket *head;
+               sk->sk_hash = inet_sk_ehashfn(sk);
+               head = inet_ehash_bucket(hashinfo, sk->sk_hash);
+               list = &head->chain;
+               lock = &head->lock;
                write_lock(lock);
        }
        __sk_add_node(sk, list);
@@ -268,9 +276,8 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk)
                inet_listen_wlock(hashinfo);
                lock = &hashinfo->lhash_lock;
        } else {
-               struct inet_ehash_bucket *head = &hashinfo->ehash[sk->sk_hashent];
-               lock = &head->lock;
-               write_lock_bh(&head->lock);
+               lock = &inet_ehash_bucket(hashinfo, sk->sk_hash)->lock;
+               write_lock_bh(lock);
        }
 
        if (__sk_del_node_init(sk))
@@ -337,23 +344,27 @@ sherry_cache:
 #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \
        const __u64 __name = (((__u64)(__daddr)) << 32) | ((__u64)(__saddr));
 #endif /* __BIG_ENDIAN */
-#define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
-       (((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie))  &&      \
+#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
+       (((__sk)->sk_hash == (__hash))                          &&      \
+        ((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie))  &&      \
         ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports))   &&      \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
-#define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
-       (((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) &&  \
+#define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
+       (((__sk)->sk_hash == (__hash))                          &&      \
+        ((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) &&  \
         ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) &&   \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
 #else /* 32-bit arch */
 #define INET_ADDR_COOKIE(__name, __saddr, __daddr)
-#define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)   \
-       ((inet_sk(__sk)->daddr          == (__saddr))           &&      \
+#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)   \
+       (((__sk)->sk_hash == (__hash))                          &&      \
+        (inet_sk(__sk)->daddr          == (__saddr))           &&      \
         (inet_sk(__sk)->rcv_saddr      == (__daddr))           &&      \
         ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports))   &&      \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
-#define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)        \
-       ((inet_twsk(__sk)->tw_daddr     == (__saddr))           &&      \
+#define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \
+       (((__sk)->sk_hash == (__hash))                          &&      \
+        (inet_twsk(__sk)->tw_daddr     == (__saddr))           &&      \
         (inet_twsk(__sk)->tw_rcv_saddr == (__daddr))           &&      \
         ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) &&   \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
@@ -378,18 +389,19 @@ static inline struct sock *
        /* Optimize here for direct hit, only listening connections can
         * have wildcards anyways.
         */
-       const int hash = inet_ehashfn(daddr, hnum, saddr, sport, hashinfo->ehash_size);
-       struct inet_ehash_bucket *head = &hashinfo->ehash[hash];
+       unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport);
+       struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
 
+       prefetch(head->chain.first);
        read_lock(&head->lock);
        sk_for_each(sk, node, &head->chain) {
-               if (INET_MATCH(sk, acookie, saddr, daddr, ports, dif))
+               if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
                        goto hit; /* You sunk my battleship! */
        }
 
        /* Must check for a TIME_WAIT'er before going to listener hash. */
        sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
-               if (INET_TW_MATCH(sk, acookie, saddr, daddr, ports, dif))
+               if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
                        goto hit;
        }
        sk = NULL;
index 3b070352e869822a86d137036c6937402096be76..4ade56ef3a4da8894a42978a7663d883219cc3df 100644 (file)
@@ -112,6 +112,7 @@ struct inet_timewait_sock {
 #define tw_node                        __tw_common.skc_node
 #define tw_bind_node           __tw_common.skc_bind_node
 #define tw_refcnt              __tw_common.skc_refcnt
+#define tw_hash                        __tw_common.skc_hash
 #define tw_prot                        __tw_common.skc_prot
        volatile unsigned char  tw_substate;
        /* 3 bits hole, try to pack */
@@ -126,7 +127,6 @@ struct inet_timewait_sock {
        /* And these are ours. */
        __u8                    tw_ipv6only:1;
        /* 31 bits hole, try to pack */
-       int                     tw_hashent;
        int                     tw_timeout;
        unsigned long           tw_ttd;
        struct inet_bind_bucket *tw_tb;
index 06b4235aa0164c1844c7b48eb3457380e5984835..ecb2b061f597a62f65fc0e3c4ec2482ff6135a04 100644 (file)
@@ -832,7 +832,7 @@ extern void ip_vs_app_inc_put(struct ip_vs_app *inc);
 
 extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff **pskb);
 extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff **pskb);
-extern int ip_vs_skb_replace(struct sk_buff *skb, int pri,
+extern int ip_vs_skb_replace(struct sk_buff *skb, unsigned int __nocast pri,
                             char *o_buf, int o_len, char *n_buf, int n_len);
 extern int ip_vs_app_init(void);
 extern void ip_vs_app_cleanup(void);
index f6328aeddcce064a9eebd2c570ede0a2b5b1d33e..1c5f19f995ad2beb8f0feb8ac04df7f115c99900 100644 (file)
@@ -103,16 +103,20 @@ enum sctp_optname {
 #define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
        SCTP_SOCKOPT_PEELOFF,   /* peel off association. */
 #define SCTP_SOCKOPT_PEELOFF   SCTP_SOCKOPT_PEELOFF
-       SCTP_GET_PEER_ADDRS_NUM,        /* Get number of peer addresss. */
-#define SCTP_GET_PEER_ADDRS_NUM        SCTP_GET_PEER_ADDRS_NUM
+       SCTP_GET_PEER_ADDRS_NUM_OLD,    /* Get number of peer addresss. */
+#define SCTP_GET_PEER_ADDRS_NUM_OLD    SCTP_GET_PEER_ADDRS_NUM_OLD
+       SCTP_GET_PEER_ADDRS_OLD,        /* Get all peer addresss. */
+#define SCTP_GET_PEER_ADDRS_OLD        SCTP_GET_PEER_ADDRS_OLD
+       SCTP_GET_LOCAL_ADDRS_NUM_OLD,   /* Get number of local addresss. */
+#define SCTP_GET_LOCAL_ADDRS_NUM_OLD   SCTP_GET_LOCAL_ADDRS_NUM_OLD
+       SCTP_GET_LOCAL_ADDRS_OLD,       /* Get all local addresss. */
+#define SCTP_GET_LOCAL_ADDRS_OLD       SCTP_GET_LOCAL_ADDRS_OLD
+       SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
+#define SCTP_SOCKOPT_CONNECTX  SCTP_SOCKOPT_CONNECTX
        SCTP_GET_PEER_ADDRS,    /* Get all peer addresss. */
 #define SCTP_GET_PEER_ADDRS    SCTP_GET_PEER_ADDRS
-       SCTP_GET_LOCAL_ADDRS_NUM,       /* Get number of local addresss. */
-#define SCTP_GET_LOCAL_ADDRS_NUM       SCTP_GET_LOCAL_ADDRS_NUM
        SCTP_GET_LOCAL_ADDRS,   /* Get all local addresss. */
 #define SCTP_GET_LOCAL_ADDRS   SCTP_GET_LOCAL_ADDRS
-       SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
-#define SCTP_SOCKOPT_CONNECTX  SCTP_SOCKOPT_CONNECTX
 };
 
 /*
@@ -239,7 +243,7 @@ struct sctp_paddr_change {
        int spc_state;
        int spc_error;
        sctp_assoc_t spc_assoc_id;
-};
+} __attribute__((packed, aligned(4)));
 
 /*
  *    spc_state:  32 bits (signed integer)
@@ -464,7 +468,7 @@ struct sctp_assocparams {
 struct sctp_setpeerprim {
        sctp_assoc_t            sspp_assoc_id;
        struct sockaddr_storage sspp_addr;
-};
+} __attribute__((packed, aligned(4)));
 
 /*
  * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
@@ -477,7 +481,7 @@ struct sctp_setpeerprim {
 struct sctp_prim {
        sctp_assoc_t            ssp_assoc_id;
        struct sockaddr_storage ssp_addr;
-};
+} __attribute__((packed, aligned(4)));
 
 /*
  * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
@@ -504,7 +508,7 @@ struct sctp_paddrparams {
        struct sockaddr_storage spp_address;
        __u32                   spp_hbinterval;
        __u16                   spp_pathmaxrxt;
-};
+} __attribute__((packed, aligned(4)));
 
 /*
  * 7.2.2 Peer Address Information
@@ -523,7 +527,7 @@ struct sctp_paddrinfo {
        __u32                   spinfo_srtt;
        __u32                   spinfo_rto;
        __u32                   spinfo_mtu;
-};
+} __attribute__((packed, aligned(4)));
 
 /* Peer addresses's state. */
 enum sctp_spinfo_state {
@@ -559,11 +563,16 @@ struct sctp_status {
  * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
  * sctp_getpaddrs() and sctp_getladdrs() API. 
  */
-struct sctp_getaddrs {
+struct sctp_getaddrs_old {
        sctp_assoc_t            assoc_id;
        int                     addr_num;
        struct sockaddr         __user *addrs;
 };
+struct sctp_getaddrs {
+       sctp_assoc_t            assoc_id; /*input*/
+       __u32                   addr_num; /*output*/
+       __u8                    addrs[0]; /*output, variable size*/
+};
 
 /* These are bit fields for msghdr->msg_flags.  See section 5.1.  */
 /* On user space Linux, these live in <bits/socket.h> as an enum.  */
index 8c48fbecb7cf8fc9e4828a81fdd9a3ca8bd35457..b6440805c4201a81fe58c2846faead77c3a4ca7e 100644 (file)
@@ -99,6 +99,7 @@ struct proto;
  *     @skc_node: main hash linkage for various protocol lookup tables
  *     @skc_bind_node: bind hash linkage for various protocol lookup tables
  *     @skc_refcnt: reference count
+ *     @skc_hash: hash value used with various protocol lookup tables
  *     @skc_prot: protocol handlers inside a network family
  *
  *     This is the minimal network layer representation of sockets, the header
@@ -112,6 +113,7 @@ struct sock_common {
        struct hlist_node       skc_node;
        struct hlist_node       skc_bind_node;
        atomic_t                skc_refcnt;
+       unsigned int            skc_hash;
        struct proto            *skc_prot;
 };
 
@@ -139,7 +141,6 @@ struct sock_common {
   *    @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
   *    @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
   *    @sk_lingertime: %SO_LINGER l_linger setting
-  *    @sk_hashent: hash entry in several tables (e.g. inet_hashinfo.ehash)
   *    @sk_backlog: always used with the per-socket spinlock held
   *    @sk_callback_lock: used with the callbacks in the end of this struct
   *    @sk_error_queue: rarely used
@@ -186,6 +187,7 @@ struct sock {
 #define sk_node                        __sk_common.skc_node
 #define sk_bind_node           __sk_common.skc_bind_node
 #define sk_refcnt              __sk_common.skc_refcnt
+#define sk_hash                        __sk_common.skc_hash
 #define sk_prot                        __sk_common.skc_prot
        unsigned char           sk_shutdown : 2,
                                sk_no_check : 2,
@@ -208,7 +210,6 @@ struct sock {
        unsigned int            sk_allocation;
        int                     sk_sndbuf;
        int                     sk_route_caps;
-       int                     sk_hashent;
        unsigned long           sk_flags;
        unsigned long           sk_lingertime;
        /*
index a9d0d8c5dfbffa04c1ca67ccb35e464940301833..b6e72f890c6cddea867bd400ffd53e96b9688912 100644 (file)
@@ -875,7 +875,7 @@ static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsig
 } 
 #endif
 
-struct xfrm_policy *xfrm_policy_alloc(int gfp);
+struct xfrm_policy *xfrm_policy_alloc(unsigned int __nocast gfp);
 extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *);
 int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
 struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel,
@@ -931,4 +931,9 @@ static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b,
        }
 }
 
+static inline int xfrm_policy_id2dir(u32 index)
+{
+       return index & 7;
+}
+
 #endif /* _NET_XFRM_H */
index f48f27e9e0ab26397ab396d49df3d25918a175d2..8118731e7d96108c0badbf195df5184e233f8865 100644 (file)
@@ -203,7 +203,7 @@ extern int rxrpc_call_write_data(struct rxrpc_call *call,
                                 size_t sioc,
                                 struct kvec *siov,
                                 uint8_t rxhdr_flags,
-                                int alloc_flags,
+                                unsigned int __nocast alloc_flags,
                                 int dup_data,
                                 size_t *size_sent);
 
index 3a59df6870b27256287b62c168667d8938aec7dd..983d9f9eee1a8bbdcccf01405cb40f03abbd6e99 100644 (file)
@@ -63,7 +63,7 @@ extern int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
                             uint8_t type,
                             int count,
                             struct kvec *diov,
-                            int alloc_flags,
+                            unsigned int __nocast alloc_flags,
                             struct rxrpc_message **_msg);
 
 extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg);
index c0e4c67d836fa66e4f72f520e33e50f7526e597d..7ece05666febc367c9da22625177a1175c9b07da 100644 (file)
@@ -163,6 +163,7 @@ struct scsi_target {
        unsigned int            id; /* target id ... replace
                                     * scsi_device.id eventually */
        unsigned long           create:1; /* signal that it needs to be added */
+       char                    scsi_level;
        void                    *hostdata; /* available to low-level driver */
        unsigned long           starget_data[0]; /* for the transport */
        /* starget_data must be the last element!!!! */
index 6a6e87b2f2fd0d245aaf48a9a42a07e4bbe9dd83..45a5719a01047b2355a6eaffe4f1b75c3e22d915 100644 (file)
@@ -968,8 +968,6 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
        char *page;
        ssize_t retval = 0;
        char *s;
-       char *start;
-       ssize_t n;
 
        if (!(page = (char *)__get_free_page(GFP_KERNEL)))
                return -ENOMEM;
@@ -999,15 +997,7 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
        *s++ = '\n';
        *s = '\0';
 
-       start = page + *ppos;
-       n = s - start;
-
-       /* Do nothing if *ppos is at the eof or beyond the eof. */
-       if (n <= 0)
-               goto out;
-
-       retval = n - copy_to_user(buf, start, min(n, nbytes));
-       *ppos += retval;
+       retval = simple_read_from_buffer(buf, nbytes, ppos, page, s - page);
 out:
        free_page((unsigned long)page);
        return retval;
index ee6d8b8abef5454fc2e224fdfbdf12a332591c6e..43077732619beef843fd6170361b1f4d04691179 100644 (file)
@@ -1203,7 +1203,7 @@ static int wait_task_stopped(task_t *p, int delayed_group_leader, int noreap,
 
                exit_code = p->exit_code;
                if (unlikely(!exit_code) ||
-                   unlikely(p->state > TASK_STOPPED))
+                   unlikely(p->state & TASK_TRACED))
                        goto bail_ref;
                return wait_noreap_copyout(p, pid, uid,
                                           why, (exit_code << 8) | 0x7f,
index 5a274705ba1945b8ec81100a139daec057fc696d..c135f5aa2c2d476df8655a67e869e5819b49d901 100644 (file)
@@ -578,7 +578,8 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
                 * is to alert stop-signal processing code when another
                 * processor has come along and cleared the flag.
                 */
-               tsk->signal->flags |= SIGNAL_STOP_DEQUEUED;
+               if (!(tsk->signal->flags & SIGNAL_GROUP_EXIT))
+                       tsk->signal->flags |= SIGNAL_STOP_DEQUEUED;
        }
        if ( signr &&
             ((info->si_code & __SI_MASK) == __SI_TIMER) &&
@@ -1763,7 +1764,8 @@ do_signal_stop(int signr)
                                 * stop is always done with the siglock held,
                                 * so this check has no races.
                                 */
-                               if (t->state < TASK_STOPPED) {
+                               if (!t->exit_state &&
+                                   !(t->state & (TASK_STOPPED|TASK_TRACED))) {
                                        stop_count++;
                                        signal_wake_up(t, 0);
                                }
index 2cc79112ecc39fc2c945047b67e1c1ac4e67723f..1b61fceef77764c1c7e8ba2f4764358ea1cd4e58 100644 (file)
@@ -127,7 +127,7 @@ static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
 }
 
 static struct ts_config *bm_init(const void *pattern, unsigned int len,
-                                int gfp_mask)
+                                unsigned int __nocast gfp_mask)
 {
        struct ts_config *conf;
        struct ts_bm *bm;
index d27c0a072940457deb3681642c607ff043b1dc50..ef9779e005062d79de05f00cff7c0aa1ee3a24a3 100644 (file)
@@ -258,7 +258,7 @@ found_match:
 }
 
 static struct ts_config *fsm_init(const void *pattern, unsigned int len,
-                                    int gfp_mask)
+                                    unsigned int __nocast gfp_mask)
 {
        int i, err = -EINVAL;
        struct ts_config *conf;
index 73266b97558587a183c0ed0059b0b8b797bca9bb..e45f0f0c2379683104c43cc16c01b5564bc941cf 100644 (file)
@@ -87,7 +87,7 @@ static inline void compute_prefix_tbl(const u8 *pattern, unsigned int len,
 }
 
 static struct ts_config *kmp_init(const void *pattern, unsigned int len,
-                                 int gfp_mask)
+                                 unsigned int __nocast gfp_mask)
 {
        struct ts_config *conf;
        struct ts_kmp *kmp;
index 8ec4e4c2a179f5fc1a8d7ddb648dad0d9f69cdbb..c1330cc197835ae66bffaa2baacc032ace0020b4 100644 (file)
@@ -61,17 +61,9 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat,
 {
        bootmem_data_t *bdata = pgdat->bdata;
        unsigned long mapsize = ((end - start)+7)/8;
-       static struct pglist_data *pgdat_last;
-
-       pgdat->pgdat_next = NULL;
-       /* Add new nodes last so that bootmem always starts
-          searching in the first nodes, not the last ones */
-       if (pgdat_last)
-               pgdat_last->pgdat_next = pgdat;
-       else {
-               pgdat_list = pgdat;     
-               pgdat_last = pgdat;
-       }
+
+       pgdat->pgdat_next = pgdat_list;
+       pgdat_list = pgdat;
 
        mapsize = ALIGN(mapsize, sizeof(long));
        bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT);
index 1d31b3a3f1e598c2da003d9dd4e5c50551719e39..7982656b9c830d7ea1c819d427240ca5a797a210 100644 (file)
@@ -100,8 +100,7 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
                        continue;
 
                if (to->sat_addr.s_net == ATADDR_ANYNET &&
-                   to->sat_addr.s_node == ATADDR_BCAST &&
-                   at->src_net == atif->address.s_net)
+                   to->sat_addr.s_node == ATADDR_BCAST)
                        goto found;
 
                if (to->sat_addr.s_net == at->src_net &&
@@ -1443,8 +1442,10 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
        else
                atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode);
 
-       /* Not ours, so we route the packet via the correct AppleTalk iface */
        if (!atif) {
+               /* Not ours, so we route the packet via the correct
+                * AppleTalk iface
+                */
                atalk_route_packet(skb, dev, ddp, &ddphv, origlen);
                goto out;
        }
@@ -1592,9 +1593,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
 
        if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) {
                rt = atrtr_find(&usat->sat_addr);
-               if (!rt)
-                       return -ENETUNREACH;
-
                dev = rt->dev;
        } else {
                struct atalk_addr at_hint;
@@ -1603,11 +1601,12 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
                at_hint.s_net  = at->src_net;
 
                rt = atrtr_find(&at_hint);
-               if (!rt)
-                       return -ENETUNREACH;
-
                dev = rt->dev;
        }
+       if (!rt)
+               return -ENETUNREACH;
+
+       dev = rt->dev;
 
        SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n",
                        sk, size, dev->name);
@@ -1677,6 +1676,20 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
                SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk);
                /* loop back */
                skb_orphan(skb);
+               if (ddp->deh_dnode == ATADDR_BCAST) {
+                       struct atalk_addr at_lo;
+
+                       at_lo.s_node = 0;
+                       at_lo.s_net  = 0;
+
+                       rt = atrtr_find(&at_lo);
+                       if (!rt) {
+                               kfree_skb(skb);
+                               return -ENETUNREACH;
+                       }
+                       dev = rt->dev;
+                       skb->dev = dev;
+               }
                ddp_dl->request(ddp_dl, skb, dev->dev_addr);
        } else {
                SOCK_DEBUG(sk, "SK %p: send out.\n", sk);
index 1c8867f7f54a920cdc996b14ba1eebdd8b42dfac..3060fd0ba4b9fb51ca79a8079f22365433cc4470 100644 (file)
@@ -44,29 +44,43 @@ static void notify_sigd(struct atm_dev *dev)
        sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL);
 }
 
-void atm_reset_addr(struct atm_dev *dev)
+void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t atype)
 {
        unsigned long flags;
        struct atm_dev_addr *this, *p;
+       struct list_head *head;
 
        spin_lock_irqsave(&dev->lock, flags);
-       list_for_each_entry_safe(this, p, &dev->local, entry)
-           kfree(this);
+       if (atype == ATM_ADDR_LECS)
+               head = &dev->lecs;
+       else
+               head = &dev->local;
+       list_for_each_entry_safe(this, p, head, entry) {
+               list_del(&this->entry);
+               kfree(this);
+       }
        spin_unlock_irqrestore(&dev->lock, flags);
-       notify_sigd(dev);
+       if (head == &dev->local)
+               notify_sigd(dev);
 }
 
-int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr)
+int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
+                enum atm_addr_type_t atype)
 {
        unsigned long flags;
        struct atm_dev_addr *this;
+       struct list_head *head;
        int error;
 
        error = check_addr(addr);
        if (error)
                return error;
        spin_lock_irqsave(&dev->lock, flags);
-       list_for_each_entry(this, &dev->local, entry) {
+       if (atype == ATM_ADDR_LECS)
+               head = &dev->lecs;
+       else
+               head = &dev->local;
+       list_for_each_entry(this, head, entry) {
                if (identical(&this->addr, addr)) {
                        spin_unlock_irqrestore(&dev->lock, flags);
                        return -EEXIST;
@@ -78,28 +92,36 @@ int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr)
                return -ENOMEM;
        }
        this->addr = *addr;
-       list_add(&this->entry, &dev->local);
+       list_add(&this->entry, head);
        spin_unlock_irqrestore(&dev->lock, flags);
-       notify_sigd(dev);
+       if (head == &dev->local)
+               notify_sigd(dev);
        return 0;
 }
 
-int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr)
+int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
+                enum atm_addr_type_t atype)
 {
        unsigned long flags;
        struct atm_dev_addr *this;
+       struct list_head *head;
        int error;
 
        error = check_addr(addr);
        if (error)
                return error;
        spin_lock_irqsave(&dev->lock, flags);
-       list_for_each_entry(this, &dev->local, entry) {
+       if (atype == ATM_ADDR_LECS)
+               head = &dev->lecs;
+       else
+               head = &dev->local;
+       list_for_each_entry(this, head, entry) {
                if (identical(&this->addr, addr)) {
                        list_del(&this->entry);
                        spin_unlock_irqrestore(&dev->lock, flags);
                        kfree(this);
-                       notify_sigd(dev);
+                       if (head == &dev->local)
+                               notify_sigd(dev);
                        return 0;
                }
        }
@@ -108,22 +130,27 @@ int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr)
 }
 
 int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf,
-                size_t size)
+                size_t size, enum atm_addr_type_t atype)
 {
        unsigned long flags;
        struct atm_dev_addr *this;
+       struct list_head *head;
        int total = 0, error;
        struct sockaddr_atmsvc *tmp_buf, *tmp_bufp;
 
        spin_lock_irqsave(&dev->lock, flags);
-       list_for_each_entry(this, &dev->local, entry)
+       if (atype == ATM_ADDR_LECS)
+               head = &dev->lecs;
+       else
+               head = &dev->local;
+       list_for_each_entry(this, head, entry)
            total += sizeof(struct sockaddr_atmsvc);
        tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC);
        if (!tmp_buf) {
                spin_unlock_irqrestore(&dev->lock, flags);
                return -ENOMEM;
        }
-       list_for_each_entry(this, &dev->local, entry)
+       list_for_each_entry(this, head, entry)
            memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc));
        spin_unlock_irqrestore(&dev->lock, flags);
        error = total > size ? -E2BIG : total;
index 3099d21feeaa427d49197f8ea879183ce4c3f26c..f39433ad45dab62bd02c6628552f4d964cdb03f8 100644 (file)
@@ -9,10 +9,12 @@
 #include <linux/atm.h>
 #include <linux/atmdev.h>
 
-
-void atm_reset_addr(struct atm_dev *dev);
-int atm_add_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr);
-int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr);
-int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc __user *buf,size_t size);
+void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t type);
+int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
+                enum atm_addr_type_t type);
+int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
+                enum atm_addr_type_t type);
+int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user *buf,
+                size_t size, enum atm_addr_type_t type);
 
 #endif
index b2113c3454ae6b31d0b5faab356990611160b665..71abc99ec815e78bbc050bbf0714a7c8885ccf4d 100644 (file)
@@ -25,7 +25,7 @@ int atm_charge(struct atm_vcc *vcc,int truesize)
 
 
 struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
-    int gfp_flags)
+    unsigned int __nocast gfp_flags)
 {
        struct sock *sk = sk_atm(vcc);
        int guess = atm_guess_pdu2truesize(pdu_size);
index 289956c4dd3e8c1bc1501e9ed429a3f2de272ce8..72f3f7b8de8012060c33f860322ecd227b45b877 100644 (file)
@@ -220,7 +220,7 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
                /* netif_stop_queue(dev); */
                dev_kfree_skb(skb);
                read_unlock(&devs_lock);
-               return -EUNATCH;
+               return 0;
        }
        if (!br2684_xmit_vcc(skb, brdev, brvcc)) {
                /*
index 28dab55a4387c7fc0436876413efc5540c1f7bd7..4f54c9a5e84a440b9820c3450af722848d15a80c 100644 (file)
@@ -310,7 +310,7 @@ static int clip_constructor(struct neighbour *neigh)
        if (neigh->type != RTN_UNICAST) return -EINVAL;
 
        rcu_read_lock();
-       in_dev = rcu_dereference(__in_dev_get(dev));
+       in_dev = __in_dev_get_rcu(dev);
        if (!in_dev) {
                rcu_read_unlock();
                return -EINVAL;
index e93e838069e8794980c90dc80ef99bca31a2a4db..63feea49fb139f6a0e96888c3f4f99c2325ac883 100644 (file)
@@ -46,7 +46,7 @@ static void __vcc_insert_socket(struct sock *sk)
        struct atm_vcc *vcc = atm_sk(sk);
        struct hlist_head *head = &vcc_hash[vcc->vci &
                                        (VCC_HTABLE_SIZE - 1)];
-       sk->sk_hashent = vcc->vci & (VCC_HTABLE_SIZE - 1);
+       sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE - 1);
        sk_add_node(sk, head);
 }
 
@@ -178,8 +178,6 @@ static void vcc_destroy_socket(struct sock *sk)
                if (vcc->push)
                        vcc->push(vcc, NULL); /* atmarpd has no push */
 
-               vcc_remove_socket(sk);  /* no more receive */
-
                while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
                        atm_return(vcc,skb->truesize);
                        kfree_skb(skb);
@@ -188,6 +186,8 @@ static void vcc_destroy_socket(struct sock *sk)
                module_put(vcc->dev->ops->owner);
                atm_dev_put(vcc->dev);
        }
+
+       vcc_remove_socket(sk);
 }
 
 
index d89056ec44d4ff11a842b045a8403253151cdae4..a150198b05a3984751c13aced3cbe226314a56b4 100644 (file)
@@ -105,17 +105,35 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        if (!error)
                                sock->state = SS_CONNECTED;
                        goto done;
-               default:
+               case ATM_SETBACKEND:
+               case ATM_NEWBACKENDIF:
+                       {
+                               atm_backend_t backend;
+                               error = get_user(backend, (atm_backend_t __user *) argp);
+                               if (error)
+                                       goto done;
+                               switch (backend) {
+                                       case ATM_BACKEND_PPP:
+                                               request_module("pppoatm");
+                                               break;
+                                       case ATM_BACKEND_BR2684:
+                                               request_module("br2684");
+                                               break;
+                               }
+                       }
+                       break;
+               case ATMMPC_CTRL:
+               case ATMMPC_DATA:
+                       request_module("mpoa");
+                       break;
+               case ATMARPD_CTRL:
+                       request_module("clip");
+                       break;
+               case ATMLEC_CTRL:
+                       request_module("lec");
                        break;
        }
 
-       if (cmd == ATMMPC_CTRL || cmd == ATMMPC_DATA)
-               request_module("mpoa");
-       if (cmd == ATMARPD_CTRL)
-               request_module("clip");
-       if (cmd == ATMLEC_CTRL)
-               request_module("lec");
-
        error = -ENOIOCTLCMD;
 
        down(&ioctl_mutex);
index a0752487026d5f299ab9044592a4652fbaab3508..ad840b9afba8a3a68e644a682f9bf6499e38d765 100644 (file)
@@ -686,9 +686,19 @@ static unsigned char lec_ctrl_magic[] = {
         0x01,
         0x01 };
 
+#define LEC_DATA_DIRECT_8023  2
+#define LEC_DATA_DIRECT_8025  3
+
+static int lec_is_data_direct(struct atm_vcc *vcc)
+{ 
+       return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) ||
+               (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025));
+} 
+
 static void 
 lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
 {
+       unsigned long flags;
         struct net_device *dev = (struct net_device *)vcc->proto_data;
         struct lec_priv *priv = (struct lec_priv *)dev->priv; 
 
@@ -728,7 +738,8 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
                 skb_queue_tail(&sk->sk_receive_queue, skb);
                 sk->sk_data_ready(sk, skb->len);
         } else { /* Data frame, queue to protocol handlers */
-                unsigned char *dst;
+               struct lec_arp_table *entry;
+                unsigned char *src, *dst;
 
                 atm_return(vcc,skb->truesize);
                 if (*(uint16_t *)skb->data == htons(priv->lecid) ||
@@ -741,10 +752,30 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
                         return;
                 }
 #ifdef CONFIG_TR
-                if (priv->is_trdev) dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest;
+                if (priv->is_trdev)
+                       dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest;
                 else
 #endif
-                dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
+               dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest;
+
+               /* If this is a Data Direct VCC, and the VCC does not match
+                * the LE_ARP cache entry, delete the LE_ARP cache entry.
+                */
+               spin_lock_irqsave(&priv->lec_arp_lock, flags);
+               if (lec_is_data_direct(vcc)) {
+#ifdef CONFIG_TR
+                       if (priv->is_trdev)
+                               src = ((struct lecdatahdr_8025 *) skb->data)->h_source;
+                       else
+#endif
+                       src = ((struct lecdatahdr_8023 *) skb->data)->h_source;
+                       entry = lec_arp_find(priv, src);
+                       if (entry && entry->vcc != vcc) {
+                               lec_arp_remove(priv, entry);
+                               kfree(entry);
+                       }
+               }
+               spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 
                 if (!(dst[0]&0x01) &&   /* Never filter Multi/Broadcast */
                     !priv->is_proxy &&  /* Proxy wants all the packets */
@@ -1990,6 +2021,12 @@ lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find,
                         found = entry->vcc;
                        goto out;
                 }
+               /* If the LE_ARP cache entry is still pending, reset count to 0
+                * so another LE_ARP request can be made for this frame.
+                */
+               if (entry->status == ESI_ARP_PENDING) {
+                       entry->no_tries = 0;
+               }
                 /* Data direct VC not yet set up, check to see if the unknown
                    frame count is greater than the limit. If the limit has
                    not been reached, allow the caller to send packet to
index a57a9268bd2436e565cdaf1e15cc9dcf10bb14c7..415d2615d475fa3c284d4a11cf565408d8c5c385 100644 (file)
@@ -40,6 +40,7 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
        dev->link_rate = ATM_OC3_PCR;
        spin_lock_init(&dev->lock);
        INIT_LIST_HEAD(&dev->local);
+       INIT_LIST_HEAD(&dev->lecs);
 
        return dev;
 }
@@ -320,10 +321,12 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
                                error = -EPERM;
                                goto done;
                        }
-                       atm_reset_addr(dev);
+                       atm_reset_addr(dev, ATM_ADDR_LOCAL);
                        break;
                case ATM_ADDADDR:
                case ATM_DELADDR:
+               case ATM_ADDLECSADDR:
+               case ATM_DELLECSADDR:
                        if (!capable(CAP_NET_ADMIN)) {
                                error = -EPERM;
                                goto done;
@@ -335,14 +338,21 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
                                        error = -EFAULT;
                                        goto done;
                                }
-                               if (cmd == ATM_ADDADDR)
-                                       error = atm_add_addr(dev, &addr);
+                               if (cmd == ATM_ADDADDR || cmd == ATM_ADDLECSADDR)
+                                       error = atm_add_addr(dev, &addr,
+                                                            (cmd == ATM_ADDADDR ?
+                                                             ATM_ADDR_LOCAL : ATM_ADDR_LECS));
                                else
-                                       error = atm_del_addr(dev, &addr);
+                                       error = atm_del_addr(dev, &addr,
+                                                            (cmd == ATM_DELADDR ?
+                                                             ATM_ADDR_LOCAL : ATM_ADDR_LECS));
                                goto done;
                        }
                case ATM_GETADDR:
-                       error = atm_get_addr(dev, buf, len);
+               case ATM_GETLECSADDR:
+                       error = atm_get_addr(dev, buf, len,
+                                            (cmd == ATM_GETADDR ?
+                                             ATM_ADDR_LOCAL : ATM_ADDR_LECS));
                        if (error < 0)
                                goto done;
                        size = error;
index f7c449ac1800cffe9cb355806886f7d1d19e8950..e7211a7f382c5b35ea059bd36feabfa5f8a32cfd 100644 (file)
@@ -217,8 +217,9 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type,
 static void purge_vcc(struct atm_vcc *vcc)
 {
        if (sk_atm(vcc)->sk_family == PF_ATMSVC &&
-           !test_bit(ATM_VF_META,&vcc->flags)) {
-               set_bit(ATM_VF_RELEASED,&vcc->flags);
+           !test_bit(ATM_VF_META, &vcc->flags)) {
+               set_bit(ATM_VF_RELEASED, &vcc->flags);
+               clear_bit(ATM_VF_REGIS, &vcc->flags);
                vcc_release_async(vcc, -EUNATCH);
        }
 }
@@ -243,8 +244,7 @@ static void sigd_close(struct atm_vcc *vcc)
                sk_for_each(s, node, head) {
                        struct atm_vcc *vcc = atm_sk(s);
 
-                       if (vcc->dev)
-                               purge_vcc(vcc);
+                       purge_vcc(vcc);
                }
        }
        read_unlock(&vcc_sklist_lock);
index 08e46052a3e4a896714254fce4a6c46702152d7c..d7b266136bf64168d0ce7ac8cc5796801fc11f13 100644 (file)
@@ -302,6 +302,7 @@ static int svc_listen(struct socket *sock,int backlog)
                error = -EINVAL;
                goto out;
        }
+       vcc_insert_socket(sk);
        set_bit(ATM_VF_WAITING, &vcc->flags);
        prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE);
        sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local);
index 810c9c76c2e022b08d171e255a0bf1340159f97f..73cfc3411c461d50d7dbb7d718dd3e2315d26428 100644 (file)
@@ -123,7 +123,7 @@ int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
                }
 
                skb_pull(skb, 1);       /* Remove PID */
-               skb->h.raw    = skb->data;
+               skb->mac.raw  = skb->nh.raw;
                skb->nh.raw   = skb->data;
                skb->dev      = ax25->ax25_dev->dev;
                skb->pkt_type = PACKET_HOST;
index da9bf71421a7ef98e6ade66ea8902d7cfaadb37f..81987df536eb83f04d28da673806693589582993 100644 (file)
@@ -211,74 +211,45 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
 int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
                            struct iovec *to, int len)
 {
-       int start = skb_headlen(skb);
-       int i, copy = start - offset;
-
-       /* Copy header. */
-       if (copy > 0) {
-               if (copy > len)
-                       copy = len;
-               if (memcpy_toiovec(to, skb->data + offset, copy))
-                       goto fault;
-               if ((len -= copy) == 0)
-                       return 0;
-               offset += copy;
-       }
+       int i, err, fraglen, end = 0;
+       struct sk_buff *next = skb_shinfo(skb)->frag_list;
+next_skb:
+       fraglen = skb_headlen(skb);
+       i = -1;
 
-       /* Copy paged appendix. Hmm... why does this look so complicated? */
-       for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-               int end;
-
-               BUG_TRAP(start <= offset + len);
+       while (1) {
+               int start = end;
 
-               end = start + skb_shinfo(skb)->frags[i].size;
-               if ((copy = end - offset) > 0) {
-                       int err;
-                       u8  *vaddr;
-                       skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
-                       struct page *page = frag->page;
+               if ((end += fraglen) > offset) {
+                       int copy = end - offset, o = offset - start;
 
                        if (copy > len)
                                copy = len;
-                       vaddr = kmap(page);
-                       err = memcpy_toiovec(to, vaddr + frag->page_offset +
-                                            offset - start, copy);
-                       kunmap(page);
+                       if (i == -1)
+                               err = memcpy_toiovec(to, skb->data + o, copy);
+                       else {
+                               skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+                               struct page *page = frag->page;
+                               void *p = kmap(page) + frag->page_offset + o;
+                               err = memcpy_toiovec(to, p, copy);
+                               kunmap(page);
+                       }
                        if (err)
                                goto fault;
                        if (!(len -= copy))
                                return 0;
                        offset += copy;
                }
-               start = end;
+               if (++i >= skb_shinfo(skb)->nr_frags)
+                       break;
+               fraglen = skb_shinfo(skb)->frags[i].size;
        }
-
-       if (skb_shinfo(skb)->frag_list) {
-               struct sk_buff *list = skb_shinfo(skb)->frag_list;
-
-               for (; list; list = list->next) {
-                       int end;
-
-                       BUG_TRAP(start <= offset + len);
-
-                       end = start + list->len;
-                       if ((copy = end - offset) > 0) {
-                               if (copy > len)
-                                       copy = len;
-                               if (skb_copy_datagram_iovec(list,
-                                                           offset - start,
-                                                           to, copy))
-                                       goto fault;
-                               if ((len -= copy) == 0)
-                                       return 0;
-                               offset += copy;
-                       }
-                       start = end;
-               }
+       if (next) {
+               skb = next;
+               BUG_ON(skb_shinfo(skb)->frag_list);
+               next = skb->next;
+               goto next_skb;
        }
-       if (!len)
-               return 0;
-
 fault:
        return -EFAULT;
 }
index 37c881070963aec33f184dac0341f7862877ca3b..9066c874e273b6f3bced25f16b876cd5b85e23f3 100644 (file)
@@ -1259,6 +1259,8 @@ int dev_queue_xmit(struct sk_buff *skb)
                if (skb_checksum_help(skb, 0))
                        goto out_kfree_skb;
 
+       spin_lock_prefetch(&dev->queue_lock);
+
        /* Disable soft irqs for various locks below. Also 
         * stops preemption for RCU. 
         */
index 5265dfd699284a960c5fd95b33a6daf722b1a0bc..802fe11efad0b2ad53942f28ce591435380e8008 100644 (file)
@@ -703,7 +703,7 @@ int netpoll_setup(struct netpoll *np)
 
        if (!np->local_ip) {
                rcu_read_lock();
-               in_dev = __in_dev_get(ndev);
+               in_dev = __in_dev_get_rcu(ndev);
 
                if (!in_dev || !in_dev->ifa_list) {
                        rcu_read_unlock();
index ef430b1e8e42acc87af3d12fb4c95544c8996570..5f043d346694dc012ba3403b82d875cd6a0133f1 100644 (file)
 
 /* Used to help with determining the pkts on receive */
 #define PKTGEN_MAGIC 0xbe9be955
-#define PG_PROC_DIR "pktgen"
+#define PG_PROC_DIR "net/pktgen"
 
 #define MAX_CFLOWS  65536
 
@@ -1476,18 +1476,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer,
 
 static int create_proc_dir(void)
 {
-        int     len;
-        /*  does proc_dir already exists */
-        len = strlen(PG_PROC_DIR);
-
-        for (pg_proc_dir = proc_net->subdir; pg_proc_dir; pg_proc_dir=pg_proc_dir->next) {
-                if ((pg_proc_dir->namelen == len) &&
-                   (! memcmp(pg_proc_dir->name, PG_PROC_DIR, len))) 
-                        break;
-        }
-        
-        if (!pg_proc_dir) 
-                pg_proc_dir = create_proc_entry(PG_PROC_DIR, S_IFDIR, proc_net);
+       pg_proc_dir = proc_mkdir(PG_PROC_DIR, NULL);
         
         if (!pg_proc_dir) 
                 return -ENODEV;
@@ -1497,7 +1486,7 @@ static int create_proc_dir(void)
 
 static int remove_proc_dir(void)
 {
-        remove_proc_entry(PG_PROC_DIR, proc_net);
+        remove_proc_entry(PG_PROC_DIR, NULL);
         return 0;
 }
 
@@ -1678,13 +1667,12 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
                        struct in_device *in_dev; 
 
                        rcu_read_lock();
-                       in_dev = __in_dev_get(pkt_dev->odev);
+                       in_dev = __in_dev_get_rcu(pkt_dev->odev);
                        if (in_dev) {
                                if (in_dev->ifa_list) {
                                        pkt_dev->saddr_min = in_dev->ifa_list->ifa_address;
                                        pkt_dev->saddr_max = pkt_dev->saddr_min;
                                }
-                               __in_dev_put(in_dev);   
                        }
                        rcu_read_unlock();
                }
@@ -2908,7 +2896,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname)
                 pkt_dev->udp_dst_max = 9;
 
                 strncpy(pkt_dev->ifname, ifname, 31);
-                sprintf(pkt_dev->fname, "net/%s/%s", PG_PROC_DIR, ifname);
+                sprintf(pkt_dev->fname, "%s/%s", PG_PROC_DIR, ifname);
 
                 if (! pktgen_setup_dev(pkt_dev)) {
                         printk("pktgen: ERROR: pktgen_setup_dev failed.\n");
@@ -2981,7 +2969,7 @@ static int pktgen_create_thread(const char* name, int cpu)
         spin_lock_init(&t->if_lock);
        t->cpu = cpu;
         
-        sprintf(t->fname, "net/%s/%s", PG_PROC_DIR, t->name);
+        sprintf(t->fname, "%s/%s", PG_PROC_DIR, t->name);
         t->proc_ent = create_proc_entry(t->fname, 0600, NULL);
         if (!t->proc_ent) {
                 printk("pktgen: cannot create %s procfs entry.\n", t->fname);
@@ -3064,7 +3052,7 @@ static int __init pg_init(void)
 
        create_proc_dir();
 
-        sprintf(module_fname, "net/%s/pgctrl", PG_PROC_DIR);
+        sprintf(module_fname, "%s/pgctrl", PG_PROC_DIR);
         module_proc_ent = create_proc_entry(module_fname, 0600, NULL);
         if (!module_proc_ent) {
                 printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname);
index f80a28785610d62c180313310a47d2ad0fa11736..0e9431b59fb2ad770e75423811b8346c454ec56a 100644 (file)
@@ -71,8 +71,6 @@
 static kmem_cache_t *skbuff_head_cache __read_mostly;
 static kmem_cache_t *skbuff_fclone_cache __read_mostly;
 
-struct timeval __read_mostly skb_tv_base;
-
 /*
  *     Keep out-of-line to prevent kernel bloat.
  *     __builtin_return_address is not used because it is not always
@@ -1708,8 +1706,6 @@ void __init skb_init(void)
                                                NULL, NULL);
        if (!skbuff_fclone_cache)
                panic("cannot create skbuff cache");
-
-       do_gettimeofday(&skb_tv_base);
 }
 
 EXPORT_SYMBOL(___pskb_trim);
@@ -1743,4 +1739,3 @@ EXPORT_SYMBOL(skb_prepare_seq_read);
 EXPORT_SYMBOL(skb_seq_read);
 EXPORT_SYMBOL(skb_abort_seq_read);
 EXPORT_SYMBOL(skb_find_text);
-EXPORT_SYMBOL(skb_tv_base);
index ac63b56e23b29c45113df81fa226bc2c9568d758..928d2a1d6d8e7bbc42dcb01f56d598244b12e575 100644 (file)
@@ -660,16 +660,20 @@ struct sock *sk_alloc(int family, unsigned int __nocast priority,
                        sock_lock_init(sk);
                }
                
-               if (security_sk_alloc(sk, family, priority)) {
-                       if (slab != NULL)
-                               kmem_cache_free(slab, sk);
-                       else
-                               kfree(sk);
-                       sk = NULL;
-               } else
-                       __module_get(prot->owner);
+               if (security_sk_alloc(sk, family, priority))
+                       goto out_free;
+
+               if (!try_module_get(prot->owner))
+                       goto out_free;
        }
        return sk;
+
+out_free:
+       if (slab != NULL)
+               kmem_cache_free(slab, sk);
+       else
+               kfree(sk);
+       return NULL;
 }
 
 void sk_free(struct sock *sk)
index 40fe6afacde61b17559f582315c53110fb544fc4..ae088d1347af025359eb09e5a3a606386e66f948 100644 (file)
@@ -62,27 +62,27 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
        const int dif = sk->sk_bound_dev_if;
        INET_ADDR_COOKIE(acookie, saddr, daddr)
        const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
-       const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport,
-                                     dccp_hashinfo.ehash_size);
-       struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash];
+       unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
+       struct inet_ehash_bucket *head = inet_ehash_bucket(&dccp_hashinfo, hash);
        const struct sock *sk2;
        const struct hlist_node *node;
        struct inet_timewait_sock *tw;
 
+       prefetch(head->chain.first);
        write_lock(&head->lock);
 
        /* Check TIME-WAIT sockets first. */
        sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) {
                tw = inet_twsk(sk2);
 
-               if (INET_TW_MATCH(sk2, acookie, saddr, daddr, ports, dif))
+               if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif))
                        goto not_unique;
        }
        tw = NULL;
 
        /* And established part... */
        sk_for_each(sk2, node, &head->chain) {
-               if (INET_MATCH(sk2, acookie, saddr, daddr, ports, dif))
+               if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif))
                        goto not_unique;
        }
 
@@ -90,7 +90,7 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
         * in hash table socket with a funny identity. */
        inet->num = lport;
        inet->sport = htons(lport);
-       sk->sk_hashent = hash;
+       sk->sk_hash = hash;
        BUG_TRAP(sk_unhashed(sk));
        __sk_add_node(sk, &head->chain);
        sock_prot_inc_use(sk->sk_prot);
index 348f36b529f741e2f82005f69e86a1d353a63761..34d4128d56d541a60c657f36c6cd43054b929d9d 100644 (file)
@@ -452,7 +452,8 @@ static struct proto dn_proto = {
        .obj_size = sizeof(struct dn_sock),
 };
 
-static struct sock *dn_alloc_sock(struct socket *sock, int gfp)
+static struct sock *dn_alloc_sock(struct socket *sock,
+                                 unsigned int __nocast gfp)
 {
        struct dn_scp *scp;
        struct sock *sk = sk_alloc(PF_DECnet, gfp, &dn_proto, 1);
@@ -804,7 +805,8 @@ static int dn_auto_bind(struct socket *sock)
        return rv;
 }
 
-static int dn_confirm_accept(struct sock *sk, long *timeo, int allocation)
+static int dn_confirm_accept(struct sock *sk, long *timeo,
+                               unsigned int __nocast allocation)
 {
        struct dn_scp *scp = DN_SK(sk);
        DEFINE_WAIT(wait);
index 53633d352868766f699298754b0c6b192595f7bb..cd08244aa10c1191043dfb8876d4a9ea221d5a77 100644 (file)
@@ -117,7 +117,8 @@ try_again:
  * The eventual aim is for each socket to have a cached header size
  * for its outgoing packets, and to set hdr from this when sk != NULL.
  */
-struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri)
+struct sk_buff *dn_alloc_skb(struct sock *sk, int size,
+                            unsigned int __nocast pri)
 {
        struct sk_buff *skb;
        int hdr = 64;
@@ -210,7 +211,8 @@ static void dn_nsp_rtt(struct sock *sk, long rtt)
  *
  * Returns: The number of times the packet has been sent previously
  */
-static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb, int gfp)
+static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb,
+                                            unsigned int __nocast gfp)
 {
        struct dn_skb_cb *cb = DN_SKB_CB(skb);
        struct sk_buff *skb2;
@@ -350,7 +352,8 @@ static unsigned short *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *sk
        return ptr;
 }
 
-void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, int gfp, int oth)
+void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb,
+                       unsigned int __nocast gfp, int oth)
 {
        struct dn_scp *scp = DN_SK(sk);
        struct dn_skb_cb *cb = DN_SKB_CB(skb);
@@ -517,7 +520,7 @@ static int dn_nsp_retrans_conn_conf(struct sock *sk)
        return 0;
 }
 
-void dn_send_conn_conf(struct sock *sk, int gfp)
+void dn_send_conn_conf(struct sock *sk, unsigned int __nocast gfp)
 {
        struct dn_scp *scp = DN_SK(sk);
        struct sk_buff *skb = NULL;
@@ -549,7 +552,8 @@ void dn_send_conn_conf(struct sock *sk, int gfp)
 
 
 static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, 
-                       unsigned short reason, int gfp, struct dst_entry *dst,
+                       unsigned short reason, unsigned int __nocast gfp,
+                       struct dst_entry *dst,
                        int ddl, unsigned char *dd, __u16 rem, __u16 loc)
 {
        struct sk_buff *skb = NULL;
@@ -591,7 +595,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
 
 
 void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, 
-                       unsigned short reason, int gfp)
+                       unsigned short reason, unsigned int __nocast gfp)
 {
        struct dn_scp *scp = DN_SK(sk);
        int ddl = 0;
@@ -612,7 +616,7 @@ void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg,
 {
        struct dn_skb_cb *cb = DN_SKB_CB(skb);
        int ddl = 0;
-       int gfp = GFP_ATOMIC;
+       unsigned int __nocast gfp = GFP_ATOMIC;
 
        dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl, 
                        NULL, cb->src_port, cb->dst_port);
@@ -624,7 +628,7 @@ void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval)
        struct dn_scp *scp = DN_SK(sk);
        struct sk_buff *skb;
        unsigned char *ptr;
-       int gfp = GFP_ATOMIC;
+       unsigned int __nocast gfp = GFP_ATOMIC;
 
        if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL)
                return;
@@ -659,7 +663,8 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
        unsigned char menuver;
        struct dn_skb_cb *cb;
        unsigned char type = 1;
-       int allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC;
+       unsigned int __nocast allocation =
+                       (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC;
        struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation);
 
        if (!skb)
index 4a62093eb343afae44042592e75271c40f0fc2fd..34fdac51df965d45d22b850da9aa379e17cfeac0 100644 (file)
@@ -406,7 +406,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
                unsigned long network = 0;
 
                rcu_read_lock();
-               idev = __in_dev_get(dev);
+               idev = __in_dev_get_rcu(dev);
                if (idev) {
                        if (idev->ifa_list)
                                network = ntohl(idev->ifa_list->ifa_address) & 
index 87a052a9a84f9b4025ebf430f0c6197afd3a759c..68a5ca866442c059c4d21359f5f7632fa971f8bd 100644 (file)
@@ -146,6 +146,19 @@ int eth_rebuild_header(struct sk_buff *skb)
        return 0;
 }
 
+static inline unsigned int compare_eth_addr(const unsigned char *__a, const unsigned char *__b)
+{
+       const unsigned short *dest = (unsigned short *) __a;
+       const unsigned short *devaddr = (unsigned short *) __b;
+       unsigned int res;
+
+       BUILD_BUG_ON(ETH_ALEN != 6);
+       res = ((dest[0] ^ devaddr[0]) |
+              (dest[1] ^ devaddr[1]) |
+              (dest[2] ^ devaddr[2])) != 0;
+
+       return res;
+}
 
 /*
  *     Determine the packet's protocol ID. The rule here is that we 
@@ -158,16 +171,15 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
        struct ethhdr *eth;
        unsigned char *rawp;
        
-       skb->mac.raw=skb->data;
+       skb->mac.raw = skb->data;
        skb_pull(skb,ETH_HLEN);
        eth = eth_hdr(skb);
        
-       if(*eth->h_dest&1)
-       {
-               if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
-                       skb->pkt_type=PACKET_BROADCAST;
+       if (*eth->h_dest&1) {
+               if (!compare_eth_addr(eth->h_dest, dev->broadcast))
+                       skb->pkt_type = PACKET_BROADCAST;
                else
-                       skb->pkt_type=PACKET_MULTICAST;
+                       skb->pkt_type = PACKET_MULTICAST;
        }
        
        /*
@@ -178,10 +190,9 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
         *      seems to set IFF_PROMISC.
         */
         
-       else if(1 /*dev->flags&IFF_PROMISC*/)
-       {
-               if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN))
-                       skb->pkt_type=PACKET_OTHERHOST;
+       else if(1 /*dev->flags&IFF_PROMISC*/) {
+               if (unlikely(compare_eth_addr(eth->h_dest, dev->dev_addr)))
+                       skb->pkt_type = PACKET_OTHERHOST;
        }
        
        if (ntohs(eth->h_proto) >= 1536)
index 03a47343ddc75a386370e9e07861299faf9e71ae..6059e9e37123b711554c6e50a18daf8a5872c793 100644 (file)
@@ -230,7 +230,7 @@ static int __init ieee80211_init(void)
        struct proc_dir_entry *e;
 
        ieee80211_debug_level = debug;
-       ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net);
+       ieee80211_proc = proc_mkdir(DRV_NAME, proc_net);
        if (ieee80211_proc == NULL) {
                IEEE80211_ERROR("Unable to create " DRV_NAME
                                " proc directory\n");
index c9aaff3fea1e41f8c0211253b44cefec0edf5345..ecdf9f7a538fe19745bfeedd9d3bb743e5ca5618 100644 (file)
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb)
 }
 
 static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
-                                                int gfp_mask)
+                                                unsigned int __nocast gfp_mask)
 {
        struct ieee80211_txb *txb;
        int i;
index 8bf312bdea13c50f48291df5481affb6cfc10f4a..b425748f02d7cbc1a088fcfb4bcecb1e68fc34cf 100644 (file)
@@ -241,7 +241,7 @@ static int arp_constructor(struct neighbour *neigh)
        neigh->type = inet_addr_type(addr);
 
        rcu_read_lock();
-       in_dev = rcu_dereference(__in_dev_get(dev));
+       in_dev = __in_dev_get_rcu(dev);
        if (in_dev == NULL) {
                rcu_read_unlock();
                return -EINVAL;
@@ -697,12 +697,6 @@ void arp_send(int type, int ptype, u32 dest_ip,
        arp_xmit(skb);
 }
 
-static void parp_redo(struct sk_buff *skb)
-{
-       nf_reset(skb);
-       arp_rcv(skb, skb->dev, NULL, skb->dev);
-}
-
 /*
  *     Process an arp request.
  */
@@ -922,6 +916,11 @@ out:
        return 0;
 }
 
+static void parp_redo(struct sk_buff *skb)
+{
+       arp_process(skb);
+}
+
 
 /*
  *     Receive an arp request from the device layer.
@@ -990,8 +989,8 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev)
                        ipv4_devconf.proxy_arp = 1;
                        return 0;
                }
-               if (__in_dev_get(dev)) {
-                       __in_dev_get(dev)->cnf.proxy_arp = 1;
+               if (__in_dev_get_rtnl(dev)) {
+                       __in_dev_get_rtnl(dev)->cnf.proxy_arp = 1;
                        return 0;
                }
                return -ENXIO;
@@ -1096,8 +1095,8 @@ static int arp_req_delete(struct arpreq *r, struct net_device * dev)
                                ipv4_devconf.proxy_arp = 0;
                                return 0;
                        }
-                       if (__in_dev_get(dev)) {
-                               __in_dev_get(dev)->cnf.proxy_arp = 0;
+                       if (__in_dev_get_rtnl(dev)) {
+                               __in_dev_get_rtnl(dev)->cnf.proxy_arp = 0;
                                return 0;
                        }
                        return -ENXIO;
index ba2895ae81514ab1aea769339876acce7bf6a76c..74f2207e131ae06b165f6203eb55b7d7e9b9456f 100644 (file)
@@ -351,7 +351,7 @@ static int inet_insert_ifa(struct in_ifaddr *ifa)
 
 static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
 {
-       struct in_device *in_dev = __in_dev_get(dev);
+       struct in_device *in_dev = __in_dev_get_rtnl(dev);
 
        ASSERT_RTNL();
 
@@ -449,7 +449,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
                goto out;
 
        rc = -ENOBUFS;
-       if ((in_dev = __in_dev_get(dev)) == NULL) {
+       if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) {
                in_dev = inetdev_init(dev);
                if (!in_dev)
                        goto out;
@@ -584,7 +584,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
        if (colon)
                *colon = ':';
 
-       if ((in_dev = __in_dev_get(dev)) != NULL) {
+       if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
                if (tryaddrmatch) {
                        /* Matthias Andree */
                        /* compare label and address (4.4BSD style) */
@@ -748,7 +748,7 @@ rarok:
 
 static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
 {
-       struct in_device *in_dev = __in_dev_get(dev);
+       struct in_device *in_dev = __in_dev_get_rtnl(dev);
        struct in_ifaddr *ifa;
        struct ifreq ifr;
        int done = 0;
@@ -791,7 +791,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope)
        struct in_device *in_dev;
 
        rcu_read_lock();
-       in_dev = __in_dev_get(dev);
+       in_dev = __in_dev_get_rcu(dev);
        if (!in_dev)
                goto no_in_dev;
 
@@ -818,7 +818,7 @@ no_in_dev:
        read_lock(&dev_base_lock);
        rcu_read_lock();
        for (dev = dev_base; dev; dev = dev->next) {
-               if ((in_dev = __in_dev_get(dev)) == NULL)
+               if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
                        continue;
 
                for_primary_ifa(in_dev) {
@@ -887,7 +887,7 @@ u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scop
 
        if (dev) {
                rcu_read_lock();
-               if ((in_dev = __in_dev_get(dev)))
+               if ((in_dev = __in_dev_get_rcu(dev)))
                        addr = confirm_addr_indev(in_dev, dst, local, scope);
                rcu_read_unlock();
 
@@ -897,7 +897,7 @@ u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scop
        read_lock(&dev_base_lock);
        rcu_read_lock();
        for (dev = dev_base; dev; dev = dev->next) {
-               if ((in_dev = __in_dev_get(dev))) {
+               if ((in_dev = __in_dev_get_rcu(dev))) {
                        addr = confirm_addr_indev(in_dev, dst, local, scope);
                        if (addr)
                                break;
@@ -957,7 +957,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
                         void *ptr)
 {
        struct net_device *dev = ptr;
-       struct in_device *in_dev = __in_dev_get(dev);
+       struct in_device *in_dev = __in_dev_get_rtnl(dev);
 
        ASSERT_RTNL();
 
@@ -1078,7 +1078,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
                if (idx > s_idx)
                        s_ip_idx = 0;
                rcu_read_lock();
-               if ((in_dev = __in_dev_get(dev)) == NULL) {
+               if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
                        rcu_read_unlock();
                        continue;
                }
@@ -1149,7 +1149,7 @@ void inet_forward_change(void)
        for (dev = dev_base; dev; dev = dev->next) {
                struct in_device *in_dev;
                rcu_read_lock();
-               in_dev = __in_dev_get(dev);
+               in_dev = __in_dev_get_rcu(dev);
                if (in_dev)
                        in_dev->cnf.forwarding = on;
                rcu_read_unlock();
index 4e1379f712696e82be169fd4b69dde6456cee855..e61bc7177eb1b868225bf34734f85702fc311969 100644 (file)
@@ -173,7 +173,7 @@ int fib_validate_source(u32 src, u32 dst, u8 tos, int oif,
 
        no_addr = rpf = 0;
        rcu_read_lock();
-       in_dev = __in_dev_get(dev);
+       in_dev = __in_dev_get_rcu(dev);
        if (in_dev) {
                no_addr = in_dev->ifa_list == NULL;
                rpf = IN_DEV_RPFILTER(in_dev);
@@ -607,7 +607,7 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
 static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
        struct net_device *dev = ptr;
-       struct in_device *in_dev = __in_dev_get(dev);
+       struct in_device *in_dev = __in_dev_get_rtnl(dev);
 
        if (event == NETDEV_UNREGISTER) {
                fib_disable_ip(dev, 2);
index d41219e8037c7a9f8a9c69dc1bd720f36d357d0b..186f20c4a45e06a65cfaee8cbfba41ab00dfbf00 100644 (file)
@@ -1087,7 +1087,7 @@ fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm,
                rta->rta_oif = &dev->ifindex;
                if (colon) {
                        struct in_ifaddr *ifa;
-                       struct in_device *in_dev = __in_dev_get(dev);
+                       struct in_device *in_dev = __in_dev_get_rtnl(dev);
                        if (!in_dev)
                                return -ENODEV;
                        *colon = ':';
@@ -1268,7 +1268,7 @@ int fib_sync_up(struct net_device *dev)
                        }
                        if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP))
                                continue;
-                       if (nh->nh_dev != dev || __in_dev_get(dev) == NULL)
+                       if (nh->nh_dev != dev || !__in_dev_get_rtnl(dev))
                                continue;
                        alive++;
                        spin_lock_bh(&fib_multipath_lock);
index 50c0519cd70d879c0d9944ecdef3c7c8977eabf3..0093ea08c7f5378c8bbd80e966007c9eaf87f382 100644 (file)
@@ -286,6 +286,8 @@ static inline void check_tnode(const struct tnode *tn)
 
 static int halve_threshold = 25;
 static int inflate_threshold = 50;
+static int halve_threshold_root = 15;
+static int inflate_threshold_root = 25; 
 
 
 static void __alias_free_mem(struct rcu_head *head)
@@ -449,6 +451,8 @@ static struct node *resize(struct trie *t, struct tnode *tn)
        int i;
        int err = 0;
        struct tnode *old_tn;
+       int inflate_threshold_use;
+       int halve_threshold_use;
 
        if (!tn)
                return NULL;
@@ -541,10 +545,17 @@ static struct node *resize(struct trie *t, struct tnode *tn)
 
        check_tnode(tn);
 
+       /* Keep root node larger  */
+
+       if(!tn->parent)
+               inflate_threshold_use = inflate_threshold_root;
+       else 
+               inflate_threshold_use = inflate_threshold;
+
        err = 0;
        while ((tn->full_children > 0 &&
               50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >=
-                               inflate_threshold * tnode_child_length(tn))) {
+                               inflate_threshold_use * tnode_child_length(tn))) {
 
                old_tn = tn;
                tn = inflate(t, tn);
@@ -564,10 +575,18 @@ static struct node *resize(struct trie *t, struct tnode *tn)
         * node is above threshold.
         */
 
+
+       /* Keep root node larger  */
+
+       if(!tn->parent)
+               halve_threshold_use = halve_threshold_root;
+       else 
+               halve_threshold_use = halve_threshold;
+
        err = 0;
        while (tn->bits > 1 &&
               100 * (tnode_child_length(tn) - tn->empty_children) <
-              halve_threshold * tnode_child_length(tn)) {
+              halve_threshold_use * tnode_child_length(tn)) {
 
                old_tn = tn;
                tn = halve(t, tn);
index 24eb56ae1b5ac4e5d4f6235654a899ea676e4039..90dca711ac9f3061d8b247d1e9f1b50e40419e40 100644 (file)
@@ -188,7 +188,7 @@ struct icmp_err icmp_err_convert[] = {
 
 /* Control parameters for ECHO replies. */
 int sysctl_icmp_echo_ignore_all;
-int sysctl_icmp_echo_ignore_broadcasts;
+int sysctl_icmp_echo_ignore_broadcasts = 1;
 
 /* Control parameter - ignore bogus broadcast responses? */
 int sysctl_icmp_ignore_bogus_error_responses;
index 70c44e4c3ceb28385d4a2e6f604e1c5509d54e46..8b6d3939e1e60922fc41d6e7e04723486aade385 100644 (file)
@@ -1323,7 +1323,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr)
        }
        if (dev) {
                imr->imr_ifindex = dev->ifindex;
-               idev = __in_dev_get(dev);
+               idev = __in_dev_get_rtnl(dev);
        }
        return idev;
 }
index 4d1502a49852e42524ee3cb4f75f34e81212e9fb..f9076ef3a1a810b54ef5671d9620b5960cff8ac0 100644 (file)
@@ -20,7 +20,7 @@ void __inet_twsk_kill(struct inet_timewait_sock *tw, struct inet_hashinfo *hashi
        struct inet_bind_hashbucket *bhead;
        struct inet_bind_bucket *tb;
        /* Unlink from established hashes. */
-       struct inet_ehash_bucket *ehead = &hashinfo->ehash[tw->tw_hashent];
+       struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, tw->tw_hash);
 
        write_lock(&ehead->lock);
        if (hlist_unhashed(&tw->tw_node)) {
@@ -60,7 +60,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
 {
        const struct inet_sock *inet = inet_sk(sk);
        const struct inet_connection_sock *icsk = inet_csk(sk);
-       struct inet_ehash_bucket *ehead = &hashinfo->ehash[sk->sk_hashent];
+       struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash);
        struct inet_bind_hashbucket *bhead;
        /* Step 1: Put TW into bind hash. Original socket stays there too.
           Note, that any socket with inet->num != 0 MUST be bound in
@@ -106,7 +106,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
                tw->tw_dport        = inet->dport;
                tw->tw_family       = sk->sk_family;
                tw->tw_reuse        = sk->sk_reuse;
-               tw->tw_hashent      = sk->sk_hashent;
+               tw->tw_hash         = sk->sk_hash;
                tw->tw_ipv6only     = 0;
                tw->tw_prot         = sk->sk_prot_creator;
                atomic_set(&tw->tw_refcnt, 1);
index f0d5740d7e220f5675602ee43682c526f4dfbf8c..896ce3f8f53addd02db7e6beaaa205a7275da262 100644 (file)
@@ -1104,10 +1104,10 @@ static int ipgre_open(struct net_device *dev)
                        return -EADDRNOTAVAIL;
                dev = rt->u.dst.dev;
                ip_rt_put(rt);
-               if (__in_dev_get(dev) == NULL)
+               if (__in_dev_get_rtnl(dev) == NULL)
                        return -EADDRNOTAVAIL;
                t->mlink = dev->ifindex;
-               ip_mc_inc_group(__in_dev_get(dev), t->parms.iph.daddr);
+               ip_mc_inc_group(__in_dev_get_rtnl(dev), t->parms.iph.daddr);
        }
        return 0;
 }
index 9dbf5909f3a6a190fcef1961e3737100a4b12e57..302b7eb507c97ebae6365f6b99122650174e95b5 100644 (file)
@@ -149,7 +149,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
                if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) {
                        dev->flags |= IFF_MULTICAST;
 
-                       in_dev = __in_dev_get(dev);
+                       in_dev = __in_dev_get_rtnl(dev);
                        if (in_dev == NULL && (in_dev = inetdev_init(dev)) == NULL)
                                goto failure;
                        in_dev->cnf.rp_filter = 0;
@@ -278,7 +278,7 @@ static int vif_delete(int vifi)
 
        dev_set_allmulti(dev, -1);
 
-       if ((in_dev = __in_dev_get(dev)) != NULL) {
+       if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
                in_dev->cnf.mc_forwarding--;
                ip_rt_multicast_event(in_dev);
        }
@@ -421,7 +421,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
                return -EINVAL;
        }
 
-       if ((in_dev = __in_dev_get(dev)) == NULL)
+       if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
                return -EADDRNOTAVAIL;
        in_dev->cnf.mc_forwarding++;
        dev_set_allmulti(dev, +1);
index 6e092dadb3883964a33bdc657417331ebdbc2b25..b942ff3c886075a8c4180b4d1fd66a3acf9171b8 100644 (file)
@@ -604,7 +604,7 @@ static struct file_operations ip_vs_app_fops = {
 /*
  *     Replace a segment of data with a new segment
  */
-int ip_vs_skb_replace(struct sk_buff *skb, int pri,
+int ip_vs_skb_replace(struct sk_buff *skb, unsigned int __nocast pri,
                      char *o_buf, int o_len, char *n_buf, int n_len)
 {
        struct iphdr *iph;
index 2cd7e7d1ac9097d96d263b6c352ecc1ca068f5ba..a7659728e7a0a86abea82923e841cc9bf733458c 100644 (file)
@@ -141,7 +141,7 @@ config IP_NF_PPTP
        tristate  'PPTP protocol support'
        help
          This module adds support for PPTP (Point to Point Tunnelling
-         Protocol, RFC2637) conncection tracking and NAT. 
+         Protocol, RFC2637) connection tracking and NAT. 
        
          If you are running PPTP sessions over a stateful firewall or NAT
          box, you may want to enable this feature.  
index 577bac22dcc6421e2afeccbce5f97889c3cdbf31..186646eb249fcb9ffa08600a9c933849c1720a58 100644 (file)
@@ -58,7 +58,7 @@ static int help(struct sk_buff **pskb,
                goto out;
 
        rcu_read_lock();
-       in_dev = __in_dev_get(rt->u.dst.dev);
+       in_dev = __in_dev_get_rcu(rt->u.dst.dev);
        if (in_dev != NULL) {
                for_primary_ifa(in_dev) {
                        if (ifa->ifa_broadcast == iph->daddr) {
index d54f14d926f6e0caafc80a68cc8e84d60d1b86d7..36339eb39e172b3c0fa7dab9f816ced70003d51b 100644 (file)
@@ -240,8 +240,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
 
        pmsg->packet_id       = (unsigned long )entry;
        pmsg->data_len        = data_len;
-       pmsg->timestamp_sec   = skb_tv_base.tv_sec + entry->skb->tstamp.off_sec;
-       pmsg->timestamp_usec  = skb_tv_base.tv_usec + entry->skb->tstamp.off_usec;
+       pmsg->timestamp_sec   = entry->skb->tstamp.off_sec;
+       pmsg->timestamp_usec  = entry->skb->tstamp.off_usec;
        pmsg->mark            = entry->skb->nfmark;
        pmsg->hook            = entry->info->hook;
        pmsg->hw_protocol     = entry->skb->protocol;
index 715cb613405cca742b37540da12fd14d86d967e6..5245bfd33d526472f543756af058b87ab214b4fd 100644 (file)
@@ -93,7 +93,7 @@ redirect_target(struct sk_buff **pskb,
                newdst = 0;
                
                rcu_read_lock();
-               indev = __in_dev_get((*pskb)->dev);
+               indev = __in_dev_get_rcu((*pskb)->dev);
                if (indev && (ifa = indev->ifa_list))
                        newdst = ifa->ifa_local;
                rcu_read_unlock();
index e2c14f3cb2fc6a91e32d81bcdda5777cbd248c06..2883ccd8a91d27b8378b90a59c2cc13d0f46d4d0 100644 (file)
@@ -225,8 +225,8 @@ static void ipt_ulog_packet(unsigned int hooknum,
 
        /* copy hook, prefix, timestamp, payload, etc. */
        pm->data_len = copy_len;
-       pm->timestamp_sec = skb_tv_base.tv_sec + skb->tstamp.off_sec;
-       pm->timestamp_usec = skb_tv_base.tv_usec + skb->tstamp.off_usec;
+       pm->timestamp_sec = skb->tstamp.off_sec;
+       pm->timestamp_usec = skb->tstamp.off_usec;
        pm->mark = skb->nfmark;
        pm->hook = hooknum;
        if (prefix != NULL)
index 8549f26e2495089c8987fd4c241b9ae002a74393..381dd6a6aebbedc10ac861b957cdd1a55932dc52 100644 (file)
@@ -2128,7 +2128,7 @@ int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr,
                struct in_device *in_dev;
 
                rcu_read_lock();
-               if ((in_dev = __in_dev_get(dev)) != NULL) {
+               if ((in_dev = __in_dev_get_rcu(dev)) != NULL) {
                        int our = ip_check_mc(in_dev, daddr, saddr,
                                skb->nh.iph->protocol);
                        if (our
@@ -2443,7 +2443,9 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
                err = -ENODEV;
                if (dev_out == NULL)
                        goto out;
-               if (__in_dev_get(dev_out) == NULL) {
+
+               /* RACE: Check return value of inet_select_addr instead. */
+               if (__in_dev_get_rtnl(dev_out) == NULL) {
                        dev_put(dev_out);
                        goto out;       /* Wrong error code */
                }
index b940346de4e7cbc5bc724245992c07f6c0e41120..6d80e063c187f3464fe77ee52e6128183b5a8642 100644 (file)
@@ -136,7 +136,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                else if (cwnd < ca->last_max_cwnd + max_increment*(BICTCP_B-1))
                        /* slow start */
                        ca->cnt = (cwnd * (BICTCP_B-1))
-                               / cwnd-ca->last_max_cwnd;
+                               / (cwnd - ca->last_max_cwnd);
                else
                        /* linear increase */
                        ca->cnt = cwnd / max_increment;
index a7537c7bbd06f0040c4d44f255c081cea93a215b..677419d0c9ade7da761d5c558b9421b6e3e32f04 100644 (file)
@@ -355,8 +355,6 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp)
                        app_win -= icsk->icsk_ack.rcv_mss;
                app_win = max(app_win, 2U*tp->advmss);
 
-               if (!ofo_win)
-                       tp->window_clamp = min(tp->window_clamp, app_win);
                tp->rcv_ssthresh = min(tp->window_clamp, 2U*tp->advmss);
        }
 }
index 13dfb391cdf17a376c301c9f56973db93696c1d6..c85819d8474bba64dc433ca4fd93684bee7421c5 100644 (file)
@@ -130,19 +130,20 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport,
        int dif = sk->sk_bound_dev_if;
        INET_ADDR_COOKIE(acookie, saddr, daddr)
        const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
-       const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, tcp_hashinfo.ehash_size);
-       struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash];
+       unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
+       struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash);
        struct sock *sk2;
        const struct hlist_node *node;
        struct inet_timewait_sock *tw;
 
+       prefetch(head->chain.first);
        write_lock(&head->lock);
 
        /* Check TIME-WAIT sockets first. */
        sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) {
                tw = inet_twsk(sk2);
 
-               if (INET_TW_MATCH(sk2, acookie, saddr, daddr, ports, dif)) {
+               if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) {
                        const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2);
                        struct tcp_sock *tp = tcp_sk(sk);
 
@@ -179,7 +180,7 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport,
 
        /* And established part... */
        sk_for_each(sk2, node, &head->chain) {
-               if (INET_MATCH(sk2, acookie, saddr, daddr, ports, dif))
+               if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif))
                        goto not_unique;
        }
 
@@ -188,7 +189,7 @@ unique:
         * in hash table socket with a funny identity. */
        inet->num = lport;
        inet->sport = htons(lport);
-       sk->sk_hashent = hash;
+       sk->sk_hash = hash;
        BUG_TRAP(sk_unhashed(sk));
        __sk_add_node(sk, &head->chain);
        sock_prot_inc_use(sk->sk_prot);
index d6e3d269e90611250fabaea9005d0dc3abc3dea3..c5b911f9b662cb33b959755cebd3f2fb8d8c7fe0 100644 (file)
@@ -190,7 +190,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
        }
 
        /* Set initial window to value enough for senders,
-        * following RFC1414. Senders, not following this RFC,
+        * following RFC2414. Senders, not following this RFC,
         * will be satisfied with 2.
         */
        if (mss > (1<<*rcv_wscale)) {
index 4e509e52fbc129d84762b2a36a7a5fc7f6a7a6da..a970b4727ce8c9c2f8d61cf8a976113ced190ce5 100644 (file)
@@ -1806,7 +1806,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
        }
 
         for (dev = dev_base; dev != NULL; dev = dev->next) {
-               struct in_device * in_dev = __in_dev_get(dev);
+               struct in_device * in_dev = __in_dev_get_rtnl(dev);
                if (in_dev && (dev->flags & IFF_UP)) {
                        struct in_ifaddr * ifa;
 
index 2f589f24c09397fa58cffe9d54ec866b02e78598..563b442ffab8fcabd26292199a340499cddd4fbb 100644 (file)
@@ -666,7 +666,7 @@ slow_path:
                 */
                fh->nexthdr = nexthdr;
                fh->reserved = 0;
-               if (frag_id) {
+               if (!frag_id) {
                        ipv6_select_ident(skb, fh);
                        frag_id = fh->identification;
                } else
index 519899fb11d50bfad08cfd0135d117193a1f1f3f..39a96c768102f3915e347fbf3880ace5445db5fc 100644 (file)
@@ -1393,7 +1393,7 @@ static void mld_sendpack(struct sk_buff *skb)
 
 static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel)
 {
-       return sizeof(struct mld2_grec) + 4*mld_scount(pmc,type,gdel,sdel);
+       return sizeof(struct mld2_grec) + 16 * mld_scount(pmc,type,gdel,sdel);
 }
 
 static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc,
index 555a31347eda60577aef1b098a4120964ed4cc6e..305d9ee6d7dbc3f154f6cb11c2b6a997c25bf0cb 100644 (file)
@@ -1450,7 +1450,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
 
 static void pndisc_redo(struct sk_buff *skb)
 {
-       ndisc_rcv(skb);
+       ndisc_recv_ns(skb);
        kfree_skb(skb);
 }
 
index aa11cf366efab29a428434e014c08034b0eb54ee..5027bbe6415e7e89da9d27fcbc797c1f7432b2ee 100644 (file)
@@ -238,8 +238,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
 
        pmsg->packet_id       = (unsigned long )entry;
        pmsg->data_len        = data_len;
-       pmsg->timestamp_sec   = skb_tv_base.tv_sec + entry->skb->tstamp.off_sec;
-       pmsg->timestamp_usec  = skb_tv_base.tv_usec + entry->skb->tstamp.off_usec;
+       pmsg->timestamp_sec   = entry->skb->tstamp.off_sec;
+       pmsg->timestamp_usec  = entry->skb->tstamp.off_usec;
        pmsg->mark            = entry->skb->nfmark;
        pmsg->hook            = entry->info->hook;
        pmsg->hw_protocol     = entry->skb->protocol;
index 80643e6b346b97b36466fb23099898de5d7ebda3..d693cb988b78f99407f529e0a956e099e468c6ef 100644 (file)
@@ -209,9 +209,11 @@ static __inline__ void __tcp_v6_hash(struct sock *sk)
                lock = &tcp_hashinfo.lhash_lock;
                inet_listen_wlock(&tcp_hashinfo);
        } else {
-               sk->sk_hashent = inet6_sk_ehashfn(sk, tcp_hashinfo.ehash_size);
-               list = &tcp_hashinfo.ehash[sk->sk_hashent].chain;
-               lock = &tcp_hashinfo.ehash[sk->sk_hashent].lock;
+               unsigned int hash;
+               sk->sk_hash = hash = inet6_sk_ehashfn(sk);
+               hash &= (tcp_hashinfo.ehash_size - 1);
+               list = &tcp_hashinfo.ehash[hash].chain;
+               lock = &tcp_hashinfo.ehash[hash].lock;
                write_lock(lock);
        }
 
@@ -322,13 +324,13 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport,
        const struct in6_addr *saddr = &np->daddr;
        const int dif = sk->sk_bound_dev_if;
        const u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
-       const int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport,
-                                      tcp_hashinfo.ehash_size);
-       struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash];
+       unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport);
+       struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash);
        struct sock *sk2;
        const struct hlist_node *node;
        struct inet_timewait_sock *tw;
 
+       prefetch(head->chain.first);
        write_lock(&head->lock);
 
        /* Check TIME-WAIT sockets first. */
@@ -365,14 +367,14 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport,
 
        /* And established part... */
        sk_for_each(sk2, node, &head->chain) {
-               if (INET6_MATCH(sk2, saddr, daddr, ports, dif))
+               if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif))
                        goto not_unique;
        }
 
 unique:
        BUG_TRAP(sk_unhashed(sk));
        __sk_add_node(sk, &head->chain);
-       sk->sk_hashent = hash;
+       sk->sk_hash = hash;
        sock_prot_inc_use(sk->sk_prot);
        write_unlock(&head->lock);
 
index 6001948600f31bcbe622f18a9fc4461f6ef8531b..bf9519341fd30ad28a0b9652d09bcd7628765dc4 100644 (file)
@@ -99,7 +99,7 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
                next:;
                }
                result = best;
-               for(;; result += UDP_HTABLE_SIZE) {
+               for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) {
                        if (result > sysctl_local_port_range[1])
                                result = sysctl_local_port_range[0]
                                        + ((result - sysctl_local_port_range[0]) &
@@ -107,6 +107,8 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
                        if (!udp_lport_inuse(result))
                                break;
                }
+               if (i >= (1 << 16) / UDP_HTABLE_SIZE)
+                       goto fail;
 gotit:
                udp_port_rover = snum = result;
        } else {
@@ -852,10 +854,16 @@ do_append_data:
        else if (!corkreq)
                err = udp_v6_push_pending_frames(sk, up);
 
-       if (dst && connected)
-               ip6_dst_store(sk, dst,
-                             ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ?
-                             &np->daddr : NULL);
+       if (dst) {
+               if (connected) {
+                       ip6_dst_store(sk, dst,
+                                     ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ?
+                                     &np->daddr : NULL);
+               } else {
+                       dst_release(dst);
+               }
+       }
+
        if (err > 0)
                err = np->recverr ? net_xmit_errno(err) : 0;
        release_sock(sk);
index 071cd2cefd8a285db72825899ef47c68e42ad426..953e255d2bc86d030c0eded616504f982ba0bb4f 100644 (file)
@@ -310,7 +310,7 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
 #ifdef CONFIG_INET
        IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n");
        rcu_read_lock();
-       in_dev = __in_dev_get(dev);
+       in_dev = __in_dev_get_rcu(dev);
        if (in_dev == NULL)
                goto out;
        if (in_dev->ifa_list)
index 4879743b945ae5956c6713a6c50dc5a2052f37ae..bbf0f69181baff8298e8b3bb6e381ae2bf0d222f 100644 (file)
@@ -185,7 +185,7 @@ static int pfkey_release(struct socket *sock)
 }
 
 static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
-                              int allocation, struct sock *sk)
+                              unsigned int __nocast allocation, struct sock *sk)
 {
        int err = -ENOBUFS;
 
@@ -217,7 +217,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
 #define BROADCAST_ONE          1
 #define BROADCAST_REGISTERED   2
 #define BROADCAST_PROMISC_ONLY 4
-static int pfkey_broadcast(struct sk_buff *skb, int allocation,
+static int pfkey_broadcast(struct sk_buff *skb, unsigned int __nocast allocation,
                           int broadcast_flags, struct sock *one_sk)
 {
        struct sock *sk;
@@ -1416,7 +1416,8 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
        return 0;
 }
 
-static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig, int allocation)
+static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig,
+                                             unsigned int __nocast allocation)
 {
        struct sk_buff *skb;
        struct sadb_msg *hdr;
@@ -2153,6 +2154,7 @@ out:
 
 static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs)
 {
+       unsigned int dir;
        int err;
        struct sadb_x_policy *pol;
        struct xfrm_policy *xp;
@@ -2161,7 +2163,11 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
        if ((pol = ext_hdrs[SADB_X_EXT_POLICY-1]) == NULL)
                return -EINVAL;
 
-       xp = xfrm_policy_byid(0, pol->sadb_x_policy_id,
+       dir = xfrm_policy_id2dir(pol->sadb_x_policy_id);
+       if (dir >= XFRM_POLICY_MAX)
+               return -EINVAL;
+
+       xp = xfrm_policy_byid(dir, pol->sadb_x_policy_id,
                              hdr->sadb_msg_type == SADB_X_SPDDELETE2);
        if (xp == NULL)
                return -ENOENT;
@@ -2173,9 +2179,9 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
        if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) {
                c.data.byid = 1;
                c.event = XFRM_MSG_DELPOLICY;
-               km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
+               km_policy_notify(xp, dir, &c);
        } else {
-               err = key_pol_get_resp(sk, xp, hdr, pol->sadb_x_policy_dir-1);
+               err = key_pol_get_resp(sk, xp, hdr, dir);
        }
 
        xfrm_pol_put(xp);
index 49a3900e3d32b24d9ad91dc03340d62364d0ff25..34d671974a4d9522f7e6f393a2d5fa4b154b0df5 100644 (file)
@@ -195,7 +195,8 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
 
 int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
 {
-       int allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
+       unsigned int __nocast allocation =
+                       in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
        int err = 0;
 
        NETLINK_CB(skb).dst_group = group;
index ff5601ceedcb60aed7d0a760e9271bc5b3373be6..efcd10f996ba516294f5e607c72a0268bd0ce808 100644 (file)
@@ -494,8 +494,8 @@ __build_packet_message(struct nfulnl_instance *inst,
        if (skb->tstamp.off_sec) {
                struct nfulnl_msg_packet_timestamp ts;
 
-               ts.sec = cpu_to_be64(skb_tv_base.tv_sec + skb->tstamp.off_sec);
-               ts.usec = cpu_to_be64(skb_tv_base.tv_usec + skb->tstamp.off_usec);
+               ts.sec = cpu_to_be64(skb->tstamp.off_sec);
+               ts.usec = cpu_to_be64(skb->tstamp.off_usec);
 
                NFA_PUT(inst->skb, NFULA_TIMESTAMP, sizeof(ts), &ts);
        }
index f81fe8c52e99ba2d3d90762cecc9ac4194fbf956..eaa44c49567be362e95ceaf359b4f7fa9d2ea532 100644 (file)
@@ -492,8 +492,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
        if (entry->skb->tstamp.off_sec) {
                struct nfqnl_msg_packet_timestamp ts;
 
-               ts.sec = cpu_to_be64(skb_tv_base.tv_sec + entry->skb->tstamp.off_sec);
-               ts.usec = cpu_to_be64(skb_tv_base.tv_usec + entry->skb->tstamp.off_usec);
+               ts.sec = cpu_to_be64(entry->skb->tstamp.off_sec);
+               ts.usec = cpu_to_be64(entry->skb->tstamp.off_usec);
 
                NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts);
        }
index 4e66eef9a03479f0ead803fabdfb3d1f73e0b18f..509afddae5694a4aae228127c2e379f618bdd40a 100644 (file)
@@ -58,7 +58,7 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev)
 
        /* Spoof incoming device */
        skb->dev      = dev;
-       skb->h.raw    = skb->data;
+       skb->mac.raw  = skb->nh.raw;
        skb->nh.raw   = skb->data;
        skb->pkt_type = PACKET_HOST;
 
index 6a67a87384cc2d3c95270d425e868bfcf53fdb1f..499ae3df4a440b42c0765d1e691bb647c2230050 100644 (file)
@@ -654,8 +654,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
                __net_timestamp(skb);
                sock_enable_timestamp(sk);
        }
-       h->tp_sec = skb_tv_base.tv_sec + skb->tstamp.off_sec;
-       h->tp_usec = skb_tv_base.tv_usec + skb->tstamp.off_usec;
+       h->tp_sec = skb->tstamp.off_sec;
+       h->tp_usec = skb->tstamp.off_usec;
 
        sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h)));
        sll->sll_halen = 0;
index 5acb1680524ab5a3ae381b2a741fabd0219f8bc1..829fdbc4400be21af83e3846fd913cd746fdca3b 100644 (file)
@@ -1472,22 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62
 static int __init rose_proto_init(void)
 {
        int i;
-       int rc = proto_register(&rose_proto, 0);
+       int rc;
 
+       if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
+               printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
+               rc = -EINVAL;
+               goto out;
+       }
+
+       rc = proto_register(&rose_proto, 0);
        if (rc != 0)
                goto out;
 
        rose_callsign = null_ax25_address;
 
-       if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
-               printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
-               return -1;
-       }
-
        dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
        if (dev_rose == NULL) {
                printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
-               return -1;
+               rc = -ENOMEM;
+               goto out_proto_unregister;
        }
 
        memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*));
@@ -1500,10 +1503,12 @@ static int __init rose_proto_init(void)
                                   name, rose_setup);
                if (!dev) {
                        printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
+                       rc = -ENOMEM;
                        goto fail;
                }
-               if (register_netdev(dev)) {
-                       printk(KERN_ERR "ROSE: netdevice regeistration failed\n");
+               rc = register_netdev(dev);
+               if (rc) {
+                       printk(KERN_ERR "ROSE: netdevice registration failed\n");
                        free_netdev(dev);
                        goto fail;
                }
@@ -1536,8 +1541,9 @@ fail:
                free_netdev(dev_rose[i]);
        }
        kfree(dev_rose);
+out_proto_unregister:
        proto_unregister(&rose_proto);
-       return -ENOMEM;
+       goto out;
 }
 module_init(rose_proto_init);
 
index 5cfd4cadee424fedbaa750d3649072a09335c98b..86f77705263389b4347ca79cc032f435973005cd 100644 (file)
@@ -1923,7 +1923,7 @@ int rxrpc_call_write_data(struct rxrpc_call *call,
                          size_t sioc,
                          struct kvec *siov,
                          u8 rxhdr_flags,
-                         int alloc_flags,
+                         unsigned int __nocast alloc_flags,
                          int dup_data,
                          size_t *size_sent)
 {
index 61463c74f8cc8998ad727fe1adf9fa3ae4af9d37..be4b2be58956a775c16a669c0a4af5c07f8aafaa 100644 (file)
@@ -522,7 +522,7 @@ int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
                      uint8_t type,
                      int dcount,
                      struct kvec diov[],
-                     int alloc_flags,
+                     unsigned int __nocast alloc_flags,
                      struct rxrpc_message **_msg)
 {
        struct rxrpc_message *msg;
index 00eae5f9a01aab28d810e333f938de7e735e8dbf..cf68a59fdc5a4d4d6ac2bfbd5b63f99cd4574cee 100644 (file)
@@ -393,10 +393,10 @@ META_COLLECTOR(int_sk_route_caps)
        dst->value = skb->sk->sk_route_caps;
 }
 
-META_COLLECTOR(int_sk_hashent)
+META_COLLECTOR(int_sk_hash)
 {
        SKIP_NONLOCAL(skb);
-       dst->value = skb->sk->sk_hashent;
+       dst->value = skb->sk->sk_hash;
 }
 
 META_COLLECTOR(int_sk_lingertime)
@@ -515,7 +515,7 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
                [META_ID(SK_FORWARD_ALLOCS)]    = META_FUNC(int_sk_fwd_alloc),
                [META_ID(SK_ALLOCS)]            = META_FUNC(int_sk_alloc),
                [META_ID(SK_ROUTE_CAPS)]        = META_FUNC(int_sk_route_caps),
-               [META_ID(SK_HASHENT)]           = META_FUNC(int_sk_hashent),
+               [META_ID(SK_HASH)]              = META_FUNC(int_sk_hash),
                [META_ID(SK_LINGERTIME)]        = META_FUNC(int_sk_lingertime),
                [META_ID(SK_ACK_BACKLOG)]       = META_FUNC(int_sk_ack_bl),
                [META_ID(SK_MAX_ACK_BACKLOG)]   = META_FUNC(int_sk_max_ack_bl),
index e7025be77691c096d23807fbc75818d00610380e..f01d1c9002a1a6db62746f41f5554fd86176d9cb 100644 (file)
@@ -147,7 +147,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
        struct sctp_sockaddr_entry *addr;
 
        rcu_read_lock();
-       if ((in_dev = __in_dev_get(dev)) == NULL) {
+       if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
                rcu_read_unlock();
                return;
        }
index 91ec8c9369135ade53002ff4a5bdebc139e7a80a..02e068d3450d125b11255e441601e98e7120c4fa 100644 (file)
@@ -3159,8 +3159,9 @@ static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval
        return 0;
 }
 
-static int sctp_getsockopt_peer_addrs_num(struct sock *sk, int len,
-                                         char __user *optval, int __user *optlen)
+static int sctp_getsockopt_peer_addrs_num_old(struct sock *sk, int len,
+                                             char __user *optval,
+                                             int __user *optlen)
 {
        sctp_assoc_t id;
        struct sctp_association *asoc;
@@ -3185,23 +3186,28 @@ static int sctp_getsockopt_peer_addrs_num(struct sock *sk, int len,
        return cnt;
 }
 
-static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
-                                     char __user *optval, int __user *optlen)
+/* 
+ * Old API for getting list of peer addresses. Does not work for 32-bit
+ * programs running on a 64-bit kernel
+ */
+static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
+                                         char __user *optval,
+                                         int __user *optlen)
 {
        struct sctp_association *asoc;
        struct list_head *pos;
        int cnt = 0;
-       struct sctp_getaddrs getaddrs;
+       struct sctp_getaddrs_old getaddrs;
        struct sctp_transport *from;
        void __user *to;
        union sctp_addr temp;
        struct sctp_sock *sp = sctp_sk(sk);
        int addrlen;
 
-       if (len != sizeof(struct sctp_getaddrs))
+       if (len != sizeof(struct sctp_getaddrs_old))
                return -EINVAL;
 
-       if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs)))
+       if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old)))
                return -EFAULT;
 
        if (getaddrs.addr_num <= 0) return -EINVAL;
@@ -3225,15 +3231,69 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
                if (cnt >= getaddrs.addr_num) break;
        }
        getaddrs.addr_num = cnt;
-       if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs)))
+       if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old)))
+               return -EFAULT;
+
+       return 0;
+}
+
+static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
+                                     char __user *optval, int __user *optlen)
+{
+       struct sctp_association *asoc;
+       struct list_head *pos;
+       int cnt = 0;
+       struct sctp_getaddrs getaddrs;
+       struct sctp_transport *from;
+       void __user *to;
+       union sctp_addr temp;
+       struct sctp_sock *sp = sctp_sk(sk);
+       int addrlen;
+       size_t space_left;
+       int bytes_copied;
+
+       if (len < sizeof(struct sctp_getaddrs))
+               return -EINVAL;
+
+       if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs)))
+               return -EFAULT;
+
+       /* For UDP-style sockets, id specifies the association to query.  */
+       asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
+       if (!asoc)
+               return -EINVAL;
+
+       to = optval + offsetof(struct sctp_getaddrs,addrs);
+       space_left = len - sizeof(struct sctp_getaddrs) - 
+                       offsetof(struct sctp_getaddrs,addrs);
+
+       list_for_each(pos, &asoc->peer.transport_addr_list) {
+               from = list_entry(pos, struct sctp_transport, transports);
+               memcpy(&temp, &from->ipaddr, sizeof(temp));
+               sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
+               addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
+               if(space_left < addrlen)
+                       return -ENOMEM;
+               temp.v4.sin_port = htons(temp.v4.sin_port);
+               if (copy_to_user(to, &temp, addrlen))
+                       return -EFAULT;
+               to += addrlen;
+               cnt++;
+               space_left -= addrlen;
+       }
+
+       if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num))
+               return -EFAULT;
+       bytes_copied = ((char __user *)to) - optval;
+       if (put_user(bytes_copied, optlen))
                return -EFAULT;
 
        return 0;
 }
 
-static int sctp_getsockopt_local_addrs_num(struct sock *sk, int len,
-                                               char __user *optval,
-                                               int __user *optlen)
+static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
+                                              char __user *optval,
+                                              int __user *optlen)
 {
        sctp_assoc_t id;
        struct sctp_bind_addr *bp;
@@ -3306,8 +3366,8 @@ done:
 /* Helper function that copies local addresses to user and returns the number
  * of addresses copied.
  */
-static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, int max_addrs,
-                                   void __user *to)
+static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_addrs,
+                                       void __user *to)
 {
        struct list_head *pos;
        struct sctp_sockaddr_entry *addr;
@@ -3341,14 +3401,54 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, int max_addrs,
        return cnt;
 }
 
-static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
-                                      char __user *optval, int __user *optlen)
+static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port,
+                                   void * __user *to, size_t space_left)
+{
+       struct list_head *pos;
+       struct sctp_sockaddr_entry *addr;
+       unsigned long flags;
+       union sctp_addr temp;
+       int cnt = 0;
+       int addrlen;
+
+       sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
+       list_for_each(pos, &sctp_local_addr_list) {
+               addr = list_entry(pos, struct sctp_sockaddr_entry, list);
+               if ((PF_INET == sk->sk_family) && 
+                   (AF_INET6 == addr->a.sa.sa_family))
+                       continue;
+               memcpy(&temp, &addr->a, sizeof(temp));
+               sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
+                                                               &temp);
+               addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
+               if(space_left<addrlen)
+                       return -ENOMEM;
+               temp.v4.sin_port = htons(port);
+               if (copy_to_user(*to, &temp, addrlen)) {
+                       sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
+                                                   flags);
+                       return -EFAULT;
+               }
+               *to += addrlen;
+               cnt ++;
+               space_left -= addrlen;
+       }
+       sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
+
+       return cnt;
+}
+
+/* Old API for getting list of local addresses. Does not work for 32-bit
+ * programs running on a 64-bit kernel
+ */
+static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
+                                          char __user *optval, int __user *optlen)
 {
        struct sctp_bind_addr *bp;
        struct sctp_association *asoc;
        struct list_head *pos;
        int cnt = 0;
-       struct sctp_getaddrs getaddrs;
+       struct sctp_getaddrs_old getaddrs;
        struct sctp_sockaddr_entry *addr;
        void __user *to;
        union sctp_addr temp;
@@ -3357,10 +3457,10 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
        rwlock_t *addr_lock;
        int err = 0;
 
-       if (len != sizeof(struct sctp_getaddrs))
+       if (len != sizeof(struct sctp_getaddrs_old))
                return -EINVAL;
 
-       if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs)))
+       if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old)))
                return -EFAULT;
 
        if (getaddrs.addr_num <= 0) return -EINVAL;
@@ -3392,8 +3492,9 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
                addr = list_entry(bp->address_list.next,
                                  struct sctp_sockaddr_entry, list);
                if (sctp_is_any(&addr->a)) {
-                       cnt = sctp_copy_laddrs_to_user(sk, bp->port,
-                                                      getaddrs.addr_num, to);
+                       cnt = sctp_copy_laddrs_to_user_old(sk, bp->port,
+                                                          getaddrs.addr_num,
+                                                          to);
                        if (cnt < 0) {
                                err = cnt;
                                goto unlock;
@@ -3419,7 +3520,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
 
 copy_getaddrs:
        getaddrs.addr_num = cnt;
-       if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs)))
+       if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old)))
                err = -EFAULT;
 
 unlock:
@@ -3427,6 +3528,99 @@ unlock:
        return err;
 }
 
+static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
+                                      char __user *optval, int __user *optlen)
+{
+       struct sctp_bind_addr *bp;
+       struct sctp_association *asoc;
+       struct list_head *pos;
+       int cnt = 0;
+       struct sctp_getaddrs getaddrs;
+       struct sctp_sockaddr_entry *addr;
+       void __user *to;
+       union sctp_addr temp;
+       struct sctp_sock *sp = sctp_sk(sk);
+       int addrlen;
+       rwlock_t *addr_lock;
+       int err = 0;
+       size_t space_left;
+       int bytes_copied;
+
+       if (len <= sizeof(struct sctp_getaddrs))
+               return -EINVAL;
+
+       if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs)))
+               return -EFAULT;
+
+       /*
+        *  For UDP-style sockets, id specifies the association to query.
+        *  If the id field is set to the value '0' then the locally bound
+        *  addresses are returned without regard to any particular
+        *  association.
+        */
+       if (0 == getaddrs.assoc_id) {
+               bp = &sctp_sk(sk)->ep->base.bind_addr;
+               addr_lock = &sctp_sk(sk)->ep->base.addr_lock;
+       } else {
+               asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
+               if (!asoc)
+                       return -EINVAL;
+               bp = &asoc->base.bind_addr;
+               addr_lock = &asoc->base.addr_lock;
+       }
+
+       to = optval + offsetof(struct sctp_getaddrs,addrs);
+       space_left = len - sizeof(struct sctp_getaddrs) -
+                        offsetof(struct sctp_getaddrs,addrs);
+
+       sctp_read_lock(addr_lock);
+
+       /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid
+        * addresses from the global local address list.
+        */
+       if (sctp_list_single_entry(&bp->address_list)) {
+               addr = list_entry(bp->address_list.next,
+                                 struct sctp_sockaddr_entry, list);
+               if (sctp_is_any(&addr->a)) {
+                       cnt = sctp_copy_laddrs_to_user(sk, bp->port,
+                                                      &to, space_left);
+                       if (cnt < 0) {
+                               err = cnt;
+                               goto unlock;
+                       }
+                       goto copy_getaddrs;             
+               }
+       }
+
+       list_for_each(pos, &bp->address_list) {
+               addr = list_entry(pos, struct sctp_sockaddr_entry, list);
+               memcpy(&temp, &addr->a, sizeof(temp));
+               sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
+               addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
+               if(space_left < addrlen)
+                       return -ENOMEM; /*fixme: right error?*/
+               temp.v4.sin_port = htons(temp.v4.sin_port);
+               if (copy_to_user(to, &temp, addrlen)) {
+                       err = -EFAULT;
+                       goto unlock;
+               }
+               to += addrlen;
+               cnt ++;
+               space_left -= addrlen;
+       }
+
+copy_getaddrs:
+       if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num))
+               return -EFAULT;
+       bytes_copied = ((char __user *)to) - optval;
+       if (put_user(bytes_copied, optlen))
+               return -EFAULT;
+
+unlock:
+       sctp_read_unlock(addr_lock);
+       return err;
+}
+
 /* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
  *
  * Requests that the local SCTP stack use the enclosed peer address as
@@ -3807,12 +4001,20 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
        case SCTP_INITMSG:
                retval = sctp_getsockopt_initmsg(sk, len, optval, optlen);
                break;
-       case SCTP_GET_PEER_ADDRS_NUM:
-               retval = sctp_getsockopt_peer_addrs_num(sk, len, optval,
+       case SCTP_GET_PEER_ADDRS_NUM_OLD:
+               retval = sctp_getsockopt_peer_addrs_num_old(sk, len, optval,
+                                                           optlen);
+               break;
+       case SCTP_GET_LOCAL_ADDRS_NUM_OLD:
+               retval = sctp_getsockopt_local_addrs_num_old(sk, len, optval,
+                                                            optlen);
+               break;
+       case SCTP_GET_PEER_ADDRS_OLD:
+               retval = sctp_getsockopt_peer_addrs_old(sk, len, optval,
                                                        optlen);
                break;
-       case SCTP_GET_LOCAL_ADDRS_NUM:
-               retval = sctp_getsockopt_local_addrs_num(sk, len, optval,
+       case SCTP_GET_LOCAL_ADDRS_OLD:
+               retval = sctp_getsockopt_local_addrs_old(sk, len, optval,
                                                         optlen);
                break;
        case SCTP_GET_PEER_ADDRS:
index dbd1a6851edd7921a46879dca01505fe02055611..3145103cdf5471b1d688b0593e04237cadc5dd2e 100644 (file)
@@ -1145,8 +1145,11 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
        if (!try_module_get(net_families[family]->owner))
                goto out_release;
 
-       if ((err = net_families[family]->create(sock, protocol)) < 0)
+       if ((err = net_families[family]->create(sock, protocol)) < 0) {
+               sock->ops = NULL;
                goto out_module_put;
+       }
+
        /*
         * Now to bump the refcnt of the [loadable] module that owns this
         * socket at sock_release time we decrement its refcnt.
@@ -1360,16 +1363,16 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _
        newsock->type = sock->type;
        newsock->ops = sock->ops;
 
-       err = security_socket_accept(sock, newsock);
-       if (err)
-               goto out_release;
-
        /*
         * We don't need try_module_get here, as the listening socket (sock)
         * has the protocol module (sock->ops->owner) held.
         */
        __module_get(newsock->ops->owner);
 
+       err = security_socket_accept(sock, newsock);
+       if (err)
+               goto out_release;
+
        err = sock->ops->accept(sock, newsock, sock->file->f_flags);
        if (err < 0)
                goto out_release;
index f3104035e35d446828a0d29b92e947dfb7dfdcc5..ade730eaf401a9c888e497d718bf94a3dc59e22d 100644 (file)
@@ -719,7 +719,7 @@ static void rpc_async_schedule(void *arg)
 void *
 rpc_malloc(struct rpc_task *task, size_t size)
 {
-       int     gfp;
+       unsigned int __nocast   gfp;
 
        if (task->tk_flags & RPC_TASK_SWAPPER)
                gfp = GFP_ATOMIC;
index c5241fcbb9662451918242557022da60ff003ca0..55538f6b60ffc56648687f9f72fd7d0ebafe6af3 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/mm.h>
 #include <linux/sysctl.h>
 
+#include <net/sock.h>
+
 #ifdef CONFIG_INET
 #include <net/ip.h>
 #endif
index fda737d77edcb6c274efdd3433ff6af9e1134d1e..061b44cc245170ac7f9336cf3447d0597bb15164 100644 (file)
@@ -163,7 +163,7 @@ static void xfrm_policy_timer(unsigned long data)
        if (xp->dead)
                goto out;
 
-       dir = xp->index & 7;
+       dir = xfrm_policy_id2dir(xp->index);
 
        if (xp->lft.hard_add_expires_seconds) {
                long tmo = xp->lft.hard_add_expires_seconds +
@@ -225,7 +225,7 @@ expired:
  * SPD calls.
  */
 
-struct xfrm_policy *xfrm_policy_alloc(int gfp)
+struct xfrm_policy *xfrm_policy_alloc(unsigned int __nocast gfp)
 {
        struct xfrm_policy *policy;
 
@@ -417,7 +417,7 @@ struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete)
        struct xfrm_policy *pol, **p;
 
        write_lock_bh(&xfrm_policy_lock);
-       for (p = &xfrm_policy_list[id & 7]; (pol=*p)!=NULL; p = &pol->next) {
+       for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) {
                if (pol->index == id) {
                        xfrm_pol_hold(pol);
                        if (delete)
index c392d750b20883129420c227e32cd350ae330b11..5145adfb6a05cabec8864b81ee7c5f692dbf03cd 100644 (file)
@@ -6,6 +6,7 @@ obj-y := \
        key.o \
        keyring.o \
        keyctl.o \
+       permission.o \
        process_keys.o \
        request_key.o \
        request_key_auth.o \
diff --git a/security/keys/permission.c b/security/keys/permission.c
new file mode 100644 (file)
index 0000000..03db073
--- /dev/null
@@ -0,0 +1,70 @@
+/* permission.c: key permission determination
+ *
+ * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include "internal.h"
+
+/*****************************************************************************/
+/*
+ * check to see whether permission is granted to use a key in the desired way,
+ * but permit the security modules to override
+ */
+int key_task_permission(const key_ref_t key_ref,
+                       struct task_struct *context,
+                       key_perm_t perm)
+{
+       struct key *key;
+       key_perm_t kperm;
+       int ret;
+
+       key = key_ref_to_ptr(key_ref);
+
+       /* use the second 8-bits of permissions for keys the caller owns */
+       if (key->uid == context->fsuid) {
+               kperm = key->perm >> 16;
+               goto use_these_perms;
+       }
+
+       /* use the third 8-bits of permissions for keys the caller has a group
+        * membership in common with */
+       if (key->gid != -1 && key->perm & KEY_GRP_ALL) {
+               if (key->gid == context->fsgid) {
+                       kperm = key->perm >> 8;
+                       goto use_these_perms;
+               }
+
+               task_lock(context);
+               ret = groups_search(context->group_info, key->gid);
+               task_unlock(context);
+
+               if (ret) {
+                       kperm = key->perm >> 8;
+                       goto use_these_perms;
+               }
+       }
+
+       /* otherwise use the least-significant 8-bits */
+       kperm = key->perm;
+
+use_these_perms:
+       /* use the top 8-bits of permissions for keys the caller possesses
+        * - possessor permissions are additive with other permissions
+        */
+       if (is_key_possessed(key_ref))
+               kperm |= key->perm >> 24;
+
+       kperm = kperm & perm & KEY_ALL;
+
+       return kperm == perm;
+
+} /* end key_task_permission() */
+
+EXPORT_SYMBOL(key_task_permission);
index e6dd366d43a35b0b70e6d1a40edec79a706a72d8..5cc4bba70db61eab5157bb0bb7ffe6b673a11ab3 100644 (file)
@@ -7,6 +7,8 @@
  * 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.
+ *
+ * See Documentation/keys-request-key.txt
  */
 
 #include <linux/module.h>
index 1ecd3d3fa9f895850a66e35c446b5ab506e85aab..a8e4069d48cbf93d91b6bcab3ee173549139221c 100644 (file)
@@ -7,6 +7,8 @@
  * 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.
+ *
+ * See Documentation/keys-request-key.txt
  */
 
 #include <linux/module.h>
@@ -96,6 +98,7 @@ static void request_key_auth_destroy(struct key *key)
        kenter("{%d}", key->serial);
 
        key_put(rka->target_key);
+       kfree(rka);
 
 } /* end request_key_auth_destroy() */
 
index 6e4937fe062b40f2c4b3c05baaa9cc96f85c4cd8..b13be15165f57d527ea6e334bf1ca8fe9606b6b8 100644 (file)
@@ -630,6 +630,16 @@ static inline u16 inode_mode_to_security_class(umode_t mode)
        return SECCLASS_FILE;
 }
 
+static inline int default_protocol_stream(int protocol)
+{
+       return (protocol == IPPROTO_IP || protocol == IPPROTO_TCP);
+}
+
+static inline int default_protocol_dgram(int protocol)
+{
+       return (protocol == IPPROTO_IP || protocol == IPPROTO_UDP);
+}
+
 static inline u16 socket_type_to_security_class(int family, int type, int protocol)
 {
        switch (family) {
@@ -646,10 +656,16 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
        case PF_INET6:
                switch (type) {
                case SOCK_STREAM:
-                       return SECCLASS_TCP_SOCKET;
+                       if (default_protocol_stream(protocol))
+                               return SECCLASS_TCP_SOCKET;
+                       else
+                               return SECCLASS_RAWIP_SOCKET;
                case SOCK_DGRAM:
-                       return SECCLASS_UDP_SOCKET;
-               case SOCK_RAW:
+                       if (default_protocol_dgram(protocol))
+                               return SECCLASS_UDP_SOCKET;
+                       else
+                               return SECCLASS_RAWIP_SOCKET;
+               default:
                        return SECCLASS_RAWIP_SOCKET;
                }
                break;
@@ -2970,6 +2986,8 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
 
        /*
         * If PF_INET or PF_INET6, check name_bind permission for the port.
+        * Multiple address binding for SCTP is not supported yet: we just
+        * check the first address now.
         */
        family = sock->sk->sk_family;
        if (family == PF_INET || family == PF_INET6) {
@@ -3014,12 +3032,12 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
                                goto out;
                }
                
-               switch(sk->sk_protocol) {
-               case IPPROTO_TCP:
+               switch(isec->sclass) {
+               case SECCLASS_TCP_SOCKET:
                        node_perm = TCP_SOCKET__NODE_BIND;
                        break;
                        
-               case IPPROTO_UDP:
+               case SECCLASS_UDP_SOCKET:
                        node_perm = UDP_SOCKET__NODE_BIND;
                        break;